sources/network/rconsession.cpp

branch
experimental
changeset 38
80b26bc9707a
parent 32
ee770597a281
child 39
052393cf9016
--- a/sources/network/rconsession.cpp	Mon Dec 15 09:12:50 2014 +0200
+++ b/sources/network/rconsession.cpp	Mon Dec 15 10:31:52 2014 +0200
@@ -187,6 +187,29 @@
 			case SVRC_UPDATE:
 				process_server_updates (packet);
 				break;
+
+			case SVRC_TABCOMPLETE:
+				{
+					StringList completes;
+
+					for (signed int i = packet.read_byte(); i > 0; --i)
+						completes << packet.read_string();
+
+					if (completes.size() == 1)
+						Interface::tab_complete (m_lastTabComplete, completes[0]);
+					else if (not completes.is_empty())
+					{
+						print ("Completions for '%1':\n", m_lastTabComplete);
+
+						for (int i = 0; i < completes.size(); i += 8)
+						{
+							Range<int> spliceRange (i, min (i + 8, completes.size() - 1));
+							StringList splice (completes.splice (spliceRange));
+							print ("- %1\n", splice.join (", "));
+						}
+					}
+				}
+				break;
 			}
 		}
 	}
@@ -340,3 +363,21 @@
 {
 	return m_level;
 }
+
+// -------------------------------------------------------------------------------------------------
+//
+METHOD
+RCONSession::request_tab_complete (const String& part) -> void
+{
+	if (m_serverProtocol >= 4)
+	{
+		Bytestream packet;
+		packet.write_byte (CLRC_TABCOMPLETE);
+		packet.write_string (part);
+		send (packet);
+		bump_last_ping();
+		m_lastTabComplete = part;
+	}
+	else
+		print ("Server protocol is %1, cannot tab-complete\n", m_serverProtocol);
+}

mercurial