1use crate::enums;
2use crate::error::Error;
3use libtw2_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::positive;
11use libtw2_packer::sanitize;
12use libtw2_packer::to_bool;
13use libtw2_packer::with_packer;
14use libtw2_warn::Panic;
15use libtw2_warn::Warn;
16use libtw2_warn::wrap;
17use std::fmt;
18use super::MessageId;
19use super::SystemOrGame;
20use uuid::Uuid;
21
22pub use libtw2_gamenet_common::msg::TuneParam;
23
24impl<'a> Game<'a> {
25 pub fn decode<W>(warn: &mut W, p: &mut Unpacker<'a>) -> Result<Game<'a>, Error>
26 where W: Warn<Warning>
27 {
28 if let SystemOrGame::Game(msg_id) = SystemOrGame::decode_id(warn, p)? {
29 Game::decode_msg(warn, msg_id, p)
30 } else {
31 Err(Error::UnknownId)
32 }
33 }
34 pub fn encode<'d, 's>(&self, mut p: Packer<'d, 's>)
35 -> Result<&'d [u8], CapacityError>
36 {
37 with_packer(&mut p, |p| SystemOrGame::Game(self.msg_id()).encode_id(p))?;
38 with_packer(&mut p, |p| self.encode_msg(p))?;
39 Ok(p.written())
40 }
41}
42
43pub const SV_MOTD: i32 = 1;
44pub const SV_BROADCAST: i32 = 2;
45pub const SV_CHAT: i32 = 3;
46pub const SV_KILL_MSG: i32 = 4;
47pub const SV_SOUND_GLOBAL: i32 = 5;
48pub const SV_TUNE_PARAMS: i32 = 6;
49pub const UNUSED: i32 = 7;
50pub const SV_READY_TO_ENTER: i32 = 8;
51pub const SV_WEAPON_PICKUP: i32 = 9;
52pub const SV_EMOTICON: i32 = 10;
53pub const SV_VOTE_CLEAR_OPTIONS: i32 = 11;
54pub const SV_VOTE_OPTION_LIST_ADD: i32 = 12;
55pub const SV_VOTE_OPTION_ADD: i32 = 13;
56pub const SV_VOTE_OPTION_REMOVE: i32 = 14;
57pub const SV_VOTE_SET: i32 = 15;
58pub const SV_VOTE_STATUS: i32 = 16;
59pub const CL_SAY: i32 = 17;
60pub const CL_SET_TEAM: i32 = 18;
61pub const CL_SET_SPECTATOR_MODE: i32 = 19;
62pub const CL_START_INFO: i32 = 20;
63pub const CL_CHANGE_INFO: i32 = 21;
64pub const CL_KILL: i32 = 22;
65pub const CL_EMOTICON: i32 = 23;
66pub const CL_VOTE: i32 = 24;
67pub const CL_CALL_VOTE: i32 = 25;
68pub const CL_IS_DDNET_LEGACY: i32 = 26;
69pub const SV_DDRACE_TIME_LEGACY: i32 = 27;
70pub const SV_RECORD_LEGACY: i32 = 28;
71pub const UNUSED2: i32 = 29;
72pub const SV_TEAMS_STATE_LEGACY: i32 = 30;
73pub const CL_SHOW_OTHERS_LEGACY: i32 = 31;
74pub const SV_MY_OWN_MESSAGE: Uuid = Uuid::from_u128(0x1231e484_f607_3722_a89a_bd85db46f5d2);
75pub const CL_SHOW_DISTANCE: Uuid = Uuid::from_u128(0x53bb28af_4252_3ac9_8fd3_6ccbc2a603e3);
76pub const CL_SHOW_OTHERS: Uuid = Uuid::from_u128(0x7f264cdd_71a2_3962_bbce_0f94bbd81913);
77pub const CL_CAMERA_INFO: Uuid = Uuid::from_u128(0x8c470228_ee11_3808_93b9_c5c87d08b51c);
78pub const SV_TEAMS_STATE: Uuid = Uuid::from_u128(0xa091961a_95e8_3744_bb60_5eac9bd563c6);
79pub const SV_DDRACE_TIME: Uuid = Uuid::from_u128(0x5dde8b3c_6f6f_37ac_a72a_bb341fe76de5);
80pub const SV_RECORD: Uuid = Uuid::from_u128(0x804f149f_9b53_3b0a_897f_59663a1c4eb9);
81pub const SV_KILL_MSG_TEAM: Uuid = Uuid::from_u128(0xee610b6f_909f_311e_93f7_11a95f55a086);
82pub const SV_YOUR_VOTE: Uuid = Uuid::from_u128(0xbfd7f0fc_16d5_3e10_8015_a78380f13870);
83pub const SV_RACE_FINISH: Uuid = Uuid::from_u128(0xc915ba68_0a49_3324_915a_7a6220cecf33);
84pub const SV_COMMAND_INFO: Uuid = Uuid::from_u128(0x90778f65_1b8f_322a_9713_cf741aa44a05);
85pub const SV_COMMAND_INFO_REMOVE: Uuid = Uuid::from_u128(0xeb2e77ce_e9a2_35aa_94be_235f523ac1aa);
86pub const SV_VOTE_OPTION_GROUP_START: Uuid = Uuid::from_u128(0x969d127c_b768_390d_8879_6104993769fa);
87pub const SV_VOTE_OPTION_GROUP_END: Uuid = Uuid::from_u128(0x4f096765_39b1_3766_82dc_61b20ccf589a);
88pub const SV_COMMAND_INFO_GROUP_START: Uuid = Uuid::from_u128(0x9e220138_d393_3cb0_90f1_e587c00ab1d0);
89pub const SV_COMMAND_INFO_GROUP_END: Uuid = Uuid::from_u128(0x054125d8_0062_3891_840b_47462285a01f);
90pub const SV_CHANGE_INFO_COOLDOWN: Uuid = Uuid::from_u128(0x746cb54c_6b2b_39a7_8cd8_7c7a1c6c3009);
91pub const SV_MAP_SOUND_GLOBAL: Uuid = Uuid::from_u128(0x669c9741_695a_369b_856c_a254f6b7f0cb);
92pub const SV_PRE_INPUT: Uuid = Uuid::from_u128(0xb5d3a686_ad59_382c_b3de_d9fedc3320ae);
93pub const SV_SAVE_CODE: Uuid = Uuid::from_u128(0xdc9edffb_266a_3bd6_b101_a949fa44e16b);
94pub const SV_SERVER_ALERT: Uuid = Uuid::from_u128(0x035206dc_9f8b_315c_9abf_5ab9153a857c);
95pub const SV_MODERATOR_ALERT: Uuid = Uuid::from_u128(0xd7c55683_7983_32f0_8d9a_877434ea19d5);
96pub const CL_ENABLE_SPECTATOR_COUNT: Uuid = Uuid::from_u128(0xe19b66e8_0646_351b_aa03_d4aba7b9545f);
97
98#[derive(Clone, Copy)]
99pub enum Game<'a> {
100 SvMotd(SvMotd<'a>),
101 SvBroadcast(SvBroadcast<'a>),
102 SvChat(SvChat<'a>),
103 SvKillMsg(SvKillMsg),
104 SvSoundGlobal(SvSoundGlobal),
105 SvTuneParams(SvTuneParams),
106 Unused(Unused),
107 SvReadyToEnter(SvReadyToEnter),
108 SvWeaponPickup(SvWeaponPickup),
109 SvEmoticon(SvEmoticon),
110 SvVoteClearOptions(SvVoteClearOptions),
111 SvVoteOptionListAdd(SvVoteOptionListAdd<'a>),
112 SvVoteOptionAdd(SvVoteOptionAdd<'a>),
113 SvVoteOptionRemove(SvVoteOptionRemove<'a>),
114 SvVoteSet(SvVoteSet<'a>),
115 SvVoteStatus(SvVoteStatus),
116 ClSay(ClSay<'a>),
117 ClSetTeam(ClSetTeam),
118 ClSetSpectatorMode(ClSetSpectatorMode),
119 ClStartInfo(ClStartInfo<'a>),
120 ClChangeInfo(ClChangeInfo<'a>),
121 ClKill(ClKill),
122 ClEmoticon(ClEmoticon),
123 ClVote(ClVote),
124 ClCallVote(ClCallVote<'a>),
125 ClIsDdnetLegacy(ClIsDdnetLegacy),
126 SvDdraceTimeLegacy(SvDdraceTimeLegacy),
127 SvRecordLegacy(SvRecordLegacy),
128 Unused2(Unused2),
129 SvTeamsStateLegacy(SvTeamsStateLegacy),
130 ClShowOthersLegacy(ClShowOthersLegacy),
131 SvMyOwnMessage(SvMyOwnMessage),
132 ClShowDistance(ClShowDistance),
133 ClShowOthers(ClShowOthers),
134 ClCameraInfo(ClCameraInfo),
135 SvTeamsState(SvTeamsState),
136 SvDdraceTime(SvDdraceTime),
137 SvRecord(SvRecord),
138 SvKillMsgTeam(SvKillMsgTeam),
139 SvYourVote(SvYourVote),
140 SvRaceFinish(SvRaceFinish),
141 SvCommandInfo(SvCommandInfo<'a>),
142 SvCommandInfoRemove(SvCommandInfoRemove<'a>),
143 SvVoteOptionGroupStart(SvVoteOptionGroupStart),
144 SvVoteOptionGroupEnd(SvVoteOptionGroupEnd),
145 SvCommandInfoGroupStart(SvCommandInfoGroupStart),
146 SvCommandInfoGroupEnd(SvCommandInfoGroupEnd),
147 SvChangeInfoCooldown(SvChangeInfoCooldown),
148 SvMapSoundGlobal(SvMapSoundGlobal),
149 SvPreInput(SvPreInput),
150 SvSaveCode(SvSaveCode<'a>),
151 SvServerAlert(SvServerAlert<'a>),
152 SvModeratorAlert(SvModeratorAlert<'a>),
153 ClEnableSpectatorCount(ClEnableSpectatorCount),
154}
155
156impl<'a> Game<'a> {
157 pub fn decode_msg<W: Warn<Warning>>(warn: &mut W, msg_id: MessageId, _p: &mut Unpacker<'a>) -> Result<Game<'a>, Error> {
158 use self::MessageId::*;
159 Ok(match msg_id {
160 Ordinal(SV_MOTD) => Game::SvMotd(SvMotd::decode(warn, _p)?),
161 Ordinal(SV_BROADCAST) => Game::SvBroadcast(SvBroadcast::decode(warn, _p)?),
162 Ordinal(SV_CHAT) => Game::SvChat(SvChat::decode(warn, _p)?),
163 Ordinal(SV_KILL_MSG) => Game::SvKillMsg(SvKillMsg::decode(warn, _p)?),
164 Ordinal(SV_SOUND_GLOBAL) => Game::SvSoundGlobal(SvSoundGlobal::decode(warn, _p)?),
165 Ordinal(SV_TUNE_PARAMS) => Game::SvTuneParams(SvTuneParams::decode(warn, _p)?),
166 Ordinal(UNUSED) => Game::Unused(Unused::decode(warn, _p)?),
167 Ordinal(SV_READY_TO_ENTER) => Game::SvReadyToEnter(SvReadyToEnter::decode(warn, _p)?),
168 Ordinal(SV_WEAPON_PICKUP) => Game::SvWeaponPickup(SvWeaponPickup::decode(warn, _p)?),
169 Ordinal(SV_EMOTICON) => Game::SvEmoticon(SvEmoticon::decode(warn, _p)?),
170 Ordinal(SV_VOTE_CLEAR_OPTIONS) => Game::SvVoteClearOptions(SvVoteClearOptions::decode(warn, _p)?),
171 Ordinal(SV_VOTE_OPTION_LIST_ADD) => Game::SvVoteOptionListAdd(SvVoteOptionListAdd::decode(warn, _p)?),
172 Ordinal(SV_VOTE_OPTION_ADD) => Game::SvVoteOptionAdd(SvVoteOptionAdd::decode(warn, _p)?),
173 Ordinal(SV_VOTE_OPTION_REMOVE) => Game::SvVoteOptionRemove(SvVoteOptionRemove::decode(warn, _p)?),
174 Ordinal(SV_VOTE_SET) => Game::SvVoteSet(SvVoteSet::decode(warn, _p)?),
175 Ordinal(SV_VOTE_STATUS) => Game::SvVoteStatus(SvVoteStatus::decode(warn, _p)?),
176 Ordinal(CL_SAY) => Game::ClSay(ClSay::decode(warn, _p)?),
177 Ordinal(CL_SET_TEAM) => Game::ClSetTeam(ClSetTeam::decode(warn, _p)?),
178 Ordinal(CL_SET_SPECTATOR_MODE) => Game::ClSetSpectatorMode(ClSetSpectatorMode::decode(warn, _p)?),
179 Ordinal(CL_START_INFO) => Game::ClStartInfo(ClStartInfo::decode(warn, _p)?),
180 Ordinal(CL_CHANGE_INFO) => Game::ClChangeInfo(ClChangeInfo::decode(warn, _p)?),
181 Ordinal(CL_KILL) => Game::ClKill(ClKill::decode(warn, _p)?),
182 Ordinal(CL_EMOTICON) => Game::ClEmoticon(ClEmoticon::decode(warn, _p)?),
183 Ordinal(CL_VOTE) => Game::ClVote(ClVote::decode(warn, _p)?),
184 Ordinal(CL_CALL_VOTE) => Game::ClCallVote(ClCallVote::decode(warn, _p)?),
185 Ordinal(CL_IS_DDNET_LEGACY) => Game::ClIsDdnetLegacy(ClIsDdnetLegacy::decode(warn, _p)?),
186 Ordinal(SV_DDRACE_TIME_LEGACY) => Game::SvDdraceTimeLegacy(SvDdraceTimeLegacy::decode(warn, _p)?),
187 Ordinal(SV_RECORD_LEGACY) => Game::SvRecordLegacy(SvRecordLegacy::decode(warn, _p)?),
188 Ordinal(UNUSED2) => Game::Unused2(Unused2::decode(warn, _p)?),
189 Ordinal(SV_TEAMS_STATE_LEGACY) => Game::SvTeamsStateLegacy(SvTeamsStateLegacy::decode(warn, _p)?),
190 Ordinal(CL_SHOW_OTHERS_LEGACY) => Game::ClShowOthersLegacy(ClShowOthersLegacy::decode(warn, _p)?),
191 Uuid(SV_MY_OWN_MESSAGE) => Game::SvMyOwnMessage(SvMyOwnMessage::decode(warn, _p)?),
192 Uuid(CL_SHOW_DISTANCE) => Game::ClShowDistance(ClShowDistance::decode(warn, _p)?),
193 Uuid(CL_SHOW_OTHERS) => Game::ClShowOthers(ClShowOthers::decode(warn, _p)?),
194 Uuid(CL_CAMERA_INFO) => Game::ClCameraInfo(ClCameraInfo::decode(warn, _p)?),
195 Uuid(SV_TEAMS_STATE) => Game::SvTeamsState(SvTeamsState::decode(warn, _p)?),
196 Uuid(SV_DDRACE_TIME) => Game::SvDdraceTime(SvDdraceTime::decode(warn, _p)?),
197 Uuid(SV_RECORD) => Game::SvRecord(SvRecord::decode(warn, _p)?),
198 Uuid(SV_KILL_MSG_TEAM) => Game::SvKillMsgTeam(SvKillMsgTeam::decode(warn, _p)?),
199 Uuid(SV_YOUR_VOTE) => Game::SvYourVote(SvYourVote::decode(warn, _p)?),
200 Uuid(SV_RACE_FINISH) => Game::SvRaceFinish(SvRaceFinish::decode(warn, _p)?),
201 Uuid(SV_COMMAND_INFO) => Game::SvCommandInfo(SvCommandInfo::decode(warn, _p)?),
202 Uuid(SV_COMMAND_INFO_REMOVE) => Game::SvCommandInfoRemove(SvCommandInfoRemove::decode(warn, _p)?),
203 Uuid(SV_VOTE_OPTION_GROUP_START) => Game::SvVoteOptionGroupStart(SvVoteOptionGroupStart::decode(warn, _p)?),
204 Uuid(SV_VOTE_OPTION_GROUP_END) => Game::SvVoteOptionGroupEnd(SvVoteOptionGroupEnd::decode(warn, _p)?),
205 Uuid(SV_COMMAND_INFO_GROUP_START) => Game::SvCommandInfoGroupStart(SvCommandInfoGroupStart::decode(warn, _p)?),
206 Uuid(SV_COMMAND_INFO_GROUP_END) => Game::SvCommandInfoGroupEnd(SvCommandInfoGroupEnd::decode(warn, _p)?),
207 Uuid(SV_CHANGE_INFO_COOLDOWN) => Game::SvChangeInfoCooldown(SvChangeInfoCooldown::decode(warn, _p)?),
208 Uuid(SV_MAP_SOUND_GLOBAL) => Game::SvMapSoundGlobal(SvMapSoundGlobal::decode(warn, _p)?),
209 Uuid(SV_PRE_INPUT) => Game::SvPreInput(SvPreInput::decode(warn, _p)?),
210 Uuid(SV_SAVE_CODE) => Game::SvSaveCode(SvSaveCode::decode(warn, _p)?),
211 Uuid(SV_SERVER_ALERT) => Game::SvServerAlert(SvServerAlert::decode(warn, _p)?),
212 Uuid(SV_MODERATOR_ALERT) => Game::SvModeratorAlert(SvModeratorAlert::decode(warn, _p)?),
213 Uuid(CL_ENABLE_SPECTATOR_COUNT) => Game::ClEnableSpectatorCount(ClEnableSpectatorCount::decode(warn, _p)?),
214 _ => return Err(Error::UnknownId),
215 })
216 }
217 pub fn msg_id(&self) -> MessageId {
218 match *self {
219 Game::SvMotd(_) => MessageId::from(SV_MOTD),
220 Game::SvBroadcast(_) => MessageId::from(SV_BROADCAST),
221 Game::SvChat(_) => MessageId::from(SV_CHAT),
222 Game::SvKillMsg(_) => MessageId::from(SV_KILL_MSG),
223 Game::SvSoundGlobal(_) => MessageId::from(SV_SOUND_GLOBAL),
224 Game::SvTuneParams(_) => MessageId::from(SV_TUNE_PARAMS),
225 Game::Unused(_) => MessageId::from(UNUSED),
226 Game::SvReadyToEnter(_) => MessageId::from(SV_READY_TO_ENTER),
227 Game::SvWeaponPickup(_) => MessageId::from(SV_WEAPON_PICKUP),
228 Game::SvEmoticon(_) => MessageId::from(SV_EMOTICON),
229 Game::SvVoteClearOptions(_) => MessageId::from(SV_VOTE_CLEAR_OPTIONS),
230 Game::SvVoteOptionListAdd(_) => MessageId::from(SV_VOTE_OPTION_LIST_ADD),
231 Game::SvVoteOptionAdd(_) => MessageId::from(SV_VOTE_OPTION_ADD),
232 Game::SvVoteOptionRemove(_) => MessageId::from(SV_VOTE_OPTION_REMOVE),
233 Game::SvVoteSet(_) => MessageId::from(SV_VOTE_SET),
234 Game::SvVoteStatus(_) => MessageId::from(SV_VOTE_STATUS),
235 Game::ClSay(_) => MessageId::from(CL_SAY),
236 Game::ClSetTeam(_) => MessageId::from(CL_SET_TEAM),
237 Game::ClSetSpectatorMode(_) => MessageId::from(CL_SET_SPECTATOR_MODE),
238 Game::ClStartInfo(_) => MessageId::from(CL_START_INFO),
239 Game::ClChangeInfo(_) => MessageId::from(CL_CHANGE_INFO),
240 Game::ClKill(_) => MessageId::from(CL_KILL),
241 Game::ClEmoticon(_) => MessageId::from(CL_EMOTICON),
242 Game::ClVote(_) => MessageId::from(CL_VOTE),
243 Game::ClCallVote(_) => MessageId::from(CL_CALL_VOTE),
244 Game::ClIsDdnetLegacy(_) => MessageId::from(CL_IS_DDNET_LEGACY),
245 Game::SvDdraceTimeLegacy(_) => MessageId::from(SV_DDRACE_TIME_LEGACY),
246 Game::SvRecordLegacy(_) => MessageId::from(SV_RECORD_LEGACY),
247 Game::Unused2(_) => MessageId::from(UNUSED2),
248 Game::SvTeamsStateLegacy(_) => MessageId::from(SV_TEAMS_STATE_LEGACY),
249 Game::ClShowOthersLegacy(_) => MessageId::from(CL_SHOW_OTHERS_LEGACY),
250 Game::SvMyOwnMessage(_) => MessageId::from(SV_MY_OWN_MESSAGE),
251 Game::ClShowDistance(_) => MessageId::from(CL_SHOW_DISTANCE),
252 Game::ClShowOthers(_) => MessageId::from(CL_SHOW_OTHERS),
253 Game::ClCameraInfo(_) => MessageId::from(CL_CAMERA_INFO),
254 Game::SvTeamsState(_) => MessageId::from(SV_TEAMS_STATE),
255 Game::SvDdraceTime(_) => MessageId::from(SV_DDRACE_TIME),
256 Game::SvRecord(_) => MessageId::from(SV_RECORD),
257 Game::SvKillMsgTeam(_) => MessageId::from(SV_KILL_MSG_TEAM),
258 Game::SvYourVote(_) => MessageId::from(SV_YOUR_VOTE),
259 Game::SvRaceFinish(_) => MessageId::from(SV_RACE_FINISH),
260 Game::SvCommandInfo(_) => MessageId::from(SV_COMMAND_INFO),
261 Game::SvCommandInfoRemove(_) => MessageId::from(SV_COMMAND_INFO_REMOVE),
262 Game::SvVoteOptionGroupStart(_) => MessageId::from(SV_VOTE_OPTION_GROUP_START),
263 Game::SvVoteOptionGroupEnd(_) => MessageId::from(SV_VOTE_OPTION_GROUP_END),
264 Game::SvCommandInfoGroupStart(_) => MessageId::from(SV_COMMAND_INFO_GROUP_START),
265 Game::SvCommandInfoGroupEnd(_) => MessageId::from(SV_COMMAND_INFO_GROUP_END),
266 Game::SvChangeInfoCooldown(_) => MessageId::from(SV_CHANGE_INFO_COOLDOWN),
267 Game::SvMapSoundGlobal(_) => MessageId::from(SV_MAP_SOUND_GLOBAL),
268 Game::SvPreInput(_) => MessageId::from(SV_PRE_INPUT),
269 Game::SvSaveCode(_) => MessageId::from(SV_SAVE_CODE),
270 Game::SvServerAlert(_) => MessageId::from(SV_SERVER_ALERT),
271 Game::SvModeratorAlert(_) => MessageId::from(SV_MODERATOR_ALERT),
272 Game::ClEnableSpectatorCount(_) => MessageId::from(CL_ENABLE_SPECTATOR_COUNT),
273 }
274 }
275 pub fn encode_msg<'d, 's>(&self, p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
276 match *self {
277 Game::SvMotd(ref i) => i.encode(p),
278 Game::SvBroadcast(ref i) => i.encode(p),
279 Game::SvChat(ref i) => i.encode(p),
280 Game::SvKillMsg(ref i) => i.encode(p),
281 Game::SvSoundGlobal(ref i) => i.encode(p),
282 Game::SvTuneParams(ref i) => i.encode(p),
283 Game::Unused(ref i) => i.encode(p),
284 Game::SvReadyToEnter(ref i) => i.encode(p),
285 Game::SvWeaponPickup(ref i) => i.encode(p),
286 Game::SvEmoticon(ref i) => i.encode(p),
287 Game::SvVoteClearOptions(ref i) => i.encode(p),
288 Game::SvVoteOptionListAdd(ref i) => i.encode(p),
289 Game::SvVoteOptionAdd(ref i) => i.encode(p),
290 Game::SvVoteOptionRemove(ref i) => i.encode(p),
291 Game::SvVoteSet(ref i) => i.encode(p),
292 Game::SvVoteStatus(ref i) => i.encode(p),
293 Game::ClSay(ref i) => i.encode(p),
294 Game::ClSetTeam(ref i) => i.encode(p),
295 Game::ClSetSpectatorMode(ref i) => i.encode(p),
296 Game::ClStartInfo(ref i) => i.encode(p),
297 Game::ClChangeInfo(ref i) => i.encode(p),
298 Game::ClKill(ref i) => i.encode(p),
299 Game::ClEmoticon(ref i) => i.encode(p),
300 Game::ClVote(ref i) => i.encode(p),
301 Game::ClCallVote(ref i) => i.encode(p),
302 Game::ClIsDdnetLegacy(ref i) => i.encode(p),
303 Game::SvDdraceTimeLegacy(ref i) => i.encode(p),
304 Game::SvRecordLegacy(ref i) => i.encode(p),
305 Game::Unused2(ref i) => i.encode(p),
306 Game::SvTeamsStateLegacy(ref i) => i.encode(p),
307 Game::ClShowOthersLegacy(ref i) => i.encode(p),
308 Game::SvMyOwnMessage(ref i) => i.encode(p),
309 Game::ClShowDistance(ref i) => i.encode(p),
310 Game::ClShowOthers(ref i) => i.encode(p),
311 Game::ClCameraInfo(ref i) => i.encode(p),
312 Game::SvTeamsState(ref i) => i.encode(p),
313 Game::SvDdraceTime(ref i) => i.encode(p),
314 Game::SvRecord(ref i) => i.encode(p),
315 Game::SvKillMsgTeam(ref i) => i.encode(p),
316 Game::SvYourVote(ref i) => i.encode(p),
317 Game::SvRaceFinish(ref i) => i.encode(p),
318 Game::SvCommandInfo(ref i) => i.encode(p),
319 Game::SvCommandInfoRemove(ref i) => i.encode(p),
320 Game::SvVoteOptionGroupStart(ref i) => i.encode(p),
321 Game::SvVoteOptionGroupEnd(ref i) => i.encode(p),
322 Game::SvCommandInfoGroupStart(ref i) => i.encode(p),
323 Game::SvCommandInfoGroupEnd(ref i) => i.encode(p),
324 Game::SvChangeInfoCooldown(ref i) => i.encode(p),
325 Game::SvMapSoundGlobal(ref i) => i.encode(p),
326 Game::SvPreInput(ref i) => i.encode(p),
327 Game::SvSaveCode(ref i) => i.encode(p),
328 Game::SvServerAlert(ref i) => i.encode(p),
329 Game::SvModeratorAlert(ref i) => i.encode(p),
330 Game::ClEnableSpectatorCount(ref i) => i.encode(p),
331 }
332 }
333}
334
335impl<'a> fmt::Debug for Game<'a> {
336 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
337 match *self {
338 Game::SvMotd(ref i) => i.fmt(f),
339 Game::SvBroadcast(ref i) => i.fmt(f),
340 Game::SvChat(ref i) => i.fmt(f),
341 Game::SvKillMsg(ref i) => i.fmt(f),
342 Game::SvSoundGlobal(ref i) => i.fmt(f),
343 Game::SvTuneParams(ref i) => i.fmt(f),
344 Game::Unused(ref i) => i.fmt(f),
345 Game::SvReadyToEnter(ref i) => i.fmt(f),
346 Game::SvWeaponPickup(ref i) => i.fmt(f),
347 Game::SvEmoticon(ref i) => i.fmt(f),
348 Game::SvVoteClearOptions(ref i) => i.fmt(f),
349 Game::SvVoteOptionListAdd(ref i) => i.fmt(f),
350 Game::SvVoteOptionAdd(ref i) => i.fmt(f),
351 Game::SvVoteOptionRemove(ref i) => i.fmt(f),
352 Game::SvVoteSet(ref i) => i.fmt(f),
353 Game::SvVoteStatus(ref i) => i.fmt(f),
354 Game::ClSay(ref i) => i.fmt(f),
355 Game::ClSetTeam(ref i) => i.fmt(f),
356 Game::ClSetSpectatorMode(ref i) => i.fmt(f),
357 Game::ClStartInfo(ref i) => i.fmt(f),
358 Game::ClChangeInfo(ref i) => i.fmt(f),
359 Game::ClKill(ref i) => i.fmt(f),
360 Game::ClEmoticon(ref i) => i.fmt(f),
361 Game::ClVote(ref i) => i.fmt(f),
362 Game::ClCallVote(ref i) => i.fmt(f),
363 Game::ClIsDdnetLegacy(ref i) => i.fmt(f),
364 Game::SvDdraceTimeLegacy(ref i) => i.fmt(f),
365 Game::SvRecordLegacy(ref i) => i.fmt(f),
366 Game::Unused2(ref i) => i.fmt(f),
367 Game::SvTeamsStateLegacy(ref i) => i.fmt(f),
368 Game::ClShowOthersLegacy(ref i) => i.fmt(f),
369 Game::SvMyOwnMessage(ref i) => i.fmt(f),
370 Game::ClShowDistance(ref i) => i.fmt(f),
371 Game::ClShowOthers(ref i) => i.fmt(f),
372 Game::ClCameraInfo(ref i) => i.fmt(f),
373 Game::SvTeamsState(ref i) => i.fmt(f),
374 Game::SvDdraceTime(ref i) => i.fmt(f),
375 Game::SvRecord(ref i) => i.fmt(f),
376 Game::SvKillMsgTeam(ref i) => i.fmt(f),
377 Game::SvYourVote(ref i) => i.fmt(f),
378 Game::SvRaceFinish(ref i) => i.fmt(f),
379 Game::SvCommandInfo(ref i) => i.fmt(f),
380 Game::SvCommandInfoRemove(ref i) => i.fmt(f),
381 Game::SvVoteOptionGroupStart(ref i) => i.fmt(f),
382 Game::SvVoteOptionGroupEnd(ref i) => i.fmt(f),
383 Game::SvCommandInfoGroupStart(ref i) => i.fmt(f),
384 Game::SvCommandInfoGroupEnd(ref i) => i.fmt(f),
385 Game::SvChangeInfoCooldown(ref i) => i.fmt(f),
386 Game::SvMapSoundGlobal(ref i) => i.fmt(f),
387 Game::SvPreInput(ref i) => i.fmt(f),
388 Game::SvSaveCode(ref i) => i.fmt(f),
389 Game::SvServerAlert(ref i) => i.fmt(f),
390 Game::SvModeratorAlert(ref i) => i.fmt(f),
391 Game::ClEnableSpectatorCount(ref i) => i.fmt(f),
392 }
393 }
394}
395
396impl<'a> From<SvMotd<'a>> for Game<'a> {
397 fn from(i: SvMotd<'a>) -> Game<'a> {
398 Game::SvMotd(i)
399 }
400}
401
402impl<'a> From<SvBroadcast<'a>> for Game<'a> {
403 fn from(i: SvBroadcast<'a>) -> Game<'a> {
404 Game::SvBroadcast(i)
405 }
406}
407
408impl<'a> From<SvChat<'a>> for Game<'a> {
409 fn from(i: SvChat<'a>) -> Game<'a> {
410 Game::SvChat(i)
411 }
412}
413
414impl<'a> From<SvKillMsg> for Game<'a> {
415 fn from(i: SvKillMsg) -> Game<'a> {
416 Game::SvKillMsg(i)
417 }
418}
419
420impl<'a> From<SvSoundGlobal> for Game<'a> {
421 fn from(i: SvSoundGlobal) -> Game<'a> {
422 Game::SvSoundGlobal(i)
423 }
424}
425
426impl<'a> From<SvTuneParams> for Game<'a> {
427 fn from(i: SvTuneParams) -> Game<'a> {
428 Game::SvTuneParams(i)
429 }
430}
431
432impl<'a> From<Unused> for Game<'a> {
433 fn from(i: Unused) -> Game<'a> {
434 Game::Unused(i)
435 }
436}
437
438impl<'a> From<SvReadyToEnter> for Game<'a> {
439 fn from(i: SvReadyToEnter) -> Game<'a> {
440 Game::SvReadyToEnter(i)
441 }
442}
443
444impl<'a> From<SvWeaponPickup> for Game<'a> {
445 fn from(i: SvWeaponPickup) -> Game<'a> {
446 Game::SvWeaponPickup(i)
447 }
448}
449
450impl<'a> From<SvEmoticon> for Game<'a> {
451 fn from(i: SvEmoticon) -> Game<'a> {
452 Game::SvEmoticon(i)
453 }
454}
455
456impl<'a> From<SvVoteClearOptions> for Game<'a> {
457 fn from(i: SvVoteClearOptions) -> Game<'a> {
458 Game::SvVoteClearOptions(i)
459 }
460}
461
462impl<'a> From<SvVoteOptionListAdd<'a>> for Game<'a> {
463 fn from(i: SvVoteOptionListAdd<'a>) -> Game<'a> {
464 Game::SvVoteOptionListAdd(i)
465 }
466}
467
468impl<'a> From<SvVoteOptionAdd<'a>> for Game<'a> {
469 fn from(i: SvVoteOptionAdd<'a>) -> Game<'a> {
470 Game::SvVoteOptionAdd(i)
471 }
472}
473
474impl<'a> From<SvVoteOptionRemove<'a>> for Game<'a> {
475 fn from(i: SvVoteOptionRemove<'a>) -> Game<'a> {
476 Game::SvVoteOptionRemove(i)
477 }
478}
479
480impl<'a> From<SvVoteSet<'a>> for Game<'a> {
481 fn from(i: SvVoteSet<'a>) -> Game<'a> {
482 Game::SvVoteSet(i)
483 }
484}
485
486impl<'a> From<SvVoteStatus> for Game<'a> {
487 fn from(i: SvVoteStatus) -> Game<'a> {
488 Game::SvVoteStatus(i)
489 }
490}
491
492impl<'a> From<ClSay<'a>> for Game<'a> {
493 fn from(i: ClSay<'a>) -> Game<'a> {
494 Game::ClSay(i)
495 }
496}
497
498impl<'a> From<ClSetTeam> for Game<'a> {
499 fn from(i: ClSetTeam) -> Game<'a> {
500 Game::ClSetTeam(i)
501 }
502}
503
504impl<'a> From<ClSetSpectatorMode> for Game<'a> {
505 fn from(i: ClSetSpectatorMode) -> Game<'a> {
506 Game::ClSetSpectatorMode(i)
507 }
508}
509
510impl<'a> From<ClStartInfo<'a>> for Game<'a> {
511 fn from(i: ClStartInfo<'a>) -> Game<'a> {
512 Game::ClStartInfo(i)
513 }
514}
515
516impl<'a> From<ClChangeInfo<'a>> for Game<'a> {
517 fn from(i: ClChangeInfo<'a>) -> Game<'a> {
518 Game::ClChangeInfo(i)
519 }
520}
521
522impl<'a> From<ClKill> for Game<'a> {
523 fn from(i: ClKill) -> Game<'a> {
524 Game::ClKill(i)
525 }
526}
527
528impl<'a> From<ClEmoticon> for Game<'a> {
529 fn from(i: ClEmoticon) -> Game<'a> {
530 Game::ClEmoticon(i)
531 }
532}
533
534impl<'a> From<ClVote> for Game<'a> {
535 fn from(i: ClVote) -> Game<'a> {
536 Game::ClVote(i)
537 }
538}
539
540impl<'a> From<ClCallVote<'a>> for Game<'a> {
541 fn from(i: ClCallVote<'a>) -> Game<'a> {
542 Game::ClCallVote(i)
543 }
544}
545
546impl<'a> From<ClIsDdnetLegacy> for Game<'a> {
547 fn from(i: ClIsDdnetLegacy) -> Game<'a> {
548 Game::ClIsDdnetLegacy(i)
549 }
550}
551
552impl<'a> From<SvDdraceTimeLegacy> for Game<'a> {
553 fn from(i: SvDdraceTimeLegacy) -> Game<'a> {
554 Game::SvDdraceTimeLegacy(i)
555 }
556}
557
558impl<'a> From<SvRecordLegacy> for Game<'a> {
559 fn from(i: SvRecordLegacy) -> Game<'a> {
560 Game::SvRecordLegacy(i)
561 }
562}
563
564impl<'a> From<Unused2> for Game<'a> {
565 fn from(i: Unused2) -> Game<'a> {
566 Game::Unused2(i)
567 }
568}
569
570impl<'a> From<SvTeamsStateLegacy> for Game<'a> {
571 fn from(i: SvTeamsStateLegacy) -> Game<'a> {
572 Game::SvTeamsStateLegacy(i)
573 }
574}
575
576impl<'a> From<ClShowOthersLegacy> for Game<'a> {
577 fn from(i: ClShowOthersLegacy) -> Game<'a> {
578 Game::ClShowOthersLegacy(i)
579 }
580}
581
582impl<'a> From<SvMyOwnMessage> for Game<'a> {
583 fn from(i: SvMyOwnMessage) -> Game<'a> {
584 Game::SvMyOwnMessage(i)
585 }
586}
587
588impl<'a> From<ClShowDistance> for Game<'a> {
589 fn from(i: ClShowDistance) -> Game<'a> {
590 Game::ClShowDistance(i)
591 }
592}
593
594impl<'a> From<ClShowOthers> for Game<'a> {
595 fn from(i: ClShowOthers) -> Game<'a> {
596 Game::ClShowOthers(i)
597 }
598}
599
600impl<'a> From<ClCameraInfo> for Game<'a> {
601 fn from(i: ClCameraInfo) -> Game<'a> {
602 Game::ClCameraInfo(i)
603 }
604}
605
606impl<'a> From<SvTeamsState> for Game<'a> {
607 fn from(i: SvTeamsState) -> Game<'a> {
608 Game::SvTeamsState(i)
609 }
610}
611
612impl<'a> From<SvDdraceTime> for Game<'a> {
613 fn from(i: SvDdraceTime) -> Game<'a> {
614 Game::SvDdraceTime(i)
615 }
616}
617
618impl<'a> From<SvRecord> for Game<'a> {
619 fn from(i: SvRecord) -> Game<'a> {
620 Game::SvRecord(i)
621 }
622}
623
624impl<'a> From<SvKillMsgTeam> for Game<'a> {
625 fn from(i: SvKillMsgTeam) -> Game<'a> {
626 Game::SvKillMsgTeam(i)
627 }
628}
629
630impl<'a> From<SvYourVote> for Game<'a> {
631 fn from(i: SvYourVote) -> Game<'a> {
632 Game::SvYourVote(i)
633 }
634}
635
636impl<'a> From<SvRaceFinish> for Game<'a> {
637 fn from(i: SvRaceFinish) -> Game<'a> {
638 Game::SvRaceFinish(i)
639 }
640}
641
642impl<'a> From<SvCommandInfo<'a>> for Game<'a> {
643 fn from(i: SvCommandInfo<'a>) -> Game<'a> {
644 Game::SvCommandInfo(i)
645 }
646}
647
648impl<'a> From<SvCommandInfoRemove<'a>> for Game<'a> {
649 fn from(i: SvCommandInfoRemove<'a>) -> Game<'a> {
650 Game::SvCommandInfoRemove(i)
651 }
652}
653
654impl<'a> From<SvVoteOptionGroupStart> for Game<'a> {
655 fn from(i: SvVoteOptionGroupStart) -> Game<'a> {
656 Game::SvVoteOptionGroupStart(i)
657 }
658}
659
660impl<'a> From<SvVoteOptionGroupEnd> for Game<'a> {
661 fn from(i: SvVoteOptionGroupEnd) -> Game<'a> {
662 Game::SvVoteOptionGroupEnd(i)
663 }
664}
665
666impl<'a> From<SvCommandInfoGroupStart> for Game<'a> {
667 fn from(i: SvCommandInfoGroupStart) -> Game<'a> {
668 Game::SvCommandInfoGroupStart(i)
669 }
670}
671
672impl<'a> From<SvCommandInfoGroupEnd> for Game<'a> {
673 fn from(i: SvCommandInfoGroupEnd) -> Game<'a> {
674 Game::SvCommandInfoGroupEnd(i)
675 }
676}
677
678impl<'a> From<SvChangeInfoCooldown> for Game<'a> {
679 fn from(i: SvChangeInfoCooldown) -> Game<'a> {
680 Game::SvChangeInfoCooldown(i)
681 }
682}
683
684impl<'a> From<SvMapSoundGlobal> for Game<'a> {
685 fn from(i: SvMapSoundGlobal) -> Game<'a> {
686 Game::SvMapSoundGlobal(i)
687 }
688}
689
690impl<'a> From<SvPreInput> for Game<'a> {
691 fn from(i: SvPreInput) -> Game<'a> {
692 Game::SvPreInput(i)
693 }
694}
695
696impl<'a> From<SvSaveCode<'a>> for Game<'a> {
697 fn from(i: SvSaveCode<'a>) -> Game<'a> {
698 Game::SvSaveCode(i)
699 }
700}
701
702impl<'a> From<SvServerAlert<'a>> for Game<'a> {
703 fn from(i: SvServerAlert<'a>) -> Game<'a> {
704 Game::SvServerAlert(i)
705 }
706}
707
708impl<'a> From<SvModeratorAlert<'a>> for Game<'a> {
709 fn from(i: SvModeratorAlert<'a>) -> Game<'a> {
710 Game::SvModeratorAlert(i)
711 }
712}
713
714impl<'a> From<ClEnableSpectatorCount> for Game<'a> {
715 fn from(i: ClEnableSpectatorCount) -> Game<'a> {
716 Game::ClEnableSpectatorCount(i)
717 }
718}
719#[derive(Clone, Copy)]
720pub struct SvMotd<'a> {
721 pub message: &'a [u8],
722}
723
724#[derive(Clone, Copy)]
725pub struct SvBroadcast<'a> {
726 pub message: &'a [u8],
727}
728
729#[derive(Clone, Copy)]
730pub struct SvChat<'a> {
731 pub team: i32,
732 pub client_id: i32,
733 pub message: &'a [u8],
734}
735
736#[derive(Clone, Copy)]
737pub struct SvKillMsg {
738 pub killer: i32,
739 pub victim: i32,
740 pub weapon: i32,
741 pub mode_special: i32,
742}
743
744#[derive(Clone, Copy)]
745pub struct SvSoundGlobal {
746 pub sound_id: enums::Sound,
747}
748
749#[derive(Clone, Copy)]
750pub struct SvTuneParams {
751 pub ground_control_speed: TuneParam,
752 pub ground_control_accel: TuneParam,
753 pub ground_friction: TuneParam,
754 pub ground_jump_impulse: TuneParam,
755 pub air_jump_impulse: TuneParam,
756 pub air_control_speed: TuneParam,
757 pub air_control_accel: TuneParam,
758 pub air_friction: TuneParam,
759 pub hook_length: TuneParam,
760 pub hook_fire_speed: TuneParam,
761 pub hook_drag_accel: TuneParam,
762 pub hook_drag_speed: TuneParam,
763 pub gravity: TuneParam,
764 pub velramp_start: TuneParam,
765 pub velramp_range: TuneParam,
766 pub velramp_curvature: TuneParam,
767 pub gun_curvature: TuneParam,
768 pub gun_speed: TuneParam,
769 pub gun_lifetime: TuneParam,
770 pub shotgun_curvature: TuneParam,
771 pub shotgun_speed: TuneParam,
772 pub shotgun_speeddiff: TuneParam,
773 pub shotgun_lifetime: TuneParam,
774 pub grenade_curvature: TuneParam,
775 pub grenade_speed: TuneParam,
776 pub grenade_lifetime: TuneParam,
777 pub laser_reach: TuneParam,
778 pub laser_bounce_delay: TuneParam,
779 pub laser_bounce_num: TuneParam,
780 pub laser_bounce_cost: TuneParam,
781 pub laser_damage: TuneParam,
782 pub player_collision: TuneParam,
783 pub player_hooking: TuneParam,
784 pub jetpack_strength: TuneParam,
785 pub shotgun_strength: TuneParam,
786 pub explosion_strength: TuneParam,
787 pub hammer_strength: TuneParam,
788 pub hook_duration: TuneParam,
789 pub hammer_fire_delay: TuneParam,
790 pub gun_fire_delay: TuneParam,
791 pub shotgun_fire_delay: TuneParam,
792 pub grenade_fire_delay: TuneParam,
793 pub laser_fire_delay: TuneParam,
794 pub ninja_fire_delay: TuneParam,
795 pub hammer_hit_fire_delay: TuneParam,
796 pub ground_elasticity_x: TuneParam,
797 pub ground_elasticity_y: TuneParam,
798}
799
800#[derive(Clone, Copy)]
801pub struct Unused;
802
803#[derive(Clone, Copy)]
804pub struct SvReadyToEnter;
805
806#[derive(Clone, Copy)]
807pub struct SvWeaponPickup {
808 pub weapon: enums::Weapon,
809}
810
811#[derive(Clone, Copy)]
812pub struct SvEmoticon {
813 pub client_id: i32,
814 pub emoticon: enums::Emoticon,
815}
816
817#[derive(Clone, Copy)]
818pub struct SvVoteClearOptions;
819
820#[derive(Clone, Copy)]
821pub struct SvVoteOptionListAdd<'a> {
822 pub num_options: i32,
823 pub description: [&'a [u8]; 15],
824}
825
826#[derive(Clone, Copy)]
827pub struct SvVoteOptionAdd<'a> {
828 pub description: &'a [u8],
829}
830
831#[derive(Clone, Copy)]
832pub struct SvVoteOptionRemove<'a> {
833 pub description: &'a [u8],
834}
835
836#[derive(Clone, Copy)]
837pub struct SvVoteSet<'a> {
838 pub timeout: i32,
839 pub description: &'a [u8],
840 pub reason: &'a [u8],
841}
842
843#[derive(Clone, Copy)]
844pub struct SvVoteStatus {
845 pub yes: i32,
846 pub no: i32,
847 pub pass: i32,
848 pub total: i32,
849}
850
851#[derive(Clone, Copy)]
852pub struct ClSay<'a> {
853 pub team: bool,
854 pub message: &'a [u8],
855}
856
857#[derive(Clone, Copy)]
858pub struct ClSetTeam {
859 pub team: enums::Team,
860}
861
862#[derive(Clone, Copy)]
863pub struct ClSetSpectatorMode {
864 pub spectator_id: i32,
865}
866
867#[derive(Clone, Copy)]
868pub struct ClStartInfo<'a> {
869 pub name: &'a [u8],
870 pub clan: &'a [u8],
871 pub country: i32,
872 pub skin: &'a [u8],
873 pub use_custom_color: bool,
874 pub color_body: i32,
875 pub color_feet: i32,
876}
877
878#[derive(Clone, Copy)]
879pub struct ClChangeInfo<'a> {
880 pub name: &'a [u8],
881 pub clan: &'a [u8],
882 pub country: i32,
883 pub skin: &'a [u8],
884 pub use_custom_color: bool,
885 pub color_body: i32,
886 pub color_feet: i32,
887}
888
889#[derive(Clone, Copy)]
890pub struct ClKill;
891
892#[derive(Clone, Copy)]
893pub struct ClEmoticon {
894 pub emoticon: enums::Emoticon,
895}
896
897#[derive(Clone, Copy)]
898pub struct ClVote {
899 pub vote: i32,
900}
901
902#[derive(Clone, Copy)]
903pub struct ClCallVote<'a> {
904 pub type_: &'a [u8],
905 pub value: &'a [u8],
906 pub reason: &'a [u8],
907}
908
909#[derive(Clone, Copy)]
910pub struct ClIsDdnetLegacy {
911 pub ddnet_version: i32,
912}
913
914#[derive(Clone, Copy)]
915pub struct SvDdraceTimeLegacy {
916 pub time: i32,
917 pub check: i32,
918 pub finish: i32,
919}
920
921#[derive(Clone, Copy)]
922pub struct SvRecordLegacy {
923 pub server_time_best: i32,
924 pub player_time_best: i32,
925}
926
927#[derive(Clone, Copy)]
928pub struct Unused2;
929
930#[derive(Clone, Copy)]
931pub struct SvTeamsStateLegacy {
932 pub teams: [i32; 128],
933}
934
935#[derive(Clone, Copy)]
936pub struct ClShowOthersLegacy {
937 pub show: bool,
938}
939
940#[derive(Clone, Copy)]
941pub struct SvMyOwnMessage {
942 pub test: i32,
943}
944
945#[derive(Clone, Copy)]
946pub struct ClShowDistance {
947 pub x: i32,
948 pub y: i32,
949}
950
951#[derive(Clone, Copy)]
952pub struct ClShowOthers {
953 pub show: i32,
954}
955
956#[derive(Clone, Copy)]
957pub struct ClCameraInfo {
958 pub zoom: i32,
959 pub deadzone: i32,
960 pub follow_factor: i32,
961}
962
963#[derive(Clone, Copy)]
964pub struct SvTeamsState {
965 pub teams: [i32; 128],
966}
967
968#[derive(Clone, Copy)]
969pub struct SvDdraceTime {
970 pub time: i32,
971 pub check: i32,
972 pub finish: i32,
973}
974
975#[derive(Clone, Copy)]
976pub struct SvRecord {
977 pub server_time_best: i32,
978 pub player_time_best: i32,
979}
980
981#[derive(Clone, Copy)]
982pub struct SvKillMsgTeam {
983 pub team: i32,
984 pub first: i32,
985}
986
987#[derive(Clone, Copy)]
988pub struct SvYourVote {
989 pub voted: i32,
990}
991
992#[derive(Clone, Copy)]
993pub struct SvRaceFinish {
994 pub client_id: i32,
995 pub time: i32,
996 pub diff: i32,
997 pub record_personal: bool,
998 pub record_server: bool,
999}
1000
1001#[derive(Clone, Copy)]
1002pub struct SvCommandInfo<'a> {
1003 pub name: &'a [u8],
1004 pub args_format: &'a [u8],
1005 pub help_text: &'a [u8],
1006}
1007
1008#[derive(Clone, Copy)]
1009pub struct SvCommandInfoRemove<'a> {
1010 pub name: &'a [u8],
1011}
1012
1013#[derive(Clone, Copy)]
1014pub struct SvVoteOptionGroupStart;
1015
1016#[derive(Clone, Copy)]
1017pub struct SvVoteOptionGroupEnd;
1018
1019#[derive(Clone, Copy)]
1020pub struct SvCommandInfoGroupStart;
1021
1022#[derive(Clone, Copy)]
1023pub struct SvCommandInfoGroupEnd;
1024
1025#[derive(Clone, Copy)]
1026pub struct SvChangeInfoCooldown {
1027 pub wait_until: crate::snap_obj::Tick,
1028}
1029
1030#[derive(Clone, Copy)]
1031pub struct SvMapSoundGlobal {
1032 pub sound_id: i32,
1033}
1034
1035#[derive(Clone, Copy)]
1036pub struct SvPreInput {
1037 pub direction: i32,
1038 pub target_x: i32,
1039 pub target_y: i32,
1040 pub jump: i32,
1041 pub fire: i32,
1042 pub hook: i32,
1043 pub wanted_weapon: i32,
1044 pub next_weapon: i32,
1045 pub prev_weapon: i32,
1046 pub owner: i32,
1047 pub intended_tick: crate::snap_obj::Tick,
1048}
1049
1050#[derive(Clone, Copy)]
1051pub struct SvSaveCode<'a> {
1052 pub state: i32,
1053 pub error: &'a [u8],
1054 pub save_requester: &'a [u8],
1055 pub server_name: &'a [u8],
1056 pub generated_code: &'a [u8],
1057 pub code: &'a [u8],
1058 pub team_members: &'a [u8],
1059}
1060
1061#[derive(Clone, Copy)]
1062pub struct SvServerAlert<'a> {
1063 pub message: &'a [u8],
1064}
1065
1066#[derive(Clone, Copy)]
1067pub struct SvModeratorAlert<'a> {
1068 pub message: &'a [u8],
1069}
1070
1071#[derive(Clone, Copy)]
1072pub struct ClEnableSpectatorCount {
1073 pub enable: bool,
1074}
1075
1076impl<'a> SvMotd<'a> {
1077 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvMotd<'a>, Error> {
1078 let result = Ok(SvMotd {
1079 message: _p.read_string()?,
1080 });
1081 _p.finish(wrap(warn));
1082 result
1083 }
1084 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1085 _p.write_string(self.message)?;
1086 Ok(_p.written())
1087 }
1088}
1089impl<'a> fmt::Debug for SvMotd<'a> {
1090 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1091 f.debug_struct("SvMotd")
1092 .field("message", &pretty::Bytes::new(&self.message))
1093 .finish()
1094 }
1095}
1096
1097impl<'a> SvBroadcast<'a> {
1098 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvBroadcast<'a>, Error> {
1099 let result = Ok(SvBroadcast {
1100 message: _p.read_string()?,
1101 });
1102 _p.finish(wrap(warn));
1103 result
1104 }
1105 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1106 _p.write_string(self.message)?;
1107 Ok(_p.written())
1108 }
1109}
1110impl<'a> fmt::Debug for SvBroadcast<'a> {
1111 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1112 f.debug_struct("SvBroadcast")
1113 .field("message", &pretty::Bytes::new(&self.message))
1114 .finish()
1115 }
1116}
1117
1118impl<'a> SvChat<'a> {
1119 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvChat<'a>, Error> {
1120 let result = Ok(SvChat {
1121 team: in_range(_p.read_int(warn)?, -2, 3)?,
1122 client_id: in_range(_p.read_int(warn)?, -1, 127)?,
1123 message: sanitize(warn, _p.read_string()?)?,
1124 });
1125 _p.finish(wrap(warn));
1126 result
1127 }
1128 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1129 assert!(-2 <= self.team && self.team <= 3);
1130 assert!(-1 <= self.client_id && self.client_id <= 127);
1131 sanitize(&mut Panic, self.message).unwrap();
1132 _p.write_int(self.team)?;
1133 _p.write_int(self.client_id)?;
1134 _p.write_string(self.message)?;
1135 Ok(_p.written())
1136 }
1137}
1138impl<'a> fmt::Debug for SvChat<'a> {
1139 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1140 f.debug_struct("SvChat")
1141 .field("team", &self.team)
1142 .field("client_id", &self.client_id)
1143 .field("message", &pretty::Bytes::new(&self.message))
1144 .finish()
1145 }
1146}
1147
1148impl SvKillMsg {
1149 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvKillMsg, Error> {
1150 let result = Ok(SvKillMsg {
1151 killer: in_range(_p.read_int(warn)?, 0, 127)?,
1152 victim: in_range(_p.read_int(warn)?, 0, 127)?,
1153 weapon: in_range(_p.read_int(warn)?, -3, 5)?,
1154 mode_special: _p.read_int(warn)?,
1155 });
1156 _p.finish(wrap(warn));
1157 result
1158 }
1159 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1160 assert!(0 <= self.killer && self.killer <= 127);
1161 assert!(0 <= self.victim && self.victim <= 127);
1162 assert!(-3 <= self.weapon && self.weapon <= 5);
1163 _p.write_int(self.killer)?;
1164 _p.write_int(self.victim)?;
1165 _p.write_int(self.weapon)?;
1166 _p.write_int(self.mode_special)?;
1167 Ok(_p.written())
1168 }
1169}
1170impl fmt::Debug for SvKillMsg {
1171 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1172 f.debug_struct("SvKillMsg")
1173 .field("killer", &self.killer)
1174 .field("victim", &self.victim)
1175 .field("weapon", &self.weapon)
1176 .field("mode_special", &self.mode_special)
1177 .finish()
1178 }
1179}
1180
1181impl SvSoundGlobal {
1182 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvSoundGlobal, Error> {
1183 let result = Ok(SvSoundGlobal {
1184 sound_id: enums::Sound::from_i32(_p.read_int(warn)?)?,
1185 });
1186 _p.finish(wrap(warn));
1187 result
1188 }
1189 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1190 _p.write_int(self.sound_id.to_i32())?;
1191 Ok(_p.written())
1192 }
1193}
1194impl fmt::Debug for SvSoundGlobal {
1195 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1196 f.debug_struct("SvSoundGlobal")
1197 .field("sound_id", &self.sound_id)
1198 .finish()
1199 }
1200}
1201
1202impl SvTuneParams {
1203 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTuneParams, Error> {
1204 let result = Ok(SvTuneParams {
1205 ground_control_speed: TuneParam(_p.read_int(warn)?),
1206 ground_control_accel: TuneParam(_p.read_int(warn)?),
1207 ground_friction: TuneParam(_p.read_int(warn)?),
1208 ground_jump_impulse: TuneParam(_p.read_int(warn)?),
1209 air_jump_impulse: TuneParam(_p.read_int(warn)?),
1210 air_control_speed: TuneParam(_p.read_int(warn)?),
1211 air_control_accel: TuneParam(_p.read_int(warn)?),
1212 air_friction: TuneParam(_p.read_int(warn)?),
1213 hook_length: TuneParam(_p.read_int(warn)?),
1214 hook_fire_speed: TuneParam(_p.read_int(warn)?),
1215 hook_drag_accel: TuneParam(_p.read_int(warn)?),
1216 hook_drag_speed: TuneParam(_p.read_int(warn)?),
1217 gravity: TuneParam(_p.read_int(warn)?),
1218 velramp_start: TuneParam(_p.read_int(warn)?),
1219 velramp_range: TuneParam(_p.read_int(warn)?),
1220 velramp_curvature: TuneParam(_p.read_int(warn)?),
1221 gun_curvature: TuneParam(_p.read_int(warn)?),
1222 gun_speed: TuneParam(_p.read_int(warn)?),
1223 gun_lifetime: TuneParam(_p.read_int(warn)?),
1224 shotgun_curvature: TuneParam(_p.read_int(warn)?),
1225 shotgun_speed: TuneParam(_p.read_int(warn)?),
1226 shotgun_speeddiff: TuneParam(_p.read_int(warn)?),
1227 shotgun_lifetime: TuneParam(_p.read_int(warn)?),
1228 grenade_curvature: TuneParam(_p.read_int(warn)?),
1229 grenade_speed: TuneParam(_p.read_int(warn)?),
1230 grenade_lifetime: TuneParam(_p.read_int(warn)?),
1231 laser_reach: TuneParam(_p.read_int(warn)?),
1232 laser_bounce_delay: TuneParam(_p.read_int(warn)?),
1233 laser_bounce_num: TuneParam(_p.read_int(warn)?),
1234 laser_bounce_cost: TuneParam(_p.read_int(warn)?),
1235 laser_damage: TuneParam(_p.read_int(warn)?),
1236 player_collision: TuneParam(_p.read_int(warn)?),
1237 player_hooking: TuneParam(_p.read_int(warn)?),
1238 jetpack_strength: TuneParam(_p.read_int(warn)?),
1239 shotgun_strength: TuneParam(_p.read_int(warn)?),
1240 explosion_strength: TuneParam(_p.read_int(warn)?),
1241 hammer_strength: TuneParam(_p.read_int(warn)?),
1242 hook_duration: TuneParam(_p.read_int(warn)?),
1243 hammer_fire_delay: TuneParam(_p.read_int(warn)?),
1244 gun_fire_delay: TuneParam(_p.read_int(warn)?),
1245 shotgun_fire_delay: TuneParam(_p.read_int(warn)?),
1246 grenade_fire_delay: TuneParam(_p.read_int(warn)?),
1247 laser_fire_delay: TuneParam(_p.read_int(warn)?),
1248 ninja_fire_delay: TuneParam(_p.read_int(warn)?),
1249 hammer_hit_fire_delay: TuneParam(_p.read_int(warn)?),
1250 ground_elasticity_x: TuneParam(_p.read_int(warn)?),
1251 ground_elasticity_y: TuneParam(_p.read_int(warn)?),
1252 });
1253 _p.finish(wrap(warn));
1254 result
1255 }
1256 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1257 _p.write_int(self.ground_control_speed.0)?;
1258 _p.write_int(self.ground_control_accel.0)?;
1259 _p.write_int(self.ground_friction.0)?;
1260 _p.write_int(self.ground_jump_impulse.0)?;
1261 _p.write_int(self.air_jump_impulse.0)?;
1262 _p.write_int(self.air_control_speed.0)?;
1263 _p.write_int(self.air_control_accel.0)?;
1264 _p.write_int(self.air_friction.0)?;
1265 _p.write_int(self.hook_length.0)?;
1266 _p.write_int(self.hook_fire_speed.0)?;
1267 _p.write_int(self.hook_drag_accel.0)?;
1268 _p.write_int(self.hook_drag_speed.0)?;
1269 _p.write_int(self.gravity.0)?;
1270 _p.write_int(self.velramp_start.0)?;
1271 _p.write_int(self.velramp_range.0)?;
1272 _p.write_int(self.velramp_curvature.0)?;
1273 _p.write_int(self.gun_curvature.0)?;
1274 _p.write_int(self.gun_speed.0)?;
1275 _p.write_int(self.gun_lifetime.0)?;
1276 _p.write_int(self.shotgun_curvature.0)?;
1277 _p.write_int(self.shotgun_speed.0)?;
1278 _p.write_int(self.shotgun_speeddiff.0)?;
1279 _p.write_int(self.shotgun_lifetime.0)?;
1280 _p.write_int(self.grenade_curvature.0)?;
1281 _p.write_int(self.grenade_speed.0)?;
1282 _p.write_int(self.grenade_lifetime.0)?;
1283 _p.write_int(self.laser_reach.0)?;
1284 _p.write_int(self.laser_bounce_delay.0)?;
1285 _p.write_int(self.laser_bounce_num.0)?;
1286 _p.write_int(self.laser_bounce_cost.0)?;
1287 _p.write_int(self.laser_damage.0)?;
1288 _p.write_int(self.player_collision.0)?;
1289 _p.write_int(self.player_hooking.0)?;
1290 _p.write_int(self.jetpack_strength.0)?;
1291 _p.write_int(self.shotgun_strength.0)?;
1292 _p.write_int(self.explosion_strength.0)?;
1293 _p.write_int(self.hammer_strength.0)?;
1294 _p.write_int(self.hook_duration.0)?;
1295 _p.write_int(self.hammer_fire_delay.0)?;
1296 _p.write_int(self.gun_fire_delay.0)?;
1297 _p.write_int(self.shotgun_fire_delay.0)?;
1298 _p.write_int(self.grenade_fire_delay.0)?;
1299 _p.write_int(self.laser_fire_delay.0)?;
1300 _p.write_int(self.ninja_fire_delay.0)?;
1301 _p.write_int(self.hammer_hit_fire_delay.0)?;
1302 _p.write_int(self.ground_elasticity_x.0)?;
1303 _p.write_int(self.ground_elasticity_y.0)?;
1304 Ok(_p.written())
1305 }
1306}
1307impl fmt::Debug for SvTuneParams {
1308 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1309 f.debug_struct("SvTuneParams")
1310 .field("ground_control_speed", &self.ground_control_speed)
1311 .field("ground_control_accel", &self.ground_control_accel)
1312 .field("ground_friction", &self.ground_friction)
1313 .field("ground_jump_impulse", &self.ground_jump_impulse)
1314 .field("air_jump_impulse", &self.air_jump_impulse)
1315 .field("air_control_speed", &self.air_control_speed)
1316 .field("air_control_accel", &self.air_control_accel)
1317 .field("air_friction", &self.air_friction)
1318 .field("hook_length", &self.hook_length)
1319 .field("hook_fire_speed", &self.hook_fire_speed)
1320 .field("hook_drag_accel", &self.hook_drag_accel)
1321 .field("hook_drag_speed", &self.hook_drag_speed)
1322 .field("gravity", &self.gravity)
1323 .field("velramp_start", &self.velramp_start)
1324 .field("velramp_range", &self.velramp_range)
1325 .field("velramp_curvature", &self.velramp_curvature)
1326 .field("gun_curvature", &self.gun_curvature)
1327 .field("gun_speed", &self.gun_speed)
1328 .field("gun_lifetime", &self.gun_lifetime)
1329 .field("shotgun_curvature", &self.shotgun_curvature)
1330 .field("shotgun_speed", &self.shotgun_speed)
1331 .field("shotgun_speeddiff", &self.shotgun_speeddiff)
1332 .field("shotgun_lifetime", &self.shotgun_lifetime)
1333 .field("grenade_curvature", &self.grenade_curvature)
1334 .field("grenade_speed", &self.grenade_speed)
1335 .field("grenade_lifetime", &self.grenade_lifetime)
1336 .field("laser_reach", &self.laser_reach)
1337 .field("laser_bounce_delay", &self.laser_bounce_delay)
1338 .field("laser_bounce_num", &self.laser_bounce_num)
1339 .field("laser_bounce_cost", &self.laser_bounce_cost)
1340 .field("laser_damage", &self.laser_damage)
1341 .field("player_collision", &self.player_collision)
1342 .field("player_hooking", &self.player_hooking)
1343 .field("jetpack_strength", &self.jetpack_strength)
1344 .field("shotgun_strength", &self.shotgun_strength)
1345 .field("explosion_strength", &self.explosion_strength)
1346 .field("hammer_strength", &self.hammer_strength)
1347 .field("hook_duration", &self.hook_duration)
1348 .field("hammer_fire_delay", &self.hammer_fire_delay)
1349 .field("gun_fire_delay", &self.gun_fire_delay)
1350 .field("shotgun_fire_delay", &self.shotgun_fire_delay)
1351 .field("grenade_fire_delay", &self.grenade_fire_delay)
1352 .field("laser_fire_delay", &self.laser_fire_delay)
1353 .field("ninja_fire_delay", &self.ninja_fire_delay)
1354 .field("hammer_hit_fire_delay", &self.hammer_hit_fire_delay)
1355 .field("ground_elasticity_x", &self.ground_elasticity_x)
1356 .field("ground_elasticity_y", &self.ground_elasticity_y)
1357 .finish()
1358 }
1359}
1360
1361impl Unused {
1362 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<Unused, Error> {
1363 let result = Ok(Unused);
1364 _p.finish(wrap(warn));
1365 result
1366 }
1367 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1368 Ok(_p.written())
1369 }
1370}
1371impl fmt::Debug for Unused {
1372 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1373 f.debug_struct("Unused")
1374 .finish()
1375 }
1376}
1377
1378impl SvReadyToEnter {
1379 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvReadyToEnter, Error> {
1380 let result = Ok(SvReadyToEnter);
1381 _p.finish(wrap(warn));
1382 result
1383 }
1384 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1385 Ok(_p.written())
1386 }
1387}
1388impl fmt::Debug for SvReadyToEnter {
1389 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1390 f.debug_struct("SvReadyToEnter")
1391 .finish()
1392 }
1393}
1394
1395impl SvWeaponPickup {
1396 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvWeaponPickup, Error> {
1397 let result = Ok(SvWeaponPickup {
1398 weapon: enums::Weapon::from_i32(_p.read_int(warn)?)?,
1399 });
1400 _p.finish(wrap(warn));
1401 result
1402 }
1403 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1404 _p.write_int(self.weapon.to_i32())?;
1405 Ok(_p.written())
1406 }
1407}
1408impl fmt::Debug for SvWeaponPickup {
1409 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1410 f.debug_struct("SvWeaponPickup")
1411 .field("weapon", &self.weapon)
1412 .finish()
1413 }
1414}
1415
1416impl SvEmoticon {
1417 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvEmoticon, Error> {
1418 let result = Ok(SvEmoticon {
1419 client_id: in_range(_p.read_int(warn)?, 0, 127)?,
1420 emoticon: enums::Emoticon::from_i32(_p.read_int(warn)?)?,
1421 });
1422 _p.finish(wrap(warn));
1423 result
1424 }
1425 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1426 assert!(0 <= self.client_id && self.client_id <= 127);
1427 _p.write_int(self.client_id)?;
1428 _p.write_int(self.emoticon.to_i32())?;
1429 Ok(_p.written())
1430 }
1431}
1432impl fmt::Debug for SvEmoticon {
1433 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1434 f.debug_struct("SvEmoticon")
1435 .field("client_id", &self.client_id)
1436 .field("emoticon", &self.emoticon)
1437 .finish()
1438 }
1439}
1440
1441impl SvVoteClearOptions {
1442 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteClearOptions, Error> {
1443 let result = Ok(SvVoteClearOptions);
1444 _p.finish(wrap(warn));
1445 result
1446 }
1447 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1448 Ok(_p.written())
1449 }
1450}
1451impl fmt::Debug for SvVoteClearOptions {
1452 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1453 f.debug_struct("SvVoteClearOptions")
1454 .finish()
1455 }
1456}
1457
1458impl<'a> SvVoteOptionListAdd<'a> {
1459 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionListAdd<'a>, Error> {
1460 let result = Ok(SvVoteOptionListAdd {
1461 num_options: in_range(_p.read_int(warn)?, 1, 15)?,
1462 description: [
1463 sanitize(warn, _p.read_string()?)?,
1464 sanitize(warn, _p.read_string()?)?,
1465 sanitize(warn, _p.read_string()?)?,
1466 sanitize(warn, _p.read_string()?)?,
1467 sanitize(warn, _p.read_string()?)?,
1468 sanitize(warn, _p.read_string()?)?,
1469 sanitize(warn, _p.read_string()?)?,
1470 sanitize(warn, _p.read_string()?)?,
1471 sanitize(warn, _p.read_string()?)?,
1472 sanitize(warn, _p.read_string()?)?,
1473 sanitize(warn, _p.read_string()?)?,
1474 sanitize(warn, _p.read_string()?)?,
1475 sanitize(warn, _p.read_string()?)?,
1476 sanitize(warn, _p.read_string()?)?,
1477 sanitize(warn, _p.read_string()?)?,
1478 ],
1479 });
1480 _p.finish(wrap(warn));
1481 result
1482 }
1483 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1484 assert!(1 <= self.num_options && self.num_options <= 15);
1485 for &e in &self.description {
1486 sanitize(&mut Panic, e).unwrap();
1487 }
1488 _p.write_int(self.num_options)?;
1489 for &e in &self.description {
1490 _p.write_string(e)?;
1491 }
1492 Ok(_p.written())
1493 }
1494}
1495impl<'a> fmt::Debug for SvVoteOptionListAdd<'a> {
1496 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1497 f.debug_struct("SvVoteOptionListAdd")
1498 .field("num_options", &self.num_options)
1499 .field("description", &DebugSlice::new(&self.description, |e| pretty::Bytes::new(&e)))
1500 .finish()
1501 }
1502}
1503
1504impl<'a> SvVoteOptionAdd<'a> {
1505 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionAdd<'a>, Error> {
1506 let result = Ok(SvVoteOptionAdd {
1507 description: sanitize(warn, _p.read_string()?)?,
1508 });
1509 _p.finish(wrap(warn));
1510 result
1511 }
1512 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1513 sanitize(&mut Panic, self.description).unwrap();
1514 _p.write_string(self.description)?;
1515 Ok(_p.written())
1516 }
1517}
1518impl<'a> fmt::Debug for SvVoteOptionAdd<'a> {
1519 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1520 f.debug_struct("SvVoteOptionAdd")
1521 .field("description", &pretty::Bytes::new(&self.description))
1522 .finish()
1523 }
1524}
1525
1526impl<'a> SvVoteOptionRemove<'a> {
1527 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteOptionRemove<'a>, Error> {
1528 let result = Ok(SvVoteOptionRemove {
1529 description: sanitize(warn, _p.read_string()?)?,
1530 });
1531 _p.finish(wrap(warn));
1532 result
1533 }
1534 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1535 sanitize(&mut Panic, self.description).unwrap();
1536 _p.write_string(self.description)?;
1537 Ok(_p.written())
1538 }
1539}
1540impl<'a> fmt::Debug for SvVoteOptionRemove<'a> {
1541 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1542 f.debug_struct("SvVoteOptionRemove")
1543 .field("description", &pretty::Bytes::new(&self.description))
1544 .finish()
1545 }
1546}
1547
1548impl<'a> SvVoteSet<'a> {
1549 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvVoteSet<'a>, Error> {
1550 let result = Ok(SvVoteSet {
1551 timeout: positive(_p.read_int(warn)?)?,
1552 description: sanitize(warn, _p.read_string()?)?,
1553 reason: sanitize(warn, _p.read_string()?)?,
1554 });
1555 _p.finish(wrap(warn));
1556 result
1557 }
1558 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1559 assert!(self.timeout >= 0);
1560 sanitize(&mut Panic, self.description).unwrap();
1561 sanitize(&mut Panic, self.reason).unwrap();
1562 _p.write_int(self.timeout)?;
1563 _p.write_string(self.description)?;
1564 _p.write_string(self.reason)?;
1565 Ok(_p.written())
1566 }
1567}
1568impl<'a> fmt::Debug for SvVoteSet<'a> {
1569 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1570 f.debug_struct("SvVoteSet")
1571 .field("timeout", &self.timeout)
1572 .field("description", &pretty::Bytes::new(&self.description))
1573 .field("reason", &pretty::Bytes::new(&self.reason))
1574 .finish()
1575 }
1576}
1577
1578impl SvVoteStatus {
1579 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteStatus, Error> {
1580 let result = Ok(SvVoteStatus {
1581 yes: in_range(_p.read_int(warn)?, 0, 128)?,
1582 no: in_range(_p.read_int(warn)?, 0, 128)?,
1583 pass: in_range(_p.read_int(warn)?, 0, 128)?,
1584 total: in_range(_p.read_int(warn)?, 0, 128)?,
1585 });
1586 _p.finish(wrap(warn));
1587 result
1588 }
1589 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1590 assert!(0 <= self.yes && self.yes <= 128);
1591 assert!(0 <= self.no && self.no <= 128);
1592 assert!(0 <= self.pass && self.pass <= 128);
1593 assert!(0 <= self.total && self.total <= 128);
1594 _p.write_int(self.yes)?;
1595 _p.write_int(self.no)?;
1596 _p.write_int(self.pass)?;
1597 _p.write_int(self.total)?;
1598 Ok(_p.written())
1599 }
1600}
1601impl fmt::Debug for SvVoteStatus {
1602 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1603 f.debug_struct("SvVoteStatus")
1604 .field("yes", &self.yes)
1605 .field("no", &self.no)
1606 .field("pass", &self.pass)
1607 .field("total", &self.total)
1608 .finish()
1609 }
1610}
1611
1612impl<'a> ClSay<'a> {
1613 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClSay<'a>, Error> {
1614 let result = Ok(ClSay {
1615 team: to_bool(_p.read_int(warn)?)?,
1616 message: sanitize(warn, _p.read_string()?)?,
1617 });
1618 _p.finish(wrap(warn));
1619 result
1620 }
1621 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1622 sanitize(&mut Panic, self.message).unwrap();
1623 _p.write_int(self.team as i32)?;
1624 _p.write_string(self.message)?;
1625 Ok(_p.written())
1626 }
1627}
1628impl<'a> fmt::Debug for ClSay<'a> {
1629 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1630 f.debug_struct("ClSay")
1631 .field("team", &self.team)
1632 .field("message", &pretty::Bytes::new(&self.message))
1633 .finish()
1634 }
1635}
1636
1637impl ClSetTeam {
1638 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClSetTeam, Error> {
1639 let result = Ok(ClSetTeam {
1640 team: enums::Team::from_i32(_p.read_int(warn)?)?,
1641 });
1642 _p.finish(wrap(warn));
1643 result
1644 }
1645 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1646 _p.write_int(self.team.to_i32())?;
1647 Ok(_p.written())
1648 }
1649}
1650impl fmt::Debug for ClSetTeam {
1651 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1652 f.debug_struct("ClSetTeam")
1653 .field("team", &self.team)
1654 .finish()
1655 }
1656}
1657
1658impl ClSetSpectatorMode {
1659 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClSetSpectatorMode, Error> {
1660 let result = Ok(ClSetSpectatorMode {
1661 spectator_id: in_range(_p.read_int(warn)?, -1, 127)?,
1662 });
1663 _p.finish(wrap(warn));
1664 result
1665 }
1666 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1667 assert!(-1 <= self.spectator_id && self.spectator_id <= 127);
1668 _p.write_int(self.spectator_id)?;
1669 Ok(_p.written())
1670 }
1671}
1672impl fmt::Debug for ClSetSpectatorMode {
1673 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1674 f.debug_struct("ClSetSpectatorMode")
1675 .field("spectator_id", &self.spectator_id)
1676 .finish()
1677 }
1678}
1679
1680impl<'a> ClStartInfo<'a> {
1681 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClStartInfo<'a>, Error> {
1682 let result = Ok(ClStartInfo {
1683 name: sanitize(warn, _p.read_string()?)?,
1684 clan: sanitize(warn, _p.read_string()?)?,
1685 country: _p.read_int(warn)?,
1686 skin: sanitize(warn, _p.read_string()?)?,
1687 use_custom_color: to_bool(_p.read_int(warn)?)?,
1688 color_body: _p.read_int(warn)?,
1689 color_feet: _p.read_int(warn)?,
1690 });
1691 _p.finish(wrap(warn));
1692 result
1693 }
1694 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1695 sanitize(&mut Panic, self.name).unwrap();
1696 sanitize(&mut Panic, self.clan).unwrap();
1697 sanitize(&mut Panic, self.skin).unwrap();
1698 _p.write_string(self.name)?;
1699 _p.write_string(self.clan)?;
1700 _p.write_int(self.country)?;
1701 _p.write_string(self.skin)?;
1702 _p.write_int(self.use_custom_color as i32)?;
1703 _p.write_int(self.color_body)?;
1704 _p.write_int(self.color_feet)?;
1705 Ok(_p.written())
1706 }
1707}
1708impl<'a> fmt::Debug for ClStartInfo<'a> {
1709 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1710 f.debug_struct("ClStartInfo")
1711 .field("name", &pretty::Bytes::new(&self.name))
1712 .field("clan", &pretty::Bytes::new(&self.clan))
1713 .field("country", &self.country)
1714 .field("skin", &pretty::Bytes::new(&self.skin))
1715 .field("use_custom_color", &self.use_custom_color)
1716 .field("color_body", &self.color_body)
1717 .field("color_feet", &self.color_feet)
1718 .finish()
1719 }
1720}
1721
1722impl<'a> ClChangeInfo<'a> {
1723 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClChangeInfo<'a>, Error> {
1724 let result = Ok(ClChangeInfo {
1725 name: sanitize(warn, _p.read_string()?)?,
1726 clan: sanitize(warn, _p.read_string()?)?,
1727 country: _p.read_int(warn)?,
1728 skin: sanitize(warn, _p.read_string()?)?,
1729 use_custom_color: to_bool(_p.read_int(warn)?)?,
1730 color_body: _p.read_int(warn)?,
1731 color_feet: _p.read_int(warn)?,
1732 });
1733 _p.finish(wrap(warn));
1734 result
1735 }
1736 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1737 sanitize(&mut Panic, self.name).unwrap();
1738 sanitize(&mut Panic, self.clan).unwrap();
1739 sanitize(&mut Panic, self.skin).unwrap();
1740 _p.write_string(self.name)?;
1741 _p.write_string(self.clan)?;
1742 _p.write_int(self.country)?;
1743 _p.write_string(self.skin)?;
1744 _p.write_int(self.use_custom_color as i32)?;
1745 _p.write_int(self.color_body)?;
1746 _p.write_int(self.color_feet)?;
1747 Ok(_p.written())
1748 }
1749}
1750impl<'a> fmt::Debug for ClChangeInfo<'a> {
1751 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1752 f.debug_struct("ClChangeInfo")
1753 .field("name", &pretty::Bytes::new(&self.name))
1754 .field("clan", &pretty::Bytes::new(&self.clan))
1755 .field("country", &self.country)
1756 .field("skin", &pretty::Bytes::new(&self.skin))
1757 .field("use_custom_color", &self.use_custom_color)
1758 .field("color_body", &self.color_body)
1759 .field("color_feet", &self.color_feet)
1760 .finish()
1761 }
1762}
1763
1764impl ClKill {
1765 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClKill, Error> {
1766 let result = Ok(ClKill);
1767 _p.finish(wrap(warn));
1768 result
1769 }
1770 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1771 Ok(_p.written())
1772 }
1773}
1774impl fmt::Debug for ClKill {
1775 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1776 f.debug_struct("ClKill")
1777 .finish()
1778 }
1779}
1780
1781impl ClEmoticon {
1782 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClEmoticon, Error> {
1783 let result = Ok(ClEmoticon {
1784 emoticon: enums::Emoticon::from_i32(_p.read_int(warn)?)?,
1785 });
1786 _p.finish(wrap(warn));
1787 result
1788 }
1789 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1790 _p.write_int(self.emoticon.to_i32())?;
1791 Ok(_p.written())
1792 }
1793}
1794impl fmt::Debug for ClEmoticon {
1795 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1796 f.debug_struct("ClEmoticon")
1797 .field("emoticon", &self.emoticon)
1798 .finish()
1799 }
1800}
1801
1802impl ClVote {
1803 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClVote, Error> {
1804 let result = Ok(ClVote {
1805 vote: in_range(_p.read_int(warn)?, -1, 1)?,
1806 });
1807 _p.finish(wrap(warn));
1808 result
1809 }
1810 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1811 assert!(-1 <= self.vote && self.vote <= 1);
1812 _p.write_int(self.vote)?;
1813 Ok(_p.written())
1814 }
1815}
1816impl fmt::Debug for ClVote {
1817 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1818 f.debug_struct("ClVote")
1819 .field("vote", &self.vote)
1820 .finish()
1821 }
1822}
1823
1824impl<'a> ClCallVote<'a> {
1825 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<ClCallVote<'a>, Error> {
1826 let result = Ok(ClCallVote {
1827 type_: sanitize(warn, _p.read_string()?)?,
1828 value: sanitize(warn, _p.read_string()?)?,
1829 reason: sanitize(warn, _p.read_string()?)?,
1830 });
1831 _p.finish(wrap(warn));
1832 result
1833 }
1834 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1835 sanitize(&mut Panic, self.type_).unwrap();
1836 sanitize(&mut Panic, self.value).unwrap();
1837 sanitize(&mut Panic, self.reason).unwrap();
1838 _p.write_string(self.type_)?;
1839 _p.write_string(self.value)?;
1840 _p.write_string(self.reason)?;
1841 Ok(_p.written())
1842 }
1843}
1844impl<'a> fmt::Debug for ClCallVote<'a> {
1845 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1846 f.debug_struct("ClCallVote")
1847 .field("type_", &pretty::Bytes::new(&self.type_))
1848 .field("value", &pretty::Bytes::new(&self.value))
1849 .field("reason", &pretty::Bytes::new(&self.reason))
1850 .finish()
1851 }
1852}
1853
1854impl ClIsDdnetLegacy {
1855 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClIsDdnetLegacy, Error> {
1856 let result = Ok(ClIsDdnetLegacy {
1857 ddnet_version: _p.read_int(warn)?,
1858 });
1859 _p.finish(wrap(warn));
1860 result
1861 }
1862 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1863 _p.write_int(self.ddnet_version)?;
1864 Ok(_p.written())
1865 }
1866}
1867impl fmt::Debug for ClIsDdnetLegacy {
1868 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1869 f.debug_struct("ClIsDdnetLegacy")
1870 .field("ddnet_version", &self.ddnet_version)
1871 .finish()
1872 }
1873}
1874
1875impl SvDdraceTimeLegacy {
1876 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvDdraceTimeLegacy, Error> {
1877 let result = Ok(SvDdraceTimeLegacy {
1878 time: _p.read_int(warn)?,
1879 check: _p.read_int(warn)?,
1880 finish: in_range(_p.read_int(warn)?, 0, 1)?,
1881 });
1882 _p.finish(wrap(warn));
1883 result
1884 }
1885 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1886 assert!(0 <= self.finish && self.finish <= 1);
1887 _p.write_int(self.time)?;
1888 _p.write_int(self.check)?;
1889 _p.write_int(self.finish)?;
1890 Ok(_p.written())
1891 }
1892}
1893impl fmt::Debug for SvDdraceTimeLegacy {
1894 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1895 f.debug_struct("SvDdraceTimeLegacy")
1896 .field("time", &self.time)
1897 .field("check", &self.check)
1898 .field("finish", &self.finish)
1899 .finish()
1900 }
1901}
1902
1903impl SvRecordLegacy {
1904 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvRecordLegacy, Error> {
1905 let result = Ok(SvRecordLegacy {
1906 server_time_best: _p.read_int(warn)?,
1907 player_time_best: _p.read_int(warn)?,
1908 });
1909 _p.finish(wrap(warn));
1910 result
1911 }
1912 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1913 _p.write_int(self.server_time_best)?;
1914 _p.write_int(self.player_time_best)?;
1915 Ok(_p.written())
1916 }
1917}
1918impl fmt::Debug for SvRecordLegacy {
1919 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1920 f.debug_struct("SvRecordLegacy")
1921 .field("server_time_best", &self.server_time_best)
1922 .field("player_time_best", &self.player_time_best)
1923 .finish()
1924 }
1925}
1926
1927impl Unused2 {
1928 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<Unused2, Error> {
1929 let result = Ok(Unused2);
1930 _p.finish(wrap(warn));
1931 result
1932 }
1933 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
1934 Ok(_p.written())
1935 }
1936}
1937impl fmt::Debug for Unused2 {
1938 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
1939 f.debug_struct("Unused2")
1940 .finish()
1941 }
1942}
1943
1944impl SvTeamsStateLegacy {
1945 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTeamsStateLegacy, Error> {
1946 let result = Ok(SvTeamsStateLegacy {
1947 teams: [
1948 in_range(_p.read_int(warn)?, 0, 128)?,
1949 in_range(_p.read_int(warn)?, 0, 128)?,
1950 in_range(_p.read_int(warn)?, 0, 128)?,
1951 in_range(_p.read_int(warn)?, 0, 128)?,
1952 in_range(_p.read_int(warn)?, 0, 128)?,
1953 in_range(_p.read_int(warn)?, 0, 128)?,
1954 in_range(_p.read_int(warn)?, 0, 128)?,
1955 in_range(_p.read_int(warn)?, 0, 128)?,
1956 in_range(_p.read_int(warn)?, 0, 128)?,
1957 in_range(_p.read_int(warn)?, 0, 128)?,
1958 in_range(_p.read_int(warn)?, 0, 128)?,
1959 in_range(_p.read_int(warn)?, 0, 128)?,
1960 in_range(_p.read_int(warn)?, 0, 128)?,
1961 in_range(_p.read_int(warn)?, 0, 128)?,
1962 in_range(_p.read_int(warn)?, 0, 128)?,
1963 in_range(_p.read_int(warn)?, 0, 128)?,
1964 in_range(_p.read_int(warn)?, 0, 128)?,
1965 in_range(_p.read_int(warn)?, 0, 128)?,
1966 in_range(_p.read_int(warn)?, 0, 128)?,
1967 in_range(_p.read_int(warn)?, 0, 128)?,
1968 in_range(_p.read_int(warn)?, 0, 128)?,
1969 in_range(_p.read_int(warn)?, 0, 128)?,
1970 in_range(_p.read_int(warn)?, 0, 128)?,
1971 in_range(_p.read_int(warn)?, 0, 128)?,
1972 in_range(_p.read_int(warn)?, 0, 128)?,
1973 in_range(_p.read_int(warn)?, 0, 128)?,
1974 in_range(_p.read_int(warn)?, 0, 128)?,
1975 in_range(_p.read_int(warn)?, 0, 128)?,
1976 in_range(_p.read_int(warn)?, 0, 128)?,
1977 in_range(_p.read_int(warn)?, 0, 128)?,
1978 in_range(_p.read_int(warn)?, 0, 128)?,
1979 in_range(_p.read_int(warn)?, 0, 128)?,
1980 in_range(_p.read_int(warn)?, 0, 128)?,
1981 in_range(_p.read_int(warn)?, 0, 128)?,
1982 in_range(_p.read_int(warn)?, 0, 128)?,
1983 in_range(_p.read_int(warn)?, 0, 128)?,
1984 in_range(_p.read_int(warn)?, 0, 128)?,
1985 in_range(_p.read_int(warn)?, 0, 128)?,
1986 in_range(_p.read_int(warn)?, 0, 128)?,
1987 in_range(_p.read_int(warn)?, 0, 128)?,
1988 in_range(_p.read_int(warn)?, 0, 128)?,
1989 in_range(_p.read_int(warn)?, 0, 128)?,
1990 in_range(_p.read_int(warn)?, 0, 128)?,
1991 in_range(_p.read_int(warn)?, 0, 128)?,
1992 in_range(_p.read_int(warn)?, 0, 128)?,
1993 in_range(_p.read_int(warn)?, 0, 128)?,
1994 in_range(_p.read_int(warn)?, 0, 128)?,
1995 in_range(_p.read_int(warn)?, 0, 128)?,
1996 in_range(_p.read_int(warn)?, 0, 128)?,
1997 in_range(_p.read_int(warn)?, 0, 128)?,
1998 in_range(_p.read_int(warn)?, 0, 128)?,
1999 in_range(_p.read_int(warn)?, 0, 128)?,
2000 in_range(_p.read_int(warn)?, 0, 128)?,
2001 in_range(_p.read_int(warn)?, 0, 128)?,
2002 in_range(_p.read_int(warn)?, 0, 128)?,
2003 in_range(_p.read_int(warn)?, 0, 128)?,
2004 in_range(_p.read_int(warn)?, 0, 128)?,
2005 in_range(_p.read_int(warn)?, 0, 128)?,
2006 in_range(_p.read_int(warn)?, 0, 128)?,
2007 in_range(_p.read_int(warn)?, 0, 128)?,
2008 in_range(_p.read_int(warn)?, 0, 128)?,
2009 in_range(_p.read_int(warn)?, 0, 128)?,
2010 in_range(_p.read_int(warn)?, 0, 128)?,
2011 in_range(_p.read_int(warn)?, 0, 128)?,
2012 in_range(_p.read_int(warn)?, 0, 128)?,
2013 in_range(_p.read_int(warn)?, 0, 128)?,
2014 in_range(_p.read_int(warn)?, 0, 128)?,
2015 in_range(_p.read_int(warn)?, 0, 128)?,
2016 in_range(_p.read_int(warn)?, 0, 128)?,
2017 in_range(_p.read_int(warn)?, 0, 128)?,
2018 in_range(_p.read_int(warn)?, 0, 128)?,
2019 in_range(_p.read_int(warn)?, 0, 128)?,
2020 in_range(_p.read_int(warn)?, 0, 128)?,
2021 in_range(_p.read_int(warn)?, 0, 128)?,
2022 in_range(_p.read_int(warn)?, 0, 128)?,
2023 in_range(_p.read_int(warn)?, 0, 128)?,
2024 in_range(_p.read_int(warn)?, 0, 128)?,
2025 in_range(_p.read_int(warn)?, 0, 128)?,
2026 in_range(_p.read_int(warn)?, 0, 128)?,
2027 in_range(_p.read_int(warn)?, 0, 128)?,
2028 in_range(_p.read_int(warn)?, 0, 128)?,
2029 in_range(_p.read_int(warn)?, 0, 128)?,
2030 in_range(_p.read_int(warn)?, 0, 128)?,
2031 in_range(_p.read_int(warn)?, 0, 128)?,
2032 in_range(_p.read_int(warn)?, 0, 128)?,
2033 in_range(_p.read_int(warn)?, 0, 128)?,
2034 in_range(_p.read_int(warn)?, 0, 128)?,
2035 in_range(_p.read_int(warn)?, 0, 128)?,
2036 in_range(_p.read_int(warn)?, 0, 128)?,
2037 in_range(_p.read_int(warn)?, 0, 128)?,
2038 in_range(_p.read_int(warn)?, 0, 128)?,
2039 in_range(_p.read_int(warn)?, 0, 128)?,
2040 in_range(_p.read_int(warn)?, 0, 128)?,
2041 in_range(_p.read_int(warn)?, 0, 128)?,
2042 in_range(_p.read_int(warn)?, 0, 128)?,
2043 in_range(_p.read_int(warn)?, 0, 128)?,
2044 in_range(_p.read_int(warn)?, 0, 128)?,
2045 in_range(_p.read_int(warn)?, 0, 128)?,
2046 in_range(_p.read_int(warn)?, 0, 128)?,
2047 in_range(_p.read_int(warn)?, 0, 128)?,
2048 in_range(_p.read_int(warn)?, 0, 128)?,
2049 in_range(_p.read_int(warn)?, 0, 128)?,
2050 in_range(_p.read_int(warn)?, 0, 128)?,
2051 in_range(_p.read_int(warn)?, 0, 128)?,
2052 in_range(_p.read_int(warn)?, 0, 128)?,
2053 in_range(_p.read_int(warn)?, 0, 128)?,
2054 in_range(_p.read_int(warn)?, 0, 128)?,
2055 in_range(_p.read_int(warn)?, 0, 128)?,
2056 in_range(_p.read_int(warn)?, 0, 128)?,
2057 in_range(_p.read_int(warn)?, 0, 128)?,
2058 in_range(_p.read_int(warn)?, 0, 128)?,
2059 in_range(_p.read_int(warn)?, 0, 128)?,
2060 in_range(_p.read_int(warn)?, 0, 128)?,
2061 in_range(_p.read_int(warn)?, 0, 128)?,
2062 in_range(_p.read_int(warn)?, 0, 128)?,
2063 in_range(_p.read_int(warn)?, 0, 128)?,
2064 in_range(_p.read_int(warn)?, 0, 128)?,
2065 in_range(_p.read_int(warn)?, 0, 128)?,
2066 in_range(_p.read_int(warn)?, 0, 128)?,
2067 in_range(_p.read_int(warn)?, 0, 128)?,
2068 in_range(_p.read_int(warn)?, 0, 128)?,
2069 in_range(_p.read_int(warn)?, 0, 128)?,
2070 in_range(_p.read_int(warn)?, 0, 128)?,
2071 in_range(_p.read_int(warn)?, 0, 128)?,
2072 in_range(_p.read_int(warn)?, 0, 128)?,
2073 in_range(_p.read_int(warn)?, 0, 128)?,
2074 in_range(_p.read_int(warn)?, 0, 128)?,
2075 in_range(_p.read_int(warn)?, 0, 128)?,
2076 ],
2077 });
2078 _p.finish(wrap(warn));
2079 result
2080 }
2081 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2082 for &e in &self.teams {
2083 assert!(0 <= e && e <= 128);
2084 }
2085 for &e in &self.teams {
2086 _p.write_int(e)?;
2087 }
2088 Ok(_p.written())
2089 }
2090}
2091impl fmt::Debug for SvTeamsStateLegacy {
2092 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2093 f.debug_struct("SvTeamsStateLegacy")
2094 .field("teams", &self.teams)
2095 .finish()
2096 }
2097}
2098
2099impl ClShowOthersLegacy {
2100 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowOthersLegacy, Error> {
2101 let result = Ok(ClShowOthersLegacy {
2102 show: to_bool(_p.read_int(warn)?)?,
2103 });
2104 _p.finish(wrap(warn));
2105 result
2106 }
2107 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2108 _p.write_int(self.show as i32)?;
2109 Ok(_p.written())
2110 }
2111}
2112impl fmt::Debug for ClShowOthersLegacy {
2113 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2114 f.debug_struct("ClShowOthersLegacy")
2115 .field("show", &self.show)
2116 .finish()
2117 }
2118}
2119
2120impl SvMyOwnMessage {
2121 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvMyOwnMessage, Error> {
2122 let result = Ok(SvMyOwnMessage {
2123 test: _p.read_int(warn)?,
2124 });
2125 _p.finish(wrap(warn));
2126 result
2127 }
2128 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2129 _p.write_int(self.test)?;
2130 Ok(_p.written())
2131 }
2132}
2133impl fmt::Debug for SvMyOwnMessage {
2134 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2135 f.debug_struct("SvMyOwnMessage")
2136 .field("test", &self.test)
2137 .finish()
2138 }
2139}
2140
2141impl ClShowDistance {
2142 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowDistance, Error> {
2143 let result = Ok(ClShowDistance {
2144 x: _p.read_int(warn)?,
2145 y: _p.read_int(warn)?,
2146 });
2147 _p.finish(wrap(warn));
2148 result
2149 }
2150 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2151 _p.write_int(self.x)?;
2152 _p.write_int(self.y)?;
2153 Ok(_p.written())
2154 }
2155}
2156impl fmt::Debug for ClShowDistance {
2157 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2158 f.debug_struct("ClShowDistance")
2159 .field("x", &self.x)
2160 .field("y", &self.y)
2161 .finish()
2162 }
2163}
2164
2165impl ClShowOthers {
2166 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClShowOthers, Error> {
2167 let result = Ok(ClShowOthers {
2168 show: in_range(_p.read_int(warn)?, 0, 2)?,
2169 });
2170 _p.finish(wrap(warn));
2171 result
2172 }
2173 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2174 assert!(0 <= self.show && self.show <= 2);
2175 _p.write_int(self.show)?;
2176 Ok(_p.written())
2177 }
2178}
2179impl fmt::Debug for ClShowOthers {
2180 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2181 f.debug_struct("ClShowOthers")
2182 .field("show", &self.show)
2183 .finish()
2184 }
2185}
2186
2187impl ClCameraInfo {
2188 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClCameraInfo, Error> {
2189 let result = Ok(ClCameraInfo {
2190 zoom: _p.read_int(warn)?,
2191 deadzone: _p.read_int(warn)?,
2192 follow_factor: _p.read_int(warn)?,
2193 });
2194 _p.finish(wrap(warn));
2195 result
2196 }
2197 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2198 _p.write_int(self.zoom)?;
2199 _p.write_int(self.deadzone)?;
2200 _p.write_int(self.follow_factor)?;
2201 Ok(_p.written())
2202 }
2203}
2204impl fmt::Debug for ClCameraInfo {
2205 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2206 f.debug_struct("ClCameraInfo")
2207 .field("zoom", &self.zoom)
2208 .field("deadzone", &self.deadzone)
2209 .field("follow_factor", &self.follow_factor)
2210 .finish()
2211 }
2212}
2213
2214impl SvTeamsState {
2215 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvTeamsState, Error> {
2216 let result = Ok(SvTeamsState {
2217 teams: [
2218 in_range(_p.read_int(warn)?, 0, 128)?,
2219 in_range(_p.read_int(warn)?, 0, 128)?,
2220 in_range(_p.read_int(warn)?, 0, 128)?,
2221 in_range(_p.read_int(warn)?, 0, 128)?,
2222 in_range(_p.read_int(warn)?, 0, 128)?,
2223 in_range(_p.read_int(warn)?, 0, 128)?,
2224 in_range(_p.read_int(warn)?, 0, 128)?,
2225 in_range(_p.read_int(warn)?, 0, 128)?,
2226 in_range(_p.read_int(warn)?, 0, 128)?,
2227 in_range(_p.read_int(warn)?, 0, 128)?,
2228 in_range(_p.read_int(warn)?, 0, 128)?,
2229 in_range(_p.read_int(warn)?, 0, 128)?,
2230 in_range(_p.read_int(warn)?, 0, 128)?,
2231 in_range(_p.read_int(warn)?, 0, 128)?,
2232 in_range(_p.read_int(warn)?, 0, 128)?,
2233 in_range(_p.read_int(warn)?, 0, 128)?,
2234 in_range(_p.read_int(warn)?, 0, 128)?,
2235 in_range(_p.read_int(warn)?, 0, 128)?,
2236 in_range(_p.read_int(warn)?, 0, 128)?,
2237 in_range(_p.read_int(warn)?, 0, 128)?,
2238 in_range(_p.read_int(warn)?, 0, 128)?,
2239 in_range(_p.read_int(warn)?, 0, 128)?,
2240 in_range(_p.read_int(warn)?, 0, 128)?,
2241 in_range(_p.read_int(warn)?, 0, 128)?,
2242 in_range(_p.read_int(warn)?, 0, 128)?,
2243 in_range(_p.read_int(warn)?, 0, 128)?,
2244 in_range(_p.read_int(warn)?, 0, 128)?,
2245 in_range(_p.read_int(warn)?, 0, 128)?,
2246 in_range(_p.read_int(warn)?, 0, 128)?,
2247 in_range(_p.read_int(warn)?, 0, 128)?,
2248 in_range(_p.read_int(warn)?, 0, 128)?,
2249 in_range(_p.read_int(warn)?, 0, 128)?,
2250 in_range(_p.read_int(warn)?, 0, 128)?,
2251 in_range(_p.read_int(warn)?, 0, 128)?,
2252 in_range(_p.read_int(warn)?, 0, 128)?,
2253 in_range(_p.read_int(warn)?, 0, 128)?,
2254 in_range(_p.read_int(warn)?, 0, 128)?,
2255 in_range(_p.read_int(warn)?, 0, 128)?,
2256 in_range(_p.read_int(warn)?, 0, 128)?,
2257 in_range(_p.read_int(warn)?, 0, 128)?,
2258 in_range(_p.read_int(warn)?, 0, 128)?,
2259 in_range(_p.read_int(warn)?, 0, 128)?,
2260 in_range(_p.read_int(warn)?, 0, 128)?,
2261 in_range(_p.read_int(warn)?, 0, 128)?,
2262 in_range(_p.read_int(warn)?, 0, 128)?,
2263 in_range(_p.read_int(warn)?, 0, 128)?,
2264 in_range(_p.read_int(warn)?, 0, 128)?,
2265 in_range(_p.read_int(warn)?, 0, 128)?,
2266 in_range(_p.read_int(warn)?, 0, 128)?,
2267 in_range(_p.read_int(warn)?, 0, 128)?,
2268 in_range(_p.read_int(warn)?, 0, 128)?,
2269 in_range(_p.read_int(warn)?, 0, 128)?,
2270 in_range(_p.read_int(warn)?, 0, 128)?,
2271 in_range(_p.read_int(warn)?, 0, 128)?,
2272 in_range(_p.read_int(warn)?, 0, 128)?,
2273 in_range(_p.read_int(warn)?, 0, 128)?,
2274 in_range(_p.read_int(warn)?, 0, 128)?,
2275 in_range(_p.read_int(warn)?, 0, 128)?,
2276 in_range(_p.read_int(warn)?, 0, 128)?,
2277 in_range(_p.read_int(warn)?, 0, 128)?,
2278 in_range(_p.read_int(warn)?, 0, 128)?,
2279 in_range(_p.read_int(warn)?, 0, 128)?,
2280 in_range(_p.read_int(warn)?, 0, 128)?,
2281 in_range(_p.read_int(warn)?, 0, 128)?,
2282 in_range(_p.read_int(warn)?, 0, 128)?,
2283 in_range(_p.read_int(warn)?, 0, 128)?,
2284 in_range(_p.read_int(warn)?, 0, 128)?,
2285 in_range(_p.read_int(warn)?, 0, 128)?,
2286 in_range(_p.read_int(warn)?, 0, 128)?,
2287 in_range(_p.read_int(warn)?, 0, 128)?,
2288 in_range(_p.read_int(warn)?, 0, 128)?,
2289 in_range(_p.read_int(warn)?, 0, 128)?,
2290 in_range(_p.read_int(warn)?, 0, 128)?,
2291 in_range(_p.read_int(warn)?, 0, 128)?,
2292 in_range(_p.read_int(warn)?, 0, 128)?,
2293 in_range(_p.read_int(warn)?, 0, 128)?,
2294 in_range(_p.read_int(warn)?, 0, 128)?,
2295 in_range(_p.read_int(warn)?, 0, 128)?,
2296 in_range(_p.read_int(warn)?, 0, 128)?,
2297 in_range(_p.read_int(warn)?, 0, 128)?,
2298 in_range(_p.read_int(warn)?, 0, 128)?,
2299 in_range(_p.read_int(warn)?, 0, 128)?,
2300 in_range(_p.read_int(warn)?, 0, 128)?,
2301 in_range(_p.read_int(warn)?, 0, 128)?,
2302 in_range(_p.read_int(warn)?, 0, 128)?,
2303 in_range(_p.read_int(warn)?, 0, 128)?,
2304 in_range(_p.read_int(warn)?, 0, 128)?,
2305 in_range(_p.read_int(warn)?, 0, 128)?,
2306 in_range(_p.read_int(warn)?, 0, 128)?,
2307 in_range(_p.read_int(warn)?, 0, 128)?,
2308 in_range(_p.read_int(warn)?, 0, 128)?,
2309 in_range(_p.read_int(warn)?, 0, 128)?,
2310 in_range(_p.read_int(warn)?, 0, 128)?,
2311 in_range(_p.read_int(warn)?, 0, 128)?,
2312 in_range(_p.read_int(warn)?, 0, 128)?,
2313 in_range(_p.read_int(warn)?, 0, 128)?,
2314 in_range(_p.read_int(warn)?, 0, 128)?,
2315 in_range(_p.read_int(warn)?, 0, 128)?,
2316 in_range(_p.read_int(warn)?, 0, 128)?,
2317 in_range(_p.read_int(warn)?, 0, 128)?,
2318 in_range(_p.read_int(warn)?, 0, 128)?,
2319 in_range(_p.read_int(warn)?, 0, 128)?,
2320 in_range(_p.read_int(warn)?, 0, 128)?,
2321 in_range(_p.read_int(warn)?, 0, 128)?,
2322 in_range(_p.read_int(warn)?, 0, 128)?,
2323 in_range(_p.read_int(warn)?, 0, 128)?,
2324 in_range(_p.read_int(warn)?, 0, 128)?,
2325 in_range(_p.read_int(warn)?, 0, 128)?,
2326 in_range(_p.read_int(warn)?, 0, 128)?,
2327 in_range(_p.read_int(warn)?, 0, 128)?,
2328 in_range(_p.read_int(warn)?, 0, 128)?,
2329 in_range(_p.read_int(warn)?, 0, 128)?,
2330 in_range(_p.read_int(warn)?, 0, 128)?,
2331 in_range(_p.read_int(warn)?, 0, 128)?,
2332 in_range(_p.read_int(warn)?, 0, 128)?,
2333 in_range(_p.read_int(warn)?, 0, 128)?,
2334 in_range(_p.read_int(warn)?, 0, 128)?,
2335 in_range(_p.read_int(warn)?, 0, 128)?,
2336 in_range(_p.read_int(warn)?, 0, 128)?,
2337 in_range(_p.read_int(warn)?, 0, 128)?,
2338 in_range(_p.read_int(warn)?, 0, 128)?,
2339 in_range(_p.read_int(warn)?, 0, 128)?,
2340 in_range(_p.read_int(warn)?, 0, 128)?,
2341 in_range(_p.read_int(warn)?, 0, 128)?,
2342 in_range(_p.read_int(warn)?, 0, 128)?,
2343 in_range(_p.read_int(warn)?, 0, 128)?,
2344 in_range(_p.read_int(warn)?, 0, 128)?,
2345 in_range(_p.read_int(warn)?, 0, 128)?,
2346 ],
2347 });
2348 _p.finish(wrap(warn));
2349 result
2350 }
2351 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2352 for &e in &self.teams {
2353 assert!(0 <= e && e <= 128);
2354 }
2355 for &e in &self.teams {
2356 _p.write_int(e)?;
2357 }
2358 Ok(_p.written())
2359 }
2360}
2361impl fmt::Debug for SvTeamsState {
2362 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2363 f.debug_struct("SvTeamsState")
2364 .field("teams", &self.teams)
2365 .finish()
2366 }
2367}
2368
2369impl SvDdraceTime {
2370 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvDdraceTime, Error> {
2371 let result = Ok(SvDdraceTime {
2372 time: _p.read_int(warn)?,
2373 check: _p.read_int(warn)?,
2374 finish: in_range(_p.read_int(warn)?, 0, 1)?,
2375 });
2376 _p.finish(wrap(warn));
2377 result
2378 }
2379 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2380 assert!(0 <= self.finish && self.finish <= 1);
2381 _p.write_int(self.time)?;
2382 _p.write_int(self.check)?;
2383 _p.write_int(self.finish)?;
2384 Ok(_p.written())
2385 }
2386}
2387impl fmt::Debug for SvDdraceTime {
2388 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2389 f.debug_struct("SvDdraceTime")
2390 .field("time", &self.time)
2391 .field("check", &self.check)
2392 .field("finish", &self.finish)
2393 .finish()
2394 }
2395}
2396
2397impl SvRecord {
2398 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvRecord, Error> {
2399 let result = Ok(SvRecord {
2400 server_time_best: _p.read_int(warn)?,
2401 player_time_best: _p.read_int(warn)?,
2402 });
2403 _p.finish(wrap(warn));
2404 result
2405 }
2406 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2407 _p.write_int(self.server_time_best)?;
2408 _p.write_int(self.player_time_best)?;
2409 Ok(_p.written())
2410 }
2411}
2412impl fmt::Debug for SvRecord {
2413 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2414 f.debug_struct("SvRecord")
2415 .field("server_time_best", &self.server_time_best)
2416 .field("player_time_best", &self.player_time_best)
2417 .finish()
2418 }
2419}
2420
2421impl SvKillMsgTeam {
2422 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvKillMsgTeam, Error> {
2423 let result = Ok(SvKillMsgTeam {
2424 team: in_range(_p.read_int(warn)?, 0, 127)?,
2425 first: in_range(_p.read_int(warn)?, -1, 127)?,
2426 });
2427 _p.finish(wrap(warn));
2428 result
2429 }
2430 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2431 assert!(0 <= self.team && self.team <= 127);
2432 assert!(-1 <= self.first && self.first <= 127);
2433 _p.write_int(self.team)?;
2434 _p.write_int(self.first)?;
2435 Ok(_p.written())
2436 }
2437}
2438impl fmt::Debug for SvKillMsgTeam {
2439 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2440 f.debug_struct("SvKillMsgTeam")
2441 .field("team", &self.team)
2442 .field("first", &self.first)
2443 .finish()
2444 }
2445}
2446
2447impl SvYourVote {
2448 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvYourVote, Error> {
2449 let result = Ok(SvYourVote {
2450 voted: in_range(_p.read_int(warn)?, -1, 1)?,
2451 });
2452 _p.finish(wrap(warn));
2453 result
2454 }
2455 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2456 assert!(-1 <= self.voted && self.voted <= 1);
2457 _p.write_int(self.voted)?;
2458 Ok(_p.written())
2459 }
2460}
2461impl fmt::Debug for SvYourVote {
2462 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2463 f.debug_struct("SvYourVote")
2464 .field("voted", &self.voted)
2465 .finish()
2466 }
2467}
2468
2469impl SvRaceFinish {
2470 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvRaceFinish, Error> {
2471 let result = Ok(SvRaceFinish {
2472 client_id: in_range(_p.read_int(warn)?, 0, 127)?,
2473 time: _p.read_int(warn)?,
2474 diff: _p.read_int(warn)?,
2475 record_personal: to_bool(_p.read_int(warn)?)?,
2476 record_server: to_bool(_p.read_int(warn)?)?,
2477 });
2478 _p.finish(wrap(warn));
2479 result
2480 }
2481 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2482 assert!(0 <= self.client_id && self.client_id <= 127);
2483 _p.write_int(self.client_id)?;
2484 _p.write_int(self.time)?;
2485 _p.write_int(self.diff)?;
2486 _p.write_int(self.record_personal as i32)?;
2487 _p.write_int(self.record_server as i32)?;
2488 Ok(_p.written())
2489 }
2490}
2491impl fmt::Debug for SvRaceFinish {
2492 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2493 f.debug_struct("SvRaceFinish")
2494 .field("client_id", &self.client_id)
2495 .field("time", &self.time)
2496 .field("diff", &self.diff)
2497 .field("record_personal", &self.record_personal)
2498 .field("record_server", &self.record_server)
2499 .finish()
2500 }
2501}
2502
2503impl<'a> SvCommandInfo<'a> {
2504 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvCommandInfo<'a>, Error> {
2505 let result = Ok(SvCommandInfo {
2506 name: sanitize(warn, _p.read_string()?)?,
2507 args_format: sanitize(warn, _p.read_string()?)?,
2508 help_text: sanitize(warn, _p.read_string()?)?,
2509 });
2510 _p.finish(wrap(warn));
2511 result
2512 }
2513 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2514 sanitize(&mut Panic, self.name).unwrap();
2515 sanitize(&mut Panic, self.args_format).unwrap();
2516 sanitize(&mut Panic, self.help_text).unwrap();
2517 _p.write_string(self.name)?;
2518 _p.write_string(self.args_format)?;
2519 _p.write_string(self.help_text)?;
2520 Ok(_p.written())
2521 }
2522}
2523impl<'a> fmt::Debug for SvCommandInfo<'a> {
2524 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2525 f.debug_struct("SvCommandInfo")
2526 .field("name", &pretty::Bytes::new(&self.name))
2527 .field("args_format", &pretty::Bytes::new(&self.args_format))
2528 .field("help_text", &pretty::Bytes::new(&self.help_text))
2529 .finish()
2530 }
2531}
2532
2533impl<'a> SvCommandInfoRemove<'a> {
2534 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvCommandInfoRemove<'a>, Error> {
2535 let result = Ok(SvCommandInfoRemove {
2536 name: sanitize(warn, _p.read_string()?)?,
2537 });
2538 _p.finish(wrap(warn));
2539 result
2540 }
2541 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2542 sanitize(&mut Panic, self.name).unwrap();
2543 _p.write_string(self.name)?;
2544 Ok(_p.written())
2545 }
2546}
2547impl<'a> fmt::Debug for SvCommandInfoRemove<'a> {
2548 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2549 f.debug_struct("SvCommandInfoRemove")
2550 .field("name", &pretty::Bytes::new(&self.name))
2551 .finish()
2552 }
2553}
2554
2555impl SvVoteOptionGroupStart {
2556 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteOptionGroupStart, Error> {
2557 let result = Ok(SvVoteOptionGroupStart);
2558 _p.finish(wrap(warn));
2559 result
2560 }
2561 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2562 Ok(_p.written())
2563 }
2564}
2565impl fmt::Debug for SvVoteOptionGroupStart {
2566 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2567 f.debug_struct("SvVoteOptionGroupStart")
2568 .finish()
2569 }
2570}
2571
2572impl SvVoteOptionGroupEnd {
2573 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvVoteOptionGroupEnd, Error> {
2574 let result = Ok(SvVoteOptionGroupEnd);
2575 _p.finish(wrap(warn));
2576 result
2577 }
2578 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2579 Ok(_p.written())
2580 }
2581}
2582impl fmt::Debug for SvVoteOptionGroupEnd {
2583 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2584 f.debug_struct("SvVoteOptionGroupEnd")
2585 .finish()
2586 }
2587}
2588
2589impl SvCommandInfoGroupStart {
2590 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvCommandInfoGroupStart, Error> {
2591 let result = Ok(SvCommandInfoGroupStart);
2592 _p.finish(wrap(warn));
2593 result
2594 }
2595 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2596 Ok(_p.written())
2597 }
2598}
2599impl fmt::Debug for SvCommandInfoGroupStart {
2600 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2601 f.debug_struct("SvCommandInfoGroupStart")
2602 .finish()
2603 }
2604}
2605
2606impl SvCommandInfoGroupEnd {
2607 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvCommandInfoGroupEnd, Error> {
2608 let result = Ok(SvCommandInfoGroupEnd);
2609 _p.finish(wrap(warn));
2610 result
2611 }
2612 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2613 Ok(_p.written())
2614 }
2615}
2616impl fmt::Debug for SvCommandInfoGroupEnd {
2617 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2618 f.debug_struct("SvCommandInfoGroupEnd")
2619 .finish()
2620 }
2621}
2622
2623impl SvChangeInfoCooldown {
2624 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvChangeInfoCooldown, Error> {
2625 let result = Ok(SvChangeInfoCooldown {
2626 wait_until: crate::snap_obj::Tick(_p.read_int(warn)?),
2627 });
2628 _p.finish(wrap(warn));
2629 result
2630 }
2631 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2632 _p.write_int(self.wait_until.0)?;
2633 Ok(_p.written())
2634 }
2635}
2636impl fmt::Debug for SvChangeInfoCooldown {
2637 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2638 f.debug_struct("SvChangeInfoCooldown")
2639 .field("wait_until", &self.wait_until)
2640 .finish()
2641 }
2642}
2643
2644impl SvMapSoundGlobal {
2645 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvMapSoundGlobal, Error> {
2646 let result = Ok(SvMapSoundGlobal {
2647 sound_id: _p.read_int(warn)?,
2648 });
2649 _p.finish(wrap(warn));
2650 result
2651 }
2652 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2653 _p.write_int(self.sound_id)?;
2654 Ok(_p.written())
2655 }
2656}
2657impl fmt::Debug for SvMapSoundGlobal {
2658 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2659 f.debug_struct("SvMapSoundGlobal")
2660 .field("sound_id", &self.sound_id)
2661 .finish()
2662 }
2663}
2664
2665impl SvPreInput {
2666 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<SvPreInput, Error> {
2667 let result = Ok(SvPreInput {
2668 direction: _p.read_int(warn)?,
2669 target_x: _p.read_int(warn)?,
2670 target_y: _p.read_int(warn)?,
2671 jump: _p.read_int(warn)?,
2672 fire: _p.read_int(warn)?,
2673 hook: _p.read_int(warn)?,
2674 wanted_weapon: _p.read_int(warn)?,
2675 next_weapon: _p.read_int(warn)?,
2676 prev_weapon: _p.read_int(warn)?,
2677 owner: in_range(_p.read_int(warn)?, 0, 127)?,
2678 intended_tick: crate::snap_obj::Tick(_p.read_int(warn)?),
2679 });
2680 _p.finish(wrap(warn));
2681 result
2682 }
2683 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2684 assert!(0 <= self.owner && self.owner <= 127);
2685 _p.write_int(self.direction)?;
2686 _p.write_int(self.target_x)?;
2687 _p.write_int(self.target_y)?;
2688 _p.write_int(self.jump)?;
2689 _p.write_int(self.fire)?;
2690 _p.write_int(self.hook)?;
2691 _p.write_int(self.wanted_weapon)?;
2692 _p.write_int(self.next_weapon)?;
2693 _p.write_int(self.prev_weapon)?;
2694 _p.write_int(self.owner)?;
2695 _p.write_int(self.intended_tick.0)?;
2696 Ok(_p.written())
2697 }
2698}
2699impl fmt::Debug for SvPreInput {
2700 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2701 f.debug_struct("SvPreInput")
2702 .field("direction", &self.direction)
2703 .field("target_x", &self.target_x)
2704 .field("target_y", &self.target_y)
2705 .field("jump", &self.jump)
2706 .field("fire", &self.fire)
2707 .field("hook", &self.hook)
2708 .field("wanted_weapon", &self.wanted_weapon)
2709 .field("next_weapon", &self.next_weapon)
2710 .field("prev_weapon", &self.prev_weapon)
2711 .field("owner", &self.owner)
2712 .field("intended_tick", &self.intended_tick)
2713 .finish()
2714 }
2715}
2716
2717impl<'a> SvSaveCode<'a> {
2718 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvSaveCode<'a>, Error> {
2719 let result = Ok(SvSaveCode {
2720 state: in_range(_p.read_int(warn)?, 0, 4)?,
2721 error: sanitize(warn, _p.read_string()?)?,
2722 save_requester: sanitize(warn, _p.read_string()?)?,
2723 server_name: sanitize(warn, _p.read_string()?)?,
2724 generated_code: sanitize(warn, _p.read_string()?)?,
2725 code: sanitize(warn, _p.read_string()?)?,
2726 team_members: sanitize(warn, _p.read_string()?)?,
2727 });
2728 _p.finish(wrap(warn));
2729 result
2730 }
2731 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2732 assert!(0 <= self.state && self.state <= 4);
2733 sanitize(&mut Panic, self.error).unwrap();
2734 sanitize(&mut Panic, self.save_requester).unwrap();
2735 sanitize(&mut Panic, self.server_name).unwrap();
2736 sanitize(&mut Panic, self.generated_code).unwrap();
2737 sanitize(&mut Panic, self.code).unwrap();
2738 sanitize(&mut Panic, self.team_members).unwrap();
2739 _p.write_int(self.state)?;
2740 _p.write_string(self.error)?;
2741 _p.write_string(self.save_requester)?;
2742 _p.write_string(self.server_name)?;
2743 _p.write_string(self.generated_code)?;
2744 _p.write_string(self.code)?;
2745 _p.write_string(self.team_members)?;
2746 Ok(_p.written())
2747 }
2748}
2749impl<'a> fmt::Debug for SvSaveCode<'a> {
2750 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2751 f.debug_struct("SvSaveCode")
2752 .field("state", &self.state)
2753 .field("error", &pretty::Bytes::new(&self.error))
2754 .field("save_requester", &pretty::Bytes::new(&self.save_requester))
2755 .field("server_name", &pretty::Bytes::new(&self.server_name))
2756 .field("generated_code", &pretty::Bytes::new(&self.generated_code))
2757 .field("code", &pretty::Bytes::new(&self.code))
2758 .field("team_members", &pretty::Bytes::new(&self.team_members))
2759 .finish()
2760 }
2761}
2762
2763impl<'a> SvServerAlert<'a> {
2764 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvServerAlert<'a>, Error> {
2765 let result = Ok(SvServerAlert {
2766 message: _p.read_string()?,
2767 });
2768 _p.finish(wrap(warn));
2769 result
2770 }
2771 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2772 _p.write_string(self.message)?;
2773 Ok(_p.written())
2774 }
2775}
2776impl<'a> fmt::Debug for SvServerAlert<'a> {
2777 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2778 f.debug_struct("SvServerAlert")
2779 .field("message", &pretty::Bytes::new(&self.message))
2780 .finish()
2781 }
2782}
2783
2784impl<'a> SvModeratorAlert<'a> {
2785 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker<'a>) -> Result<SvModeratorAlert<'a>, Error> {
2786 let result = Ok(SvModeratorAlert {
2787 message: _p.read_string()?,
2788 });
2789 _p.finish(wrap(warn));
2790 result
2791 }
2792 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2793 _p.write_string(self.message)?;
2794 Ok(_p.written())
2795 }
2796}
2797impl<'a> fmt::Debug for SvModeratorAlert<'a> {
2798 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2799 f.debug_struct("SvModeratorAlert")
2800 .field("message", &pretty::Bytes::new(&self.message))
2801 .finish()
2802 }
2803}
2804
2805impl ClEnableSpectatorCount {
2806 pub fn decode<W: Warn<Warning>>(warn: &mut W, _p: &mut Unpacker) -> Result<ClEnableSpectatorCount, Error> {
2807 let result = Ok(ClEnableSpectatorCount {
2808 enable: to_bool(_p.read_int(warn)?)?,
2809 });
2810 _p.finish(wrap(warn));
2811 result
2812 }
2813 pub fn encode<'d, 's>(&self, mut _p: Packer<'d, 's>) -> Result<&'d [u8], CapacityError> {
2814 _p.write_int(self.enable as i32)?;
2815 Ok(_p.written())
2816 }
2817}
2818impl fmt::Debug for ClEnableSpectatorCount {
2819 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
2820 f.debug_struct("ClEnableSpectatorCount")
2821 .field("enable", &self.enable)
2822 .finish()
2823 }
2824}
2825