12135
|
1 |
use server::coretypes::{ServerVar, GameCfg, TeamInfo, HedgehogInfo};
|
12136
|
2 |
use std;
|
|
3 |
use std::ops;
|
|
4 |
use std::convert::From;
|
12135
|
5 |
|
12136
|
6 |
#[derive(PartialEq, Debug)]
|
12138
|
7 |
pub enum HWProtocolMessage<'a> {
|
12135
|
8 |
// core
|
|
9 |
Ping,
|
|
10 |
Pong,
|
12138
|
11 |
Quit(Option<&'a str>),
|
|
12 |
//Cmd(&'a str, Vec<&'a str>),
|
|
13 |
Global(&'a str),
|
|
14 |
Watch(&'a str),
|
12135
|
15 |
ToggleServerRegisteredOnly,
|
|
16 |
SuperPower,
|
12138
|
17 |
Info(&'a str),
|
12135
|
18 |
// not entered state
|
12138
|
19 |
Nick(&'a str),
|
12135
|
20 |
Proto(u32),
|
12138
|
21 |
Password(&'a str, &'a str),
|
12140
|
22 |
Checker(u32, &'a str, &'a str),
|
12135
|
23 |
// lobby
|
|
24 |
List,
|
12138
|
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),
|
12135
|
34 |
BanList,
|
12138
|
35 |
Unban(&'a str),
|
12135
|
36 |
SetServerVar(ServerVar),
|
|
37 |
GetServerVar,
|
|
38 |
RestartServer,
|
|
39 |
Stats,
|
|
40 |
// in room
|
12138
|
41 |
Part(Option<&'a str>),
|
12135
|
42 |
Cfg(GameCfg),
|
|
43 |
AddTeam(TeamInfo),
|
12138
|
44 |
RemoveTeam(&'a str),
|
|
45 |
SetHedgehogsNumber(&'a str, u8),
|
|
46 |
SetTeamColor(&'a str, u8),
|
12135
|
47 |
ToggleReady,
|
|
48 |
StartGame,
|
12138
|
49 |
EngineMessage(&'a str),
|
12135
|
50 |
RoundFinished,
|
|
51 |
ToggleRestrictJoin,
|
|
52 |
ToggleRestrictTeams,
|
|
53 |
ToggleRegisteredOnly,
|
12138
|
54 |
RoomName(&'a str),
|
|
55 |
Delegate(&'a str),
|
|
56 |
TeamChat(&'a str),
|
12135
|
57 |
MaxTeams(u8),
|
|
58 |
Fix,
|
|
59 |
Unfix,
|
12138
|
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),
|
12140
|
65 |
Delete(&'a str),
|
12138
|
66 |
SaveRoom(&'a str),
|
|
67 |
LoadRoom(&'a str),
|
12135
|
68 |
}
|
12136
|
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 |
}
|