diff options
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/application.cc | 5 | ||||
-rw-r--r-- | src/core/cvar.cc | 2 | ||||
-rw-r--r-- | src/core/cvar.h | 2 | ||||
-rw-r--r-- | src/core/gameinterface.cc | 33 |
4 files changed, 30 insertions, 12 deletions
diff --git a/src/core/application.cc b/src/core/application.cc index 09b3f61..fb82c6c 100644 --- a/src/core/application.cc +++ b/src/core/application.cc @@ -130,7 +130,10 @@ void Application::init(int count, char **arguments) // client can set this to 1 Cvar::sv_private = Cvar::get("sv_private", "0"); - Cvar::sv_private->set_info("[bool] indicates the client runs a networked server"); + Cvar::sv_private->set_info("[bool] enable or disable network server for a client"); + + Cvar::cl_prediction = Cvar::get("cl_prediction", "1", Cvar::Archive); + Cvar::cl_prediction->set_info("[bool] enable or disable client prediction"); // load configuration load_config(); diff --git a/src/core/cvar.cc b/src/core/cvar.cc index 83ec5c4..9d90afd 100644 --- a/src/core/cvar.cc +++ b/src/core/cvar.cc @@ -23,6 +23,8 @@ Cvar *Cvar::sv_private = 0; Cvar *Cvar::sv_framerate = 0; Cvar *Cvar::sv_name = 0; +Cvar *Cvar::cl_prediction = 0; + Cvar *Cvar::net_host = 0; Cvar *Cvar::net_port = 0; Cvar *Cvar::net_maxclients = 0; diff --git a/src/core/cvar.h b/src/core/cvar.h index fceb79b..620096b 100644 --- a/src/core/cvar.h +++ b/src/core/cvar.h @@ -116,6 +116,8 @@ public: static Cvar *con_ansi; // console ANSI colors + static Cvar *cl_prediction; // client prediction + static Cvar *net_host; // network server ip (default binds to all interfaces) static Cvar *net_port; // network port static Cvar *net_maxclients;// maximum number of connected clients diff --git a/src/core/gameinterface.cc b/src/core/gameinterface.cc index f50c1cc..cfa557b 100644 --- a/src/core/gameinterface.cc +++ b/src/core/gameinterface.cc @@ -128,17 +128,23 @@ void GameInterface::update_entity_clientstate(Entity *entity) entity->entity_clientstate->assign(entity); } - if (!(entity->flags() & core::Entity::Static)) + if(Cvar::cl_prediction->value() == 0) { + + entity->state()->state_axis.assign(entity->axis()); + entity->state()->state_location.assign(entity->location()); return; + } + + if (!(entity->flags() & core::Entity::Static)) { - if (game_clientframetime < game_serverframetime) { + // clientstate location + entity->state()->state_location = entity->state()->previouslocation() + + (entity->location() - entity->state()->previouslocation()) * timeoffset(); + + if (game_clientframetime < game_serverframetime) { - if (!(entity->flags() & core::Entity::Static)) { - - // clientstate location - entity->state()->state_location = entity->state()->previouslocation() + - (entity->location() - entity->state()->previouslocation()) * timeoffset(); - + //FIXME this is hopelessly broken + // http://local.wasp.uwa.edu.au/~pbourke/geometry/planeline/ float cosangle; float angle; @@ -164,7 +170,7 @@ void GameInterface::update_entity_clientstate(Entity *entity) l = p.length(); if ((fabs(side) - MIN_DELTA > 0)) { - cosangle = math::dotproduct(p, entity->state()->axis().up()); + cosangle = math::dotproduct(p, entity->state()->axis().up()); if (fabs(cosangle) + MIN_DELTA < 1 ) { angle = acos(cosangle) * 180.0f / M_PI; angle = math::sgnf(side) * angle * timeoffset(); @@ -216,15 +222,20 @@ void GameInterface::update_entity_clientstate(Entity *entity) } } + } else { + entity->state()->state_axis.assign(entity->axis()); } } else { + entity->state()->assign(entity); } } void GameInterface::update_clientstate(float seconds) { + game_clientframetime += seconds; + std::map<unsigned int, core::Entity *>::iterator it; for (it=core::Entity::registry.begin(); it != core::Entity::registry.end(); it++) { update_entity_clientstate((*it).second); @@ -233,8 +244,8 @@ void GameInterface::update_clientstate(float seconds) float GameInterface::timeoffset() { - if (game_clientframetime > game_serverframetime) - return 1; + //if (game_clientframetime > game_serverframetime) + // return 1; float d = game_serverframetime - game_previousframetime; if (d <= 0) |