diff options
Diffstat (limited to 'src/core/gameserver.cc')
-rw-r--r-- | src/core/gameserver.cc | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/src/core/gameserver.cc b/src/core/gameserver.cc index 4181824..09a0fff 100644 --- a/src/core/gameserver.cc +++ b/src/core/gameserver.cc @@ -530,6 +530,55 @@ void GameServer::frame(unsigned long timestamp) } } + // engine state updates for each player + for (std::list<Player *>::iterator it = game_players.begin(); it != game_players.end(); it++) { + Player *player = (*it); + Entity *view = player->view(); + EntityControlable *control = player->control(); + + // the player is viewing an entity + if (view) { + // the view has changed zone + if (view->zone() != player->zone()) { + if (control) { + // player is docked at a jumping entity + if (control->state() == Entity::Docked) { + control->get_location().assign(view->location()); + control->set_zone(view->zone()); + player->set_zone(view->zone()); + } else { + player->set_zone(control->zone()); + player->set_view(0); + } + control->set_dirty(); + } else { + // spectator following a jumping entity + player->set_zone(view->zone()); + } + player->set_dirty(); + } + + // view is to be deleted + if (view->destroyed()) + { + if (control) { + // player is docked at deleted entity + if (control->state() == Entity::Docked) { + control->get_location().assign(view->location()); + control->set_state(Entity::Normal); + control->set_dirty(); + } else { + player->set_view(0); + } + } else { + // spectator following a deleted entity + player->set_view(0); + } + player->set_dirty(); + } + } + } + if (server_network) { // send network updates server_network->frame(server_timestamp); |