12130
|
1 |
use server::coretypes::{ServerVar, GameCfg, TeamInfo, HedgehogInfo};
|
12131
|
2 |
use std;
|
|
3 |
use std::ops;
|
|
4 |
use std::convert::From;
|
12130
|
5 |
|
12131
|
6 |
#[derive(PartialEq, Debug)]
|
12133
|
7 |
pub enum HWProtocolMessage<'a> {
|
12130
|
8 |
// core
|
|
9 |
Ping,
|
|
10 |
Pong,
|
12133
|
11 |
Quit(Option<&'a str>),
|
|
12 |
//Cmd(&'a str, Vec<&'a str>),
|
|
13 |
Global(&'a str),
|
|
14 |
Watch(&'a str),
|
12130
|
15 |
ToggleServerRegisteredOnly,
|
|
16 |
SuperPower,
|
12133
|
17 |
Info(&'a str),
|
12130
|
18 |
// not entered state
|
12133
|
19 |
Nick(&'a str),
|
12130
|
20 |
Proto(u32),
|
12133
|
21 |
Password(&'a str, &'a str),
|
12135
|
22 |
Checker(u32, &'a str, &'a str),
|
12130
|
23 |
// lobby
|
|
24 |
List,
|
12133
|
25 |
Chat(&'a str),
|
|
26 |
CreateRoom(&'a str, Option<&'a str>),
|
|
27 |
Join(&'a str, Option<&'a str>),
|
|
28 |
Follow(&'a str),
|
|
29 |
Rnd(Vec<&'a str>),
|
|
30 |
Kick(&'a str),
|
|
31 |
Ban(&'a str, &'a str, u32),
|
|
32 |
BanIP(&'a str, &'a str, u32),
|
|
33 |
BanNick(&'a str, &'a str, u32),
|
12130
|
34 |
BanList,
|
12133
|
35 |
Unban(&'a str),
|
12130
|
36 |
SetServerVar(ServerVar),
|
|
37 |
GetServerVar,
|
|
38 |
RestartServer,
|
|
39 |
Stats,
|
|
40 |
// in room
|
12133
|
41 |
Part(Option<&'a str>),
|
12130
|
42 |
Cfg(GameCfg),
|
|
43 |
AddTeam(TeamInfo),
|
12133
|
44 |
RemoveTeam(&'a str),
|
|
45 |
SetHedgehogsNumber(&'a str, u8),
|
|
46 |
SetTeamColor(&'a str, u8),
|
12130
|
47 |
ToggleReady,
|
|
48 |
StartGame,
|
12133
|
49 |
EngineMessage(&'a str),
|
12130
|
50 |
RoundFinished,
|
|
51 |
ToggleRestrictJoin,
|
|
52 |
ToggleRestrictTeams,
|
|
53 |
ToggleRegisteredOnly,
|
12133
|
54 |
RoomName(&'a str),
|
|
55 |
Delegate(&'a str),
|
|
56 |
TeamChat(&'a str),
|
12130
|
57 |
MaxTeams(u8),
|
|
58 |
Fix,
|
|
59 |
Unfix,
|
12133
|
60 |
Greeting(&'a str),
|
|
61 |
CallVote(Option<(&'a str, Option<&'a str>)>),
|
|
62 |
Vote(&'a str),
|
|
63 |
ForceVote(&'a str),
|
|
64 |
Save(&'a str, &'a str),
|
12135
|
65 |
Delete(&'a str),
|
12133
|
66 |
SaveRoom(&'a str),
|
|
67 |
LoadRoom(&'a str),
|
12130
|
68 |
}
|
12131
|
69 |
|
|
70 |
pub fn number<T: From<u8>
|
|
71 |
+ std::default::Default
|
|
72 |
+ std::ops::MulAssign
|
|
73 |
+ std::ops::AddAssign>
|
|
74 |
(digits: Vec<u8>) -> T {
|
|
75 |
let mut value: T = T::default();
|
|
76 |
for digit in digits {
|
|
77 |
value *= T::from(10);
|
|
78 |
value += T::from(digit);
|
|
79 |
}
|
|
80 |
value
|
|
81 |
}
|