Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions rust/crates/aaemu-game/src/systems/ai/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand All @@ -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]);
}
}
9 changes: 7 additions & 2 deletions rust/crates/aaemu-game/src/systems/instances/packets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion rust/crates/aaemu-game/src/systems/instances/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions rust/crates/aaemu-game/src/systems/social/packets/trial.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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 {
Expand Down
Loading