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>2008-07-13 16:37:18 +0000
committerStijn Buys <ingar@osirion.org>2008-07-13 16:37:18 +0000
commit3a3ba622dbf9c035b0f26979601b2d4d192b4167 (patch)
tree1439700a9df9ba1dd32ae1f7ca86c5caa0fd4d1c /src/core/netconnection.cc
parent2e789cb9894ac5a9565013b134f1c1e51174f430 (diff)
connection sequence updates, breaks network protocol
Diffstat (limited to 'src/core/netconnection.cc')
-rw-r--r--src/core/netconnection.cc30
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);
}
-
}
}