--- a/sources/network/rconsession.cpp Sun May 17 22:07:48 2015 +0300 +++ b/sources/network/rconsession.cpp Wed May 27 21:15:52 2015 +0300 @@ -28,6 +28,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include <time.h> #include "rconsession.h" #include "../interface.h" @@ -41,7 +42,7 @@ { if (not m_socket.set_blocking (false)) { - print_to (stderr, "unable to set socket as non-blocking: %s\n", + fprintf (stderr, "unable to set socket as non-blocking: %s\n", m_socket.error_string().chars()); exit (EXIT_FAILURE); } @@ -71,7 +72,7 @@ Bytestream packet; packet.write_byte (CLRC_DISCONNECT); this->send (packet); - m_interface->print ("Disconnected from %1\n", m_address.to_string (IP_WITH_PORT)); + m_interface->print ("Disconnected from %s\n", m_address.to_string (IP_WITH_PORT).chars()); m_interface->update_statusbar(); } @@ -136,13 +137,11 @@ case SVRC_OLDPROTOCOL: m_interface->print_error ("Your RCON client is using outdated protocol.\n"); m_state = RCON_DISCONNECTED; - m_interface->disconnected(); break; case SVRC_BANNED: m_interface->print_error ("You have been banned from the server.\n"); m_state = RCON_DISCONNECTED; - m_interface->disconnected(); break; case SVRC_SALT: @@ -154,14 +153,13 @@ case SVRC_INVALIDPASSWORD: m_interface->print_error ("Login failed.\n"); m_state = RCON_DISCONNECTED; - m_interface->disconnected(); break; case SVRC_MESSAGE: { String message = packet.read_string(); message.normalize(); - m_interface->print ("%1\n", message); + m_interface->print ("%s\n", message.chars()); } break; @@ -181,7 +179,7 @@ { String message = packet.read_string(); message.normalize(); - m_interface->print ("--- %1\n", message); + m_interface->print ("--- %s\n", message.chars()); } m_interface->print ("End of previous messages.\n"); @@ -194,8 +192,8 @@ case SVRC_TOOMANYTABCOMPLETES: { unsigned int numCompletions = packet.read_short(); - m_interface->print ("%1 completions for '%2'.\n", - int (numCompletions), m_lastTabComplete); + m_interface->print ("%d completions for '%s'.\n", + int (numCompletions), m_lastTabComplete.chars()); } break; @@ -212,53 +210,23 @@ } else if (not completes.is_empty()) { - m_interface->print ("Completions for '%1':\n", m_lastTabComplete); + m_interface->print ("Completions for '%s':\n", m_lastTabComplete.chars()); for (int i = 0; i < completes.size(); i += 8) { Range<int> spliceRange (i, min (i + 8, completes.size() - 1)); StringList splice (completes.splice (spliceRange)); - m_interface->print ("- %1\n", splice.join (", ")); + m_interface->print ("- %s\n", splice.join (", ").chars()); } } } break; - - case SVRC_WATCHINGCVAR: - m_interface->print ("Server acknowledges watch on %1\n", packet.read_string()); - m_interface->print ("Its current value is %1\n", packet.read_string()); - break; - - case SVRC_ALREADYWATCHINGCVAR: - m_interface->print ("Server says you are already watching %1\n", packet.read_string()); - break; - - case SVRC_WATCHCVARNOTFOUND: - m_interface->print ("No such cvar %1\n", packet.read_string()); - break; - - case SVRC_CVARCHANGED: - { - String name = packet.read_string(); - String value = packet.read_string(); - m_interface->print ("New value of %1: %2\n", name, value); - } - break; - - case SVRC_YOUREDISCONNECTED: - { - String message = packet.read_string(); - m_interface->print_error ("Connection error: %1\n", message); - m_state = RCON_DISCONNECTED; - m_interface->disconnected(); - } - break; } } } catch (std::exception& e) { - m_interface->print_warning ("Couldn't process packet: %1\n", e.what()); + m_interface->print_warning ("Couldn't process packet: %s\n", e.what()); } } @@ -306,7 +274,7 @@ // void RCONSession::send_hello() { - m_interface->print ("Connecting to %1...\n", m_address.to_string (IP_WITH_PORT)); + m_interface->print ("Connecting to %s...\n", m_address.to_string (IP_WITH_PORT).chars()); Bytestream packet; packet.write_byte (CLRC_BEGINCONNECTION); packet.write_byte (RCON_PROTOCOL_VERSION); @@ -357,24 +325,6 @@ if (m_state != RCON_CONNECTED or message.is_empty()) return false; - if (message.starts_with ("/watch ")) - { - String cvarnamelist = message.mid (String ("/watch ").length(), -1); - cvarnamelist.normalize(); - - Bytestream packet; - packet.write_byte (CLRC_WATCHCVAR); - - for (String cvarname : cvarnamelist.split (' ')) - { - m_interface->print (TEXTCOLOR_Green "Requesting watch on %1...\n", cvarname); - packet.write_string (cvarname); - } - send (packet); - bump_last_ping(); - return true; - } - Bytestream packet; packet.write_byte (CLRC_COMMAND); packet.write_string (message); @@ -425,5 +375,7 @@ m_lastTabComplete = part; } else - m_interface->print ("Server protocol is %1, cannot tab-complete\n", m_serverProtocol); -} + { + m_interface->print ("This server does not support tab-completion\n", m_serverProtocol); + } +} \ No newline at end of file