From 3a3ba622dbf9c035b0f26979601b2d4d192b4167 Mon Sep 17 00:00:00 2001 From: Stijn Buys Date: Sun, 13 Jul 2008 16:37:18 +0000 Subject: connection sequence updates, breaks network protocol --- src/core/netconnection.cc | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'src/core/netconnection.cc') 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); } - } } -- cgit v1.2.3