rust/hedgewars-server/src/protocol/messages.rs
changeset 14785 a1077e8d26f4
parent 14784 8390d5e4e39c
child 14786 8ecdb5c6bb2a
--- a/rust/hedgewars-server/src/protocol/messages.rs	Wed Apr 10 19:30:08 2019 +0300
+++ b/rust/hedgewars-server/src/protocol/messages.rs	Wed Apr 10 23:56:53 2019 +0300
@@ -8,7 +8,7 @@
     Pong,
     Quit(Option<String>),
     Global(String),
-    Watch(String),
+    Watch(u32),
     ToggleServerRegisteredOnly,
     SuperPower,
     Info(String),
@@ -210,6 +210,26 @@
     }
 }
 
+impl TeamInfo {
+    pub fn to_protocol(&self) -> Vec<String> {
+        let mut info = vec![
+            self.name.clone(),
+            self.grave.clone(),
+            self.fort.clone(),
+            self.voice_pack.clone(),
+            self.flag.clone(),
+            self.owner.clone(),
+            self.difficulty.to_string(),
+        ];
+        let hogs = self
+            .hedgehogs
+            .iter()
+            .flat_map(|h| once(h.name.clone()).chain(once(h.hat.clone())));
+        info.extend(hogs);
+        info
+    }
+}
+
 macro_rules! const_braces {
     ($e: expr) => {
         "{}\n"