From 66ce015e5927c30801110acd289310fdff181792 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Fri, 17 Sep 2010 18:58:46 +0000 Subject: Initial support for players docking other players' ships. --- src/core/entity.h | 6 +++++- src/core/gameserver.cc | 49 +++++++++++++++++++++++++++++++++++++++++++++++ src/core/netconnection.cc | 2 +- src/core/netserver.cc | 3 ++- 4 files changed, 57 insertions(+), 3 deletions(-) (limited to 'src/core') diff --git a/src/core/entity.h b/src/core/entity.h index 6a7fa7e..fea784a 100644 --- a/src/core/entity.h +++ b/src/core/entity.h @@ -183,7 +183,11 @@ public: /// find a menu MenuDescription *find_menu(const std::string &label); - + + /// true if the entity is to be deleted + inline bool destroyed() const { + return entity_destroyed; + } /* ---- mutators -------------------------------------------------- */ 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::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); diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 684e6b3..39bed62 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -836,7 +836,7 @@ void NetConnection::parse_incoming_message(const std::string & message) info->receive_server_update(msgstream); info->clear_timestamp(); - con_debug << "Received info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl; + //con_debug << "Received info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl; } } diff --git a/src/core/netserver.cc b/src/core/netserver.cc index c632284..2d83728 100644 --- a/src/core/netserver.cc +++ b/src/core/netserver.cc @@ -325,6 +325,7 @@ void NetServer::client_frame(NetClient *client, unsigned long timestamp) Zone *zone = client->player()->zone(); if (zone) { + if (client->player()->zonechange()) { // send zone info @@ -733,7 +734,7 @@ void NetServer::parse_incoming_message(NetClient *client, const std::string & me if (id) { info = Info::find(id); if (info) { - con_debug << "Sending info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl; + //con_debug << "Sending info for " << info->id() << " " << info->type()->label() << ":" << info->label() << std::endl; send_info_update(client, info); client->transmit(); } -- cgit v1.2.3