sources/network/rconsession.cpp

changeset 182
20ca0a6be175
parent 180
2e7225dbd9b2
child 183
9b6a0daedfc0
--- a/sources/network/rconsession.cpp	Wed Jan 27 13:17:11 2021 +0200
+++ b/sources/network/rconsession.cpp	Wed Jan 27 14:04:53 2021 +0200
@@ -31,6 +31,7 @@
 #include <time.h>
 #include "rconsession.h"
 #include "../interface.h"
+#include "../md5.h"
 BEGIN_ZFC_NAMESPACE
 
 // -------------------------------------------------------------------------------------------------
@@ -44,7 +45,7 @@
 	if (not m_socket.set_blocking(false))
 	{
 		fprintf(stderr, "unable to set socket as non-blocking: %s\n",
-			m_socket.error_string().chars());
+			m_socket.error_string().data());
 		exit(EXIT_FAILURE);
 	}
 }
@@ -157,8 +158,8 @@
 			case SVRC_MESSAGE:
 				{
 					String message = stream.readString();
-					message.normalize();
-					m_interface->printText("%s\n", message.chars());
+					normalize(message);
+					m_interface->printText("%s\n", message.data());
 				}
 				break;
 
@@ -177,8 +178,8 @@
 				for (int i = stream.readByte(); i > 0; --i)
 				{
 					String message = stream.readString();
-					message.normalize();
-					m_interface->printText("--- %s\n", message.chars());
+					normalize(message);
+					m_interface->printText("--- %s\n", message.data());
 				}
 
 				m_interface->print("End of previous messages.\n");
@@ -192,7 +193,7 @@
 				{
 					unsigned int numCompletions = stream.readShort();
 					m_interface->print("%d completions for '%s'.\n",
-						int(numCompletions), m_lastTabComplete.chars());
+						int(numCompletions), m_lastTabComplete.data());
 				}
 				break;
 
@@ -210,13 +211,13 @@
 					}
 					else if (completes.size() > 0)
 					{
-						m_interface->print("Completions for '%s':\n", m_lastTabComplete.chars());
+						m_interface->print("Completions for '%s':\n", m_lastTabComplete.data());
 
 						for (int i : range(0, static_cast<int>(completes.size()), 8))
 						{
 							const int end = min(i + 8, static_cast<int>(completes.size()));
 							StringList splices = splice(completes, i, end);
-							m_interface->print("- %s\n", join_string_list(splices, ", ").chars());
+							m_interface->print("- %s\n", join_string_list(splices, ", ").data());
 						}
 					}
 				}
@@ -227,7 +228,7 @@
 	catch (std::exception& e)
 	{
 		m_interface->printWarning("Couldn't process packet: %s\n", e.what());
-		m_interface->printWarning("Packet contents was: %s\n", quote(message).chars());
+		m_interface->printWarning("Packet contents was: %s\n", quote(message).data());
 		m_interface->printWarning("Stream position in payload was: %d\n", stream.position());
 	}
 }
@@ -276,7 +277,7 @@
 //
 void RCONSession::sendHello()
 {
-	m_interface->print("Connecting to %s...\n", m_address.to_string(IPAddress::WITH_PORT).chars());
+	m_interface->print("Connecting to %s...\n", m_address.to_string(IPAddress::WITH_PORT).data());
 	send({CLRC_BEGINCONNECTION, RCON_PROTOCOL_VERSION});
 	bumpLastPing();
 }
@@ -289,7 +290,7 @@
 	ByteArray message;
 	Bytestream stream(message);
 	stream.writeByte(CLRC_PASSWORD);
-	stream.writeString((m_salt + m_password).md5());
+	stream.writeString(md5((m_salt + m_password).data()));
 	send(message);
 	bumpLastPing();
 }
@@ -322,7 +323,7 @@
 //
 bool RCONSession::sendCommand(const String& commandString)
 {
-	if (m_state != RCON_CONNECTED or commandString.isEmpty())
+	if (m_state != RCON_CONNECTED or commandString.empty())
 		return false;
 
 	ByteArray message;

mercurial