Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2013-05-01 17:29:20 +0000
committerStijn Buys <ingar@osirion.org>2013-05-01 17:29:20 +0000
commite77f8bdd8aba9744188a35e0c7eefc5c3a77f5a3 (patch)
treeb670ade4807cd4454ade0169a5723773b757fbdb /src
parent7a61137a7201ccab999e1c82d7a4d3e7f26f92fb (diff)
Delete client-side projectiles outside effects range.
Diffstat (limited to 'src')
-rw-r--r--src/core/gameconnection.cc42
1 files changed, 36 insertions, 6 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index de0b4e5..7bdadad 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -14,6 +14,7 @@
#include "core/entityprojectile.h"
#include "core/gameconnection.h"
#include "core/net.h"
+#include "core/range.h"
namespace core
@@ -226,20 +227,49 @@ void GameConnection::frame(unsigned long timestamp)
// get incoming messages
connection_network->frame();
+ // determine player location
+ math::Vector3f player_location;
+
+ if (localplayer()->view()) {
+ player_location.assign(localplayer()->view()->location());
+ } else if (localcontrol()) {
+ player_location.assign(localcontrol()->location());
+ }
+
// update client-sde state
- for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) {
+ for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end();) {
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());
+
+ if (projectile->zone() == localplayer()->zone()) {
+
+ // delete projectile if it goes out of range
+ if (math::distance(projectile->location(), player_location) > range::fxdistance) {
+ projectile->die();
+
+ } else 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());
+ }
}
+ } else {
+ projectile->die();
}
}
+
+ // delete entities were required
+ if (entity->destroyed()) {
+ Entity::registry().erase(it++);
+ } else {
+ ++it;
+ }
+
+
}
float f = 0;