gameServer2/src/protocol/messages.rs
changeset 13806 5fb40c8e5542
parent 13805 0118b7412570
child 14355 31717e1436cd
equal deleted inserted replaced
13805:0118b7412570 13806:5fb40c8e5542
    98     RunGame,
    98     RunGame,
    99     ForwardEngineMessage(Vec<String>),
    99     ForwardEngineMessage(Vec<String>),
   100     RoundFinished,
   100     RoundFinished,
   101 
   101 
   102     ServerMessage(String),
   102     ServerMessage(String),
       
   103     Notice(String),
   103     Warning(String),
   104     Warning(String),
   104     Error(String),
   105     Error(String),
   105     Connected(u32),
   106     Connected(u32),
   106     Unreachable,
   107     Unreachable,
       
   108 
       
   109     //Deprecated messages
       
   110     LegacyReady(bool, Vec<String>)
   107 }
   111 }
   108 
   112 
   109 pub fn server_chat(msg: String) -> HWServerMessage  {
   113 pub fn server_chat(msg: String) -> HWServerMessage  {
   110     HWServerMessage::ChatMsg{ nick: "[server]".to_string(), msg }
   114     HWServerMessage::ChatMsg{ nick: "[server]".to_string(), msg }
   111 }
   115 }
   121             Seed(s) => ("SEED".to_string(), vec![s.to_string()]),
   125             Seed(s) => ("SEED".to_string(), vec![s.to_string()]),
   122             Template(t) => ("TEMPLATE".to_string(), vec![t.to_string()]),
   126             Template(t) => ("TEMPLATE".to_string(), vec![t.to_string()]),
   123 
   127 
   124             Ammo(n, None) => ("AMMO".to_string(), vec![n.to_string()]),
   128             Ammo(n, None) => ("AMMO".to_string(), vec![n.to_string()]),
   125             Ammo(n, Some(s)) => ("AMMO".to_string(), vec![n.to_string(), s.to_string()]),
   129             Ammo(n, Some(s)) => ("AMMO".to_string(), vec![n.to_string(), s.to_string()]),
   126             Scheme(n, None) => ("SCHEME".to_string(), vec![n.to_string()]),
   130             Scheme(n, s) if s.is_empty() => ("SCHEME".to_string(), vec![n.to_string()]),
   127             Scheme(n, Some(s)) => ("SCHEME".to_string(), {
   131             Scheme(n, s) => ("SCHEME".to_string(), {
   128                 let mut v = vec![n.to_string()];
   132                 let mut v = vec![n.to_string()];
   129                 v.extend(s.clone().into_iter());
   133                 v.extend(s.clone().into_iter());
   130                 v
   134                 v
   131             }),
   135             }),
   132             Script(s) => ("SCRIPT".to_string(), vec![s.to_string()]),
   136             Script(s) => ("SCRIPT".to_string(), vec![s.to_string()]),
   297             ForwardEngineMessage(em) =>
   301             ForwardEngineMessage(em) =>
   298                 construct_message(&["EM"], &em),
   302                 construct_message(&["EM"], &em),
   299             RoundFinished => msg!["ROUND_FINISHED"],
   303             RoundFinished => msg!["ROUND_FINISHED"],
   300             ChatMsg {nick, msg} => msg!["CHAT", nick, msg],
   304             ChatMsg {nick, msg} => msg!["CHAT", nick, msg],
   301             ServerMessage(msg) => msg!["SERVER_MESSAGE", msg],
   305             ServerMessage(msg) => msg!["SERVER_MESSAGE", msg],
       
   306             Notice(msg) => msg!["NOTICE", msg],
   302             Warning(msg) => msg!["WARNING", msg],
   307             Warning(msg) => msg!["WARNING", msg],
   303             Error(msg) => msg!["ERROR", msg],
   308             Error(msg) => msg!["ERROR", msg],
       
   309 
       
   310             LegacyReady(is_ready, nicks) =>
       
   311                 construct_message(&[if *is_ready {"READY"} else {"NOT_READY"}], &nicks),
       
   312 
   304             _ => msg!["ERROR", "UNIMPLEMENTED"],
   313             _ => msg!["ERROR", "UNIMPLEMENTED"],
   305         }
   314         }
   306     }
   315     }
   307 }
   316 }