diff options
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r-- | src/core/netconnection.cc | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index a3a2a43..790b037 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -93,7 +93,7 @@ void NetConnection::connect(std::string const &to_host, int to_port) connection_keepalive = application()->time(); connection_state = Pending; - game()->localplayer()->player_dirty = true; + game()->localplayer()->set_dirty(); con_print << "Connecting to " << inet_ntoa(*((struct in_addr *)serverhostent->h_addr)) << ":" << to_port << "..." << std::endl; } @@ -350,7 +350,7 @@ void NetConnection::send_playerinfo() localplayer()->serialize_client_update(msg); msg << '\n'; this->send_raw(msg.str()); - localplayer()->player_dirty = false; + localplayer()->set_dirty(false); } // send a "cup" client update message to the server @@ -628,17 +628,25 @@ void NetConnection::parse_incoming_message(const std::string & message) } } else { // find player - // FIXME player might be localplayer() Player *player = 0; - for (GameInterface::Players::iterator it = game()->players().begin(); it != game()->players().end() && !player; it++) { - if( (*it)->id() == player_id) { - player = (*it); + + 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); + } } } + if (!player) { player = new Player(); game()->players().push_back(player); } + player->receive_server_update(msgstream); } |