diff -r d1368c776a4f -r 5fb27f94fc3b gameServer2/src/protocol/messages.rs --- a/gameServer2/src/protocol/messages.rs Sun Jun 24 12:09:31 2018 -0400 +++ b/gameServer2/src/protocol/messages.rs Tue Jun 26 23:22:38 2018 +0300 @@ -91,6 +91,7 @@ TeamAccepted(String), TeamColor(String, u8), HedgehogsNumber(String, u8), + ConfigEntry(String, Vec), ServerMessage(String), Warning(String), @@ -99,6 +100,33 @@ Unreachable, } +impl GameCfg { + pub fn into_server_msg(self) -> HWServerMessage { + use self::HWServerMessage::ConfigEntry; + use server::coretypes::GameCfg::*; + match self { + FeatureSize(s) => ConfigEntry("FEATURE_SIZE".to_string(), vec![s.to_string()]), + MapType(t) => ConfigEntry("MAP".to_string(), vec![t.to_string()]), + MapGenerator(g) => ConfigEntry("MAPGEN".to_string(), vec![g.to_string()]), + MazeSize(s) => ConfigEntry("MAZE_SIZE".to_string(), vec![s.to_string()]), + Seed(s) => ConfigEntry("SEED".to_string(), vec![s.to_string()]), + Template(t) => ConfigEntry("TEMPLATE".to_string(), vec![t.to_string()]), + + Ammo(n, None) => ConfigEntry("AMMO".to_string(), vec![n.to_string()]), + Ammo(n, Some(s)) => ConfigEntry("AMMO".to_string(), vec![n.to_string(), s.to_string()]), + Scheme(n, None) => ConfigEntry("SCHEME".to_string(), vec![n.to_string()]), + Scheme(n, Some(s)) => ConfigEntry("SCHEME".to_string(), { + let mut v = vec![n.to_string()]; + v.extend(s.into_iter()); + v + }), + Script(s) => ConfigEntry("SCRIPT".to_string(), vec![s.to_string()]), + Theme(t) => ConfigEntry("THEME".to_string(), vec![t.to_string()]), + DrawnMap(m) => ConfigEntry("DRAWNMAP".to_string(), vec![m.to_string()]) + } + } +} + impl<'a> HWProtocolMessage { pub fn to_raw_protocol(&self) -> String { use self::HWProtocolMessage::*; @@ -229,6 +257,8 @@ TeamAccepted(name) => msg!["TEAM_ACCEPTED", name], TeamColor(name, color) => msg!["TEAM_COLOR", name, color], HedgehogsNumber(name, number) => msg!["HH_NUM", name, number], + ConfigEntry(name, values) => + construct_message(&["CFG", name], &values), ChatMsg(nick, msg) => msg!["CHAT", nick, msg], ServerMessage(msg) => msg!["SERVER_MESSAGE", msg], Warning(msg) => msg!["WARNING", msg],