diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:26:13 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:26:13 +0000 |
commit | d932627a498f8315d348c48e809779e8215563c4 (patch) | |
tree | 024517d6384c9b63f9d8f576676fac0321ce94c6 /src | |
parent | 3318b29475ffc5f462e2926f9b1141beca8305ae (diff) |
Add client-side movement for projectiles.
Diffstat (limited to 'src')
-rw-r--r-- | src/core/gameconnection.cc | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc index 70d19ef..b4778e0 100644 --- a/src/core/gameconnection.cc +++ b/src/core/gameconnection.cc @@ -9,10 +9,13 @@ #include "sys/sys.h" #include "filesystem/filesystem.h" +#include "core/application.h" #include "core/cvar.h" +#include "core/entityprojectile.h" #include "core/gameconnection.h" #include "core/net.h" + namespace core { const unsigned long INFOTIMEOUT = 2500; // 2500ms info request timeout @@ -220,10 +223,24 @@ void GameConnection::frame(unsigned long timestamp) return; } - //update_clientstate(); - // get incoming messages connection_network->frame(); + + // update client-sde state + for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { + Entity *entity = (*it).second; + + if (entity->type() == Entity::Projectile) { + EntityProjectile *projectile = static_cast<EntityProjectile *>(entity); + if (projectile->state() == Entity::Normal) { + unsigned long elapsed = application()->timestamp() - projectile->timestamp(); + if (elapsed > 0) { + projectile->set_location(projectile->location() + projectile->axis().forward() * projectile->speed() * ((float) elapsed / 1000.0f)); + projectile->set_timestamp(application()->timestamp()); + } + } + } + } float f = 0; if (core::Cvar::net_framerate->value()) { |