wow_world_messages/world/shared/
smsg_spline_move_unroot_vanilla_tbc_wrath.rs1use std::io::{Read, Write};
2
3use crate::Guid;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord, Default)]
12pub struct SMSG_SPLINE_MOVE_UNROOT {
13 pub guid: Guid,
14}
15
16impl crate::private::Sealed for SMSG_SPLINE_MOVE_UNROOT {}
17impl SMSG_SPLINE_MOVE_UNROOT {
18 fn read_inner(mut r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseErrorKind> {
19 if !(1..=9).contains(&body_size) {
20 return Err(crate::errors::ParseErrorKind::InvalidSize);
21 }
22
23 let guid = crate::util::read_packed_guid(&mut r)?;
25
26 Ok(Self {
27 guid,
28 })
29 }
30
31}
32
33impl crate::Message for SMSG_SPLINE_MOVE_UNROOT {
34 const OPCODE: u32 = 0x0304;
35
36 #[cfg(feature = "print-testcase")]
37 fn message_name(&self) -> &'static str {
38 "SMSG_SPLINE_MOVE_UNROOT"
39 }
40
41 #[cfg(feature = "print-testcase")]
42 fn to_test_case_string(&self) -> Option<String> {
43 use std::fmt::Write;
44 use crate::traits::Message;
45
46 let mut s = String::new();
47
48 writeln!(s, "test SMSG_SPLINE_MOVE_UNROOT {{").unwrap();
49 writeln!(s, " guid = {};", self.guid.guid()).unwrap();
51
52 writeln!(s, "}} [").unwrap();
53
54 let [a, b] = (u16::try_from(self.size() + 2).unwrap()).to_be_bytes();
55 writeln!(s, " {a:#04X}, {b:#04X}, /* size */").unwrap();
56 let [a, b] = 772_u16.to_le_bytes();
57 writeln!(s, " {a:#04X}, {b:#04X}, /* opcode */").unwrap();
58 let mut bytes: Vec<u8> = Vec::new();
59 self.write_into_vec(&mut bytes).unwrap();
60 let mut bytes = bytes.into_iter();
61
62 crate::util::write_bytes(&mut s, &mut bytes, crate::util::packed_guid_size(&self.guid), "guid", " ");
63
64
65 writeln!(s, "] {{").unwrap();
66 writeln!(s, " versions = \"{}\";", std::env::var("WOWM_TEST_CASE_WORLD_VERSION").unwrap_or("1.12 2 3".to_string())).unwrap();
67 writeln!(s, "}}\n").unwrap();
68
69 Some(s)
70 }
71
72 fn size_without_header(&self) -> u32 {
73 self.size() as u32
74 }
75
76 fn write_into_vec(&self, mut w: impl Write) -> Result<(), std::io::Error> {
77 crate::util::write_packed_guid(&self.guid, &mut w)?;
79
80 Ok(())
81 }
82
83 fn read_body<S: crate::private::Sealed>(r: &mut &[u8], body_size: u32) -> Result<Self, crate::errors::ParseError> {
84 Self::read_inner(r, body_size).map_err(|a| crate::errors::ParseError::new(772, "SMSG_SPLINE_MOVE_UNROOT", body_size, a))
85 }
86
87}
88
89#[cfg(feature = "vanilla")]
90impl crate::vanilla::ServerMessage for SMSG_SPLINE_MOVE_UNROOT {}
91
92#[cfg(feature = "tbc")]
93impl crate::tbc::ServerMessage for SMSG_SPLINE_MOVE_UNROOT {}
94
95#[cfg(feature = "wrath")]
96impl crate::wrath::ServerMessage for SMSG_SPLINE_MOVE_UNROOT {}
97
98impl SMSG_SPLINE_MOVE_UNROOT {
99 pub(crate) const fn size(&self) -> usize {
100 crate::util::packed_guid_size(&self.guid) }
102}
103