diff options
author | Stijn Buys <ingar@osirion.org> | 2013-11-04 21:40:20 +0000 |
---|---|---|
committer | Stijn Buys <ingar@osirion.org> | 2013-11-04 21:40:20 +0000 |
commit | a045ea4846861404ee26c0d077ea639c1987a8cb (patch) | |
tree | 3338eced9df04ca0c6645f9bd7fcb827c67e3437 /src/core/gameserver.cc | |
parent | 5f74a6b0f3e84ec00e68cda63da6e66df33a8149 (diff) |
Improved zone keepalive updates.
Diffstat (limited to 'src/core/gameserver.cc')
-rw-r--r-- | src/core/gameserver.cc | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index c27f5d4..003b9c6 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -622,6 +622,32 @@ 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) { + + Entity *view = (*it)->view(); + if (view && view->zone()) { + // add player view to keepalive bounding box + if (!view->zone()->keepalive_run()) { + view->zone()->keepalive_box().assign(view->location()); + view->zone()->set_keepalive_run(true); + } else { + view->zone()->keepalive_box().expand(view->location()); + } + } else { + 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()); + controlable->zone()->set_keepalive_run(true); + } else { + controlable->zone()->keepalive_box().expand(controlable->location()); + } + } + } + } // run entity game frames for (Entity::Registry::iterator it = Entity::registry().begin(); it != Entity::registry().end(); ++it) { @@ -669,7 +695,7 @@ void GameServer::frame(const unsigned long timestamp) } // engine state updates for each player - for (std::list<Player *>::iterator it = game_players.begin(); it != game_players.end(); ++it) { + for (Players::iterator it = game_players.begin(); it != game_players.end(); ++it) { Player *player = (*it); Entity *view = player->view(); EntityControlable *control = player->control(); |