libtw2_gamenet_ddnet/msg/
game.rs

1use crate::enums;
2use crate::error::Error;
3use buffer::CapacityError;
4use libtw2_common::pretty;
5use libtw2_gamenet_common::debug::DebugSlice;
6use libtw2_packer::Packer;
7use libtw2_packer::Unpacker;
8use libtw2_packer::Warning;
9use libtw2_packer::in_range;
10use libtw2_packer::sanitize;
11use libtw2_packer::to_bool;
12use libtw2_packer::with_packer;
13use std::fmt;
14use super::MessageId;
15use super::SystemOrGame;
16use uuid::Uuid;
17use warn::Panic;
18use warn::Warn;
19
20pub use libtw2_gamenet_common::msg::TuneParam;
21
22impl<'a> Game<'a> {
23    pub fn decode<W>(warn: &mut W, p: &mut Unpacker<'a>) -> Result<Game<'a>, Error>
24        where W: Warn<Warning>
25    {
26        if let SystemOrGame::Game(msg_id) = SystemOrGame::decode_id(warn, p)? {
27            Game::decode_msg(warn, msg_id, p)
28        } else {
29            Err(Error::UnknownId)
30        }
31    }
32    pub fn encode<'d, 's>(&self, mut p: Packer<'d, 's>)
33        -> Result<&'d [u8], CapacityError>
34    {
35        with_packer(&mut p, |p| SystemOrGame::Game(self.msg_id()).encode_id(p))?;
36        with_packer(&mut p, |p| self.encode_msg(p))?;
37        Ok(p.written())
38    }
39}
40
41pub const SV_MOTD: i32 = 1;
42pub const SV_BROADCAST: i32 = 2;
43pub const SV_CHAT: i32 = 3;
44pub const SV_KILL_MSG: i32 = 4;
45pub const SV_SOUND_GLOBAL: i32 = 5;
46pub const SV_TUNE_PARAMS: i32 = 6;
47pub const UNUSED: i32 = 7;
48pub const SV_READY_TO_ENTER: i32 = 8;
49pub const SV_WEAPON_PICKUP: i32 = 9;
50pub const SV_EMOTICON: i32 = 10;
51pub const SV_VOTE_CLEAR_OPTIONS: i32 = 11;
52pub const SV_VOTE_OPTION_LIST_ADD: i32 = 12;
53pub const SV_VOTE_OPTION_ADD: i32 = 13;
54pub const SV_VOTE_OPTION_REMOVE: i32 = 14;
55pub const SV_VOTE_SET: i32 = 15;
56pub const SV_VOTE_STATUS: i32 = 16;
57pub const CL_SAY: i32 = 17;
58pub const CL_SET_TEAM: i32 = 18;
59pub const CL_SET_SPECTATOR_MODE: i32 = 19;
60pub const CL_START_INFO: i32 = 20;
61pub const CL_CHANGE_INFO: i32 = 21;
62pub const CL_KILL: i32 = 22;
63pub const CL_EMOTICON: i32 = 23;
64pub const CL_VOTE: i32 = 24;
65pub const CL_CALL_VOTE: i32 = 25;
66pub const CL_IS_DDNET_LEGACY: i32 = 26;
67pub const SV_DDRACE_TIME_LEGACY: i32 = 27;
68pub const SV_RECORD_LEGACY: i32 = 28;
69pub const UNUSED2: i32 = 29;
70pub const SV_TEAMS_STATE_LEGACY: i32 = 30;
71pub const CL_SHOW_OTHERS_LEGACY: i32 = 31;
72pub const SV_MY_OWN_MESSAGE: Uuid = Uuid::from_u128(0x1231e484_f607_3722_a89a_bd85db46f5d2);
73pub const CL_SHOW_DISTANCE: Uuid = Uuid::from_u128(0x53bb28af_4252_3ac9_8fd3_6ccbc2a603e3);
74pub const CL_SHOW_OTHERS: Uuid = Uuid::from_u128(0x7f264cdd_71a2_3962_bbce_0f94bbd81913);
75pub const SV_TEAMS_STATE: Uuid = Uuid::from_u128(0xa091961a_95e8_3744_bb60_5eac9bd563c6);
76pub const SV_DDRACE_TIME: Uuid = Uuid::from_u128(0x5dde8b3c_6f6f_37ac_a72a_bb341fe76de5);
77pub const SV_RECORD: Uuid = Uuid::from_u128(0x804f149f_9b53_3b0a_897f_59663a1c4eb9);
78pub const SV_KILL_MSG_TEAM: Uuid = Uuid::from_u128(0xee610b6f_909f_311e_93f7_11a95f55a086);
79
80#[derive(Clone, Copy)]
81pub enum Game<'a> {
82    SvMotd(SvMotd<'a>),
83    SvBroadcast(SvBroadcast<'a>),
84    SvChat(SvChat<'a>),
85    SvKillMsg(SvKillMsg),
86    SvSoundGlobal(SvSoundGlobal),
87    SvTuneParams(SvTuneParams),
88    Unused(Unused),
89    SvReadyToEnter(SvReadyToEnter),
90    SvWeaponPickup(SvWeaponPickup),
91    SvEmoticon(SvEmoticon),
92    SvVoteClearOptions(SvVoteClearOptions),
93    SvVoteOptionListAdd(SvVoteOptionListAdd<'a>),
94    SvVoteOptionAdd(SvVoteOptionAdd<'a>),
95    SvVoteOptionRemove(SvVoteOptionRemove<'a>),
96    SvVoteSet(SvVoteSet<'a>),
97    SvVoteStatus(SvVoteStatus),
98    ClSay(ClSay<'a>),
99    ClSetTeam(ClSetTeam),
100    ClSetSpectatorMode(ClSetSpectatorMode),
101    ClStartInfo(ClStartInfo<'a>),
102    ClChangeInfo(ClChangeInfo<'a>),
103    ClKill(ClKill),
104    ClEmoticon(ClEmoticon),
105    ClVote(ClVote),
106    ClCallVote(ClCallVote<'a>),
107    ClIsDdnetLegacy(ClIsDdnetLegacy),
108    SvDdraceTimeLegacy(SvDdraceTimeLegacy),
109    SvRecordLegacy(SvRecordLegacy),
110    Unused2(Unused2),
111    SvTeamsStateLegacy(SvTeamsStateLegacy),
112    ClShowOthersLegacy(ClShowOthersLegacy),
113    SvMyOwnMessage(SvMyOwnMessage),
114    ClShowDistance(ClShowDistance),
115    ClShowOthers(ClShowOthers),
116    SvTeamsState(SvTeamsState),
117    SvDdraceTime(SvDdraceTime),
118    SvRecord(SvRecord),
119    SvKillMsgTeam(SvKillMsgTeam),
120}
121
122impl<'a> Game<'a> {
123    pub fn decode_msg<W: Warn<Warning>>(warn: &mut W, msg_id: MessageId, _p: &mut Unpacker<'a>) -> Result<Game<'a>, Error> {
124        use self::MessageId::*;
125        Ok(match msg_id {
126            Ordinal(SV_MOTD) => Game::SvMotd(SvMotd::decode(warn, _p)?),
127            Ordinal(SV_BROADCAST) => Game::SvBroadcast(SvBroadcast::decode(warn, _p)?),
128            Ordinal(SV_CHAT) => Game::SvChat(SvChat::decode(warn, _p)?),
129            Ordinal(SV_KILL_MSG) => Game::SvKillMsg(SvKillMsg::decode(warn, _p)?),
130            Ordinal(SV_SOUND_GLOBAL) => Game::SvSoundGlobal(SvSoundGlobal::decode(warn, _p)?),
131            Ordinal(SV_TUNE_PARAMS) => Game::SvTuneParams(SvTuneParams::decode(warn, _p)?),
132            Ordinal(UNUSED) => Game::Unused(Unused::decode(warn, _p)?),
133            Ordinal(SV_READY_TO_ENTER) => Game::SvReadyToEnter(SvReadyToEnter::decode(warn, _p)?),
134            Ordinal(SV_WEAPON_PICKUP) => Game::SvWeaponPickup(SvWeaponPickup::decode(warn, _p)?),
135            Ordinal(SV_EMOTICON) => Game::SvEmoticon(SvEmoticon::decode(warn, _p)?),
136            Ordinal(SV_VOTE_CLEAR_OPTIONS) => Game::SvVoteClearOptions(SvVoteClearOptions::decode(warn, _p)?),
137            Ordinal(SV_VOTE_OPTION_LIST_ADD) => Game::SvVoteOptionListAdd(SvVoteOptionListAdd::decode(warn, _p)?),
138            Ordinal(SV_VOTE_OPTION_ADD) => Game::SvVoteOptionAdd(SvVoteOptionAdd::decode(warn, _p)?),
139            Ordinal(SV_VOTE_OPTION_REMOVE) => Game::SvVoteOptionRemove(SvVoteOptionRemove::decode(warn, _p)?),
140            Ordinal(SV_VOTE_SET) => Game::SvVoteSet(SvVoteSet::decode(warn, _p)?),
141            Ordinal(SV_VOTE_STATUS) => Game::SvVoteStatus(SvVoteStatus::decode(warn, _p)?),
142            Ordinal(CL_SAY) => Game::ClSay(ClSay::decode(warn, _p)?),
143            Ordinal(CL_SET_TEAM) => Game::ClSetTeam(ClSetTeam::decode(warn, _p)?),
144            Ordinal(CL_SET_SPECTATOR_MODE) => Game::ClSetSpectatorMode(ClSetSpectatorMode::decode(warn, _p)?),
145            Ordinal(CL_START_INFO) => Game::ClStartInfo(ClStartInfo::decode(warn, _p)?),
146            Ordinal(CL_CHANGE_INFO) => Game::ClChangeInfo(ClChangeInfo::decode(warn, _p)?),
147            Ordinal(CL_KILL) => Game::ClKill(ClKill::decode(warn, _p)?),
148            Ordinal(CL_EMOTICON) => Game::ClEmoticon(ClEmoticon::decode(warn, _p)?),
149            Ordinal(CL_VOTE) => Game::ClVote(ClVote::decode(warn, _p)?),
150            Ordinal(CL_CALL_VOTE) => Game::ClCallVote(ClCallVote::decode(warn, _p)?),
151            Ordinal(CL_IS_DDNET_LEGACY) => Game::ClIsDdnetLegacy(ClIsDdnetLegacy::decode(warn, _p)?),
152            Ordinal(SV_DDRACE_TIME_LEGACY) => Game::SvDdraceTimeLegacy(SvDdraceTimeLegacy::decode(warn, _p)?),
153            Ordinal(SV_RECORD_LEGACY) => Game::SvRecordLegacy(SvRecordLegacy::decode(warn, _p)?),
154            Ordinal(UNUSED2) => Game::Unused2(Unused2::decode(warn, _p)?),
155            Ordinal(SV_TEAMS_STATE_LEGACY) => Game::SvTeamsStateLegacy(SvTeamsStateLegacy::decode(warn, _p)?),
156            Ordinal(CL_SHOW_OTHERS_LEGACY) => Game::ClShowOthersLegacy(ClShowOthersLegacy::decode(warn, _p)?),
157            Uuid(SV_MY_OWN_MESSAGE) => Game::SvMyOwnMessage(SvMyOwnMessage::decode(warn, _p)?),
158            Uuid(CL_SHOW_DISTANCE) => Game::ClShowDistance(ClShowDistance::decode(warn, _p)?),
159            Uuid(CL_SHOW_OTHERS) => Game::ClShowOthers(ClShowOthers::decode(warn, _p)?),
160            Uuid(SV_TEAMS_STATE) => Game::SvTeamsState(SvTeamsState::decode(warn, _p)?),
161            Uuid(SV_DDRACE_TIME) => Game::SvDdraceTime(SvDdraceTime::decode(warn, _p)?),
162            Uuid(SV_RECORD) => Game::SvRecord(SvRecord::decode(warn, _p)?),
163            Uuid(SV_KILL_MSG_TEAM) => Game::SvKillMsgTeam(SvKillMsgTeam::decode(warn, _p)?),
164            _ => return Err(Error::UnknownId),
165        })
166    }
167    pub fn msg_id(&self) -> MessageId {
168        match *self {
169            Game::SvMotd(_) => MessageId::from(SV_MOTD),
170            Game::SvBroadcast(_) => MessageId::from(SV_BROADCAST),
171            Game::SvChat(_) => MessageId::from(SV_CHAT),
172            Game::SvKillMsg(_) => MessageId::from(SV_KILL_MSG),
173            Game::SvSoundGlobal(_) => MessageId::from(SV_SOUND_GLOBAL),
174            Game::SvTuneParams(_) => MessageId::from(SV_TUNE_PARAMS),
175            Game::Unused(_) => MessageId::from(UNUSED),
176            Game::SvReadyToEnter(_) => MessageId::from(SV_READY_TO_ENTER),
177            Game::SvWeaponPickup(_) => MessageId::from(SV_WEAPON_PICKUP),
178            Game::SvEmoticon(_) => MessageId::from(SV_EMOTICON),
179            Game::SvVoteClearOptions(_) => MessageId::from(SV_VOTE_CLEAR_OPTIONS),
180            Game::SvVoteOptionListAdd(_) => MessageId::from(SV_VOTE_OPTION_LIST_ADD),
181            Game::SvVoteOptionAdd(_) => MessageId::from(SV_VOTE_OPTION_ADD),
182            Game::SvVoteOptionRemove(_) => MessageId::from(SV_VOTE_OPTION_REMOVE),
183            Game::SvVoteSet(_) => MessageId::from(SV_VOTE_SET),
184            Game::SvVoteStatus(_) => MessageId::from(SV_VOTE_STATUS),
185            Game::ClSay(_) => MessageId::from(CL_SAY),
186            Game::ClSetTeam(_) => MessageId::from(CL_SET_TEAM),
187            Game::ClSetSpectatorMode(_) => MessageId::from(CL_SET_SPECTATOR_MODE),
188            Game::ClStartInfo(_) => MessageId::from(CL_START_INFO),
189            Game::ClChangeInfo(_) => MessageId::from(CL_CHANGE_INFO),
190            Game::ClKill(_) => MessageId::from(CL_KILL),
191            Game::ClEmoticon(_) => MessageId::from(CL_EMOTICON),
192            Game::ClVote(_) => MessageId::from(CL_VOTE),
193            Game::ClCallVote(_) => MessageId::from(CL_CALL_VOTE),
194            Game::ClIsDdnetLegacy(_) => MessageId::from(CL_IS_DDNET_LEGACY),
195            Game::SvDdraceTimeLegacy(_) => MessageId::from(SV_DDRACE_TIME_LEGACY),
196            Game::SvRecordLegacy(_) => MessageId::from(SV_RECORD_LEGACY),
197            Game::Unused2(_) => MessageId::from(UNUSED2),
198            Game::SvTeamsStateLegacy(_) => MessageId::from(SV_TEAMS_STATE_LEGACY),
199            Game::ClShowOthersLegacy(_) => MessageId::from(CL_SHOW_OTHERS_LEGACY),
200            Game::SvMyOwnMessage(_) => MessageId::from(SV_MY_OWN_MESSAGE),
201            Game::ClShowDistance(_) => MessageId::from(CL_SHOW_DISTANCE),
202            Game::ClShowOthers(_) => MessageId::from(CL_SHOW_OTHERS),
203            Game::SvTeamsState(_) => MessageId::from(SV_TEAMS_STATE),
204            Game::SvDdraceTime(_) => MessageId::from(SV_DDRACE_TIME),
205            Game::SvRecord(_) => MessageId::from(SV_RECORD),
206            Game::SvKillMsgTeam(_) => MessageId::from(SV_KILL_MSG_TEAM),
207        }
208    }
209    pub fn encode_msg<'d, 's>(&self, p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
210        match *self {
211            Game::SvMotd(ref i) => i.encode(p),
212            Game::SvBroadcast(ref i) => i.encode(p),
213            Game::SvChat(ref i) => i.encode(p),
214            Game::SvKillMsg(ref i) => i.encode(p),
215            Game::SvSoundGlobal(ref i) => i.encode(p),
216            Game::SvTuneParams(ref i) => i.encode(p),
217            Game::Unused(ref i) => i.encode(p),
218            Game::SvReadyToEnter(ref i) => i.encode(p),
219            Game::SvWeaponPickup(ref i) => i.encode(p),
220            Game::SvEmoticon(ref i) => i.encode(p),
221            Game::SvVoteClearOptions(ref i) => i.encode(p),
222            Game::SvVoteOptionListAdd(ref i) => i.encode(p),
223            Game::SvVoteOptionAdd(ref i) => i.encode(p),
224            Game::SvVoteOptionRemove(ref i) => i.encode(p),
225            Game::SvVoteSet(ref i) => i.encode(p),
226            Game::SvVoteStatus(ref i) => i.encode(p),
227            Game::ClSay(ref i) => i.encode(p),
228            Game::ClSetTeam(ref i) => i.encode(p),
229            Game::ClSetSpectatorMode(ref i) => i.encode(p),
230            Game::ClStartInfo(ref i) => i.encode(p),
231            Game::ClChangeInfo(ref i) => i.encode(p),
232            Game::ClKill(ref i) => i.encode(p),
233            Game::ClEmoticon(ref i) => i.encode(p),
234            Game::ClVote(ref i) => i.encode(p),
235            Game::ClCallVote(ref i) => i.encode(p),
236            Game::ClIsDdnetLegacy(ref i) => i.encode(p),
237            Game::SvDdraceTimeLegacy(ref i) => i.encode(p),
238            Game::SvRecordLegacy(ref i) => i.encode(p),
239            Game::Unused2(ref i) => i.encode(p),
240            Game::SvTeamsStateLegacy(ref i) => i.encode(p),
241            Game::ClShowOthersLegacy(ref i) => i.encode(p),
242            Game::SvMyOwnMessage(ref i) => i.encode(p),
243            Game::ClShowDistance(ref i) => i.encode(p),
244            Game::ClShowOthers(ref i) => i.encode(p),
245            Game::SvTeamsState(ref i) => i.encode(p),
246            Game::SvDdraceTime(ref i) => i.encode(p),
247            Game::SvRecord(ref i) => i.encode(p),
248            Game::SvKillMsgTeam(ref i) => i.encode(p),
249        }
250    }
251}
252
253impl<'a> fmt::Debug for Game<'a> {
254    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
255        match *self {
256            Game::SvMotd(ref i) => i.fmt(f),
257            Game::SvBroadcast(ref i) => i.fmt(f),
258            Game::SvChat(ref i) => i.fmt(f),
259            Game::SvKillMsg(ref i) => i.fmt(f),
260            Game::SvSoundGlobal(ref i) => i.fmt(f),
261            Game::SvTuneParams(ref i) => i.fmt(f),
262            Game::Unused(ref i) => i.fmt(f),
263            Game::SvReadyToEnter(ref i) => i.fmt(f),
264            Game::SvWeaponPickup(ref i) => i.fmt(f),
265            Game::SvEmoticon(ref i) => i.fmt(f),
266            Game::SvVoteClearOptions(ref i) => i.fmt(f),
267            Game::SvVoteOptionListAdd(ref i) => i.fmt(f),
268            Game::SvVoteOptionAdd(ref i) => i.fmt(f),
269            Game::SvVoteOptionRemove(ref i) => i.fmt(f),
270            Game::SvVoteSet(ref i) => i.fmt(f),
271            Game::SvVoteStatus(ref i) => i.fmt(f),
272            Game::ClSay(ref i) => i.fmt(f),
273            Game::ClSetTeam(ref i) => i.fmt(f),
274            Game::ClSetSpectatorMode(ref i) => i.fmt(f),
275            Game::ClStartInfo(ref i) => i.fmt(f),
276            Game::ClChangeInfo(ref i) => i.fmt(f),
277            Game::ClKill(ref i) => i.fmt(f),
278            Game::ClEmoticon(ref i) => i.fmt(f),
279            Game::ClVote(ref i) => i.fmt(f),
280            Game::ClCallVote(ref i) => i.fmt(f),
281            Game::ClIsDdnetLegacy(ref i) => i.fmt(f),
282            Game::SvDdraceTimeLegacy(ref i) => i.fmt(f),
283            Game::SvRecordLegacy(ref i) => i.fmt(f),
284            Game::Unused2(ref i) => i.fmt(f),
285            Game::SvTeamsStateLegacy(ref i) => i.fmt(f),
286            Game::ClShowOthersLegacy(ref i) => i.fmt(f),
287            Game::SvMyOwnMessage(ref i) => i.fmt(f),
288            Game::ClShowDistance(ref i) => i.fmt(f),
289            Game::ClShowOthers(ref i) => i.fmt(f),
290            Game::SvTeamsState(ref i) => i.fmt(f),
291            Game::SvDdraceTime(ref i) => i.fmt(f),
292            Game::SvRecord(ref i) => i.fmt(f),
293            Game::SvKillMsgTeam(ref i) => i.fmt(f),
294        }
295    }
296}
297
298impl<'a> From<SvMotd<'a>> for Game<'a> {
299    fn from(i: SvMotd<'a>) -> Game<'a> {
300        Game::SvMotd(i)
301    }
302}
303
304impl<'a> From<SvBroadcast<'a>> for Game<'a> {
305    fn from(i: SvBroadcast<'a>) -> Game<'a> {
306        Game::SvBroadcast(i)
307    }
308}
309
310impl<'a> From<SvChat<'a>> for Game<'a> {
311    fn from(i: SvChat<'a>) -> Game<'a> {
312        Game::SvChat(i)
313    }
314}
315
316impl<'a> From<SvKillMsg> for Game<'a> {
317    fn from(i: SvKillMsg) -> Game<'a> {
318        Game::SvKillMsg(i)
319    }
320}
321
322impl<'a> From<SvSoundGlobal> for Game<'a> {
323    fn from(i: SvSoundGlobal) -> Game<'a> {
324        Game::SvSoundGlobal(i)
325    }
326}
327
328impl<'a> From<SvTuneParams> for Game<'a> {
329    fn from(i: SvTuneParams) -> Game<'a> {
330        Game::SvTuneParams(i)
331    }
332}
333
334impl<'a> From<Unused> for Game<'a> {
335    fn from(i: Unused) -> Game<'a> {
336        Game::Unused(i)
337    }
338}
339
340impl<'a> From<SvReadyToEnter> for Game<'a> {
341    fn from(i: SvReadyToEnter) -> Game<'a> {
342        Game::SvReadyToEnter(i)
343    }
344}
345
346impl<'a> From<SvWeaponPickup> for Game<'a> {
347    fn from(i: SvWeaponPickup) -> Game<'a> {
348        Game::SvWeaponPickup(i)
349    }
350}
351
352impl<'a> From<SvEmoticon> for Game<'a> {
353    fn from(i: SvEmoticon) -> Game<'a> {
354        Game::SvEmoticon(i)
355    }
356}
357
358impl<'a> From<SvVoteClearOptions> for Game<'a> {
359    fn from(i: SvVoteClearOptions) -> Game<'a> {
360        Game::SvVoteClearOptions(i)
361    }
362}
363
364impl<'a> From<SvVoteOptionListAdd<'a>> for Game<'a> {
365    fn from(i: SvVoteOptionListAdd<'a>) -> Game<'a> {
366        Game::SvVoteOptionListAdd(i)
367    }
368}
369
370impl<'a> From<SvVoteOptionAdd<'a>> for Game<'a> {
371    fn from(i: SvVoteOptionAdd<'a>) -> Game<'a> {
372        Game::SvVoteOptionAdd(i)
373    }
374}
375
376impl<'a> From<SvVoteOptionRemove<'a>> for Game<'a> {
377    fn from(i: SvVoteOptionRemove<'a>) -> Game<'a> {
378        Game::SvVoteOptionRemove(i)
379    }
380}
381
382impl<'a> From<SvVoteSet<'a>> for Game<'a> {
383    fn from(i: SvVoteSet<'a>) -> Game<'a> {
384        Game::SvVoteSet(i)
385    }
386}
387
388impl<'a> From<SvVoteStatus> for Game<'a> {
389    fn from(i: SvVoteStatus) -> Game<'a> {
390        Game::SvVoteStatus(i)
391    }
392}
393
394impl<'a> From<ClSay<'a>> for Game<'a> {
395    fn from(i: ClSay<'a>) -> Game<'a> {
396        Game::ClSay(i)
397    }
398}
399
400impl<'a> From<ClSetTeam> for Game<'a> {
401    fn from(i: ClSetTeam) -> Game<'a> {
402        Game::ClSetTeam(i)
403    }
404}
405
406impl<'a> From<ClSetSpectatorMode> for Game<'a> {
407    fn from(i: ClSetSpectatorMode) -> Game<'a> {
408        Game::ClSetSpectatorMode(i)
409    }
410}
411
412impl<'a> From<ClStartInfo<'a>> for Game<'a> {
413    fn from(i: ClStartInfo<'a>) -> Game<'a> {
414        Game::ClStartInfo(i)
415    }
416}
417
418impl<'a> From<ClChangeInfo<'a>> for Game<'a> {
419    fn from(i: ClChangeInfo<'a>) -> Game<'a> {
420        Game::ClChangeInfo(i)
421    }
422}
423
424impl<'a> From<ClKill> for Game<'a> {
425    fn from(i: ClKill) -> Game<'a> {
426        Game::ClKill(i)
427    }
428}
429
430impl<'a> From<ClEmoticon> for Game<'a> {
431    fn from(i: ClEmoticon) -> Game<'a> {
432        Game::ClEmoticon(i)
433    }
434}
435
436impl<'a> From<ClVote> for Game<'a> {
437    fn from(i: ClVote) -> Game<'a> {
438        Game::ClVote(i)
439    }
440}
441
442impl<'a> From<ClCallVote<'a>> for Game<'a> {
443    fn from(i: ClCallVote<'a>) -> Game<'a> {
444        Game::ClCallVote(i)
445    }
446}
447
448impl<'a> From<ClIsDdnetLegacy> for Game<'a> {
449    fn from(i: ClIsDdnetLegacy) -> Game<'a> {
450        Game::ClIsDdnetLegacy(i)
451    }
452}
453
454impl<'a> From<SvDdraceTimeLegacy> for Game<'a> {
455    fn from(i: SvDdraceTimeLegacy) -> Game<'a> {
456        Game::SvDdraceTimeLegacy(i)
457    }
458}
459
460impl<'a> From<SvRecordLegacy> for Game<'a> {
461    fn from(i: SvRecordLegacy) -> Game<'a> {
462        Game::SvRecordLegacy(i)
463    }
464}
465
466impl<'a> From<Unused2> for Game<'a> {
467    fn from(i: Unused2) -> Game<'a> {
468        Game::Unused2(i)
469    }
470}
471
472impl<'a> From<SvTeamsStateLegacy> for Game<'a> {
473    fn from(i: SvTeamsStateLegacy) -> Game<'a> {
474        Game::SvTeamsStateLegacy(i)
475    }
476}
477
478impl<'a> From<ClShowOthersLegacy> for Game<'a> {
479    fn from(i: ClShowOthersLegacy) -> Game<'a> {
480        Game::ClShowOthersLegacy(i)
481    }
482}
483
484impl<'a> From<SvMyOwnMessage> for Game<'a> {
485    fn from(i: SvMyOwnMessage) -> Game<'a> {
486        Game::SvMyOwnMessage(i)
487    }
488}
489
490impl<'a> From<ClShowDistance> for Game<'a> {
491    fn from(i: ClShowDistance) -> Game<'a> {
492        Game::ClShowDistance(i)
493    }
494}
495
496impl<'a> From<ClShowOthers> for Game<'a> {
497    fn from(i: ClShowOthers) -> Game<'a> {
498        Game::ClShowOthers(i)
499    }
500}
501
502impl<'a> From<SvTeamsState> for Game<'a> {
503    fn from(i: SvTeamsState) -> Game<'a> {
504        Game::SvTeamsState(i)
505    }
506}
507
508impl<'a> From<SvDdraceTime> for Game<'a> {
509    fn from(i: SvDdraceTime) -> Game<'a> {
510        Game::SvDdraceTime(i)
511    }
512}
513
514impl<'a> From<SvRecord> for Game<'a> {
515    fn from(i: SvRecord) -> Game<'a> {
516        Game::SvRecord(i)
517    }
518}
519
520impl<'a> From<SvKillMsgTeam> for Game<'a> {
521    fn from(i: SvKillMsgTeam) -> Game<'a> {
522        Game::SvKillMsgTeam(i)
523    }
524}
525#[derive(Clone, Copy)]
526pub struct SvMotd<'a> {
527    pub message: &'a [u8],
528}
529
530#[derive(Clone, Copy)]
531pub struct SvBroadcast<'a> {
532    pub message: &'a [u8],
533}
534
535#[derive(Clone, Copy)]
536pub struct SvChat<'a> {
537    pub team: i32,
538    pub client_id: i32,
539    pub message: &'a [u8],
540}
541
542#[derive(Clone, Copy)]
543pub struct SvKillMsg {
544    pub killer: i32,
545    pub victim: i32,
546    pub weapon: i32,
547    pub mode_special: i32,
548}
549
550#[derive(Clone, Copy)]
551pub struct SvSoundGlobal {
552    pub sound_id: enums::Sound,
553}
554
555#[derive(Clone, Copy)]
556pub struct SvTuneParams {
557    pub ground_control_speed: TuneParam,
558    pub ground_control_accel: TuneParam,
559    pub ground_friction: TuneParam,
560    pub ground_jump_impulse: TuneParam,
561    pub air_jump_impulse: TuneParam,
562    pub air_control_speed: TuneParam,
563    pub air_control_accel: TuneParam,
564    pub air_friction: TuneParam,
565    pub hook_length: TuneParam,
566    pub hook_fire_speed: TuneParam,
567    pub hook_drag_accel: TuneParam,
568    pub hook_drag_speed: TuneParam,
569    pub gravity: TuneParam,
570    pub velramp_start: TuneParam,
571    pub velramp_range: TuneParam,
572    pub velramp_curvature: TuneParam,
573    pub gun_curvature: TuneParam,
574    pub gun_speed: TuneParam,
575    pub gun_lifetime: TuneParam,
576    pub shotgun_curvature: TuneParam,
577    pub shotgun_speed: TuneParam,
578    pub shotgun_speeddiff: TuneParam,
579    pub shotgun_lifetime: TuneParam,
580    pub grenade_curvature: TuneParam,
581    pub grenade_speed: TuneParam,
582    pub grenade_lifetime: TuneParam,
583    pub laser_reach: TuneParam,
584    pub laser_bounce_delay: TuneParam,
585    pub laser_bounce_num: TuneParam,
586    pub laser_bounce_cost: TuneParam,
587    pub laser_damage: TuneParam,
588    pub player_collision: TuneParam,
589    pub player_hooking: TuneParam,
590    pub jetpack_strength: TuneParam,
591    pub shotgun_strength: TuneParam,
592    pub explosion_strength: TuneParam,
593    pub hammer_strength: TuneParam,
594    pub hook_duration: TuneParam,
595    pub hammer_fire_delay: TuneParam,
596    pub gun_fire_delay: TuneParam,
597    pub shotgun_fire_delay: TuneParam,
598    pub grenade_fire_delay: TuneParam,
599    pub laser_fire_delay: TuneParam,
600    pub ninja_fire_delay: TuneParam,
601    pub hammer_hit_fire_delay: TuneParam,
602    pub ground_elasticity_x: TuneParam,
603    pub ground_elasticity_y: TuneParam,
604}
605
606#[derive(Clone, Copy)]
607pub struct Unused;
608
609#[derive(Clone, Copy)]
610pub struct SvReadyToEnter;
611
612#[derive(Clone, Copy)]
613pub struct SvWeaponPickup {
614    pub weapon: enums::Weapon,
615}
616
617#[derive(Clone, Copy)]
618pub struct SvEmoticon {
619    pub client_id: i32,
620    pub emoticon: enums::Emoticon,
621}
622
623#[derive(Clone, Copy)]
624pub struct SvVoteClearOptions;
625
626#[derive(Clone, Copy)]
627pub struct SvVoteOptionListAdd<'a> {
628    pub num_options: i32,
629    pub description: [&'a [u8]; 15],
630}
631
632#[derive(Clone, Copy)]
633pub struct SvVoteOptionAdd<'a> {
634    pub description: &'a [u8],
635}
636
637#[derive(Clone, Copy)]
638pub struct SvVoteOptionRemove<'a> {
639    pub description: &'a [u8],
640}
641
642#[derive(Clone, Copy)]
643pub struct SvVoteSet<'a> {
644    pub timeout: i32,
645    pub description: &'a [u8],
646    pub reason: &'a [u8],
647}
648
649#[derive(Clone, Copy)]
650pub struct SvVoteStatus {
651    pub yes: i32,
652    pub no: i32,
653    pub pass: i32,
654    pub total: i32,
655}
656
657#[derive(Clone, Copy)]
658pub struct ClSay<'a> {
659    pub team: bool,
660    pub message: &'a [u8],
661}
662
663#[derive(Clone, Copy)]
664pub struct ClSetTeam {
665    pub team: enums::Team,
666}
667
668#[derive(Clone, Copy)]
669pub struct ClSetSpectatorMode {
670    pub spectator_id: i32,
671}
672
673#[derive(Clone, Copy)]
674pub struct ClStartInfo<'a> {
675    pub name: &'a [u8],
676    pub clan: &'a [u8],
677    pub country: i32,
678    pub skin: &'a [u8],
679    pub use_custom_color: bool,
680    pub color_body: i32,
681    pub color_feet: i32,
682}
683
684#[derive(Clone, Copy)]
685pub struct ClChangeInfo<'a> {
686    pub name: &'a [u8],
687    pub clan: &'a [u8],
688    pub country: i32,
689    pub skin: &'a [u8],
690    pub use_custom_color: bool,
691    pub color_body: i32,
692    pub color_feet: i32,
693}
694
695#[derive(Clone, Copy)]
696pub struct ClKill;
697
698#[derive(Clone, Copy)]
699pub struct ClEmoticon {
700    pub emoticon: enums::Emoticon,
701}
702
703#[derive(Clone, Copy)]
704pub struct ClVote {
705    pub vote: i32,
706}
707
708#[derive(Clone, Copy)]
709pub struct ClCallVote<'a> {
710    pub type_: &'a [u8],
711    pub value: &'a [u8],
712    pub reason: &'a [u8],
713}
714
715#[derive(Clone, Copy)]
716pub struct ClIsDdnetLegacy {
717    pub ddnet_version: i32,
718}
719
720#[derive(Clone, Copy)]
721pub struct SvDdraceTimeLegacy {
722    pub time: i32,
723    pub check: i32,
724    pub finish: i32,
725}
726
727#[derive(Clone, Copy)]
728pub struct SvRecordLegacy {
729    pub server_time_best: i32,
730    pub player_time_best: i32,
731}
732
733#[derive(Clone, Copy)]
734pub struct Unused2;
735
736#[derive(Clone, Copy)]
737pub struct SvTeamsStateLegacy {
738    pub teams: [i32; 64],
739}
740
741#[derive(Clone, Copy)]
742pub struct ClShowOthersLegacy {
743    pub show: bool,
744}
745
746#[derive(Clone, Copy)]
747pub struct SvMyOwnMessage {
748    pub test: i32,
749}
750
751#[derive(Clone, Copy)]
752pub struct ClShowDistance {
753    pub x: i32,
754    pub y: i32,
755}
756
757#[derive(Clone, Copy)]
758pub struct ClShowOthers {
759    pub show: i32,
760}
761
762#[derive(Clone, Copy)]
763pub struct SvTeamsState {
764    pub teams: [i32; 64],
765}
766
767#[derive(Clone, Copy)]
768pub struct SvDdraceTime {
769    pub time: i32,
770    pub check: i32,
771    pub finish: i32,
772}
773
774#[derive(Clone, Copy)]
775pub struct SvRecord {
776    pub server_time_best: i32,
777    pub player_time_best: i32,
778}
779
780#[derive(Clone, Copy)]
781pub struct SvKillMsgTeam {
782    pub team: i32,
783    pub first: i32,
784}
785
786impl<'a> SvMotd<'a> {
787    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvMotd<'a>, Error> {
788        let result = Ok(SvMotd {
789            message: _p.read_string()?,
790        });
791        _p.finish(warn);
792        result
793    }
794    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
795        _p.write_string(self.message)?;
796        Ok(_p.written())
797    }
798}
799impl<'a> fmt::Debug for SvMotd<'a> {
800    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
801        f.debug_struct("SvMotd")
802            .field("message", &pretty::Bytes::new(&self.message))
803            .finish()
804    }
805}
806
807impl<'a> SvBroadcast<'a> {
808    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvBroadcast<'a>, Error> {
809        let result = Ok(SvBroadcast {
810            message: _p.read_string()?,
811        });
812        _p.finish(warn);
813        result
814    }
815    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
816        _p.write_string(self.message)?;
817        Ok(_p.written())
818    }
819}
820impl<'a> fmt::Debug for SvBroadcast<'a> {
821    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
822        f.debug_struct("SvBroadcast")
823            .field("message", &pretty::Bytes::new(&self.message))
824            .finish()
825    }
826}
827
828impl<'a> SvChat<'a> {
829    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvChat<'a>, Error> {
830        let result = Ok(SvChat {
831            team: in_range(_p.read_int(warn)?, -2, 3)?,
832            client_id: in_range(_p.read_int(warn)?, -1, 63)?,
833            message: sanitize(warn, _p.read_string()?)?,
834        });
835        _p.finish(warn);
836        result
837    }
838    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
839        assert!(-2 <= self.team && self.team <= 3);
840        assert!(-1 <= self.client_id && self.client_id <= 63);
841        sanitize(&mut Panic, self.message).unwrap();
842        _p.write_int(self.team)?;
843        _p.write_int(self.client_id)?;
844        _p.write_string(self.message)?;
845        Ok(_p.written())
846    }
847}
848impl<'a> fmt::Debug for SvChat<'a> {
849    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
850        f.debug_struct("SvChat")
851            .field("team", &self.team)
852            .field("client_id", &self.client_id)
853            .field("message", &pretty::Bytes::new(&self.message))
854            .finish()
855    }
856}
857
858impl SvKillMsg {
859    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvKillMsg, Error> {
860        let result = Ok(SvKillMsg {
861            killer: in_range(_p.read_int(warn)?, 0, 63)?,
862            victim: in_range(_p.read_int(warn)?, 0, 63)?,
863            weapon: in_range(_p.read_int(warn)?, -3, 5)?,
864            mode_special: _p.read_int(warn)?,
865        });
866        _p.finish(warn);
867        result
868    }
869    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
870        assert!(0 <= self.killer && self.killer <= 63);
871        assert!(0 <= self.victim && self.victim <= 63);
872        assert!(-3 <= self.weapon && self.weapon <= 5);
873        _p.write_int(self.killer)?;
874        _p.write_int(self.victim)?;
875        _p.write_int(self.weapon)?;
876        _p.write_int(self.mode_special)?;
877        Ok(_p.written())
878    }
879}
880impl fmt::Debug for SvKillMsg {
881    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
882        f.debug_struct("SvKillMsg")
883            .field("killer", &self.killer)
884            .field("victim", &self.victim)
885            .field("weapon", &self.weapon)
886            .field("mode_special", &self.mode_special)
887            .finish()
888    }
889}
890
891impl SvSoundGlobal {
892    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvSoundGlobal, Error> {
893        let result = Ok(SvSoundGlobal {
894            sound_id: enums::Sound::from_i32(_p.read_int(warn)?)?,
895        });
896        _p.finish(warn);
897        result
898    }
899    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
900        _p.write_int(self.sound_id.to_i32())?;
901        Ok(_p.written())
902    }
903}
904impl fmt::Debug for SvSoundGlobal {
905    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
906        f.debug_struct("SvSoundGlobal")
907            .field("sound_id", &self.sound_id)
908            .finish()
909    }
910}
911
912impl SvTuneParams {
913    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTuneParams, Error> {
914        let result = Ok(SvTuneParams {
915            ground_control_speed: TuneParam(_p.read_int(warn)?),
916            ground_control_accel: TuneParam(_p.read_int(warn)?),
917            ground_friction: TuneParam(_p.read_int(warn)?),
918            ground_jump_impulse: TuneParam(_p.read_int(warn)?),
919            air_jump_impulse: TuneParam(_p.read_int(warn)?),
920            air_control_speed: TuneParam(_p.read_int(warn)?),
921            air_control_accel: TuneParam(_p.read_int(warn)?),
922            air_friction: TuneParam(_p.read_int(warn)?),
923            hook_length: TuneParam(_p.read_int(warn)?),
924            hook_fire_speed: TuneParam(_p.read_int(warn)?),
925            hook_drag_accel: TuneParam(_p.read_int(warn)?),
926            hook_drag_speed: TuneParam(_p.read_int(warn)?),
927            gravity: TuneParam(_p.read_int(warn)?),
928            velramp_start: TuneParam(_p.read_int(warn)?),
929            velramp_range: TuneParam(_p.read_int(warn)?),
930            velramp_curvature: TuneParam(_p.read_int(warn)?),
931            gun_curvature: TuneParam(_p.read_int(warn)?),
932            gun_speed: TuneParam(_p.read_int(warn)?),
933            gun_lifetime: TuneParam(_p.read_int(warn)?),
934            shotgun_curvature: TuneParam(_p.read_int(warn)?),
935            shotgun_speed: TuneParam(_p.read_int(warn)?),
936            shotgun_speeddiff: TuneParam(_p.read_int(warn)?),
937            shotgun_lifetime: TuneParam(_p.read_int(warn)?),
938            grenade_curvature: TuneParam(_p.read_int(warn)?),
939            grenade_speed: TuneParam(_p.read_int(warn)?),
940            grenade_lifetime: TuneParam(_p.read_int(warn)?),
941            laser_reach: TuneParam(_p.read_int(warn)?),
942            laser_bounce_delay: TuneParam(_p.read_int(warn)?),
943            laser_bounce_num: TuneParam(_p.read_int(warn)?),
944            laser_bounce_cost: TuneParam(_p.read_int(warn)?),
945            laser_damage: TuneParam(_p.read_int(warn)?),
946            player_collision: TuneParam(_p.read_int(warn)?),
947            player_hooking: TuneParam(_p.read_int(warn)?),
948            jetpack_strength: TuneParam(_p.read_int(warn)?),
949            shotgun_strength: TuneParam(_p.read_int(warn)?),
950            explosion_strength: TuneParam(_p.read_int(warn)?),
951            hammer_strength: TuneParam(_p.read_int(warn)?),
952            hook_duration: TuneParam(_p.read_int(warn)?),
953            hammer_fire_delay: TuneParam(_p.read_int(warn)?),
954            gun_fire_delay: TuneParam(_p.read_int(warn)?),
955            shotgun_fire_delay: TuneParam(_p.read_int(warn)?),
956            grenade_fire_delay: TuneParam(_p.read_int(warn)?),
957            laser_fire_delay: TuneParam(_p.read_int(warn)?),
958            ninja_fire_delay: TuneParam(_p.read_int(warn)?),
959            hammer_hit_fire_delay: TuneParam(_p.read_int(warn)?),
960            ground_elasticity_x: TuneParam(_p.read_int(warn)?),
961            ground_elasticity_y: TuneParam(_p.read_int(warn)?),
962        });
963        _p.finish(warn);
964        result
965    }
966    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
967        _p.write_int(self.ground_control_speed.0)?;
968        _p.write_int(self.ground_control_accel.0)?;
969        _p.write_int(self.ground_friction.0)?;
970        _p.write_int(self.ground_jump_impulse.0)?;
971        _p.write_int(self.air_jump_impulse.0)?;
972        _p.write_int(self.air_control_speed.0)?;
973        _p.write_int(self.air_control_accel.0)?;
974        _p.write_int(self.air_friction.0)?;
975        _p.write_int(self.hook_length.0)?;
976        _p.write_int(self.hook_fire_speed.0)?;
977        _p.write_int(self.hook_drag_accel.0)?;
978        _p.write_int(self.hook_drag_speed.0)?;
979        _p.write_int(self.gravity.0)?;
980        _p.write_int(self.velramp_start.0)?;
981        _p.write_int(self.velramp_range.0)?;
982        _p.write_int(self.velramp_curvature.0)?;
983        _p.write_int(self.gun_curvature.0)?;
984        _p.write_int(self.gun_speed.0)?;
985        _p.write_int(self.gun_lifetime.0)?;
986        _p.write_int(self.shotgun_curvature.0)?;
987        _p.write_int(self.shotgun_speed.0)?;
988        _p.write_int(self.shotgun_speeddiff.0)?;
989        _p.write_int(self.shotgun_lifetime.0)?;
990        _p.write_int(self.grenade_curvature.0)?;
991        _p.write_int(self.grenade_speed.0)?;
992        _p.write_int(self.grenade_lifetime.0)?;
993        _p.write_int(self.laser_reach.0)?;
994        _p.write_int(self.laser_bounce_delay.0)?;
995        _p.write_int(self.laser_bounce_num.0)?;
996        _p.write_int(self.laser_bounce_cost.0)?;
997        _p.write_int(self.laser_damage.0)?;
998        _p.write_int(self.player_collision.0)?;
999        _p.write_int(self.player_hooking.0)?;
1000        _p.write_int(self.jetpack_strength.0)?;
1001        _p.write_int(self.shotgun_strength.0)?;
1002        _p.write_int(self.explosion_strength.0)?;
1003        _p.write_int(self.hammer_strength.0)?;
1004        _p.write_int(self.hook_duration.0)?;
1005        _p.write_int(self.hammer_fire_delay.0)?;
1006        _p.write_int(self.gun_fire_delay.0)?;
1007        _p.write_int(self.shotgun_fire_delay.0)?;
1008        _p.write_int(self.grenade_fire_delay.0)?;
1009        _p.write_int(self.laser_fire_delay.0)?;
1010        _p.write_int(self.ninja_fire_delay.0)?;
1011        _p.write_int(self.hammer_hit_fire_delay.0)?;
1012        _p.write_int(self.ground_elasticity_x.0)?;
1013        _p.write_int(self.ground_elasticity_y.0)?;
1014        Ok(_p.written())
1015    }
1016}
1017impl fmt::Debug for SvTuneParams {
1018    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1019        f.debug_struct("SvTuneParams")
1020            .field("ground_control_speed", &self.ground_control_speed)
1021            .field("ground_control_accel", &self.ground_control_accel)
1022            .field("ground_friction", &self.ground_friction)
1023            .field("ground_jump_impulse", &self.ground_jump_impulse)
1024            .field("air_jump_impulse", &self.air_jump_impulse)
1025            .field("air_control_speed", &self.air_control_speed)
1026            .field("air_control_accel", &self.air_control_accel)
1027            .field("air_friction", &self.air_friction)
1028            .field("hook_length", &self.hook_length)
1029            .field("hook_fire_speed", &self.hook_fire_speed)
1030            .field("hook_drag_accel", &self.hook_drag_accel)
1031            .field("hook_drag_speed", &self.hook_drag_speed)
1032            .field("gravity", &self.gravity)
1033            .field("velramp_start", &self.velramp_start)
1034            .field("velramp_range", &self.velramp_range)
1035            .field("velramp_curvature", &self.velramp_curvature)
1036            .field("gun_curvature", &self.gun_curvature)
1037            .field("gun_speed", &self.gun_speed)
1038            .field("gun_lifetime", &self.gun_lifetime)
1039            .field("shotgun_curvature", &self.shotgun_curvature)
1040            .field("shotgun_speed", &self.shotgun_speed)
1041            .field("shotgun_speeddiff", &self.shotgun_speeddiff)
1042            .field("shotgun_lifetime", &self.shotgun_lifetime)
1043            .field("grenade_curvature", &self.grenade_curvature)
1044            .field("grenade_speed", &self.grenade_speed)
1045            .field("grenade_lifetime", &self.grenade_lifetime)
1046            .field("laser_reach", &self.laser_reach)
1047            .field("laser_bounce_delay", &self.laser_bounce_delay)
1048            .field("laser_bounce_num", &self.laser_bounce_num)
1049            .field("laser_bounce_cost", &self.laser_bounce_cost)
1050            .field("laser_damage", &self.laser_damage)
1051            .field("player_collision", &self.player_collision)
1052            .field("player_hooking", &self.player_hooking)
1053            .field("jetpack_strength", &self.jetpack_strength)
1054            .field("shotgun_strength", &self.shotgun_strength)
1055            .field("explosion_strength", &self.explosion_strength)
1056            .field("hammer_strength", &self.hammer_strength)
1057            .field("hook_duration", &self.hook_duration)
1058            .field("hammer_fire_delay", &self.hammer_fire_delay)
1059            .field("gun_fire_delay", &self.gun_fire_delay)
1060            .field("shotgun_fire_delay", &self.shotgun_fire_delay)
1061            .field("grenade_fire_delay", &self.grenade_fire_delay)
1062            .field("laser_fire_delay", &self.laser_fire_delay)
1063            .field("ninja_fire_delay", &self.ninja_fire_delay)
1064            .field("hammer_hit_fire_delay", &self.hammer_hit_fire_delay)
1065            .field("ground_elasticity_x", &self.ground_elasticity_x)
1066            .field("ground_elasticity_y", &self.ground_elasticity_y)
1067            .finish()
1068    }
1069}
1070
1071impl Unused {
1072    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<Unused, Error> {
1073        let result = Ok(Unused);
1074        _p.finish(warn);
1075        result
1076    }
1077    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1078        Ok(_p.written())
1079    }
1080}
1081impl fmt::Debug for Unused {
1082    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1083        f.debug_struct("Unused")
1084            .finish()
1085    }
1086}
1087
1088impl SvReadyToEnter {
1089    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvReadyToEnter, Error> {
1090        let result = Ok(SvReadyToEnter);
1091        _p.finish(warn);
1092        result
1093    }
1094    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1095        Ok(_p.written())
1096    }
1097}
1098impl fmt::Debug for SvReadyToEnter {
1099    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1100        f.debug_struct("SvReadyToEnter")
1101            .finish()
1102    }
1103}
1104
1105impl SvWeaponPickup {
1106    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvWeaponPickup, Error> {
1107        let result = Ok(SvWeaponPickup {
1108            weapon: enums::Weapon::from_i32(_p.read_int(warn)?)?,
1109        });
1110        _p.finish(warn);
1111        result
1112    }
1113    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1114        _p.write_int(self.weapon.to_i32())?;
1115        Ok(_p.written())
1116    }
1117}
1118impl fmt::Debug for SvWeaponPickup {
1119    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1120        f.debug_struct("SvWeaponPickup")
1121            .field("weapon", &self.weapon)
1122            .finish()
1123    }
1124}
1125
1126impl SvEmoticon {
1127    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvEmoticon, Error> {
1128        let result = Ok(SvEmoticon {
1129            client_id: in_range(_p.read_int(warn)?, 0, 63)?,
1130            emoticon: enums::Emoticon::from_i32(_p.read_int(warn)?)?,
1131        });
1132        _p.finish(warn);
1133        result
1134    }
1135    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1136        assert!(0 <= self.client_id && self.client_id <= 63);
1137        _p.write_int(self.client_id)?;
1138        _p.write_int(self.emoticon.to_i32())?;
1139        Ok(_p.written())
1140    }
1141}
1142impl fmt::Debug for SvEmoticon {
1143    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1144        f.debug_struct("SvEmoticon")
1145            .field("client_id", &self.client_id)
1146            .field("emoticon", &self.emoticon)
1147            .finish()
1148    }
1149}
1150
1151impl SvVoteClearOptions {
1152    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteClearOptions, Error> {
1153        let result = Ok(SvVoteClearOptions);
1154        _p.finish(warn);
1155        result
1156    }
1157    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1158        Ok(_p.written())
1159    }
1160}
1161impl fmt::Debug for SvVoteClearOptions {
1162    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1163        f.debug_struct("SvVoteClearOptions")
1164            .finish()
1165    }
1166}
1167
1168impl<'a> SvVoteOptionListAdd<'a> {
1169    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionListAdd<'a>, Error> {
1170        let result = Ok(SvVoteOptionListAdd {
1171            num_options: in_range(_p.read_int(warn)?, 1, 15)?,
1172            description: [
1173                sanitize(warn, _p.read_string()?)?,
1174                sanitize(warn, _p.read_string()?)?,
1175                sanitize(warn, _p.read_string()?)?,
1176                sanitize(warn, _p.read_string()?)?,
1177                sanitize(warn, _p.read_string()?)?,
1178                sanitize(warn, _p.read_string()?)?,
1179                sanitize(warn, _p.read_string()?)?,
1180                sanitize(warn, _p.read_string()?)?,
1181                sanitize(warn, _p.read_string()?)?,
1182                sanitize(warn, _p.read_string()?)?,
1183                sanitize(warn, _p.read_string()?)?,
1184                sanitize(warn, _p.read_string()?)?,
1185                sanitize(warn, _p.read_string()?)?,
1186                sanitize(warn, _p.read_string()?)?,
1187                sanitize(warn, _p.read_string()?)?,
1188            ],
1189        });
1190        _p.finish(warn);
1191        result
1192    }
1193    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1194        assert!(1 <= self.num_options && self.num_options <= 15);
1195        for &e in &self.description {
1196            sanitize(&mut Panic, e).unwrap();
1197        }
1198        _p.write_int(self.num_options)?;
1199        for &e in &self.description {
1200            _p.write_string(e)?;
1201        }
1202        Ok(_p.written())
1203    }
1204}
1205impl<'a> fmt::Debug for SvVoteOptionListAdd<'a> {
1206    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1207        f.debug_struct("SvVoteOptionListAdd")
1208            .field("num_options", &self.num_options)
1209            .field("description", &DebugSlice::new(&self.description, |e| pretty::Bytes::new(&e)))
1210            .finish()
1211    }
1212}
1213
1214impl<'a> SvVoteOptionAdd<'a> {
1215    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionAdd<'a>, Error> {
1216        let result = Ok(SvVoteOptionAdd {
1217            description: sanitize(warn, _p.read_string()?)?,
1218        });
1219        _p.finish(warn);
1220        result
1221    }
1222    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1223        sanitize(&mut Panic, self.description).unwrap();
1224        _p.write_string(self.description)?;
1225        Ok(_p.written())
1226    }
1227}
1228impl<'a> fmt::Debug for SvVoteOptionAdd<'a> {
1229    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1230        f.debug_struct("SvVoteOptionAdd")
1231            .field("description", &pretty::Bytes::new(&self.description))
1232            .finish()
1233    }
1234}
1235
1236impl<'a> SvVoteOptionRemove<'a> {
1237    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionRemove<'a>, Error> {
1238        let result = Ok(SvVoteOptionRemove {
1239            description: sanitize(warn, _p.read_string()?)?,
1240        });
1241        _p.finish(warn);
1242        result
1243    }
1244    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1245        sanitize(&mut Panic, self.description).unwrap();
1246        _p.write_string(self.description)?;
1247        Ok(_p.written())
1248    }
1249}
1250impl<'a> fmt::Debug for SvVoteOptionRemove<'a> {
1251    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1252        f.debug_struct("SvVoteOptionRemove")
1253            .field("description", &pretty::Bytes::new(&self.description))
1254            .finish()
1255    }
1256}
1257
1258impl<'a> SvVoteSet<'a> {
1259    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteSet<'a>, Error> {
1260        let result = Ok(SvVoteSet {
1261            timeout: in_range(_p.read_int(warn)?, 0, 60)?,
1262            description: sanitize(warn, _p.read_string()?)?,
1263            reason: sanitize(warn, _p.read_string()?)?,
1264        });
1265        _p.finish(warn);
1266        result
1267    }
1268    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1269        assert!(0 <= self.timeout && self.timeout <= 60);
1270        sanitize(&mut Panic, self.description).unwrap();
1271        sanitize(&mut Panic, self.reason).unwrap();
1272        _p.write_int(self.timeout)?;
1273        _p.write_string(self.description)?;
1274        _p.write_string(self.reason)?;
1275        Ok(_p.written())
1276    }
1277}
1278impl<'a> fmt::Debug for SvVoteSet<'a> {
1279    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1280        f.debug_struct("SvVoteSet")
1281            .field("timeout", &self.timeout)
1282            .field("description", &pretty::Bytes::new(&self.description))
1283            .field("reason", &pretty::Bytes::new(&self.reason))
1284            .finish()
1285    }
1286}
1287
1288impl SvVoteStatus {
1289    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteStatus, Error> {
1290        let result = Ok(SvVoteStatus {
1291            yes: in_range(_p.read_int(warn)?, 0, 64)?,
1292            no: in_range(_p.read_int(warn)?, 0, 64)?,
1293            pass: in_range(_p.read_int(warn)?, 0, 64)?,
1294            total: in_range(_p.read_int(warn)?, 0, 64)?,
1295        });
1296        _p.finish(warn);
1297        result
1298    }
1299    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1300        assert!(0 <= self.yes && self.yes <= 64);
1301        assert!(0 <= self.no && self.no <= 64);
1302        assert!(0 <= self.pass && self.pass <= 64);
1303        assert!(0 <= self.total && self.total <= 64);
1304        _p.write_int(self.yes)?;
1305        _p.write_int(self.no)?;
1306        _p.write_int(self.pass)?;
1307        _p.write_int(self.total)?;
1308        Ok(_p.written())
1309    }
1310}
1311impl fmt::Debug for SvVoteStatus {
1312    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1313        f.debug_struct("SvVoteStatus")
1314            .field("yes", &self.yes)
1315            .field("no", &self.no)
1316            .field("pass", &self.pass)
1317            .field("total", &self.total)
1318            .finish()
1319    }
1320}
1321
1322impl<'a> ClSay<'a> {
1323    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClSay<'a>, Error> {
1324        let result = Ok(ClSay {
1325            team: to_bool(_p.read_int(warn)?)?,
1326            message: sanitize(warn, _p.read_string()?)?,
1327        });
1328        _p.finish(warn);
1329        result
1330    }
1331    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1332        sanitize(&mut Panic, self.message).unwrap();
1333        _p.write_int(self.team as i32)?;
1334        _p.write_string(self.message)?;
1335        Ok(_p.written())
1336    }
1337}
1338impl<'a> fmt::Debug for ClSay<'a> {
1339    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1340        f.debug_struct("ClSay")
1341            .field("team", &self.team)
1342            .field("message", &pretty::Bytes::new(&self.message))
1343            .finish()
1344    }
1345}
1346
1347impl ClSetTeam {
1348    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClSetTeam, Error> {
1349        let result = Ok(ClSetTeam {
1350            team: enums::Team::from_i32(_p.read_int(warn)?)?,
1351        });
1352        _p.finish(warn);
1353        result
1354    }
1355    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1356        _p.write_int(self.team.to_i32())?;
1357        Ok(_p.written())
1358    }
1359}
1360impl fmt::Debug for ClSetTeam {
1361    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1362        f.debug_struct("ClSetTeam")
1363            .field("team", &self.team)
1364            .finish()
1365    }
1366}
1367
1368impl ClSetSpectatorMode {
1369    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClSetSpectatorMode, Error> {
1370        let result = Ok(ClSetSpectatorMode {
1371            spectator_id: in_range(_p.read_int(warn)?, -1, 63)?,
1372        });
1373        _p.finish(warn);
1374        result
1375    }
1376    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1377        assert!(-1 <= self.spectator_id && self.spectator_id <= 63);
1378        _p.write_int(self.spectator_id)?;
1379        Ok(_p.written())
1380    }
1381}
1382impl fmt::Debug for ClSetSpectatorMode {
1383    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1384        f.debug_struct("ClSetSpectatorMode")
1385            .field("spectator_id", &self.spectator_id)
1386            .finish()
1387    }
1388}
1389
1390impl<'a> ClStartInfo<'a> {
1391    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClStartInfo<'a>, Error> {
1392        let result = Ok(ClStartInfo {
1393            name: sanitize(warn, _p.read_string()?)?,
1394            clan: sanitize(warn, _p.read_string()?)?,
1395            country: _p.read_int(warn)?,
1396            skin: sanitize(warn, _p.read_string()?)?,
1397            use_custom_color: to_bool(_p.read_int(warn)?)?,
1398            color_body: _p.read_int(warn)?,
1399            color_feet: _p.read_int(warn)?,
1400        });
1401        _p.finish(warn);
1402        result
1403    }
1404    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1405        sanitize(&mut Panic, self.name).unwrap();
1406        sanitize(&mut Panic, self.clan).unwrap();
1407        sanitize(&mut Panic, self.skin).unwrap();
1408        _p.write_string(self.name)?;
1409        _p.write_string(self.clan)?;
1410        _p.write_int(self.country)?;
1411        _p.write_string(self.skin)?;
1412        _p.write_int(self.use_custom_color as i32)?;
1413        _p.write_int(self.color_body)?;
1414        _p.write_int(self.color_feet)?;
1415        Ok(_p.written())
1416    }
1417}
1418impl<'a> fmt::Debug for ClStartInfo<'a> {
1419    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1420        f.debug_struct("ClStartInfo")
1421            .field("name", &pretty::Bytes::new(&self.name))
1422            .field("clan", &pretty::Bytes::new(&self.clan))
1423            .field("country", &self.country)
1424            .field("skin", &pretty::Bytes::new(&self.skin))
1425            .field("use_custom_color", &self.use_custom_color)
1426            .field("color_body", &self.color_body)
1427            .field("color_feet", &self.color_feet)
1428            .finish()
1429    }
1430}
1431
1432impl<'a> ClChangeInfo<'a> {
1433    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClChangeInfo<'a>, Error> {
1434        let result = Ok(ClChangeInfo {
1435            name: sanitize(warn, _p.read_string()?)?,
1436            clan: sanitize(warn, _p.read_string()?)?,
1437            country: _p.read_int(warn)?,
1438            skin: sanitize(warn, _p.read_string()?)?,
1439            use_custom_color: to_bool(_p.read_int(warn)?)?,
1440            color_body: _p.read_int(warn)?,
1441            color_feet: _p.read_int(warn)?,
1442        });
1443        _p.finish(warn);
1444        result
1445    }
1446    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1447        sanitize(&mut Panic, self.name).unwrap();
1448        sanitize(&mut Panic, self.clan).unwrap();
1449        sanitize(&mut Panic, self.skin).unwrap();
1450        _p.write_string(self.name)?;
1451        _p.write_string(self.clan)?;
1452        _p.write_int(self.country)?;
1453        _p.write_string(self.skin)?;
1454        _p.write_int(self.use_custom_color as i32)?;
1455        _p.write_int(self.color_body)?;
1456        _p.write_int(self.color_feet)?;
1457        Ok(_p.written())
1458    }
1459}
1460impl<'a> fmt::Debug for ClChangeInfo<'a> {
1461    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1462        f.debug_struct("ClChangeInfo")
1463            .field("name", &pretty::Bytes::new(&self.name))
1464            .field("clan", &pretty::Bytes::new(&self.clan))
1465            .field("country", &self.country)
1466            .field("skin", &pretty::Bytes::new(&self.skin))
1467            .field("use_custom_color", &self.use_custom_color)
1468            .field("color_body", &self.color_body)
1469            .field("color_feet", &self.color_feet)
1470            .finish()
1471    }
1472}
1473
1474impl ClKill {
1475    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClKill, Error> {
1476        let result = Ok(ClKill);
1477        _p.finish(warn);
1478        result
1479    }
1480    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1481        Ok(_p.written())
1482    }
1483}
1484impl fmt::Debug for ClKill {
1485    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1486        f.debug_struct("ClKill")
1487            .finish()
1488    }
1489}
1490
1491impl ClEmoticon {
1492    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClEmoticon, Error> {
1493        let result = Ok(ClEmoticon {
1494            emoticon: enums::Emoticon::from_i32(_p.read_int(warn)?)?,
1495        });
1496        _p.finish(warn);
1497        result
1498    }
1499    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1500        _p.write_int(self.emoticon.to_i32())?;
1501        Ok(_p.written())
1502    }
1503}
1504impl fmt::Debug for ClEmoticon {
1505    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1506        f.debug_struct("ClEmoticon")
1507            .field("emoticon", &self.emoticon)
1508            .finish()
1509    }
1510}
1511
1512impl ClVote {
1513    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClVote, Error> {
1514        let result = Ok(ClVote {
1515            vote: in_range(_p.read_int(warn)?, -1, 1)?,
1516        });
1517        _p.finish(warn);
1518        result
1519    }
1520    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1521        assert!(-1 <= self.vote && self.vote <= 1);
1522        _p.write_int(self.vote)?;
1523        Ok(_p.written())
1524    }
1525}
1526impl fmt::Debug for ClVote {
1527    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1528        f.debug_struct("ClVote")
1529            .field("vote", &self.vote)
1530            .finish()
1531    }
1532}
1533
1534impl<'a> ClCallVote<'a> {
1535    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClCallVote<'a>, Error> {
1536        let result = Ok(ClCallVote {
1537            type_: sanitize(warn, _p.read_string()?)?,
1538            value: sanitize(warn, _p.read_string()?)?,
1539            reason: sanitize(warn, _p.read_string()?)?,
1540        });
1541        _p.finish(warn);
1542        result
1543    }
1544    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1545        sanitize(&mut Panic, self.type_).unwrap();
1546        sanitize(&mut Panic, self.value).unwrap();
1547        sanitize(&mut Panic, self.reason).unwrap();
1548        _p.write_string(self.type_)?;
1549        _p.write_string(self.value)?;
1550        _p.write_string(self.reason)?;
1551        Ok(_p.written())
1552    }
1553}
1554impl<'a> fmt::Debug for ClCallVote<'a> {
1555    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1556        f.debug_struct("ClCallVote")
1557            .field("type_", &pretty::Bytes::new(&self.type_))
1558            .field("value", &pretty::Bytes::new(&self.value))
1559            .field("reason", &pretty::Bytes::new(&self.reason))
1560            .finish()
1561    }
1562}
1563
1564impl ClIsDdnetLegacy {
1565    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClIsDdnetLegacy, Error> {
1566        let result = Ok(ClIsDdnetLegacy {
1567            ddnet_version: _p.read_int(warn)?,
1568        });
1569        _p.finish(warn);
1570        result
1571    }
1572    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1573        _p.write_int(self.ddnet_version)?;
1574        Ok(_p.written())
1575    }
1576}
1577impl fmt::Debug for ClIsDdnetLegacy {
1578    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1579        f.debug_struct("ClIsDdnetLegacy")
1580            .field("ddnet_version", &self.ddnet_version)
1581            .finish()
1582    }
1583}
1584
1585impl SvDdraceTimeLegacy {
1586    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvDdraceTimeLegacy, Error> {
1587        let result = Ok(SvDdraceTimeLegacy {
1588            time: _p.read_int(warn)?,
1589            check: _p.read_int(warn)?,
1590            finish: in_range(_p.read_int(warn)?, 0, 1)?,
1591        });
1592        _p.finish(warn);
1593        result
1594    }
1595    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1596        assert!(0 <= self.finish && self.finish <= 1);
1597        _p.write_int(self.time)?;
1598        _p.write_int(self.check)?;
1599        _p.write_int(self.finish)?;
1600        Ok(_p.written())
1601    }
1602}
1603impl fmt::Debug for SvDdraceTimeLegacy {
1604    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1605        f.debug_struct("SvDdraceTimeLegacy")
1606            .field("time", &self.time)
1607            .field("check", &self.check)
1608            .field("finish", &self.finish)
1609            .finish()
1610    }
1611}
1612
1613impl SvRecordLegacy {
1614    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvRecordLegacy, Error> {
1615        let result = Ok(SvRecordLegacy {
1616            server_time_best: _p.read_int(warn)?,
1617            player_time_best: _p.read_int(warn)?,
1618        });
1619        _p.finish(warn);
1620        result
1621    }
1622    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1623        _p.write_int(self.server_time_best)?;
1624        _p.write_int(self.player_time_best)?;
1625        Ok(_p.written())
1626    }
1627}
1628impl fmt::Debug for SvRecordLegacy {
1629    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1630        f.debug_struct("SvRecordLegacy")
1631            .field("server_time_best", &self.server_time_best)
1632            .field("player_time_best", &self.player_time_best)
1633            .finish()
1634    }
1635}
1636
1637impl Unused2 {
1638    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<Unused2, Error> {
1639        let result = Ok(Unused2);
1640        _p.finish(warn);
1641        result
1642    }
1643    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1644        Ok(_p.written())
1645    }
1646}
1647impl fmt::Debug for Unused2 {
1648    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1649        f.debug_struct("Unused2")
1650            .finish()
1651    }
1652}
1653
1654impl SvTeamsStateLegacy {
1655    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTeamsStateLegacy, Error> {
1656        let result = Ok(SvTeamsStateLegacy {
1657            teams: [
1658                in_range(_p.read_int(warn)?, 0, 64)?,
1659                in_range(_p.read_int(warn)?, 0, 64)?,
1660                in_range(_p.read_int(warn)?, 0, 64)?,
1661                in_range(_p.read_int(warn)?, 0, 64)?,
1662                in_range(_p.read_int(warn)?, 0, 64)?,
1663                in_range(_p.read_int(warn)?, 0, 64)?,
1664                in_range(_p.read_int(warn)?, 0, 64)?,
1665                in_range(_p.read_int(warn)?, 0, 64)?,
1666                in_range(_p.read_int(warn)?, 0, 64)?,
1667                in_range(_p.read_int(warn)?, 0, 64)?,
1668                in_range(_p.read_int(warn)?, 0, 64)?,
1669                in_range(_p.read_int(warn)?, 0, 64)?,
1670                in_range(_p.read_int(warn)?, 0, 64)?,
1671                in_range(_p.read_int(warn)?, 0, 64)?,
1672                in_range(_p.read_int(warn)?, 0, 64)?,
1673                in_range(_p.read_int(warn)?, 0, 64)?,
1674                in_range(_p.read_int(warn)?, 0, 64)?,
1675                in_range(_p.read_int(warn)?, 0, 64)?,
1676                in_range(_p.read_int(warn)?, 0, 64)?,
1677                in_range(_p.read_int(warn)?, 0, 64)?,
1678                in_range(_p.read_int(warn)?, 0, 64)?,
1679                in_range(_p.read_int(warn)?, 0, 64)?,
1680                in_range(_p.read_int(warn)?, 0, 64)?,
1681                in_range(_p.read_int(warn)?, 0, 64)?,
1682                in_range(_p.read_int(warn)?, 0, 64)?,
1683                in_range(_p.read_int(warn)?, 0, 64)?,
1684                in_range(_p.read_int(warn)?, 0, 64)?,
1685                in_range(_p.read_int(warn)?, 0, 64)?,
1686                in_range(_p.read_int(warn)?, 0, 64)?,
1687                in_range(_p.read_int(warn)?, 0, 64)?,
1688                in_range(_p.read_int(warn)?, 0, 64)?,
1689                in_range(_p.read_int(warn)?, 0, 64)?,
1690                in_range(_p.read_int(warn)?, 0, 64)?,
1691                in_range(_p.read_int(warn)?, 0, 64)?,
1692                in_range(_p.read_int(warn)?, 0, 64)?,
1693                in_range(_p.read_int(warn)?, 0, 64)?,
1694                in_range(_p.read_int(warn)?, 0, 64)?,
1695                in_range(_p.read_int(warn)?, 0, 64)?,
1696                in_range(_p.read_int(warn)?, 0, 64)?,
1697                in_range(_p.read_int(warn)?, 0, 64)?,
1698                in_range(_p.read_int(warn)?, 0, 64)?,
1699                in_range(_p.read_int(warn)?, 0, 64)?,
1700                in_range(_p.read_int(warn)?, 0, 64)?,
1701                in_range(_p.read_int(warn)?, 0, 64)?,
1702                in_range(_p.read_int(warn)?, 0, 64)?,
1703                in_range(_p.read_int(warn)?, 0, 64)?,
1704                in_range(_p.read_int(warn)?, 0, 64)?,
1705                in_range(_p.read_int(warn)?, 0, 64)?,
1706                in_range(_p.read_int(warn)?, 0, 64)?,
1707                in_range(_p.read_int(warn)?, 0, 64)?,
1708                in_range(_p.read_int(warn)?, 0, 64)?,
1709                in_range(_p.read_int(warn)?, 0, 64)?,
1710                in_range(_p.read_int(warn)?, 0, 64)?,
1711                in_range(_p.read_int(warn)?, 0, 64)?,
1712                in_range(_p.read_int(warn)?, 0, 64)?,
1713                in_range(_p.read_int(warn)?, 0, 64)?,
1714                in_range(_p.read_int(warn)?, 0, 64)?,
1715                in_range(_p.read_int(warn)?, 0, 64)?,
1716                in_range(_p.read_int(warn)?, 0, 64)?,
1717                in_range(_p.read_int(warn)?, 0, 64)?,
1718                in_range(_p.read_int(warn)?, 0, 64)?,
1719                in_range(_p.read_int(warn)?, 0, 64)?,
1720                in_range(_p.read_int(warn)?, 0, 64)?,
1721                in_range(_p.read_int(warn)?, 0, 64)?,
1722            ],
1723        });
1724        _p.finish(warn);
1725        result
1726    }
1727    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1728        for &e in &self.teams {
1729            assert!(0 <= e && e <= 64);
1730        }
1731        for &e in &self.teams {
1732            _p.write_int(e)?;
1733        }
1734        Ok(_p.written())
1735    }
1736}
1737impl fmt::Debug for SvTeamsStateLegacy {
1738    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1739        f.debug_struct("SvTeamsStateLegacy")
1740            .field("teams", &self.teams)
1741            .finish()
1742    }
1743}
1744
1745impl ClShowOthersLegacy {
1746    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowOthersLegacy, Error> {
1747        let result = Ok(ClShowOthersLegacy {
1748            show: to_bool(_p.read_int(warn)?)?,
1749        });
1750        _p.finish(warn);
1751        result
1752    }
1753    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1754        _p.write_int(self.show as i32)?;
1755        Ok(_p.written())
1756    }
1757}
1758impl fmt::Debug for ClShowOthersLegacy {
1759    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1760        f.debug_struct("ClShowOthersLegacy")
1761            .field("show", &self.show)
1762            .finish()
1763    }
1764}
1765
1766impl SvMyOwnMessage {
1767    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvMyOwnMessage, Error> {
1768        let result = Ok(SvMyOwnMessage {
1769            test: _p.read_int(warn)?,
1770        });
1771        _p.finish(warn);
1772        result
1773    }
1774    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1775        _p.write_int(self.test)?;
1776        Ok(_p.written())
1777    }
1778}
1779impl fmt::Debug for SvMyOwnMessage {
1780    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1781        f.debug_struct("SvMyOwnMessage")
1782            .field("test", &self.test)
1783            .finish()
1784    }
1785}
1786
1787impl ClShowDistance {
1788    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowDistance, Error> {
1789        let result = Ok(ClShowDistance {
1790            x: _p.read_int(warn)?,
1791            y: _p.read_int(warn)?,
1792        });
1793        _p.finish(warn);
1794        result
1795    }
1796    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1797        _p.write_int(self.x)?;
1798        _p.write_int(self.y)?;
1799        Ok(_p.written())
1800    }
1801}
1802impl fmt::Debug for ClShowDistance {
1803    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1804        f.debug_struct("ClShowDistance")
1805            .field("x", &self.x)
1806            .field("y", &self.y)
1807            .finish()
1808    }
1809}
1810
1811impl ClShowOthers {
1812    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowOthers, Error> {
1813        let result = Ok(ClShowOthers {
1814            show: in_range(_p.read_int(warn)?, 0, 2)?,
1815        });
1816        _p.finish(warn);
1817        result
1818    }
1819    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1820        assert!(0 <= self.show && self.show <= 2);
1821        _p.write_int(self.show)?;
1822        Ok(_p.written())
1823    }
1824}
1825impl fmt::Debug for ClShowOthers {
1826    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1827        f.debug_struct("ClShowOthers")
1828            .field("show", &self.show)
1829            .finish()
1830    }
1831}
1832
1833impl SvTeamsState {
1834    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTeamsState, Error> {
1835        let result = Ok(SvTeamsState {
1836            teams: [
1837                in_range(_p.read_int(warn)?, 0, 64)?,
1838                in_range(_p.read_int(warn)?, 0, 64)?,
1839                in_range(_p.read_int(warn)?, 0, 64)?,
1840                in_range(_p.read_int(warn)?, 0, 64)?,
1841                in_range(_p.read_int(warn)?, 0, 64)?,
1842                in_range(_p.read_int(warn)?, 0, 64)?,
1843                in_range(_p.read_int(warn)?, 0, 64)?,
1844                in_range(_p.read_int(warn)?, 0, 64)?,
1845                in_range(_p.read_int(warn)?, 0, 64)?,
1846                in_range(_p.read_int(warn)?, 0, 64)?,
1847                in_range(_p.read_int(warn)?, 0, 64)?,
1848                in_range(_p.read_int(warn)?, 0, 64)?,
1849                in_range(_p.read_int(warn)?, 0, 64)?,
1850                in_range(_p.read_int(warn)?, 0, 64)?,
1851                in_range(_p.read_int(warn)?, 0, 64)?,
1852                in_range(_p.read_int(warn)?, 0, 64)?,
1853                in_range(_p.read_int(warn)?, 0, 64)?,
1854                in_range(_p.read_int(warn)?, 0, 64)?,
1855                in_range(_p.read_int(warn)?, 0, 64)?,
1856                in_range(_p.read_int(warn)?, 0, 64)?,
1857                in_range(_p.read_int(warn)?, 0, 64)?,
1858                in_range(_p.read_int(warn)?, 0, 64)?,
1859                in_range(_p.read_int(warn)?, 0, 64)?,
1860                in_range(_p.read_int(warn)?, 0, 64)?,
1861                in_range(_p.read_int(warn)?, 0, 64)?,
1862                in_range(_p.read_int(warn)?, 0, 64)?,
1863                in_range(_p.read_int(warn)?, 0, 64)?,
1864                in_range(_p.read_int(warn)?, 0, 64)?,
1865                in_range(_p.read_int(warn)?, 0, 64)?,
1866                in_range(_p.read_int(warn)?, 0, 64)?,
1867                in_range(_p.read_int(warn)?, 0, 64)?,
1868                in_range(_p.read_int(warn)?, 0, 64)?,
1869                in_range(_p.read_int(warn)?, 0, 64)?,
1870                in_range(_p.read_int(warn)?, 0, 64)?,
1871                in_range(_p.read_int(warn)?, 0, 64)?,
1872                in_range(_p.read_int(warn)?, 0, 64)?,
1873                in_range(_p.read_int(warn)?, 0, 64)?,
1874                in_range(_p.read_int(warn)?, 0, 64)?,
1875                in_range(_p.read_int(warn)?, 0, 64)?,
1876                in_range(_p.read_int(warn)?, 0, 64)?,
1877                in_range(_p.read_int(warn)?, 0, 64)?,
1878                in_range(_p.read_int(warn)?, 0, 64)?,
1879                in_range(_p.read_int(warn)?, 0, 64)?,
1880                in_range(_p.read_int(warn)?, 0, 64)?,
1881                in_range(_p.read_int(warn)?, 0, 64)?,
1882                in_range(_p.read_int(warn)?, 0, 64)?,
1883                in_range(_p.read_int(warn)?, 0, 64)?,
1884                in_range(_p.read_int(warn)?, 0, 64)?,
1885                in_range(_p.read_int(warn)?, 0, 64)?,
1886                in_range(_p.read_int(warn)?, 0, 64)?,
1887                in_range(_p.read_int(warn)?, 0, 64)?,
1888                in_range(_p.read_int(warn)?, 0, 64)?,
1889                in_range(_p.read_int(warn)?, 0, 64)?,
1890                in_range(_p.read_int(warn)?, 0, 64)?,
1891                in_range(_p.read_int(warn)?, 0, 64)?,
1892                in_range(_p.read_int(warn)?, 0, 64)?,
1893                in_range(_p.read_int(warn)?, 0, 64)?,
1894                in_range(_p.read_int(warn)?, 0, 64)?,
1895                in_range(_p.read_int(warn)?, 0, 64)?,
1896                in_range(_p.read_int(warn)?, 0, 64)?,
1897                in_range(_p.read_int(warn)?, 0, 64)?,
1898                in_range(_p.read_int(warn)?, 0, 64)?,
1899                in_range(_p.read_int(warn)?, 0, 64)?,
1900                in_range(_p.read_int(warn)?, 0, 64)?,
1901            ],
1902        });
1903        _p.finish(warn);
1904        result
1905    }
1906    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1907        for &e in &self.teams {
1908            assert!(0 <= e && e <= 64);
1909        }
1910        for &e in &self.teams {
1911            _p.write_int(e)?;
1912        }
1913        Ok(_p.written())
1914    }
1915}
1916impl fmt::Debug for SvTeamsState {
1917    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1918        f.debug_struct("SvTeamsState")
1919            .field("teams", &self.teams)
1920            .finish()
1921    }
1922}
1923
1924impl SvDdraceTime {
1925    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvDdraceTime, Error> {
1926        let result = Ok(SvDdraceTime {
1927            time: _p.read_int(warn)?,
1928            check: _p.read_int(warn)?,
1929            finish: in_range(_p.read_int(warn)?, 0, 1)?,
1930        });
1931        _p.finish(warn);
1932        result
1933    }
1934    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1935        assert!(0 <= self.finish && self.finish <= 1);
1936        _p.write_int(self.time)?;
1937        _p.write_int(self.check)?;
1938        _p.write_int(self.finish)?;
1939        Ok(_p.written())
1940    }
1941}
1942impl fmt::Debug for SvDdraceTime {
1943    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1944        f.debug_struct("SvDdraceTime")
1945            .field("time", &self.time)
1946            .field("check", &self.check)
1947            .field("finish", &self.finish)
1948            .finish()
1949    }
1950}
1951
1952impl SvRecord {
1953    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvRecord, Error> {
1954        let result = Ok(SvRecord {
1955            server_time_best: _p.read_int(warn)?,
1956            player_time_best: _p.read_int(warn)?,
1957        });
1958        _p.finish(warn);
1959        result
1960    }
1961    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1962        _p.write_int(self.server_time_best)?;
1963        _p.write_int(self.player_time_best)?;
1964        Ok(_p.written())
1965    }
1966}
1967impl fmt::Debug for SvRecord {
1968    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1969        f.debug_struct("SvRecord")
1970            .field("server_time_best", &self.server_time_best)
1971            .field("player_time_best", &self.player_time_best)
1972            .finish()
1973    }
1974}
1975
1976impl SvKillMsgTeam {
1977    pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvKillMsgTeam, Error> {
1978        let result = Ok(SvKillMsgTeam {
1979            team: in_range(_p.read_int(warn)?, 0, 63)?,
1980            first: in_range(_p.read_int(warn)?, -1, 63)?,
1981        });
1982        _p.finish(warn);
1983        result
1984    }
1985    pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1986        assert!(0 <= self.team && self.team <= 63);
1987        assert!(-1 <= self.first && self.first <= 63);
1988        _p.write_int(self.team)?;
1989        _p.write_int(self.first)?;
1990        Ok(_p.written())
1991    }
1992}
1993impl fmt::Debug for SvKillMsgTeam {
1994    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1995        f.debug_struct("SvKillMsgTeam")
1996            .field("team", &self.team)
1997            .field("first", &self.first)
1998            .finish()
1999    }
2000}
2001