--- a/sources/network/rconsession.cpp Sat Dec 13 07:36:00 2014 +0200 +++ b/sources/network/rconsession.cpp Sun Dec 14 17:53:24 2014 +0200 @@ -1,6 +1,6 @@ #include "rconsession.h" -static Vector<RCONSessionPointer> g_allSessions; +RCONSession* g_rconSession = nullptr; // ------------------------------------------------------------------------------------------------- // @@ -8,6 +8,14 @@ m_state (RCON_DISCONNECTED), m_lastPing (0) { + if (g_rconSession != NULL) + { + g_rconSession->disconnect(); + delete g_rconSession; + } + + g_rconSession = this; + if (not m_socket.set_blocking (false)) { // TODO: find a better way to deal with errors @@ -18,7 +26,11 @@ // ------------------------------------------------------------------------------------------------- // -RCONSession::~RCONSession() {} +RCONSession::~RCONSession() +{ + if (g_rconSession == this) + g_rconSession = nullptr; +} // ------------------------------------------------------------------------------------------------- // @@ -242,7 +254,7 @@ // ------------------------------------------------------------------------------------------------- // STATIC METHOD -RCONSession::all_sessions() -> const Vector<RCONSessionPointer>& +RCONSession::get_session() -> RCONSession* { - return g_allSessions; + return g_rconSession; }