Fixed compilation problems. protocol5

Fri, 22 Jul 2016 18:03:50 +0300

author
Teemu Piippo <teemu@compsta2.com>
date
Fri, 22 Jul 2016 18:03:50 +0300
branch
protocol5
changeset 160
cf514fa0f1cc
parent 159
970d58a01e8b
child 165
718a8c4df538

Fixed compilation problems.

sources/interface.cpp file | annotate | diff | comparison | revisions
sources/network/rconsession.cpp file | annotate | diff | comparison | revisions
sources/network/rconsession.h file | annotate | diff | comparison | revisions
--- a/sources/interface.cpp	Fri Jul 22 17:59:55 2016 +0300
+++ b/sources/interface.cpp	Fri Jul 22 18:03:50 2016 +0300
@@ -1097,7 +1097,7 @@
 	else if (command == "watch")
 	{
 		if (not args.is_empty())
-			m_session.request_watch(args);
+			m_session.requestWatch(args);
 		else
 			printError("No CVars to watch.\n");
 	}
--- a/sources/network/rconsession.cpp	Fri Jul 22 17:59:55 2016 +0300
+++ b/sources/network/rconsession.cpp	Fri Jul 22 18:03:50 2016 +0300
@@ -126,11 +126,11 @@
 
 	try
 	{
-		int32_t header = datagram.message.read_long();
-		int32_t sequenceNumber = (header != 0) ? datagram.message.read_long() : 0;
+		int32_t header = stream.readLong();
+		int32_t sequenceNumber = (header != 0) ? stream.readLong() : 0;
 		m_interface->print("Recieved packet with header 0x%x and sequence number #%d\n", header, sequenceNumber);
 
-		while (datagram.message.bytes_left() > 0)
+		while (stream.bytesLeft() > 0)
 		{
 			int header = stream.readByte();
 
@@ -187,7 +187,7 @@
 				m_interface->print("End of previous messages.\n");
 
 				// Watch sv_hostname so that we can update the titlebar when it changes.
-				request_watch("sv_hostname");
+				requestWatch("sv_hostname");
 				m_interface->print ("Watch requested.\n");
 				break;
 
@@ -230,22 +230,22 @@
 				break;
 
 			case SVRC_WATCHINGCVAR:
-				m_interface->print ("You are now watching %s\n", datagram.message.read_string().chars());
-				m_interface->print ("Its value is: %s\n", datagram.message.read_string().chars());
+				m_interface->print ("You are now watching %s\n", stream.readString().chars());
+				m_interface->print ("Its value is: %s\n", stream.readString().chars());
 				break;
 
 			case SVRC_ALREADYWATCHINGCVAR:
-				m_interface->print ("You are already watching %s\n", datagram.message.read_string().chars());
+				m_interface->print ("You are already watching %s\n", stream.readString().chars());
 				break;
 
 			case SVRC_WATCHCVARNOTFOUND:
-				m_interface->print ("CVar %s not found\n", datagram.message.read_string().chars());
+				m_interface->print ("CVar %s not found\n", stream.readString().chars());
 				break;
 
 			case SVRC_CVARCHANGED:
 				{
-					String name = datagram.message.read_string();
-					String value = datagram.message.read_string();
+					String name = stream.readString();
+					String value = stream.readString();
 					m_interface->print ("The value of CVar %s", name.chars());
 					m_interface->print (" is now %s\n", value.chars());
 
@@ -259,7 +259,7 @@
 				break;
 
 			case SVRC_YOUREDISCONNECTED:
-				m_interface->print ("You have been disconnected: %s\n", datagram.message.read_string().chars());
+				m_interface->print ("You have been disconnected: %s\n", stream.readString().chars());
 				m_interface->disconnected();
 				break;
 			}
@@ -430,25 +430,26 @@
 
 // -------------------------------------------------------------------------------------------------
 //
-void RCONSession::request_watch (const String& cvar)
+void RCONSession::requestWatch(const String& cvar)
 {
 	StringList cvars;
 	cvars.append(cvar);
-	request_watch(cvars);
+	requestWatch(cvars);
 }
 
 // -------------------------------------------------------------------------------------------------
 //
-void RCONSession::request_watch (const StringList& cvars)
+void RCONSession::requestWatch(const StringList& cvars)
 {
-	Bytestream packet;
-	packet.write_byte(CLRC_WATCHCVAR);
+	Vector<unsigned char> message;
+	Bytestream stream(message);
+	stream.writeByte(CLRC_WATCHCVAR);
 
-	for (int i = 0; i < cvars.size(); ++i)
-		packet.write_string(cvars[i].normalized());
+	for (const String& cvar : cvars)
+		stream.writeString(cvar.normalized());
 
-	packet.write_string("");
-	send(packet);
+	stream.writeString("");
+	send(message);
 }
 
 END_ZFC_NAMESPACE
--- a/sources/network/rconsession.h	Fri Jul 22 17:59:55 2016 +0300
+++ b/sources/network/rconsession.h	Fri Jul 22 18:03:50 2016 +0300
@@ -113,6 +113,8 @@
 	bool                        isActive() const;
 	void                        processServerUpdates(Bytestream& packet);
 	void                        requestTabCompletion(const String& part);
+	void                        requestWatch (const String& cvar);
+	void                        requestWatch (const StringList& cvars);
 	void                        send(const ByteArray& packet);
 	bool                        sendCommand(const String& commandString);
 	void                        sendHello();
@@ -120,8 +122,6 @@
 	void                        setInterface(class Interface* interface);
 	void                        setPassword(const String& password);
 	void                        tick();
-	void request_watch (const String& cvar);
-	void request_watch (const StringList& cvars);
 
 private:
 	RCONSessionState m_state;

mercurial