diff -r 24c7b804c99f -r 089e37c0887e sources/network/rconsession.cpp --- a/sources/network/rconsession.cpp Sun Dec 14 23:41:00 2014 +0200 +++ b/sources/network/rconsession.cpp Mon Dec 15 01:41:06 2014 +0200 @@ -7,7 +7,8 @@ // RCONSession::RCONSession() : m_state (RCON_DISCONNECTED), - m_lastPing (0) + m_lastPing (0), + m_numAdmins (0) { if (g_rconSession != NULL) { @@ -40,6 +41,8 @@ // RCONSession::~RCONSession() { + disconnect(); + if (g_rconSession == this) g_rconSession = nullptr; } @@ -51,6 +54,7 @@ { m_address = address; m_state = RCON_CONNECTING; + Interface::update_statusbar(); } // ------------------------------------------------------------------------------------------------- @@ -58,13 +62,14 @@ METHOD RCONSession::disconnect() -> void { - if (m_state == RCON_CONNECTED) + if (m_state > RCON_CONNECTING) { // Say goodbye to remote Bytestream packet; packet.write_byte (CLRC_DISCONNECT); this->send (packet); print ("Disconnected from %1\n", m_address.to_string (IP_WITH_PORT)); + Interface::update_statusbar(); } m_state = RCON_DISCONNECTED; @@ -202,11 +207,13 @@ break; case SVRCU_ADMINCOUNT: - print ("Admin count: %d1\n", packet.read_byte()); + m_numAdmins = packet.read_byte(); + Interface::update_statusbar(); break; case SVRCU_MAP: - print ("New level: %1\n", packet.read_string()); + m_level = packet.read_string(); + Interface::update_statusbar(); break; } } @@ -295,3 +302,27 @@ { return m_state; } + +// ------------------------------------------------------------------------------------------------- +// +METHOD +RCONSession::address() const -> const IPAddress& +{ + return m_address; +} + +// ------------------------------------------------------------------------------------------------- +// +METHOD +RCONSession::num_admins() const -> int +{ + return m_numAdmins; +} + +// ------------------------------------------------------------------------------------------------- +// +METHOD +RCONSession::level() const -> const String& +{ + return m_level; +}