author | unC0Rr |
Thu, 29 Sep 2022 16:30:02 +0200 | |
changeset 15882 | f185e7367dd3 |
parent 15879 | 4c58b320056c |
permissions | -rw-r--r-- |
14457 | 1 |
use base64::encode; |
2 |
use std::iter::Iterator; |
|
12126 | 3 |
|
14783 | 4 |
pub const SERVER_VERSION: u32 = 3; |
15810
ee84e417d8d0
Add parser and idempotention tests for server messages
unc0rr
parents:
15800
diff
changeset
|
5 |
pub const SERVER_MESSAGE: &str = &"Hedgewars server https://www.hedgewars.org/"; |
13416 | 6 |
|
14457 | 7 |
pub fn is_name_illegal(name: &str) -> bool { |
8 |
name.len() > 40 |
|
9 |
|| name.trim().is_empty() |
|
14781 | 10 |
|| name.trim() != name |
14457 | 11 |
|| name |
12 |
.chars() |
|
15026 | 13 |
.any(|c| "$()*+?[]^{|}\x7F".contains(c) || ('\x00'..='\x1F').contains(&c)) |
13423 | 14 |
} |
15 |
||
16 |
pub fn to_engine_msg<T>(msg: T) -> String |
|
14457 | 17 |
where |
18 |
T: Iterator<Item = u8> + Clone, |
|
13423 | 19 |
{ |
20 |
let mut tmp = Vec::new(); |
|
21 |
tmp.push(msg.clone().count() as u8); |
|
22 |
tmp.extend(msg); |
|
23 |
encode(&tmp) |
|
13801 | 24 |
} |
25 |
||
26 |
pub fn protocol_version_string(protocol_number: u16) -> &'static str { |
|
27 |
match protocol_number { |
|
28 |
17 => "0.9.7-dev", |
|
29 |
19 => "0.9.7", |
|
30 |
20 => "0.9.8-dev", |
|
31 |
21 => "0.9.8", |
|
32 |
22 => "0.9.9-dev", |
|
33 |
23 => "0.9.9", |
|
34 |
24 => "0.9.10-dev", |
|
35 |
25 => "0.9.10", |
|
36 |
26 => "0.9.11-dev", |
|
37 |
27 => "0.9.11", |
|
38 |
28 => "0.9.12-dev", |
|
39 |
29 => "0.9.12", |
|
40 |
30 => "0.9.13-dev", |
|
41 |
31 => "0.9.13", |
|
42 |
32 => "0.9.14-dev", |
|
43 |
33 => "0.9.14", |
|
44 |
34 => "0.9.15-dev", |
|
45 |
35 => "0.9.14.1", |
|
46 |
37 => "0.9.15", |
|
47 |
38 => "0.9.16-dev", |
|
48 |
39 => "0.9.16", |
|
49 |
40 => "0.9.17-dev", |
|
50 |
41 => "0.9.17", |
|
51 |
42 => "0.9.18-dev", |
|
52 |
43 => "0.9.18", |
|
53 |
44 => "0.9.19-dev", |
|
54 |
45 => "0.9.19", |
|
55 |
46 => "0.9.20-dev", |
|
56 |
47 => "0.9.20", |
|
57 |
48 => "0.9.21-dev", |
|
58 |
49 => "0.9.21", |
|
59 |
50 => "0.9.22-dev", |
|
60 |
51 => "0.9.22", |
|
61 |
52 => "0.9.23-dev", |
|
62 |
53 => "0.9.23", |
|
63 |
54 => "0.9.24-dev", |
|
64 |
55 => "0.9.24", |
|
65 |
56 => "0.9.25-dev", |
|
14456 | 66 |
57 => "0.9.25", |
67 |
58 => "1.0.0-dev", |
|
15443 | 68 |
59 => "1.0.0", |
15879
4c58b320056c
Change the next major release version number to 1.1.0
S.D.
parents:
15831
diff
changeset
|
69 |
60 => "1.1.0-dev", |
14457 | 70 |
_ => "Unknown", |
13801 | 71 |
} |
14456 | 72 |
} |