diff -r 50fcef24003f -r b3adc030104b rust/hedgewars-server/src/protocol/parser.rs --- a/rust/hedgewars-server/src/protocol/parser.rs Wed Apr 10 16:14:33 2019 +0300 +++ b/rust/hedgewars-server/src/protocol/parser.rs Wed Apr 10 18:12:30 2019 +0300 @@ -15,7 +15,9 @@ }; use super::messages::{HWProtocolMessage, HWProtocolMessage::*}; -use crate::server::coretypes::{GameCfg, HedgehogInfo, TeamInfo, VoteType, MAX_HEDGEHOGS_PER_TEAM}; +use crate::server::coretypes::{ + GameCfg, HedgehogInfo, ServerVar, TeamInfo, VoteType, MAX_HEDGEHOGS_PER_TEAM, +}; #[derive(Debug, PartialEq)] pub struct HWProtocolError {} @@ -369,6 +371,27 @@ Ok((i, Cfg(cfg))) } +fn server_var_message(input: &[u8]) -> HWResult { + precededc( + input, + hw_tag("SET_SERVER_VAR\n"), + alt(( + |i| { + precededc(i, hw_tag("MOTD_NEW\n"), a_line) + .map(|(i, s)| (i, SetServerVar(ServerVar::MOTDNew(s)))) + }, + |i| { + precededc(i, hw_tag("MOTD_OLD\n"), a_line) + .map(|(i, s)| (i, SetServerVar(ServerVar::MOTDOld(s)))) + }, + |i| { + precededc(i, hw_tag("LATEST_PROTO\n"), u16_line) + .map(|(i, n)| (i, SetServerVar(ServerVar::LatestProto(n)))) + }, + )), + ) +} + fn complex_message(input: &[u8]) -> HWResult { alt(( |i| { @@ -527,6 +550,7 @@ single_arg_message, cmd_message, config_message, + server_var_message, complex_message, )), end_of_message,