author | unC0Rr |
Mon, 02 Jan 2023 15:59:26 +0100 | |
branch | transitional_engine |
changeset 15929 | 128ace913837 |
parent 15852 | ea459da15b30 |
child 16011 | cf580d9ff7ef |
permissions | -rw-r--r-- |
15826 | 1 |
/** The parsers for the chat and multiplayer protocol. The main parser is `message`. |
2 |
* # Protocol |
|
3 |
* All messages consist of `\n`-separated strings. The end of a message is |
|
4 |
* indicated by a double newline - `\n\n`. |
|
5 |
* |
|
6 |
* For example, a nullary command like PING will be actually sent as `PING\n\n`. |
|
7 |
* A unary command, such as `START_GAME nick` will be actually sent as `START_GAME\nnick\n\n`. |
|
8 |
*/ |
|
9 |
use nom::{ |
|
10 |
branch::alt, |
|
11 |
bytes::complete::{tag, tag_no_case, take_until, take_while}, |
|
12 |
character::complete::{newline, not_line_ending}, |
|
13 |
combinator::{map, peek}, |
|
14 |
error::{ErrorKind, ParseError}, |
|
15 |
multi::separated_list0, |
|
16 |
sequence::{delimited, pair, preceded, terminated, tuple}, |
|
17 |
Err, IResult, |
|
18 |
}; |
|
19 |
||
20 |
use std::{ |
|
21 |
num::ParseIntError, |
|
22 |
str, |
|
23 |
str::{FromStr, Utf8Error}, |
|
24 |
}; |
|
25 |
||
15852 | 26 |
use crate::{ |
27 |
messages::{HwProtocolMessage, HwProtocolMessage::*, HwServerMessage}, |
|
28 |
types::{GameCfg, HedgehogInfo, ServerVar, TeamInfo, VoteType}, |
|
29 |
}; |
|
15826 | 30 |
|
31 |
#[derive(Debug, PartialEq)] |
|
32 |
pub struct HwProtocolError {} |
|
33 |
||
34 |
impl HwProtocolError { |
|
35 |
pub fn new() -> Self { |
|
36 |
HwProtocolError {} |
|
37 |
} |
|
38 |
} |
|
39 |
||
40 |
impl<I> ParseError<I> for HwProtocolError { |
|
41 |
fn from_error_kind(_input: I, _kind: ErrorKind) -> Self { |
|
42 |
HwProtocolError::new() |
|
43 |
} |
|
44 |
||
45 |
fn append(_input: I, _kind: ErrorKind, _other: Self) -> Self { |
|
46 |
HwProtocolError::new() |
|
47 |
} |
|
48 |
} |
|
49 |
||
50 |
impl From<Utf8Error> for HwProtocolError { |
|
51 |
fn from(_: Utf8Error) -> Self { |
|
52 |
HwProtocolError::new() |
|
53 |
} |
|
54 |
} |
|
55 |
||
56 |
impl From<ParseIntError> for HwProtocolError { |
|
57 |
fn from(_: ParseIntError) -> Self { |
|
58 |
HwProtocolError::new() |
|
59 |
} |
|
60 |
} |
|
61 |
||
62 |
pub type HwResult<'a, O> = IResult<&'a [u8], O, HwProtocolError>; |
|
63 |
||
64 |
fn end_of_message(input: &[u8]) -> HwResult<&[u8]> { |
|
65 |
tag("\n\n")(input) |
|
66 |
} |
|
67 |
||
68 |
fn convert_utf8(input: &[u8]) -> HwResult<&str> { |
|
69 |
match str::from_utf8(input) { |
|
70 |
Ok(str) => Ok((b"", str)), |
|
71 |
Err(utf_err) => Result::Err(Err::Failure(utf_err.into())), |
|
72 |
} |
|
73 |
} |
|
74 |
||
75 |
fn convert_from_str<T>(str: &str) -> HwResult<T> |
|
76 |
where |
|
77 |
T: FromStr<Err = ParseIntError>, |
|
78 |
{ |
|
79 |
match T::from_str(str) { |
|
80 |
Ok(x) => Ok((b"", x)), |
|
81 |
Err(format_err) => Result::Err(Err::Failure(format_err.into())), |
|
82 |
} |
|
83 |
} |
|
84 |
||
85 |
fn str_line(input: &[u8]) -> HwResult<&str> { |
|
86 |
let (i, text) = not_line_ending(<&[u8]>::clone(&input))?; |
|
87 |
if i != input { |
|
88 |
Ok((i, convert_utf8(text)?.1)) |
|
89 |
} else { |
|
90 |
Err(Err::Error(HwProtocolError::new())) |
|
91 |
} |
|
92 |
} |
|
93 |
||
94 |
fn a_line(input: &[u8]) -> HwResult<String> { |
|
95 |
map(str_line, String::from)(input) |
|
96 |
} |
|
97 |
||
98 |
fn cmd_arg(input: &[u8]) -> HwResult<String> { |
|
99 |
let delimiters = b" \n"; |
|
100 |
let (i, str) = take_while(move |c| !delimiters.contains(&c))(<&[u8]>::clone(&input))?; |
|
101 |
if i != input { |
|
102 |
Ok((i, convert_utf8(str)?.1.to_string())) |
|
103 |
} else { |
|
104 |
Err(Err::Error(HwProtocolError::new())) |
|
105 |
} |
|
106 |
} |
|
107 |
||
108 |
fn u8_line(input: &[u8]) -> HwResult<u8> { |
|
109 |
let (i, str) = str_line(input)?; |
|
110 |
Ok((i, convert_from_str(str)?.1)) |
|
111 |
} |
|
112 |
||
113 |
fn u16_line(input: &[u8]) -> HwResult<u16> { |
|
114 |
let (i, str) = str_line(input)?; |
|
115 |
Ok((i, convert_from_str(str)?.1)) |
|
116 |
} |
|
117 |
||
118 |
fn u32_line(input: &[u8]) -> HwResult<u32> { |
|
119 |
let (i, str) = str_line(input)?; |
|
120 |
Ok((i, convert_from_str(str)?.1)) |
|
121 |
} |
|
122 |
||
123 |
fn yes_no_line(input: &[u8]) -> HwResult<bool> { |
|
124 |
alt(( |
|
125 |
map(tag_no_case(b"YES"), |_| true), |
|
126 |
map(tag_no_case(b"NO"), |_| false), |
|
127 |
))(input) |
|
128 |
} |
|
129 |
||
130 |
fn opt_arg<'a>(input: &'a [u8]) -> HwResult<'a, Option<String>> { |
|
131 |
alt(( |
|
132 |
map(peek(end_of_message), |_| None), |
|
133 |
map(preceded(tag("\n"), a_line), Some), |
|
134 |
))(input) |
|
135 |
} |
|
136 |
||
137 |
fn spaces(input: &[u8]) -> HwResult<&[u8]> { |
|
138 |
preceded(tag(" "), take_while(|c| c == b' '))(input) |
|
139 |
} |
|
140 |
||
141 |
fn opt_space_arg<'a>(input: &'a [u8]) -> HwResult<'a, Option<String>> { |
|
142 |
alt(( |
|
143 |
map(peek(end_of_message), |_| None), |
|
144 |
map(preceded(spaces, a_line), Some), |
|
145 |
))(input) |
|
146 |
} |
|
147 |
||
148 |
fn hedgehog_array(input: &[u8]) -> HwResult<[HedgehogInfo; 8]> { |
|
149 |
fn hedgehog_line(input: &[u8]) -> HwResult<HedgehogInfo> { |
|
150 |
map( |
|
151 |
tuple((terminated(a_line, newline), a_line)), |
|
152 |
|(name, hat)| HedgehogInfo { name, hat }, |
|
153 |
)(input) |
|
154 |
} |
|
155 |
||
156 |
let (i, (h1, h2, h3, h4, h5, h6, h7, h8)) = tuple(( |
|
157 |
terminated(hedgehog_line, newline), |
|
158 |
terminated(hedgehog_line, newline), |
|
159 |
terminated(hedgehog_line, newline), |
|
160 |
terminated(hedgehog_line, newline), |
|
161 |
terminated(hedgehog_line, newline), |
|
162 |
terminated(hedgehog_line, newline), |
|
163 |
terminated(hedgehog_line, newline), |
|
164 |
hedgehog_line, |
|
165 |
))(input)?; |
|
166 |
||
167 |
Ok((i, [h1, h2, h3, h4, h5, h6, h7, h8])) |
|
168 |
} |
|
169 |
||
170 |
fn voting(input: &[u8]) -> HwResult<VoteType> { |
|
171 |
alt(( |
|
172 |
map(tag_no_case("PAUSE"), |_| VoteType::Pause), |
|
173 |
map(tag_no_case("NEWSEED"), |_| VoteType::NewSeed), |
|
174 |
map( |
|
175 |
preceded(pair(tag_no_case("KICK"), spaces), a_line), |
|
176 |
VoteType::Kick, |
|
177 |
), |
|
178 |
map( |
|
179 |
preceded(pair(tag_no_case("HEDGEHOGS"), spaces), u8_line), |
|
180 |
VoteType::HedgehogsPerTeam, |
|
181 |
), |
|
182 |
map(preceded(tag_no_case("MAP"), opt_space_arg), VoteType::Map), |
|
183 |
))(input) |
|
184 |
} |
|
185 |
||
186 |
fn no_arg_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
187 |
fn message<'a>( |
|
188 |
name: &'a str, |
|
189 |
msg: HwProtocolMessage, |
|
190 |
) -> impl Fn(&'a [u8]) -> HwResult<'a, HwProtocolMessage> { |
|
191 |
move |i| map(tag(name), |_| msg.clone())(i) |
|
192 |
} |
|
193 |
||
194 |
alt(( |
|
195 |
message("PING", Ping), |
|
196 |
message("PONG", Pong), |
|
197 |
message("LIST", List), |
|
198 |
message("BANLIST", BanList), |
|
199 |
message("GET_SERVER_VAR", GetServerVar), |
|
200 |
message("TOGGLE_READY", ToggleReady), |
|
201 |
message("START_GAME", StartGame), |
|
202 |
message("TOGGLE_RESTRICT_JOINS", ToggleRestrictJoin), |
|
203 |
message("TOGGLE_RESTRICT_TEAMS", ToggleRestrictTeams), |
|
204 |
message("TOGGLE_REGISTERED_ONLY", ToggleRegisteredOnly), |
|
15833
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
205 |
message("READY", CheckerReady), |
15826 | 206 |
))(input) |
207 |
} |
|
208 |
||
209 |
fn single_arg_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
210 |
fn message<'a, T, F, G>( |
|
211 |
name: &'a str, |
|
212 |
parser: F, |
|
213 |
constructor: G, |
|
214 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, HwProtocolMessage> |
|
215 |
where |
|
216 |
F: Fn(&[u8]) -> HwResult<T>, |
|
217 |
G: Fn(T) -> HwProtocolMessage, |
|
218 |
{ |
|
219 |
map(preceded(tag(name), parser), constructor) |
|
220 |
} |
|
221 |
||
222 |
alt(( |
|
223 |
message("NICK\n", a_line, Nick), |
|
224 |
message("INFO\n", a_line, Info), |
|
225 |
message("CHAT\n", a_line, Chat), |
|
226 |
message("PART", opt_arg, Part), |
|
227 |
message("FOLLOW\n", a_line, Follow), |
|
228 |
message("KICK\n", a_line, Kick), |
|
229 |
message("UNBAN\n", a_line, Unban), |
|
230 |
message("EM\n", a_line, EngineMessage), |
|
231 |
message("TEAMCHAT\n", a_line, TeamChat), |
|
232 |
message("ROOM_NAME\n", a_line, RoomName), |
|
233 |
message("REMOVE_TEAM\n", a_line, RemoveTeam), |
|
234 |
message("ROUNDFINISHED", opt_arg, |_| RoundFinished), |
|
235 |
message("PROTO\n", u16_line, Proto), |
|
236 |
message("QUIT", opt_arg, Quit), |
|
15833
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
237 |
message("CHECKED\nFAIL\n", a_line, CheckedFail), |
15826 | 238 |
))(input) |
239 |
} |
|
240 |
||
241 |
fn cmd_message<'a>(input: &'a [u8]) -> HwResult<'a, HwProtocolMessage> { |
|
242 |
fn cmd_no_arg<'a>( |
|
243 |
name: &'a str, |
|
244 |
msg: HwProtocolMessage, |
|
245 |
) -> impl Fn(&'a [u8]) -> HwResult<'a, HwProtocolMessage> { |
|
246 |
move |i| map(tag_no_case(name), |_| msg.clone())(i) |
|
247 |
} |
|
248 |
||
249 |
fn cmd_single_arg<'a, T, F, G>( |
|
250 |
name: &'a str, |
|
251 |
parser: F, |
|
252 |
constructor: G, |
|
253 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, HwProtocolMessage> |
|
254 |
where |
|
255 |
F: Fn(&'a [u8]) -> HwResult<'a, T>, |
|
256 |
G: Fn(T) -> HwProtocolMessage, |
|
257 |
{ |
|
258 |
map( |
|
259 |
preceded(pair(tag_no_case(name), spaces), parser), |
|
260 |
constructor, |
|
261 |
) |
|
262 |
} |
|
263 |
||
264 |
fn cmd_no_arg_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
265 |
alt(( |
|
266 |
cmd_no_arg("STATS", Stats), |
|
267 |
cmd_no_arg("FIX", Fix), |
|
268 |
cmd_no_arg("UNFIX", Unfix), |
|
269 |
cmd_no_arg("REGISTERED_ONLY", ToggleServerRegisteredOnly), |
|
270 |
cmd_no_arg("SUPER_POWER", SuperPower), |
|
271 |
))(input) |
|
272 |
} |
|
273 |
||
274 |
fn cmd_single_arg_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
275 |
alt(( |
|
276 |
cmd_single_arg("RESTART_SERVER", |i| tag("YES")(i), |_| RestartServer), |
|
277 |
cmd_single_arg("DELEGATE", a_line, Delegate), |
|
278 |
cmd_single_arg("DELETE", a_line, Delete), |
|
279 |
cmd_single_arg("SAVEROOM", a_line, SaveRoom), |
|
280 |
cmd_single_arg("LOADROOM", a_line, LoadRoom), |
|
281 |
cmd_single_arg("GLOBAL", a_line, Global), |
|
282 |
cmd_single_arg("WATCH", u32_line, Watch), |
|
283 |
cmd_single_arg("VOTE", yes_no_line, Vote), |
|
284 |
cmd_single_arg("FORCE", yes_no_line, ForceVote), |
|
285 |
cmd_single_arg("INFO", a_line, Info), |
|
286 |
cmd_single_arg("MAXTEAMS", u8_line, MaxTeams), |
|
287 |
cmd_single_arg("CALLVOTE", voting, |v| CallVote(Some(v))), |
|
288 |
))(input) |
|
289 |
} |
|
290 |
||
291 |
preceded( |
|
292 |
tag("CMD\n"), |
|
293 |
alt(( |
|
294 |
cmd_no_arg_message, |
|
295 |
cmd_single_arg_message, |
|
296 |
map(tag_no_case("CALLVOTE"), |_| CallVote(None)), |
|
297 |
map(preceded(tag_no_case("GREETING"), opt_space_arg), Greeting), |
|
298 |
map(preceded(tag_no_case("PART"), opt_space_arg), Part), |
|
299 |
map(preceded(tag_no_case("QUIT"), opt_space_arg), Quit), |
|
300 |
map( |
|
301 |
preceded( |
|
302 |
tag_no_case("SAVE"), |
|
303 |
pair(preceded(spaces, cmd_arg), preceded(spaces, cmd_arg)), |
|
304 |
), |
|
305 |
|(n, l)| Save(n, l), |
|
306 |
), |
|
307 |
map( |
|
308 |
preceded( |
|
309 |
tag_no_case("RND"), |
|
310 |
alt(( |
|
311 |
map(peek(end_of_message), |_| vec![]), |
|
312 |
preceded(spaces, separated_list0(spaces, cmd_arg)), |
|
313 |
)), |
|
314 |
), |
|
315 |
Rnd, |
|
316 |
), |
|
317 |
)), |
|
318 |
)(input) |
|
319 |
} |
|
320 |
||
321 |
fn config_message<'a>(input: &'a [u8]) -> HwResult<'a, HwProtocolMessage> { |
|
322 |
fn cfg_single_arg<'a, T, F, G>( |
|
323 |
name: &'a str, |
|
324 |
parser: F, |
|
325 |
constructor: G, |
|
326 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, GameCfg> |
|
327 |
where |
|
328 |
F: Fn(&[u8]) -> HwResult<T>, |
|
329 |
G: Fn(T) -> GameCfg, |
|
330 |
{ |
|
331 |
map(preceded(pair(tag(name), newline), parser), constructor) |
|
332 |
} |
|
333 |
||
334 |
let (i, cfg) = preceded( |
|
335 |
tag("CFG\n"), |
|
336 |
alt(( |
|
337 |
cfg_single_arg("THEME", a_line, GameCfg::Theme), |
|
338 |
cfg_single_arg("SCRIPT", a_line, GameCfg::Script), |
|
339 |
cfg_single_arg("MAP", a_line, GameCfg::MapType), |
|
340 |
cfg_single_arg("MAPGEN", u32_line, GameCfg::MapGenerator), |
|
341 |
cfg_single_arg("MAZE_SIZE", u32_line, GameCfg::MazeSize), |
|
342 |
cfg_single_arg("TEMPLATE", u32_line, GameCfg::Template), |
|
343 |
cfg_single_arg("FEATURE_SIZE", u32_line, GameCfg::FeatureSize), |
|
344 |
cfg_single_arg("SEED", a_line, GameCfg::Seed), |
|
345 |
cfg_single_arg("DRAWNMAP", a_line, GameCfg::DrawnMap), |
|
346 |
preceded(pair(tag("AMMO"), newline), |i| { |
|
347 |
let (i, name) = a_line(i)?; |
|
348 |
let (i, value) = opt_arg(i)?; |
|
349 |
Ok((i, GameCfg::Ammo(name, value))) |
|
350 |
}), |
|
351 |
preceded( |
|
352 |
pair(tag("SCHEME"), newline), |
|
353 |
map( |
|
354 |
pair( |
|
355 |
a_line, |
|
356 |
alt(( |
|
357 |
map(peek(end_of_message), |_| None), |
|
358 |
map(preceded(newline, separated_list0(newline, a_line)), Some), |
|
359 |
)), |
|
360 |
), |
|
361 |
|(name, values)| GameCfg::Scheme(name, values.unwrap_or_default()), |
|
362 |
), |
|
363 |
), |
|
364 |
)), |
|
365 |
)(input)?; |
|
366 |
Ok((i, Cfg(cfg))) |
|
367 |
} |
|
368 |
||
369 |
fn server_var_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
370 |
map( |
|
371 |
preceded( |
|
372 |
tag("SET_SERVER_VAR\n"), |
|
373 |
alt(( |
|
374 |
map(preceded(tag("MOTD_NEW\n"), a_line), ServerVar::MOTDNew), |
|
375 |
map(preceded(tag("MOTD_OLD\n"), a_line), ServerVar::MOTDOld), |
|
376 |
map( |
|
377 |
preceded(tag("LATEST_PROTO\n"), u16_line), |
|
378 |
ServerVar::LatestProto, |
|
379 |
), |
|
380 |
)), |
|
381 |
), |
|
382 |
SetServerVar, |
|
383 |
)(input) |
|
384 |
} |
|
385 |
||
386 |
fn complex_message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
387 |
alt(( |
|
388 |
preceded( |
|
389 |
pair(tag("PASSWORD"), newline), |
|
390 |
map(pair(terminated(a_line, newline), a_line), |(pass, salt)| { |
|
391 |
Password(pass, salt) |
|
392 |
}), |
|
393 |
), |
|
394 |
preceded( |
|
395 |
pair(tag("CHECKER"), newline), |
|
396 |
map( |
|
397 |
tuple(( |
|
398 |
terminated(u16_line, newline), |
|
399 |
terminated(a_line, newline), |
|
400 |
a_line, |
|
401 |
)), |
|
402 |
|(protocol, name, pass)| Checker(protocol, name, pass), |
|
403 |
), |
|
404 |
), |
|
405 |
preceded( |
|
406 |
pair(tag("CREATE_ROOM"), newline), |
|
407 |
map(pair(a_line, opt_arg), |(name, pass)| CreateRoom(name, pass)), |
|
408 |
), |
|
409 |
preceded( |
|
410 |
pair(tag("JOIN_ROOM"), newline), |
|
411 |
map(pair(a_line, opt_arg), |(name, pass)| JoinRoom(name, pass)), |
|
412 |
), |
|
413 |
preceded( |
|
414 |
pair(tag("ADD_TEAM"), newline), |
|
415 |
map( |
|
416 |
tuple(( |
|
417 |
terminated(a_line, newline), |
|
418 |
terminated(u8_line, newline), |
|
419 |
terminated(a_line, newline), |
|
420 |
terminated(a_line, newline), |
|
421 |
terminated(a_line, newline), |
|
422 |
terminated(a_line, newline), |
|
423 |
terminated(u8_line, newline), |
|
424 |
hedgehog_array, |
|
425 |
)), |
|
426 |
|(name, color, grave, fort, voice_pack, flag, difficulty, hedgehogs)| { |
|
427 |
AddTeam(Box::new(TeamInfo { |
|
428 |
owner: String::new(), |
|
429 |
name, |
|
430 |
color, |
|
431 |
grave, |
|
432 |
fort, |
|
433 |
voice_pack, |
|
434 |
flag, |
|
435 |
difficulty, |
|
436 |
hedgehogs, |
|
437 |
hedgehogs_number: 0, |
|
438 |
})) |
|
439 |
}, |
|
440 |
), |
|
441 |
), |
|
442 |
preceded( |
|
443 |
pair(tag("HH_NUM"), newline), |
|
444 |
map( |
|
445 |
pair(terminated(a_line, newline), u8_line), |
|
446 |
|(name, count)| SetHedgehogsNumber(name, count), |
|
447 |
), |
|
448 |
), |
|
449 |
preceded( |
|
450 |
pair(tag("TEAM_COLOR"), newline), |
|
451 |
map( |
|
452 |
pair(terminated(a_line, newline), u8_line), |
|
453 |
|(name, color)| SetTeamColor(name, color), |
|
454 |
), |
|
455 |
), |
|
456 |
preceded( |
|
457 |
pair(tag("BAN"), newline), |
|
458 |
map( |
|
459 |
tuple(( |
|
460 |
terminated(a_line, newline), |
|
461 |
terminated(a_line, newline), |
|
462 |
u32_line, |
|
463 |
)), |
|
464 |
|(name, reason, time)| Ban(name, reason, time), |
|
465 |
), |
|
466 |
), |
|
467 |
preceded( |
|
468 |
pair(tag("BAN_IP"), newline), |
|
469 |
map( |
|
470 |
tuple(( |
|
471 |
terminated(a_line, newline), |
|
472 |
terminated(a_line, newline), |
|
473 |
u32_line, |
|
474 |
)), |
|
475 |
|(ip, reason, time)| BanIp(ip, reason, time), |
|
476 |
), |
|
477 |
), |
|
478 |
preceded( |
|
479 |
pair(tag("BAN_NICK"), newline), |
|
480 |
map( |
|
481 |
tuple(( |
|
482 |
terminated(a_line, newline), |
|
483 |
terminated(a_line, newline), |
|
484 |
u32_line, |
|
485 |
)), |
|
486 |
|(nick, reason, time)| BanNick(nick, reason, time), |
|
487 |
), |
|
488 |
), |
|
15833
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
489 |
map( |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
490 |
preceded( |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
491 |
tag("CHECKED\nOK"), |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
492 |
alt(( |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
493 |
map(peek(end_of_message), |_| None), |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
494 |
map(preceded(newline, separated_list0(newline, a_line)), Some), |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
495 |
)), |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
496 |
), |
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
497 |
|values| CheckedOk(values.unwrap_or_default()), |
15852 | 498 |
), |
499 |
))(input) |
|
15826 | 500 |
} |
501 |
||
502 |
pub fn malformed_message(input: &[u8]) -> HwResult<()> { |
|
503 |
map(terminated(take_until(&b"\n\n"[..]), end_of_message), |_| ())(input) |
|
504 |
} |
|
505 |
||
506 |
pub fn message(input: &[u8]) -> HwResult<HwProtocolMessage> { |
|
507 |
delimited( |
|
508 |
take_while(|c| c == b'\n'), |
|
509 |
alt(( |
|
510 |
no_arg_message, |
|
511 |
single_arg_message, |
|
512 |
cmd_message, |
|
513 |
config_message, |
|
514 |
server_var_message, |
|
515 |
complex_message, |
|
516 |
)), |
|
517 |
end_of_message, |
|
518 |
)(input) |
|
519 |
} |
|
15832
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
520 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
521 |
pub fn server_message(input: &[u8]) -> HwResult<HwServerMessage> { |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
522 |
use HwServerMessage::*; |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
523 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
524 |
fn single_arg_message<'a, T, F, G>( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
525 |
name: &'a str, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
526 |
parser: F, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
527 |
constructor: G, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
528 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, HwServerMessage> |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
529 |
where |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
530 |
F: Fn(&[u8]) -> HwResult<T>, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
531 |
G: Fn(T) -> HwServerMessage, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
532 |
{ |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
533 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
534 |
preceded(terminated(tag(name), newline), parser), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
535 |
constructor, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
536 |
) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
537 |
} |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
538 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
539 |
fn list_message<'a, G>( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
540 |
name: &'a str, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
541 |
constructor: G, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
542 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, HwServerMessage> |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
543 |
where |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
544 |
G: Fn(Vec<String>) -> HwServerMessage, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
545 |
{ |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
546 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
547 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
548 |
tag(name), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
549 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
550 |
map(peek(end_of_message), |_| None), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
551 |
map(preceded(newline, separated_list0(newline, a_line)), Some), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
552 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
553 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
554 |
move |values| constructor(values.unwrap_or_default()), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
555 |
) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
556 |
} |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
557 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
558 |
fn string_and_list_message<'a, G>( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
559 |
name: &'a str, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
560 |
constructor: G, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
561 |
) -> impl FnMut(&'a [u8]) -> HwResult<'a, HwServerMessage> |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
562 |
where |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
563 |
G: Fn(String, Vec<String>) -> HwServerMessage, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
564 |
{ |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
565 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
566 |
pair(tag(name), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
567 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
568 |
pair( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
569 |
a_line, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
570 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
571 |
map(peek(end_of_message), |_| None), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
572 |
map(preceded(newline, separated_list0(newline, a_line)), Some), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
573 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
574 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
575 |
move |(name, values)| constructor(name, values.unwrap_or_default()), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
576 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
577 |
) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
578 |
} |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
579 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
580 |
fn message<'a>( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
581 |
name: &'a str, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
582 |
msg: HwServerMessage, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
583 |
) -> impl Fn(&'a [u8]) -> HwResult<'a, HwServerMessage> { |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
584 |
move |i| map(tag(name), |_| msg.clone())(i) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
585 |
} |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
586 |
|
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
587 |
delimited( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
588 |
take_while(|c| c == b'\n'), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
589 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
590 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
591 |
message("PING", Ping), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
592 |
message("PONG", Pong), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
593 |
message("LOGONPASSED", LogonPassed), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
594 |
message("KICKED", Kicked), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
595 |
message("RUN_GAME", RunGame), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
596 |
message("ROUND_FINISHED", RoundFinished), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
597 |
message("REPLAY_START", ReplayStart), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
598 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
599 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
600 |
single_arg_message("REDIRECT", u16_line, Redirect), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
601 |
single_arg_message("BYE", a_line, Bye), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
602 |
single_arg_message("NICK", a_line, Nick), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
603 |
single_arg_message("PROTO", u16_line, Proto), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
604 |
single_arg_message("ASKPASSWORD", a_line, AskPassword), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
605 |
single_arg_message("SERVER_AUTH", a_line, ServerAuth), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
606 |
single_arg_message("ROOM\nDEL", a_line, RoomRemove), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
607 |
single_arg_message("JOINING", a_line, Joining), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
608 |
single_arg_message("REMOVE_TEAM", a_line, TeamRemove), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
609 |
single_arg_message("TEAM_ACCEPTED", a_line, TeamAccepted), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
610 |
single_arg_message("SERVER_MESSAGE", a_line, ServerMessage), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
611 |
single_arg_message("NOTICE", a_line, Notice), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
612 |
single_arg_message("WARNING", a_line, Warning), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
613 |
single_arg_message("ERROR", a_line, Error), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
614 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
615 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
616 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
617 |
pair(tag("LOBBY:LEFT"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
618 |
map(pair(terminated(a_line, newline), a_line), |(nick, msg)| { |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
619 |
LobbyLeft(nick, msg) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
620 |
}), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
621 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
622 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
623 |
pair(tag("CHAT"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
624 |
map(pair(terminated(a_line, newline), a_line), |(nick, msg)| { |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
625 |
ChatMsg { nick, msg } |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
626 |
}), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
627 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
628 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
629 |
pair(tag("TEAM_COLOR"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
630 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
631 |
pair(terminated(a_line, newline), u8_line), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
632 |
|(name, color)| TeamColor(name, color), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
633 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
634 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
635 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
636 |
pair(tag("HH_NUM"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
637 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
638 |
pair(terminated(a_line, newline), u8_line), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
639 |
|(name, count)| HedgehogsNumber(name, count), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
640 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
641 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
642 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
643 |
pair(tag("CONNECTED"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
644 |
map( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
645 |
pair(terminated(a_line, newline), u32_line), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
646 |
|(msg, server_protocol_version)| Connected(msg, server_protocol_version), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
647 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
648 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
649 |
preceded( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
650 |
pair(tag("LEFT"), newline), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
651 |
map(pair(terminated(a_line, newline), a_line), |(nick, msg)| { |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
652 |
RoomLeft(nick, msg) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
653 |
}), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
654 |
), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
655 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
656 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
657 |
string_and_list_message("CLIENT_FLAGS", ClientFlags), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
658 |
string_and_list_message("ROOM\nUPD", RoomUpdated), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
659 |
string_and_list_message("CFG", ConfigEntry), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
660 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
661 |
alt(( |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
662 |
list_message("LOBBY:JOINED", LobbyJoined), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
663 |
list_message("ROOMS", Rooms), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
664 |
list_message("ROOM\nADD", RoomAdd), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
665 |
list_message("JOINED", RoomJoined), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
666 |
list_message("ADD_TEAM", TeamAdd), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
667 |
list_message("EM", ForwardEngineMessage), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
668 |
list_message("INFO", Info), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
669 |
list_message("SERVER_VARS", ServerVars), |
15833
a855f32ab3ca
- Update hedgewars-network-protocol library with messages needed for checker
unc0rr
parents:
15832
diff
changeset
|
670 |
list_message("REPLAY", Replay), |
15832
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
671 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
672 |
)), |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
673 |
end_of_message, |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
674 |
)(input) |
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15826
diff
changeset
|
675 |
} |