wow_world_messages/world/shared/
msg_inspect_arena_teams_server_tbc_wrath.rs1use std::io::{Read, Write};
2
3use crate::Guid;
4
5#[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 let player = crate::util::read_guid(&mut r)?;
39
40 let slot = crate::util::read_u8_le(&mut r)?;
42
43 let arena_team = crate::util::read_u32_le(&mut r)?;
45
46 let rating = crate::util::read_u32_le(&mut r)?;
48
49 let games_played_this_season = crate::util::read_u32_le(&mut r)?;
51
52 let wins_this_season = crate::util::read_u32_le(&mut r)?;
54
55 let total_games_played = crate::util::read_u32_le(&mut r)?;
57
58 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 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 w.write_all(&self.player.guid().to_le_bytes())?;
135
136 w.write_all(&self.slot.to_le_bytes())?;
138
139 w.write_all(&self.arena_team.to_le_bytes())?;
141
142 w.write_all(&self.rating.to_le_bytes())?;
144
145 w.write_all(&self.games_played_this_season.to_le_bytes())?;
147
148 w.write_all(&self.wins_this_season.to_le_bytes())?;
150
151 w.write_all(&self.total_games_played.to_le_bytes())?;
153
154 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