Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStijn Buys <ingar@osirion.org>2009-01-11 12:15:22 +0000
committerStijn Buys <ingar@osirion.org>2009-01-11 12:15:22 +0000
commit20e8e4c0fb1262a25c2491679da4587d264208a2 (patch)
treec836dc74bfb82088c70bdd636dfb1f236043f58d /src/core/netconnection.cc
parent7082a5a1b7258580c698a09cf9fb8bec0bc97472 (diff)
core::Player interface updates
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r--src/core/netconnection.cc20
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);
}