- restructured rconsession constructor a bit

Tue, 16 Dec 2014 02:30:31 +0200

author
Teemu Piippo <crimsondusk64@gmail.com>
date
Tue, 16 Dec 2014 02:30:31 +0200
changeset 57
a2f41245e387
parent 56
b4caacf567af
child 58
d175243ad169

- restructured rconsession constructor a bit

sources/network/rconsession.cpp file | annotate | diff | comparison | revisions
--- a/sources/network/rconsession.cpp	Tue Dec 16 01:46:22 2014 +0200
+++ b/sources/network/rconsession.cpp	Tue Dec 16 02:30:31 2014 +0200
@@ -8,7 +8,12 @@
 RCONSession::RCONSession() :
 	m_state (RCON_DISCONNECTED),
 	m_lastPing (0),
-	m_numAdmins (0)
+	m_numAdmins (0) {}
+
+// -------------------------------------------------------------------------------------------------
+//
+STATIC METHOD
+RCONSession::new_session() -> RCONSession*
 {
 	if (g_rconSession != NULL)
 	{
@@ -16,25 +21,17 @@
 		delete g_rconSession;
 	}
 
-	g_rconSession = this;
-}
+	g_rconSession = new RCONSession;
 
-// -------------------------------------------------------------------------------------------------
-//
-STATIC METHOD
-RCONSession::new_session() -> RCONSession*
-{
-	RCONSession* session = new RCONSession;
-
-	if (not session->socket()->set_blocking (false))
+	if (not g_rconSession->socket()->set_blocking (false))
 	{
 		print ("unable to set socket as non-blocking: %s\n",
-			session->socket()->error_string().chars());
-		delete session;
+			g_rconSession->socket()->error_string().chars());
+		delete g_rconSession;
 		return nullptr;
 	}
 
-	return session;
+	return g_rconSession;
 }
 
 // -------------------------------------------------------------------------------------------------
@@ -55,6 +52,7 @@
 	m_address = address;
 	m_state = RCON_CONNECTING;
 	Interface::update_statusbar();
+	send_hello();
 }
 
 // -------------------------------------------------------------------------------------------------

mercurial