diff options
author | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:27:25 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2012-11-25 21:27:25 +0000 |
commit | 47c1069cd2cb6ff34ea93c1f395c5e1bdd9f1432 (patch) | |
tree | 9c87c3bb7b98d0ac09cbe3b74bf0d6917e3af374 /src/core | |
parent | c7ce266051705c68f3440bcc5a83833536b2b7ca (diff) |
Added server-side distance check before sending entity create messages for projectiles.
Diffstat (limited to 'src/core')
-rw-r--r-- | src/core/netserver.cc | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/src/core/netserver.cc b/src/core/netserver.cc index 9fb5f78..467be4d 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -28,6 +28,7 @@ #include "core/cvar.h" #include "core/func.h" #include "core/core.h" +#include "core/range.h" #include "core/stats.h" #include "core/zone.h" @@ -366,6 +367,14 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) } else { // send a server frame marker send_frame_marker(client, server()->timer().timestamp()); + + // client location for server-side distance checks + math::Vector3f location; + if (client->player()->control()) { + location.assign(client->player()->control()->location()); + } else if (client->player()->view()) { + location.assign(client->player()->view()->location()); + } // send updates for entities in the zone for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); it++) { @@ -377,7 +386,9 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) send_entity_delete(client, entity); } } else if (entity->entity_created) { - send_entity_create(client, entity); + if ((entity->type() != Entity::Projectile) || (math::distance(location, entity->location()) < range::fxdistance)) { + send_entity_create(client, entity); + } } else if (entity->oldzone()) { // this entity has entered the zone |