sources/network/rconsession.cpp

branch
protocol5
changeset 79
62cfb7b97fc0
parent 78
c1d43ade656e
child 80
f992b027374b
--- a/sources/network/rconsession.cpp	Fri May 15 22:46:53 2015 +0300
+++ b/sources/network/rconsession.cpp	Sun May 17 17:22:20 2015 +0300
@@ -220,6 +220,27 @@
 					}
 				}
 				break;
+
+			case SVRC_WATCHINGCVAR:
+				m_interface->print ("Server acknowledges watch on %1\n", packet.read_string());
+				m_interface->print ("Its current value is %1\n", packet.read_string());
+				break;
+
+			case SVRC_ALREADYWATCHINGCVAR:
+				m_interface->print ("Server says you are already watching %1\n", packet.read_string());
+				break;
+
+			case SVRC_WATCHCVARNOTFOUND:
+				m_interface->print ("No such cvar %1\n", packet.read_string());
+				break;
+
+			case SVRC_CVARCHANGED:
+				{
+					String name = packet.read_string();
+					String value = packet.read_string();
+					m_interface->print ("New value of %1: %2\n", name, value);
+				}
+				break;
 			}
 		}
 	}
@@ -324,6 +345,24 @@
 	if (m_state != RCON_CONNECTED or message.is_empty())
 		return false;
 
+	if (message.starts_with ("/watch "))
+	{
+		String cvarnamelist = message.mid (String ("/watch ").length(), -1);
+		cvarnamelist.normalize();
+
+		Bytestream packet;
+		packet.write_byte (CLRC_WATCHCVAR);
+
+		for (String cvarname : cvarnamelist.split (' '))
+		{
+			m_interface->print (TEXTCOLOR_Green "Requesting watch on %1...\n", cvarname);
+			packet.write_string (cvarname);
+		}
+		send (packet);
+		bump_last_ping();
+		return true;
+	}
+
 	Bytestream packet;
 	packet.write_byte (CLRC_COMMAND);
 	packet.write_string (message);

mercurial