wow_world_messages/world/shared/
msg_inspect_arena_teams_server_tbc_wrath.rs

1use std::io::{Read, Write};
2
3use crate::Guid;
4
5/// Auto generated from the original `wowm` in file [`wow_message_parser/wowm/world/arena/msg_inspect_arena_teams.wowm:1`](https://github.com/gtker/wow_messages/tree/main/wow_message_parser/wowm/world/arena/msg_inspect_arena_teams.wowm#L1):
6/// ```text
7/// smsg MSG_INSPECT_ARENA_TEAMS_Server = 0x0377 {
8///     Guid player;
9///     u8 slot;
10///     u32 arena_team;
11///     u32 rating;
12///     u32 games_played_this_season;
13///     u32 wins_this_season;
14///     u32 total_games_played;
15///     u32 personal_rating;
16/// }
17/// ```
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
19pub struct MSG_INSPECT_ARENA_TEAMS_Server {
20    pub player: Guid,
21    pub slot: u8,
22    pub arena_team: u32,
23    pub rating: u32,
24    pub games_played_this_season: u32,
25    pub wins_this_season: u32,
26    pub total_games_played: u32,
27    pub personal_rating: u32,
28}
29
30impl crate::private::Sealed for MSG_INSPECT_ARENA_TEAMS_Server {}
31impl MSG_INSPECT_ARENA_TEAMS_Server {
32    fn read_inner(mut r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseErrorKind> {
33        if body_size != 33 {
34            return Err(crate::errors::ParseErrorKind::InvalidSize);
35        }
36
37        // player: Guid
38        let player = crate::util::read_guid(&mut r)?;
39
40        // slot: u8
41        let slot = crate::util::read_u8_le(&mut r)?;
42
43        // arena_team: u32
44        let arena_team = crate::util::read_u32_le(&mut r)?;
45
46        // rating: u32
47        let rating = crate::util::read_u32_le(&mut r)?;
48
49        // games_played_this_season: u32
50        let games_played_this_season = crate::util::read_u32_le(&mut r)?;
51
52        // wins_this_season: u32
53        let wins_this_season = crate::util::read_u32_le(&mut r)?;
54
55        // total_games_played: u32
56        let total_games_played = crate::util::read_u32_le(&mut r)?;
57
58        // personal_rating: u32
59        let personal_rating = crate::util::read_u32_le(&mut r)?;
60
61        Ok(Self {
62            player,
63            slot,
64            arena_team,
65            rating,
66            games_played_this_season,
67            wins_this_season,
68            total_games_played,
69            personal_rating,
70        })
71    }
72
73}
74
75impl crate::Message for MSG_INSPECT_ARENA_TEAMS_Server {
76    const OPCODE: u32 = 0x0377;
77
78    #[cfg(feature = "print-testcase")]
79    fn message_name(&self) -> &'static str {
80        "MSG_INSPECT_ARENA_TEAMS_Server"
81    }
82
83    #[cfg(feature = "print-testcase")]
84    fn to_test_case_string(&self) -> Option<String> {
85        use std::fmt::Write;
86        use crate::traits::Message;
87
88        let mut s = String::new();
89
90        writeln!(s, "test MSG_INSPECT_ARENA_TEAMS_Server {{").unwrap();
91        // Members
92        writeln!(s, "    player = {};", self.player.guid()).unwrap();
93        writeln!(s, "    slot = {};", self.slot).unwrap();
94        writeln!(s, "    arena_team = {};", self.arena_team).unwrap();
95        writeln!(s, "    rating = {};", self.rating).unwrap();
96        writeln!(s, "    games_played_this_season = {};", self.games_played_this_season).unwrap();
97        writeln!(s, "    wins_this_season = {};", self.wins_this_season).unwrap();
98        writeln!(s, "    total_games_played = {};", self.total_games_played).unwrap();
99        writeln!(s, "    personal_rating = {};", self.personal_rating).unwrap();
100
101        writeln!(s, "}} [").unwrap();
102
103        let [a, b] = 35_u16.to_be_bytes();
104        writeln!(s, "    {a:#04X}, {b:#04X}, /* size */").unwrap();
105        let [a, b] = 887_u16.to_le_bytes();
106        writeln!(s, "    {a:#04X}, {b:#04X}, /* opcode */").unwrap();
107        let mut bytes: Vec<u8> = Vec::new();
108        self.write_into_vec(&mut bytes).unwrap();
109        let mut bytes = bytes.into_iter();
110
111        crate::util::write_bytes(&mut s, &mut bytes, 8, "player", "    ");
112        crate::util::write_bytes(&mut s, &mut bytes, 1, "slot", "    ");
113        crate::util::write_bytes(&mut s, &mut bytes, 4, "arena_team", "    ");
114        crate::util::write_bytes(&mut s, &mut bytes, 4, "rating", "    ");
115        crate::util::write_bytes(&mut s, &mut bytes, 4, "games_played_this_season", "    ");
116        crate::util::write_bytes(&mut s, &mut bytes, 4, "wins_this_season", "    ");
117        crate::util::write_bytes(&mut s, &mut bytes, 4, "total_games_played", "    ");
118        crate::util::write_bytes(&mut s, &mut bytes, 4, "personal_rating", "    ");
119
120
121        writeln!(s, "] {{").unwrap();
122        writeln!(s, "    versions = \"{}\";", std::env::var("WOWM_TEST_CASE_WORLD_VERSION").unwrap_or("2.4.3 3".to_string())).unwrap();
123        writeln!(s, "}}\n").unwrap();
124
125        Some(s)
126    }
127
128    fn size_without_header(&self) -> u32 {
129        33
130    }
131
132    fn write_into_vec(&self, mut w: impl Write) -> Result<(), std::io::Error> {
133        // player: Guid
134        w.write_all(&self.player.guid().to_le_bytes())?;
135
136        // slot: u8
137        w.write_all(&self.slot.to_le_bytes())?;
138
139        // arena_team: u32
140        w.write_all(&self.arena_team.to_le_bytes())?;
141
142        // rating: u32
143        w.write_all(&self.rating.to_le_bytes())?;
144
145        // games_played_this_season: u32
146        w.write_all(&self.games_played_this_season.to_le_bytes())?;
147
148        // wins_this_season: u32
149        w.write_all(&self.wins_this_season.to_le_bytes())?;
150
151        // total_games_played: u32
152        w.write_all(&self.total_games_played.to_le_bytes())?;
153
154        // personal_rating: u32
155        w.write_all(&self.personal_rating.to_le_bytes())?;
156
157        Ok(())
158    }
159
160    fn read_body<S: crate::private::Sealed>(r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseError> {
161        Self::read_inner(r, body_size).map_err(|a| crate::errors::ParseError::new(887, "MSG_INSPECT_ARENA_TEAMS_Server", body_size, a))
162    }
163
164}
165
166#[cfg(feature = "tbc")]
167impl crate::tbc::ServerMessage for MSG_INSPECT_ARENA_TEAMS_Server {}
168
169#[cfg(feature = "wrath")]
170impl crate::wrath::ServerMessage for MSG_INSPECT_ARENA_TEAMS_Server {}
171