rust/hedgewars-server/src/protocol/messages.rs
changeset 14804 b3adc030104b
parent 14803 50fcef24003f
child 14805 8390d5e4e39c
--- a/rust/hedgewars-server/src/protocol/messages.rs	Wed Apr 10 16:14:33 2019 +0300
+++ b/rust/hedgewars-server/src/protocol/messages.rs	Wed Apr 10 18:12:30 2019 +0300
@@ -118,8 +118,8 @@
     Nick(String),
     Proto(u16),
     AskPassword(String),
+    ServerAuth(String),
 
-    ServerAuth(String),
     LobbyLeft(String, String),
     LobbyJoined(Vec<String>),
     ChatMsg { nick: String, msg: String },
@@ -142,6 +142,7 @@
     RoundFinished,
 
     ServerMessage(String),
+    ServerVars(Vec<String>),
     Notice(String),
     Warning(String),
     Error(String),
@@ -159,6 +160,16 @@
     }
 }
 
+impl ServerVar {
+    pub fn to_protocol(&self) -> Vec<String> {
+        match self {
+            ServerVar::MOTDNew(s) => vec!["MOTD_NEW".to_string(), s.clone()],
+            ServerVar::MOTDOld(s) => vec!["MOTD_OLD".to_string(), s.clone()],
+            ServerVar::LatestProto(n) => vec!["LATEST_PROTO".to_string(), n.to_string()],
+        }
+    }
+}
+
 impl GameCfg {
     pub fn to_protocol(&self) -> (String, Vec<String>) {
         use crate::server::coretypes::GameCfg::*;
@@ -251,7 +262,7 @@
             BanNick(nick, reason, time) => msg!("BAN_NICK", nick, reason, time),
             BanList => msg!["BANLIST"],
             Unban(name) => msg!["UNBAN", name],
-            //SetServerVar(ServerVar), ???
+            SetServerVar(var) => construct_message(&["SET_SERVER_VAR"], &var.to_protocol()),
             GetServerVar => msg!["GET_SERVER_VAR"],
             RestartServer => msg!["CMD", "RESTART_SERVER YES"],
             Stats => msg!["CMD", "STATS"],
@@ -351,6 +362,7 @@
             RoundFinished => msg!["ROUND_FINISHED"],
             ChatMsg { nick, msg } => msg!["CHAT", nick, msg],
             ServerMessage(msg) => msg!["SERVER_MESSAGE", msg],
+            ServerVars(vars) => construct_message(&["SERVER_VARS"], &vars),
             Notice(msg) => msg!["NOTICE", msg],
             Warning(msg) => msg!["WARNING", msg],
             Error(msg) => msg!["ERROR", msg],