diff options
-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()) { |