author | Wuzzy <Wuzzy2@mail.ru> |
Mon, 06 May 2019 23:03:16 +0200 | |
changeset 14893 | 66b510a8b81c |
parent 14272 | 3152d9fdb499 |
child 15264 | 7515ae6010bb |
permissions | -rw-r--r-- |
14254 | 1 |
use byteorder::{BigEndian, WriteBytesExt}; |
2 |
||
14272 | 3 |
#[derive(Debug, PartialEq, Clone)] |
14209 | 4 |
pub enum KeystrokeAction { |
5 |
Press, |
|
6 |
Release, |
|
7 |
} |
|
8 |
||
14272 | 9 |
#[derive(Debug, PartialEq, Clone)] |
14209 | 10 |
pub enum SyncedEngineMessage { |
11 |
Left(KeystrokeAction), |
|
12 |
Right(KeystrokeAction), |
|
13 |
Up(KeystrokeAction), |
|
14 |
Down(KeystrokeAction), |
|
15 |
Precise(KeystrokeAction), |
|
16 |
Attack(KeystrokeAction), |
|
17 |
NextTurn, |
|
18 |
Switch, |
|
19 |
Timer(u8), |
|
20 |
Slot(u8), |
|
21 |
SetWeapon(u8), |
|
22 |
Put(i32, i32), |
|
14211 | 23 |
CursorMove(i32, i32), |
14209 | 24 |
HighJump, |
14211 | 25 |
LongJump, |
14209 | 26 |
Skip, |
27 |
TeamControlGained(String), |
|
28 |
TeamControlLost(String), |
|
14210 | 29 |
TimeWrap, |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
30 |
Taunt(u8), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
31 |
HogSay(String), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
32 |
Heartbeat, |
14209 | 33 |
} |
34 |
||
14272 | 35 |
#[derive(Debug, PartialEq, Clone)] |
14209 | 36 |
pub enum UnsyncedEngineMessage { |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
37 |
TeamControlGained(String), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
38 |
TeamControlLost(String), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
39 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
40 |
|
14272 | 41 |
#[derive(Debug, PartialEq, Clone)] |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
42 |
pub enum UnorderedEngineMessage { |
14209 | 43 |
Ping, |
44 |
Pong, |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
45 |
ChatMessage(String), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
46 |
TeamMessage(String), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
47 |
Error(String), |
14209 | 48 |
Warning(String), |
49 |
StopSyncing, |
|
50 |
GameOver, |
|
51 |
GameInterrupted, |
|
52 |
GameSetupChecksum(String), |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
53 |
PauseToggled, |
14209 | 54 |
} |
14254 | 55 |
|
14272 | 56 |
#[derive(Debug, PartialEq, Clone)] |
14209 | 57 |
pub enum ConfigEngineMessage { |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
58 |
GameType(u8), |
14209 | 59 |
ConfigRequest, |
60 |
SetAmmo(String), |
|
61 |
SetScript(String), |
|
62 |
SetScriptParam(String), |
|
63 |
Spectate, |
|
64 |
TeamLocality(bool), |
|
65 |
SetMap(String), |
|
66 |
SetTheme(String), |
|
67 |
SetSeed(String), |
|
68 |
SetTemplateFilter(String), |
|
69 |
SetMapGenerator(String), |
|
70 |
SetFeatureSize(u8), |
|
71 |
SetDelay(u32), |
|
72 |
SetReadyDelay(u32), |
|
73 |
SetCratesFrequency(u8), |
|
74 |
SetHealthCrateProbability(u8), |
|
75 |
SetHealthCratesNumber(u8), |
|
76 |
SetRoundsTilSuddenDeath(u8), |
|
77 |
SetSuddenDeathWaterRiseSpeed(u8), |
|
78 |
SetSuddenDeathHealthDecreaseRate(u8), |
|
79 |
SetDamageMultiplier(u32), |
|
80 |
SetRopeLength(u32), |
|
81 |
SetGetawayTime(u32), |
|
82 |
SetDudMinesPercent(u8), |
|
83 |
SetMinesNumber(u32), |
|
84 |
SetAirMinesNumber(u32), |
|
85 |
SetBarrelsNumber(u32), |
|
86 |
SetTurnTime(u32), |
|
87 |
SetMinesTime(u32), |
|
88 |
SetWorldEdge(u8), |
|
89 |
Draw, |
|
90 |
// TODO |
|
91 |
SetVoicePack(String), |
|
92 |
AddHedgehog(String, u8, u32), |
|
93 |
AddTeam(String, u8), |
|
94 |
SetHedgehogCoordinates(i32, i32), |
|
95 |
SetFort(String), |
|
96 |
SetGrave(String), |
|
97 |
SetHat(String), |
|
98 |
SetFlag(String), |
|
99 |
SetOwner(String), |
|
100 |
SetOneClanMode(bool), |
|
101 |
SetMultishootMode(bool), |
|
102 |
SetSolidLand(bool), |
|
103 |
SetBorders(bool), |
|
104 |
SetDivideTeams(bool), |
|
105 |
SetLowGravity(bool), |
|
106 |
SetLaserSight(bool), |
|
107 |
SetInvulnerability(bool), |
|
108 |
SetHealthReset(bool), |
|
109 |
SetVampiric(bool), |
|
110 |
SetKarma(bool), |
|
111 |
SetArtilleryMode(bool), |
|
112 |
SetHedgehogSwitch(bool), |
|
113 |
SetRandomOrder(bool), |
|
114 |
SetKingMode(bool), |
|
115 |
SetPlaceHedgehog(bool), |
|
116 |
SetSharedAmmo(bool), |
|
117 |
SetGirdersEnabled(bool), |
|
118 |
SetLandObjectsEnabled(bool), |
|
119 |
SetAISurvivalMode(bool), |
|
120 |
SetInfiniteAttack(bool), |
|
121 |
SetResetWeapons(bool), |
|
122 |
SetAmmoPerHedgehog(bool), |
|
123 |
SetWindMode(u8), |
|
124 |
SetTagTeam(bool), |
|
125 |
SetBottomBorder(bool), |
|
126 |
SetShoppaBorder(bool), |
|
127 |
} |
|
128 |
||
14272 | 129 |
#[derive(Debug, PartialEq, Clone)] |
14209 | 130 |
pub enum EngineMessage { |
131 |
Unknown, |
|
132 |
Empty, |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
133 |
Synced(SyncedEngineMessage, u32), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
134 |
Unsynced(UnsyncedEngineMessage), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
135 |
Unordered(UnorderedEngineMessage), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
136 |
Config(ConfigEngineMessage), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
137 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
138 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
139 |
macro_rules! em { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
140 |
[$msg: expr] => { |
14254 | 141 |
vec![($msg)] |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
142 |
}; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
143 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
144 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
145 |
macro_rules! ems { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
146 |
[$msg: expr, $param: expr] => { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
147 |
{ |
14254 | 148 |
let mut v = vec![($msg)]; |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
149 |
v.extend(String::into_bytes($param.to_string()).iter()); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
150 |
v |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
151 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
152 |
}; |
14209 | 153 |
} |
154 |
||
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
155 |
impl SyncedEngineMessage { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
156 |
fn to_bytes(&self) -> Vec<u8> { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
157 |
use self::KeystrokeAction::*; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
158 |
use self::SyncedEngineMessage::*; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
159 |
match self { |
14254 | 160 |
Left(Press) => em![b'L'], |
161 |
Left(Release) => em![b'l'], |
|
162 |
Right(Press) => em![b'R'], |
|
163 |
Right(Release) => em![b'r'], |
|
164 |
Up(Press) => em![b'U'], |
|
165 |
Up(Release) => em![b'u'], |
|
166 |
Down(Press) => em![b'D'], |
|
167 |
Down(Release) => em![b'd'], |
|
168 |
Precise(Press) => em![b'Z'], |
|
169 |
Precise(Release) => em![b'z'], |
|
170 |
Attack(Press) => em![b'A'], |
|
171 |
Attack(Release) => em![b'a'], |
|
172 |
NextTurn => em![b'N'], |
|
173 |
Switch => em![b'S'], |
|
174 |
Timer(t) => vec![b'0' + t], |
|
175 |
Slot(s) => vec![b'~' , *s], |
|
176 |
SetWeapon(s) => vec![b'~', *s], |
|
177 |
Put(x, y) => { |
|
178 |
let mut v = vec![b'p']; |
|
179 |
v.write_i24::<BigEndian>(*x).unwrap(); |
|
180 |
v.write_i24::<BigEndian>(*y).unwrap(); |
|
181 |
||
182 |
v |
|
183 |
}, |
|
184 |
CursorMove(x, y) => { |
|
185 |
let mut v = vec![b'P']; |
|
186 |
v.write_i24::<BigEndian>(*x).unwrap(); |
|
187 |
v.write_i24::<BigEndian>(*y).unwrap(); |
|
188 |
||
189 |
v |
|
190 |
}, |
|
191 |
HighJump => em![b'J'], |
|
192 |
LongJump => em![b'j'], |
|
193 |
Skip => em![b','], |
|
194 |
TeamControlGained(str) => ems![b'g', str], |
|
195 |
TeamControlLost(str) => ems![b'f', str], |
|
196 |
Taunt(s) => vec![b't', *s], |
|
197 |
HogSay(str) => ems![b'h', str], |
|
198 |
Heartbeat => em![b'+'], |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
199 |
TimeWrap => unreachable!(), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
200 |
} |
14209 | 201 |
} |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
202 |
} |
14209 | 203 |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
204 |
impl UnsyncedEngineMessage { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
205 |
fn to_bytes(&self) -> Vec<u8> { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
206 |
use self::UnsyncedEngineMessage::*; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
207 |
match self { |
14254 | 208 |
TeamControlGained(str) => ems![b'G', str], |
209 |
TeamControlLost(str) => ems![b'F', str], |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
210 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
211 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
212 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
213 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
214 |
impl UnorderedEngineMessage { |
14209 | 215 |
fn to_bytes(&self) -> Vec<u8> { |
14254 | 216 |
use self::UnorderedEngineMessage::*; |
217 |
match self { |
|
218 |
Ping => em![b'?'], |
|
219 |
Pong => em![b'!'], |
|
220 |
ChatMessage(str) => ems![b's', str], |
|
221 |
TeamMessage(str) => ems![b'b', str], |
|
222 |
Error(str) => ems![b'E', str], |
|
14255 | 223 |
Warning(_) => unreachable!(), |
14254 | 224 |
StopSyncing => unreachable!(), |
225 |
GameOver => em![b'q'], |
|
226 |
GameInterrupted => em![b'Q'], |
|
227 |
GameSetupChecksum(str) => ems![b'M', str], |
|
228 |
PauseToggled => unreachable!(), |
|
229 |
} |
|
14209 | 230 |
} |
231 |
} |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
232 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
233 |
impl ConfigEngineMessage { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
234 |
fn to_bytes(&self) -> Vec<u8> { |
14254 | 235 |
unreachable!() |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
236 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
237 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
238 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
239 |
impl EngineMessage { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
240 |
pub const MAX_LEN: u16 = 49215; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
241 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
242 |
fn to_unwrapped(&self) -> Vec<u8> { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
243 |
use self::EngineMessage::*; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
244 |
match self { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
245 |
Unknown => unreachable!("you're not supposed to construct such messages"), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
246 |
Empty => unreachable!("you're not supposed to construct such messages"), |
14254 | 247 |
Synced(SyncedEngineMessage::TimeWrap, _) => vec![b'#', 0xff, 0xff], |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
248 |
Synced(msg, timestamp) => { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
249 |
let mut v = msg.to_bytes(); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
250 |
v.push((*timestamp / 256) as u8); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
251 |
v.push(*timestamp as u8); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
252 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
253 |
v |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
254 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
255 |
Unsynced(msg) => msg.to_bytes(), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
256 |
Unordered(msg) => msg.to_bytes(), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
257 |
Config(msg) => msg.to_bytes(), |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
258 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
259 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
260 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
261 |
pub fn to_bytes(&self) -> Vec<u8> { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
262 |
let mut unwrapped = self.to_unwrapped(); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
263 |
let mut size = unwrapped.len(); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
264 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
265 |
if size > EngineMessage::MAX_LEN as usize - 2 { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
266 |
size = EngineMessage::MAX_LEN as usize - 2; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
267 |
unwrapped.truncate(size); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
268 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
269 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
270 |
if size < 64 { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
271 |
unwrapped.insert(0, size as u8); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
272 |
} else { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
273 |
size -= 64; |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
274 |
unwrapped.insert(0, (size / 256 + 64) as u8); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
275 |
unwrapped.insert(1, size as u8); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
276 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
277 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
278 |
unwrapped |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
279 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
280 |
} |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
281 |
|
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
282 |
#[test] |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
283 |
fn message_contruction() { |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
284 |
assert_eq!( |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
285 |
EngineMessage::Synced(SyncedEngineMessage::TimeWrap, 0).to_bytes(), |
14254 | 286 |
vec![3, b'#', 255, 255] |
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
287 |
); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
288 |
assert_eq!( |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
289 |
EngineMessage::Synced(SyncedEngineMessage::NextTurn, 258).to_bytes(), |
14254 | 290 |
vec![3, b'N', 1, 2] |
291 |
); |
|
292 |
||
293 |
assert_eq!( |
|
294 |
EngineMessage::Synced(SyncedEngineMessage::Put(-31337, 65538), 0).to_bytes(), |
|
295 |
vec![9, b'p', 255, 133, 151, 1, 0, 2, 0, 0] |
|
14214
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
296 |
); |
77b95406631e
Implement more of parsing, start implementation of engine messages rendering
unC0Rr
parents:
14211
diff
changeset
|
297 |
} |