From 49b8e384b39dbfd25f510c91e610eb7f3bba4199 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sat, 9 Nov 2013 20:06:41 +0000 Subject: Do not run game frames and upkeep on destroyed entities. --- src/core/gameserver.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/core') diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 003b9c6..9e24c64 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -622,6 +622,7 @@ void GameServer::frame(const unsigned long timestamp) // Note: zone->keepalive_run() is set to true by EntityControlable::frame() zone->set_keepalive_run(false); } + // update zone keepalive state for (Players::iterator it = game_players.begin(); it != game_players.end(); ++it) { @@ -635,9 +636,8 @@ void GameServer::frame(const unsigned long timestamp) view->zone()->keepalive_box().expand(view->location()); } } else { - EntityControlable *controlable = (*it)->control(); + EntityControlable *controlable = (*it)->control(); if (controlable && controlable->zone()) { - // add player controlable to keepalive bounding box if (!controlable->zone()->keepalive_run()) { controlable->zone()->keepalive_box().assign(controlable->location()); @@ -652,8 +652,9 @@ void GameServer::frame(const unsigned long timestamp) // run entity game frames for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; - - entity->frame(elapsed); + if (!entity->destroyed()) { + entity->frame(elapsed); + } } @@ -669,8 +670,7 @@ void GameServer::frame(const unsigned long timestamp) for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { Entity *entity = (*it).second; Zone *zone = entity->zone(); - if (zone && entity->has_flag(Entity::KeepAlive)) { - + if (zone && entity->has_flag(Entity::KeepAlive) && !entity->destroyed()) { // reset timeout counter if the zone is active if (zone->keepalive_run() && zone->keepalive_box().inside(entity->location())) { entity->set_keepalive(this->timestamp()); -- cgit v1.2.3