sources/network/rconsession.cpp

changeset 31
b5b5a6a96d91
parent 29
e534f2f78196
child 32
ee770597a281
--- a/sources/network/rconsession.cpp	Mon Dec 15 02:15:09 2014 +0200
+++ b/sources/network/rconsession.cpp	Mon Dec 15 03:09:26 2014 +0200
@@ -88,6 +88,9 @@
 METHOD
 RCONSession::tick() -> void
 {
+	if (m_state == RCON_DISCONNECTED)
+		return;
+
 	time_t now;
 	time (&now);
 
@@ -159,6 +162,7 @@
 					String message = packet.read_string();
 					if (message.ends_with ("\n"))
 						message.remove_from_end (1);
+
 					print ("%1\n", message);
 				}
 				break;
@@ -174,12 +178,14 @@
 					process_server_updates (packet);
 
 				print ("Previous messages:\n");
+
 				for (int i = packet.read_byte(); i > 0; --i)
 				{
 					String message = packet.read_string();
 					message.normalize();
 					print ("--- %1\n", message);
 				}
+
 				print ("End of previous messages.\n");
 				break;
 
@@ -205,7 +211,6 @@
 			Vector<String> players;
 			for (int i = packet.read_byte(); i > 0; --i)
 				players << packet.read_string();
-			print ("Players: %1\n", players);
 		}
 		break;
 
@@ -278,10 +283,21 @@
 STATIC METHOD
 RCONSession::get_session() -> RCONSession*
 {
+	if (g_rconSession == nullptr)
+		new_session();
+
 	return g_rconSession;
 }
 
 // -------------------------------------------------------------------------------------------------
+//
+METHOD
+RCONSession::is_active() const -> bool
+{
+	return state() != RCON_DISCONNECTED;
+}
+
+// -------------------------------------------------------------------------------------------------
 // Returns true if the message was successfully sent.
 //
 METHOD

mercurial