diff options
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r-- | src/core/netconnection.cc | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/src/core/netconnection.cc b/src/core/netconnection.cc index 4c916a1..bee0843 100644 --- a/src/core/netconnection.cc +++ b/src/core/netconnection.cc @@ -89,6 +89,7 @@ void NetConnection::connect(std::string const &to_host, int to_port) connection_timeout = application()->time(); connection_keepalive = application()->time(); + connection_state = Pending; game()->localplayer()->player_dirty = true; @@ -278,6 +279,18 @@ void NetConnection::send(std::string const &msg) sendq.append(msg); } +void NetConnection::send_playerinfo() +{ + localplayer()->update_info(); + + std::ostringstream osstream; + osstream << "pif "; + localplayer()->serialize_client_update(osstream); + osstream << '\n'; + send(osstream.str()); + localplayer()->player_dirty = false; +} + void NetConnection::transmit() { @@ -363,9 +376,11 @@ void NetConnection::parse_incoming_message(const std::string & message) } } } else if (command == "connect") { - - connection_state = Connected; - con_print << "^BConnected." << std::endl; + if (connection_state == Pending) { + send_playerinfo(); + connection_state = Connected; + con_print << "^BConnected." << std::endl; + } return; } else if (command == "disconnect") { @@ -391,6 +406,7 @@ void NetConnection::parse_incoming_message(const std::string & message) if (e) Entity::remove(id); } + } else if (command == "ent") { unsigned int type; if (msgstream >> type) { @@ -414,6 +430,10 @@ void NetConnection::parse_incoming_message(const std::string & message) break; } } + } else if (command == "pif") { + //con_debug << "Received update player info" << std::endl; + connection()->localplayer()->recieve_server_update(msgstream); + } else if (command == "sup") { if (connection_state == Connected) { @@ -428,11 +448,7 @@ void NetConnection::parse_incoming_message(const std::string & message) } } - } else if (command == "pif") { - //con_debug << "Received update player info" << std::endl; - connection()->localplayer()->recieve_server_update(msgstream); } - } } |