diff options
Diffstat (limited to 'src')
-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 | ||||
-rw-r--r-- | src/render/camera.cc | 14 |
5 files changed, 37 insertions, 19 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) diff --git a/src/render/camera.cc b/src/render/camera.cc index a879b82..7f1f307 100644 --- a/src/render/camera.cc +++ b/src/render/camera.cc @@ -181,7 +181,7 @@ void Camera::draw(float seconds) camera_target.assign(core::localcontrol()->location()); target_axis.assign(core::localcontrol()->axis()); } - + if (core::localcontrol()->model()) { distance = core::localcontrol()->model()->radius(); } else { @@ -193,7 +193,7 @@ void Camera::draw(float seconds) float angle; float side; float u; - const float cam_speed = seconds; + //const float camspeed = 90.0f * seconds; // 180 degrees per second math::Vector3f n; math::Vector3f p; @@ -215,7 +215,7 @@ void Camera::draw(float seconds) cosangle = math::dotproduct(p, camera_axis.up()); if (fabs(cosangle) + MIN_DELTA < 1 ) { angle = acos(cosangle) * 180.0f / M_PI; - angle = math::sgnf(side) * angle * cam_speed; + angle = math::sgnf(side) * angle * seconds; camera_axis.change_pitch(-angle); } } @@ -237,7 +237,7 @@ void Camera::draw(float seconds) cosangle = math::dotproduct(p, camera_axis.forward()); if (fabs(cosangle) + MIN_DELTA < 1 ) { angle = acos(cosangle) * 180.0f / M_PI; - angle = math::sgnf(side) * angle * cam_speed; + angle = math::sgnf(side) * angle * seconds; camera_axis.change_direction(angle); } } @@ -259,16 +259,16 @@ void Camera::draw(float seconds) cosangle = math::dotproduct(p, camera_axis.up()); if (fabs(cosangle) + MIN_DELTA < 1 ) { angle = acos(cosangle) * 180.0f / M_PI; - angle = math::sgnf(side) * angle * cam_speed; + angle = math::sgnf(side) * angle * seconds; camera_axis.change_roll(angle); } } - if (core::localcontrol()->model()) { +/* if (core::localcontrol()->model()) { camera_target -= (core::localcontrol()->model()->maxbbox().x + 0.1f) * camera_axis.forward(); camera_target += (core::localcontrol()->model()->maxbbox().z + 0.1f ) * camera_axis.up(); } - +*/ } else if (mode() == Free) { camera_axis.assign(target_axis); |