diff --git a/rust/crates/aaemu-game/src/systems/ai/packets.rs b/rust/crates/aaemu-game/src/systems/ai/packets.rs index fcc9130f39..1dda4beaad 100644 --- a/rust/crates/aaemu-game/src/systems/ai/packets.rs +++ b/rust/crates/aaemu-game/src/systems/ai/packets.rs @@ -20,9 +20,10 @@ packet_def!( ); impl Marshal for SCPlaySoundPacket { fn write(&self, s: &mut PacketStream) { + // The 1.2 client's reader (x2game 397bea30) takes the NPC of a kind-2 cue as a 3-byte bc. s.write_u8(self.kind) .write_u32(self.bubble_id) - .write_u32(self.npc_obj_id); + .write_bc(self.npc_obj_id); } } @@ -37,6 +38,6 @@ mod tests { bubble_id: 0x0102_0304, npc_obj_id: 0x00AB_CDEF, }); - assert_eq!(body, vec![2, 4, 3, 2, 1, 0xEF, 0xCD, 0xAB, 0x00]); + assert_eq!(body, vec![2, 4, 3, 2, 1, 0xEF, 0xCD, 0xAB]); } } diff --git a/rust/crates/aaemu-game/src/systems/instances/packets.rs b/rust/crates/aaemu-game/src/systems/instances/packets.rs index 54b00b1dfb..66aae4c5a9 100644 --- a/rust/crates/aaemu-game/src/systems/instances/packets.rs +++ b/rust/crates/aaemu-game/src/systems/instances/packets.rs @@ -728,10 +728,15 @@ packet_def!( level = LEVEL_PLAIN, opcode = sc::SCTowerDefListPacket ); +impl SCTowerDefListPacket { + /// The 1.2 client reads the count as a byte and at most this many entries (x2game 397caad0). + pub const MAX_INFOS: usize = 100; +} impl Marshal for SCTowerDefListPacket { fn write(&self, s: &mut PacketStream) { - s.write_i32(self.infos.len() as i32); - for i in &self.infos { + let infos = &self.infos[..self.infos.len().min(Self::MAX_INFOS)]; + s.write_u8(infos.len() as u8); + for i in infos { i.write(s); } } diff --git a/rust/crates/aaemu-game/src/systems/instances/tests.rs b/rust/crates/aaemu-game/src/systems/instances/tests.rs index 1e00ccb462..1e585f2616 100644 --- a/rust/crates/aaemu-game/src/systems/instances/tests.rs +++ b/rust/crates/aaemu-game/src/systems/instances/tests.rs @@ -349,7 +349,7 @@ fn tower_def_packets_are_byte_exact() { current_step: 4, }; let mut e = PacketStream::new(); - e.write_i32(1) + e.write_u8(1) .write_u32(12) .write_u16(5) .write_u32(129) diff --git a/rust/crates/aaemu-game/src/systems/social/packets/trial.rs b/rust/crates/aaemu-game/src/systems/social/packets/trial.rs index 315e01a223..712298399f 100644 --- a/rust/crates/aaemu-game/src/systems/social/packets/trial.rs +++ b/rust/crates/aaemu-game/src/systems/social/packets/trial.rs @@ -205,11 +205,11 @@ sc_packet!( ); sc_packet!( - /// `SCCriminalArrestedPacket(criminalObjId, criminal, arrestor)` (the obj id is a plain - /// `uint`, not a bc). + /// `SCCriminalArrestedPacket(criminalObjId, criminal, arrestor)`. The 1.2 client's reader + /// (x2game 397b6870) takes the obj id as a 3-byte bc before the two names. SCCriminalArrestedPacket { criminal_obj_id: u32, criminal: String, arrestor: String } |self, s| { - s.write_u32(self.criminal_obj_id) + s.write_bc(self.criminal_obj_id) .write_str(&self.criminal) .write_str(&self.arrestor); } @@ -765,7 +765,7 @@ mod tests { criminal: "C".into(), arrestor: "A".into() }), - vec![0x0C, 0x0B, 0x0A, 0x00, 1, 0, b'C', 1, 0, b'A'] + vec![0x0C, 0x0B, 0x0A, 1, 0, b'C', 1, 0, b'A'] ); assert_eq!( body(&SCForceAttackSetPacket {