diff options
author | Stijn Buys <ingar@osirion.org> | 2008-08-30 20:48:06 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2008-08-30 20:48:06 +0000 |
commit | 57837b0236bdebd7a1032245c64b1bc459f96d62 (patch) | |
tree | d9731122b3d28a3de206aec772af3bcbdeeb66b0 /src | |
parent | 084dd555366c326b7ee18515bcb282a8f4eb394a (diff) |
dedicated server ncurses console updates
Diffstat (limited to 'src')
-rw-r--r-- | src/client/view.cc | 9 | ||||
-rw-r--r-- | src/core/gameinterface.cc | 68 | ||||
-rw-r--r-- | src/core/gameinterface.h | 2 | ||||
-rw-r--r-- | src/core/gameserver.cc | 3 | ||||
-rw-r--r-- | src/game/game.cc | 2 | ||||
-rw-r--r-- | src/server/console.cc | 79 | ||||
-rw-r--r-- | src/server/console.h | 2 |
7 files changed, 119 insertions, 46 deletions
diff --git a/src/client/view.cc b/src/client/view.cc index a737988..32f2971 100644 --- a/src/client/view.cc +++ b/src/client/view.cc @@ -121,9 +121,14 @@ void draw_entity_world_target(core::Entity *entity) if (!model) return; + if (!model->docks().size()) return; + float d = math::distance(core::localcontrol()->location(), entity->state()->location()) - entity->radius() - core::localcontrol()->radius(); + if (d > 100.0f) + return; + gl::enable(GL_DEPTH_TEST); gl::push(); gl::translate(entity->state()->location()); @@ -137,8 +142,8 @@ void draw_entity_world_target(core::Entity *entity) math::Vector3f minbox(dock->location()); for (size_t i=0; i < 3; i++) { - maxbox[i] += dock->radius(); - minbox[i] -= dock->radius(); + maxbox[i] += 0.025; + minbox[i] -= 0.025; } // top diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index ecb58fc..70224b0 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -152,39 +152,43 @@ void GameInterface::update_entity_clientstate(Entity *entity) if (game_clientframetime <= game_serverframetime) { - entity->state()->state_axis.assign(entity->state()->previousaxis()); - - float cosangle; // cosine of an angle - float angle; // angle in radians - math::Vector3f n; // normal of a plane - - n.assign(math::crossproduct( entity->state()->axis().forward(), entity->axis().forward())); - if (!(n.length() < MIN_DELTA)) { - n.normalize(); - cosangle = math::dotproduct( entity->state()->axis().forward(), entity->axis().forward()); - angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; - if (angle > MIN_DELTA) - entity->state()->state_axis.rotate(n, -angle); - } - /* - n.assign(math::crossproduct( entity->state()->axis().left(), entity->axis().left())); - if (!(n.length() < MIN_DELTA)) { - n.normalize(); - cosangle = math::dotproduct( entity->state()->axis().left(), entity->axis().left()); - angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; - if (angle > MIN_DELTA) - entity->state()->state_axis.rotate(n, -angle); + if(Cvar::cl_prediction->value() > 1) { + entity->state()->state_axis.assign(entity->state()->previousaxis()); + + float cosangle; // cosine of an angle + float angle; // angle in radians + math::Vector3f n; // normal of a plane + + n.assign(math::crossproduct( entity->state()->axis().forward(), entity->axis().forward())); + if (!(n.length() < MIN_DELTA)) { + n.normalize(); + cosangle = math::dotproduct( entity->state()->axis().forward(), entity->axis().forward()); + angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; + if (angle > MIN_DELTA) + entity->state()->state_axis.rotate(n, -angle); + } + /* + n.assign(math::crossproduct( entity->state()->axis().left(), entity->axis().left())); + if (!(n.length() < MIN_DELTA)) { + n.normalize(); + cosangle = math::dotproduct( entity->state()->axis().left(), entity->axis().left()); + angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; + if (angle > MIN_DELTA) + entity->state()->state_axis.rotate(n, -angle); + } + + n.assign(math::crossproduct( entity->state()->axis().up(), entity->axis().up())); + if (!(n.length() < MIN_DELTA)) { + n.normalize(); + cosangle = math::dotproduct( entity->state()->axis().up(), entity->axis().up()); + angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; + if (angle > MIN_DELTA) + entity->state()->state_axis.rotate(n, -angle); + } + */ + } else { + entity->state()->state_axis.assign(entity->axis()); } - - n.assign(math::crossproduct( entity->state()->axis().up(), entity->axis().up())); - if (!(n.length() < MIN_DELTA)) { - n.normalize(); - cosangle = math::dotproduct( entity->state()->axis().up(), entity->axis().up()); - angle = acos(cosangle) * timeoffset(); // * 180.0f / M_PI; - if (angle > MIN_DELTA) - entity->state()->state_axis.rotate(n, -angle); - } - */ } else { entity->state()->state_axis.assign(entity->axis()); } diff --git a/src/core/gameinterface.h b/src/core/gameinterface.h index 19c6886..ef51545 100644 --- a/src/core/gameinterface.h +++ b/src/core/gameinterface.h @@ -31,7 +31,7 @@ public: inline float serverframetime() const { return game_serverframetime; } /// return the server time of the previous received server frame - inline float previousframetime() const { return game_serverframetime; } + inline float previousframetime() const { return game_previousframetime; } /// return the server time of the previous received server frame inline float clientframetime() const { return game_clientframetime; } diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 5e1165d..14f97bb 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -541,6 +541,9 @@ void GameServer::frame(float seconds) // copy the previous entity state to the client state if (!Cvar::sv_dedicated->value()) { reset_clientstate(server_time, server_previoustime); + } else { + game_serverframetime = server_time; + game_previousframetime = server_previoustime; } // run a time frame on each entity diff --git a/src/game/game.cc b/src/game/game.cc index 2c5b8cd..3b13767 100644 --- a/src/game/game.cc +++ b/src/game/game.cc @@ -354,7 +354,7 @@ bool Game::load_zone(core::Zone *zone) aux::to_label(strval); star->entity_label.assign(strval); continue; - } else if (zoneini.got_key_string("name", star->entity_name)) { + } else if (zoneini.got_key_string("name", star->entity_name)) { continue; } else if (zoneini.got_key_vector3f("location", star->entity_location )) { continue; diff --git a/src/server/console.cc b/src/server/console.cc index c4e63e3..0fe874e 100644 --- a/src/server/console.cc +++ b/src/server/console.cc @@ -6,6 +6,10 @@ #include <iostream> #include <queue> +#include <string> +#include <sstream> +#include <iomanip> +#include <cmath> #include "server/console.h" #include "core/core.h" @@ -22,7 +26,7 @@ bool console_initialized = false; bool console_updated = false; const size_t MAXHISTOLINES = 512; - +float prev_time = 0; Console server_console; #ifdef HAVE_CURSES @@ -42,7 +46,7 @@ void Console::init() noecho(); // don't show typed characters keypad(stdwin, TRUE); // enable special keys nodelay(stdwin, TRUE); // non-blocking input - curs_set(1); // disable cursor + curs_set(1); // enable cursor if (has_colors() == TRUE) { start_color(); @@ -199,6 +203,18 @@ void Console::draw_background() mvaddnstr(0, y, versionstr.c_str(), stdwin->_maxx - 1); } +void Console::draw_status() +{ + if (core::game()) { + attroff(A_BOLD); + color_set(2, NULL); + int minutes = (int) floorf(core::game()->serverframetime() / 60.0f); + int seconds = (int) floorf( core::game()->serverframetime() - (float) minutes* 60.0f); + std::stringstream status; + status << "time " << std::setfill(' ') << std::setw(3) << minutes << ":" << std::setfill('0') << std::setw(2) << seconds; + mvaddnstr(0, 2, status.str().c_str(), status.str().size()); + } +} void Console::draw_text() { int w = stdwin->_maxx; @@ -210,7 +226,7 @@ void Console::draw_text() std::deque<std::string> lines; int console_scroll = 0; - int height = stdwin->_maxy - 2; + int height = stdwin->_maxy - 1; int width = stdwin->_maxx - 1; int bottom = (int) consoleinterface_text.size() - console_scroll; int current_line = 0; @@ -336,8 +352,6 @@ void Console::draw_input() // fill the remainder with spaces for (int i=1 + (*history_pos).size(); i < stdwin->_maxx; i++) addch(' '); - // move the cursor to input position - move(stdwin->_maxy, 1 + (*history_pos).size()); } void Console::draw() @@ -346,8 +360,10 @@ void Console::draw() return; draw_background(); + draw_status(); draw_text(); draw_input(); + move(stdwin->_maxy, 1 + input_pos); wrefresh(stdwin); console_updated = false; @@ -356,6 +372,8 @@ void Console::draw() void Console::frame(float seconds) { + std::deque<std::string>::reverse_iterator upit; + flush(); if (!console_initialized) @@ -378,11 +396,41 @@ void Console::frame(float seconds) input_updated = true; break; } else if (key == KEY_LEFT) { - } else if (key == KEY_HOME) { + if (input_pos > 0) { + input_pos--; + } + input_updated = true; + break; } else if (key == KEY_RIGHT) { + if (input_pos < (*history_pos).size()) { + input_pos++; + } + input_updated = true; + break; + } else if (key == KEY_HOME) { + input_pos = 0; + input_updated = true; + break; } else if (key == KEY_END) { + input_pos = (*history_pos).size(); + input_updated = true; + break; } else if (key == KEY_UP) { - } else if (key == KEY_DOWN) { + upit = history_pos; + ++upit; + if (upit != history.rend()) { + history_pos = upit; + input_pos = (*history_pos).size(); + input_updated = true; + } + break; + } else if (key == KEY_DOWN) { + if (history_pos != history.rbegin()) { + --history_pos; + input_pos = (*history_pos).size(); + input_updated = true; + } + break; } else if (key == KEY_ENTER || key == '\n') { if ((*history_pos).size()) { // store input into history @@ -397,7 +445,7 @@ void Console::frame(float seconds) history.push_back(""); history_pos = history.rbegin(); input_pos = 0; - input_updated = true; + console_updated = true; } break; } else if (key == KEY_PPAGE) { @@ -416,8 +464,19 @@ void Console::frame(float seconds) if (console_updated) { draw(); - } else if (input_updated) { - draw_input(); + } else { + if (input_updated) { + draw_input(); + } + if (roundf(core::game()->serverframetime()) != prev_time) { + draw_status(); + prev_time = roundf(core::game()->serverframetime()); + input_updated = true; + } + if (input_updated) { + // move the cursor to input position + move(stdwin->_maxy, 1 + input_pos); + } } } #endif // HAVE_CURSES diff --git a/src/server/console.h b/src/server/console.h index b96f593..9cfe604 100644 --- a/src/server/console.h +++ b/src/server/console.h @@ -30,6 +30,8 @@ protected: void draw(); /// clear and draw background (ncurses) void draw_background(); + /// draw status + void draw_status(); /// draw the console text (ncurses) void draw_text(); /// draw the console input (ncurses) |