diff options
Diffstat (limited to 'src/core/gameconnection.cc')
-rw-r--r-- | src/core/gameconnection.cc | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/core/gameconnection.cc b/src/core/gameconnection.cc index 4d2a745..daf47e1 100644 --- a/src/core/gameconnection.cc +++ b/src/core/gameconnection.cc @@ -47,6 +47,12 @@ GameConnection::GameConnection(std::string const &connectionstr) return; } + // send connect request + std::stringstream netmsgstream(""); + netmsgstream << "connect " << PROTOCOLVERSION << "\n"; + connection_network->send(netmsgstream.str()); + connection_network->transmit(); + connection_frametime = 0; connection_running = true; } @@ -112,26 +118,23 @@ void GameConnection::frame(float seconds) } } - if ((connection_network->state() == NetConnection::Connected) && localcontrol() && localcontrol()->dirty()) { - std::ostringstream netmsg; - netmsg << "cup " << localcontrol()->id() << " "; - localcontrol()->serialize_client_update(netmsg); - netmsg << "\n"; - - connection_network->send(netmsg.str()); - localcontrol()->entity_dirty = false; - //con_debug << netmsg.str(); - } - - if (localplayer()->dirty()) { - localplayer()->update_info(); + 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()); + localcontrol()->entity_dirty = false; + //con_debug << netmsg.str(); + } - std::ostringstream osstream; - osstream << "pif "; - localplayer()->serialize_client_update(osstream); - osstream << '\n'; - connection_network->send(osstream.str()); - localplayer()->player_dirty = false; + if (localplayer()->dirty()) { + connection_network->send_playerinfo(); + + } } connection_network->transmit(); |