# HG changeset patch # User Teemu Piippo # Date 1469028253 -10800 # Node ID 82aac80a2f1de7da0d55fb2204a427e63aec5ef5 # Parent 267ef11bd3baba3b2421090a922163ed8f08a20d# Parent 6be21be4bea1c56a00638e3f6a9093813843c717 Merged with default diff -r 267ef11bd3ba -r 82aac80a2f1d sources/network/rconsession.cpp --- a/sources/network/rconsession.cpp Wed Jul 20 17:57:35 2016 +0300 +++ b/sources/network/rconsession.cpp Wed Jul 20 18:24:13 2016 +0300 @@ -123,19 +123,18 @@ // void RCONSession::handle_packet (Datagram& datagram) { - if (datagram.from != m_address) + if (datagram.address != m_address) return; try { - Bytestream& packet = datagram.data; - int32_t header = packet.read_long(); - int32_t sequenceNumber = (header != 0) ? packet.read_long() : 0; + int32_t header = datagram.message.read_long(); + int32_t sequenceNumber = (header != 0) ? datagram.message.read_long() : 0; m_interface->print("Recieved packet with header 0x%x and sequence number #%d\n", header, sequenceNumber); - while (packet.bytes_left() > 0) + while (datagram.message.bytes_left() > 0) { - int header = packet.read_byte(); + int header = datagram.message.read_byte(); switch (ServerResponse (header)) { @@ -150,7 +149,7 @@ break; case SVRC_SALT: - m_salt = packet.read_string(); + m_salt = datagram.message.read_string(); m_state = RCON_AUTHENTICATING; send_password(); break; @@ -162,7 +161,7 @@ case SVRC_MESSAGE: { - String message = packet.read_string(); + String message = datagram.message.read_string(); message.normalize(); m_interface->printText ("%s\n", message.chars()); } @@ -170,19 +169,19 @@ case SVRC_LOGGEDIN: m_interface->print ("Login successful!\n"); - m_serverProtocol = packet.read_byte(); - m_hostname = packet.read_string(); + m_serverProtocol = datagram.message.read_byte(); + m_hostname = datagram.message.read_string(); m_interface->setTitle (m_hostname); m_state = RCON_CONNECTED; - for (int i = packet.read_byte(); i > 0; --i) - process_server_updates (packet); + for (int i = datagram.message.read_byte(); i > 0; --i) + process_server_updates (datagram.message); m_interface->print ("Previous messages:\n"); - for (int i = packet.read_byte(); i > 0; --i) + for (int i = datagram.message.read_byte(); i > 0; --i) { - String message = packet.read_string(); + String message = datagram.message.read_string(); message.normalize(); m_interface->printText ("--- %s\n", message.chars()); } @@ -195,12 +194,12 @@ break; case SVRC_UPDATE: - process_server_updates (packet); + process_server_updates (datagram.message); break; case SVRC_TOOMANYTABCOMPLETES: { - unsigned int numCompletions = packet.read_short(); + unsigned int numCompletions = datagram.message.read_short(); m_interface->print ("%d completions for '%s'.\n", int (numCompletions), m_lastTabComplete.chars()); } @@ -209,10 +208,10 @@ case SVRC_TABCOMPLETE: { StringList completes; - completes.resize(packet.read_byte()); + completes.resize(datagram.message.read_byte()); for (String& completion : completes) - completion = packet.read_string(); + completion = datagram.message.read_string(); if (completes.size() == 1) { @@ -233,22 +232,22 @@ break; case SVRC_WATCHINGCVAR: - m_interface->print ("You are now watching %s\n", packet.read_string().chars()); - m_interface->print ("Its value is: %s\n", packet.read_string().chars()); + m_interface->print ("You are now watching %s\n", datagram.message.read_string().chars()); + m_interface->print ("Its value is: %s\n", datagram.message.read_string().chars()); break; case SVRC_ALREADYWATCHINGCVAR: - m_interface->print ("You are already watching %s\n", packet.read_string().chars()); + m_interface->print ("You are already watching %s\n", datagram.message.read_string().chars()); break; case SVRC_WATCHCVARNOTFOUND: - m_interface->print ("CVar %s not found\n", packet.read_string().chars()); + m_interface->print ("CVar %s not found\n", datagram.message.read_string().chars()); break; case SVRC_CVARCHANGED: { - String name = packet.read_string(); - String value = packet.read_string(); + String name = datagram.message.read_string(); + String value = datagram.message.read_string(); m_interface->print ("The value of CVar %s", name.chars()); m_interface->print (" is now %s\n", value.chars()); @@ -262,7 +261,7 @@ break; case SVRC_YOUREDISCONNECTED: - m_interface->print ("You have been disconnected: %s\n", packet.read_string().chars()); + m_interface->print ("You have been disconnected: %s\n", datagram.message.read_string().chars()); m_interface->disconnected(); break; } diff -r 267ef11bd3ba -r 82aac80a2f1d sources/network/rconsession.h --- a/sources/network/rconsession.h Wed Jul 20 17:57:35 2016 +0300 +++ b/sources/network/rconsession.h Wed Jul 20 18:24:13 2016 +0300 @@ -138,4 +138,4 @@ class Interface* m_interface; }; -END_ZFC_NAMESPACE +END_ZFC_NAMESPACE \ No newline at end of file diff -r 267ef11bd3ba -r 82aac80a2f1d sources/network/udpsocket.cpp --- a/sources/network/udpsocket.cpp Wed Jul 20 17:57:35 2016 +0300 +++ b/sources/network/udpsocket.cpp Wed Jul 20 18:24:13 2016 +0300 @@ -137,10 +137,11 @@ unsigned char decodedPacket[MAX_DATAGRAM_LENGTH]; int decodedLength = sizeof decodedPacket; - HUFFMAN_Decode (reinterpret_cast(HuffmanBuffer), decodedPacket, length, &decodedLength); - datagram.from.host = ntohl (claddr.sin_addr.s_addr); - datagram.from.port = ntohs (claddr.sin_port); - datagram.data = Bytestream (decodedPacket, decodedLength); + HUFFMAN_Decode (reinterpret_cast (HuffmanBuffer), + decodedPacket, length, &decodedLength); + datagram.address.host = ntohl (claddr.sin_addr.s_addr); + datagram.address.port = ntohs (claddr.sin_port); + datagram.message = Bytestream (decodedPacket, decodedLength); return true; } diff -r 267ef11bd3ba -r 82aac80a2f1d sources/network/udpsocket.h --- a/sources/network/udpsocket.h Wed Jul 20 17:57:35 2016 +0300 +++ b/sources/network/udpsocket.h Wed Jul 20 18:24:13 2016 +0300 @@ -38,8 +38,8 @@ struct Datagram { - Bytestream data; - IPAddress from; + Bytestream message; + IPAddress address; }; // -------------------------------------------------------------------------------------------------