From cc88902f93645b4284805f51cd7eba8b513ed5f3 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 25 Jan 2009 11:57:03 +0000 Subject: bump network protocol version to 15, fix player level initialization, exchange player list, credits, level, ping --- src/core/netconnection.cc | 43 +++++++++++++++++++++++++++++++++---------- 1 file changed, 33 insertions(+), 10 deletions(-) (limited to 'src/core/netconnection.cc') diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index eb9ad53..fc2b6bf 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -628,19 +628,16 @@ void NetConnection::parse_incoming_message(const std::string & message) } oldzone->content().clear(); } - } else { + + } else if (player_id != localplayer()->id()) { + // find player Player *player = 0; - if (player_id == connection()->localplayer()->id()) { - // check localplayer - player = connection()->localplayer(); - } else { - // search other players - for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) { - if( (*it)->id() == player_id) { - player = (*it); - } + // search other players + for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) { + if( (*it)->id() == player_id) { + player = (*it); } } @@ -650,8 +647,34 @@ void NetConnection::parse_incoming_message(const std::string & message) } player->receive_server_update(msgstream); + player->set_dirty(false); + } + + } else if (command == "pid") { + con_debug << "Received player disconnect info" << std::endl; + + int player_id; + if (!(msgstream >> player_id)) { + con_warn << "Received illegal player disconnect message!" << std::endl; + return; + } + + // find player + if (player_id == connection()->localplayer()->id()) { + // ignore disconnect messages for local client + return; } + // search other players + Player *player = 0; + for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) { + if( (*it)->id() == player_id) { + // TODO find player assets and set owner to 0 + game()->players().erase(it); + return; + } + } + } else if (command == "sup") { if (connection_state == Connected) { -- cgit v1.2.3