From a045ea4846861404ee26c0d077ea639c1987a8cb Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Mon, 4 Nov 2013 21:40:20 +0000 Subject: Improved zone keepalive updates. --- src/core/gameserver.cc | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) (limited to 'src/core/gameserver.cc') 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::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(); -- cgit v1.2.3