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-16 22:55:07 +0000
committerStijn Buys <ingar@osirion.org>2008-07-16 22:55:07 +0000
commiteb075660e7cb61b138c2da337115c59857f89e17 (patch)
tree0fe031a8f3562b22f61d0f95b740fe5f2326fd7b /src/core/gameconnection.cc
parentfecc54ad8c5a108831c2bc268f9dd7e16b511b7e (diff)
network protocol cleanup, radar test (doesn't work)
Diffstat (limited to 'src/core/gameconnection.cc')
-rw-r--r--src/core/gameconnection.cc32
1 files changed, 12 insertions, 20 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc
index daf47e1..2085adb 100644
--- a/src/core/gameconnection.cc
+++ b/src/core/gameconnection.cc
@@ -22,6 +22,7 @@ GameConnection::GameConnection(std::string const &connectionstr)
connection_instance = this;
connection_network = 0;
connection_running = false;
+ connection_frametime = 0;
unsigned int port = DEFAULTPORT;
std::string host(connectionstr);
@@ -48,12 +49,14 @@ GameConnection::GameConnection(std::string const &connectionstr)
}
// send connect request
- std::stringstream netmsgstream("");
- netmsgstream << "connect " << PROTOCOLVERSION << "\n";
- connection_network->send(netmsgstream.str());
+ connection_network->send_connect();
connection_network->transmit();
- connection_frametime = 0;
+ if (!connection_network->connected()) {
+ abort();
+ return;
+ }
+
connection_running = true;
}
@@ -77,10 +80,7 @@ void GameConnection::forward(std::string const &cmdline)
if (!connection_network->connected())
return;
- std::string netmessage("cmd ");
- netmessage.append(cmdline);
- netmessage += '\n';
- connection_network->send(netmessage);
+ connection_network->send_command(cmdline);
}
void GameConnection::say(std::string const &args)
@@ -88,10 +88,7 @@ void GameConnection::say(std::string const &args)
if (!connection_network->connected())
return;
- std::string netmessage("say ");
- netmessage.append(args);
- netmessage += '\n';
- connection_network->send(netmessage);
+ connection_network->send_say(args);
}
void GameConnection::frame(float seconds)
@@ -120,15 +117,10 @@ void GameConnection::frame(float seconds)
if (connection_network->state() == NetConnection::Connected) {
- if(localcontrol() && localcontrol()->dirty()) {
- std::ostringstream netmsg;
- netmsg << "cup " << localcontrol()->id() << " ";
- localcontrol()->serialize_client_update(netmsg);
- netmsg << "\n";
-
- connection_network->send(netmsg.str());
+ if(localcontrol() && localcontrol()->dirty()) {
+ connection_network->send_clientupdate(localcontrol());
localcontrol()->entity_dirty = false;
- //con_debug << netmsg.str();
+
}
if (localplayer()->dirty()) {