1use std::ops::{Deref, DerefMut};
4
5use bstr::BString;
6
7use crate::enums::*;
8#[cfg(feature = "serde")]
9use crate::packets::serde::{opt_vec, VecRemote};
10use crate::types::*;
11
12#[derive(Clone, Debug)]
14#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
15pub struct ChatPublic {
16 pub id: Player,
17 pub text: BString,
18}
19
20#[derive(Clone, Debug)]
22#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
23pub struct ChatSay {
24 pub id: Player,
25 pub text: BString,
26}
27
28#[derive(Clone, Debug)]
30#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
31pub struct ChatTeam {
32 pub id: Player,
33 pub text: BString,
34}
35
36#[derive(Copy, Clone, Debug)]
38#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
39pub struct ChatVoteMutePassed {
40 pub id: Player,
41}
42
43#[derive(Clone, Debug)]
48#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
49pub struct ChatWhisper {
50 pub from: Player,
51 pub to: Player,
52 pub text: BString,
53}
54
55#[derive(Clone, Debug)]
57#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
58pub struct CommandReply {
59 pub ty: CommandReplyType,
61 pub text: BString,
62}
63
64#[derive(Copy, Clone, Debug, Default)]
68#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
69pub struct Backup;
70
71#[derive(Copy, Clone, Debug, Default)]
73#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
74pub struct Ack;
75
76#[derive(Copy, Clone, Debug, Default)]
83#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
84pub struct ChatVoteMuted;
85
86#[derive(Copy, Clone, Debug)]
89#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
90pub struct Error {
91 pub error: ErrorType,
92}
93
94#[derive(Copy, Clone, Debug)]
96#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
97pub struct EventBoost {
98 pub clock: u32,
99 pub id: Player,
100 pub boost: bool,
101 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
102 pub pos: Position,
103 pub rot: Rotation,
104 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
105 pub speed: Velocity,
106 pub energy: Energy,
107 pub energy_regen: EnergyRegen,
108}
109
110#[derive(Copy, Clone, Debug)]
112#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
113pub struct EventBounce {
114 pub clock: u32,
115 pub id: Player,
116 pub keystate: ServerKeyState,
117 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
118 pub pos: Position,
119 pub rot: Rotation,
120 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
121 pub speed: Velocity,
122}
123
124#[derive(Copy, Clone, Debug)]
129#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
130pub struct EventLeaveHorizon {
131 #[cfg_attr(feature = "serde", serde(rename = "type"))]
132 pub ty: LeaveHorizonType,
133 pub id: u16,
135}
136
137#[derive(Copy, Clone, Debug)]
139#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
140pub struct EventRepelPlayer {
141 pub id: Player,
142 pub keystate: ServerKeyState,
143 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
144 pub pos: Position,
145 pub rot: Rotation,
146 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
147 pub speed: Velocity,
148 pub energy: Energy,
149 pub energy_regen: EnergyRegen,
150 pub health: Health,
151 pub health_regen: HealthRegen,
152}
153
154#[derive(Copy, Clone, Debug)]
156#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
157pub struct EventRepelMob {
158 pub id: Mob,
159 #[cfg_attr(feature = "serde", serde(rename = "type"))]
160 pub ty: MobType,
161 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
162 pub pos: Position,
163 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
164 pub speed: Velocity,
165 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
166 pub accel: Accel,
167 pub max_speed: Speed,
168}
169
170#[derive(Clone, Debug)]
173#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
174pub struct EventRepel {
175 pub clock: u32,
176 pub id: Player,
177 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
178 pub pos: Position,
179 pub rot: Rotation,
180 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
181 pub speed: Velocity,
182 pub energy: Energy,
183 pub energy_regen: EnergyRegen,
184 pub players: Vec<EventRepelPlayer>,
185 pub mobs: Vec<EventRepelMob>,
186}
187
188#[derive(Copy, Clone, Debug)]
190#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
191pub struct EventStealth {
192 pub id: Player,
193 pub state: bool,
194 pub energy: Energy,
195 pub energy_regen: EnergyRegen,
196}
197
198#[derive(Copy, Clone, Debug)]
200#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
201pub struct GameFirewall {
202 #[cfg_attr(feature = "serde", serde(rename = "type"))]
204 pub ty: u8,
205 pub status: FirewallStatus,
206 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
207 pub pos: Position,
208 pub radius: f32,
209 pub speed: f32,
210}
211
212#[derive(Copy, Clone, Debug)]
214#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
215pub struct GameFlag {
216 #[cfg_attr(feature = "serde", serde(rename = "type"))]
217 pub ty: FlagUpdateType,
218 pub flag: u8,
219 pub id: Option<Player>,
220 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
221 pub pos: Position,
222 pub blueteam: u8,
224 pub redteam: u8,
226}
227
228#[derive(Copy, Clone, Debug)]
230#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
231pub struct GamePlayersAlive {
232 pub players: u16,
233}
234
235#[derive(Copy, Clone, Debug)]
237#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
238pub struct GameSpectate {
239 pub id: Player,
240}
241
242#[derive(Clone, Debug)]
246#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
247pub struct LoginPlayer {
248 pub id: Player,
249 pub status: PlayerStatus,
250 pub level: Level,
251 pub name: BString,
252 #[cfg_attr(feature = "serde", serde(rename = "type"))]
253 pub ty: PlaneType,
254 pub team: Team,
255 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
256 pub pos: Position,
257 pub rot: Rotation,
258 pub flag: FlagCode,
259 pub upgrades: Upgrades,
260}
261
262#[derive(Clone, Debug)]
264#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
265pub struct Login {
266 pub success: bool,
267 pub id: Player,
268 pub team: Team,
269 pub clock: u32,
270 pub token: BString,
271 #[cfg_attr(feature = "serde", serde(rename = "type"))]
272 pub ty: GameType,
273 pub room: BString,
274 pub players: Vec<LoginPlayer>,
275}
276
277#[derive(Clone, Debug)]
278#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
279pub struct LoginBot {
280 pub id: Player,
281}
282
283#[derive(Clone, Debug)]
285#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
286
287pub struct Login2 {
288 #[cfg_attr(feature = "serde", serde(flatten))]
289 pub login: Login,
290 #[cfg_attr(feature = "serde", serde(rename = "serverConfiguration"))]
291 pub config: BString,
292 pub bots: Vec<LoginBot>,
293}
294
295#[derive(Copy, Clone, Debug)]
298#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
299pub struct MobDespawnCoords {
300 pub id: Mob,
301 #[cfg_attr(feature = "serde", serde(rename = "type"))]
302 pub ty: MobType,
303 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
304 pub pos: Position,
305}
306
307#[derive(Copy, Clone, Debug)]
313#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
314pub struct MobDespawn {
315 pub id: Mob,
316 #[cfg_attr(feature = "serde", serde(rename = "type"))]
317 pub ty: DespawnType,
318}
319
320#[derive(Copy, Clone, Debug)]
324#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
325pub struct MobUpdateStationary {
326 pub id: Mob,
327 #[cfg_attr(feature = "serde", serde(rename = "type"))]
328 pub ty: MobType,
329 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
330 pub pos: Position,
331}
332
333#[derive(Copy, Clone, Debug)]
338#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
339pub struct MobUpdate {
340 pub clock: u32,
341 pub id: Mob,
342 #[cfg_attr(feature = "serde", serde(rename = "type"))]
343 pub ty: MobType,
344 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
345 pub pos: Position,
346 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
347 pub speed: Velocity,
348 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
349 pub accel: Accel,
350 pub max_speed: Speed,
351}
352
353#[derive(Copy, Clone, Debug)]
356#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
357pub struct MobUpdate2 {
358 #[cfg_attr(feature = "serde", serde(flatten))]
359 pub update: MobUpdate,
360 #[cfg_attr(feature = "serde", serde(flatten))]
361 #[cfg_attr(feature = "serde", serde(rename = "ownerId"))]
362 pub owner: Player,
363}
364
365#[derive(Copy, Clone, Debug)]
367#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
368pub struct PingResult {
369 pub ping: u16,
370 #[cfg_attr(feature = "serde", serde(rename = "playersTotal"))]
371 pub players_total: u32,
372 #[cfg_attr(feature = "serde", serde(rename = "playersGame"))]
373 pub players_game: u32,
374}
375
376#[derive(Copy, Clone, Debug)]
384#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
385pub struct Ping {
386 pub clock: u32,
387 pub num: u32,
388}
389
390#[derive(Copy, Clone, Debug)]
394#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
395pub struct PlayerFireProjectile {
396 pub id: Mob,
397 #[cfg_attr(feature = "serde", serde(rename = "type"))]
398 pub ty: MobType,
399 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
400 pub pos: Position,
401 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
402 pub speed: Velocity,
403 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
404 pub accel: Accel,
405 pub max_speed: Speed,
406}
407
408#[derive(Clone, Debug)]
410#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
411pub struct PlayerFire {
412 pub clock: u32,
413 pub id: Player,
414 pub energy: Energy,
415 pub energy_regen: EnergyRegen,
416 pub projectiles: Vec<PlayerFireProjectile>,
417}
418
419#[derive(Copy, Clone, Debug)]
421#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
422pub struct PlayerFlag {
423 pub id: Player,
424 pub flag: FlagCode,
425}
426
427#[derive(Copy, Clone, Debug)]
429#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
430pub struct PlayerHitPlayer {
431 pub id: Player,
432 pub health: Health,
433 pub health_regen: HealthRegen,
434}
435
436#[derive(Clone, Debug)]
438#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
439pub struct PlayerHit {
440 pub id: Mob,
441 pub ty: MobType,
443 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
444 pub pos: Position,
445 pub owner: Player,
446 pub players: Vec<PlayerHitPlayer>,
447}
448
449#[derive(Copy, Clone, Debug)]
450#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
451pub struct PlayerKill {
452 pub id: Player,
453 pub killer: Option<Player>,
454 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
455 pub pos: Position,
456}
457
458#[derive(Copy, Clone, Debug)]
460#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
461pub struct PlayerLeave {
462 pub id: Player,
463}
464
465#[derive(Copy, Clone, Debug)]
470#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
471pub struct PlayerLevel {
472 pub id: Player,
473 #[cfg_attr(feature = "serde", serde(rename = "type"))]
474 pub ty: PlayerLevelType,
475 pub level: Level,
476}
477
478#[derive(Clone, Debug)]
480#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
481pub struct PlayerNew {
482 pub id: Player,
483 pub status: PlayerStatus,
484 pub name: BString,
485 #[cfg_attr(feature = "serde", serde(rename = "type"))]
486 pub ty: PlaneType,
487 pub team: Team,
488 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
489 pub pos: Position,
490 pub rot: Rotation,
491 pub flag: FlagCode,
492 pub upgrades: Upgrades,
493}
494
495#[derive(Copy, Clone, Debug)]
497#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
498pub struct PlayerPowerup {
499 #[cfg_attr(feature = "serde", serde(rename = "type"))]
500 pub ty: PowerupType,
501 pub duration: u32,
503}
504
505#[derive(Copy, Clone, Debug)]
507#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
508pub struct PlayerRespawn {
509 pub id: Player,
510 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
511 pub pos: Position,
512 pub rot: Rotation,
513 pub upgrades: Upgrades,
514}
515
516#[derive(Copy, Clone, Debug)]
518#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
519pub struct PlayerReteamPlayer {
520 pub id: Player,
521 pub team: Team,
522}
523
524#[derive(Clone, Debug)]
526#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
527pub struct PlayerReteam {
528 pub players: Vec<PlayerReteamPlayer>,
530}
531
532#[derive(Copy, Clone, Debug)]
534#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
535pub struct PlayerType {
536 pub id: Player,
537 #[cfg_attr(feature = "serde", serde(rename = "type"))]
538 pub ty: PlaneType,
539}
540
541#[derive(Copy, Clone, Debug)]
543#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
544pub struct PlayerUpdate {
545 pub clock: u32,
546 pub id: Player,
547 pub keystate: ServerKeyState,
548 pub upgrades: Upgrades,
549 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
550 pub pos: Position,
551 pub rot: Rotation,
552 #[cfg_attr(feature = "serde", serde(with = "VecRemote"))]
553 pub speed: Velocity,
554}
555
556#[derive(Copy, Clone, Debug)]
558#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
559pub struct PlayerUpgrade {
560 pub upgrades: u16,
561 #[cfg_attr(feature = "serde", serde(rename = "type"))]
562 pub ty: UpgradeType,
563 pub speed: u8,
564 pub defense: u8,
565 pub energy: u8,
566 pub missile: u8,
567}
568
569#[derive(Copy, Clone, Debug)]
571#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
572pub struct ScoreBoardData {
573 pub id: Player,
574 pub score: Score,
575 pub level: Level,
576}
577
578#[derive(Copy, Clone, Debug)]
580#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
581pub struct ScoreBoardRanking {
582 pub id: Player,
583 #[cfg_attr(feature = "serde", serde(with = "opt_vec"))]
584 pub pos: Option<Position>,
585}
586
587#[derive(Clone, Debug)]
592#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
593pub struct ScoreBoard {
594 pub data: Vec<ScoreBoardData>,
595 pub rankings: Vec<ScoreBoardRanking>,
596}
597
598#[derive(Copy, Clone, Debug)]
599#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
600pub struct ScoreUpdate {
601 pub id: Player,
602 pub score: Score,
603 pub earnings: Score,
604 pub upgrades: u16,
606 pub total_kills: u32,
607 pub total_deaths: u32,
608}
609
610#[derive(Clone, Debug)]
631#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
632pub struct ServerCustom {
633 #[cfg_attr(feature = "serde", serde(rename = "type"))]
634 pub ty: ServerCustomType,
635 pub data: BString,
636}
637
638#[derive(Clone, Debug)]
640#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
641pub struct ServerMessage {
642 #[cfg_attr(feature = "serde", serde(rename = "type"))]
643 pub ty: ServerMessageType,
644 pub duration: u32,
645 pub text: BString,
646}
647
648#[derive(Copy, Clone, Debug)]
650#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
651pub struct ScoreDetailedBTREntry {
652 pub id: Player,
653 pub level: Level,
654 pub alive: bool,
655 pub wins: u16,
656 pub score: Score,
657 pub kills: u16,
658 pub deaths: u16,
659 pub damage: f32,
660 pub ping: u16,
661}
662
663#[derive(Clone, Debug)]
664#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
665pub struct ScoreDetailedBTR {
666 pub scores: Vec<ScoreDetailedBTREntry>,
667}
668
669#[derive(Copy, Clone, Debug)]
671#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
672pub struct ScoreDetailedCTFEntry {
673 pub id: Player,
674 pub level: Level,
675 pub captures: u16,
676 pub score: Score,
677 pub kills: u16,
678 pub deaths: u16,
679 pub damage: f32,
680 pub ping: u16,
681}
682
683#[derive(Clone, Debug)]
685#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
686pub struct ScoreDetailedCTF {
687 pub scores: Vec<ScoreDetailedCTFEntry>,
688}
689
690#[derive(Copy, Clone, Debug)]
692#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
693pub struct ScoreDetailedFFAEntry {
694 pub id: Player,
695 pub level: Level,
696 pub score: Score,
697 pub kills: u16,
698 pub deaths: u16,
699 pub damage: f32,
700 pub ping: u16,
701}
702
703#[derive(Clone, Debug)]
705#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
706pub struct ScoreDetailedFFA {
707 pub scores: Vec<ScoreDetailedFFAEntry>,
708}
709
710impl Deref for Login2 {
714 type Target = Login;
715
716 fn deref(&self) -> &Self::Target {
717 &self.login
718 }
719}
720
721impl DerefMut for Login2 {
722 fn deref_mut(&mut self) -> &mut Self::Target {
723 &mut self.login
724 }
725}
726
727impl Deref for MobUpdate2 {
728 type Target = MobUpdate;
729
730 fn deref(&self) -> &Self::Target {
731 &self.update
732 }
733}
734
735impl DerefMut for MobUpdate2 {
736 fn deref_mut(&mut self) -> &mut Self::Target {
737 &mut self.update
738 }
739}