From b01ec2295060f1449dab1bb59f71261fb475c425 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Sun, 30 Mar 2025 19:50:31 -0400 Subject: [PATCH] Fix and check more packet sizes --- resources/opcodes.json | 2 +- src/world/ipc/mod.rs | 63 +++++++++++++++++++++++++++++++----------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/resources/opcodes.json b/resources/opcodes.json index dd16e7f..4c241ef 100644 --- a/resources/opcodes.json +++ b/resources/opcodes.json @@ -8,7 +8,7 @@ { "name": "InitZone", "opcode": 699, - "size": 103 + "size": 112 }, { "name": "ActorControlSelf", diff --git a/src/world/ipc/mod.rs b/src/world/ipc/mod.rs index d3f4950..bf99879 100644 --- a/src/world/ipc/mod.rs +++ b/src/world/ipc/mod.rs @@ -166,8 +166,8 @@ pub enum ServerZoneIpcData { /// Sent by the server when they send a chat message ServerChatMessage { unk: u8, // channel? - #[brw(pad_after = 775)] - #[br(count = 775)] + #[brw(pad_after = 774)] + #[br(count = 774)] #[br(map = read_string)] #[bw(map = write_string)] message: String, @@ -375,14 +375,26 @@ mod tests { #[test] fn world_ipc_sizes() { let ipc_types = [ - ( - ServerZoneIpcType::ActorControlSelf, - ServerZoneIpcData::ActorControlSelf(ActorControlSelf::default()), - ), ( ServerZoneIpcType::InitializeChat, ServerZoneIpcData::InitializeChat { unk: [0; 8] }, ), + ( + ServerZoneIpcType::InitResponse, + ServerZoneIpcData::InitResponse { + unk1: 0, + character_id: 0, + unk2: 0, + }, + ), + ( + ServerZoneIpcType::InitZone, + ServerZoneIpcData::InitZone(InitZone::default()), + ), + ( + ServerZoneIpcType::ActorControlSelf, + ServerZoneIpcData::ActorControlSelf(ActorControlSelf::default()), + ), ( ServerZoneIpcType::PlayerStats, ServerZoneIpcData::PlayerStats(PlayerStats::default()), @@ -399,18 +411,37 @@ mod tests { ServerZoneIpcType::PlayerSpawn, ServerZoneIpcData::PlayerSpawn(PlayerSpawn::default()), ), + ( + ServerZoneIpcType::LogOutComplete, + ServerZoneIpcData::LogOutComplete { unk: [0; 8] }, + ), ( ServerZoneIpcType::ActorSetPos, ServerZoneIpcData::ActorSetPos(ActorSetPos::default()), ), ( - ServerZoneIpcType::NpcSpawn, - ServerZoneIpcData::NpcSpawn(NpcSpawn::default()), + ServerZoneIpcType::ServerChatMessage, + ServerZoneIpcData::ServerChatMessage { + unk: 0, + message: String::new(), + }, + ), + ( + ServerZoneIpcType::PrepareZoning, + ServerZoneIpcData::PrepareZoning { unk: [0; 4] }, ), ( ServerZoneIpcType::ActorControl, ServerZoneIpcData::ActorControl(ActorControl::default()), ), + ( + ServerZoneIpcType::ActorMove, + ServerZoneIpcData::ActorMove(ActorMove::default()), + ), + ( + ServerZoneIpcType::NpcSpawn, + ServerZoneIpcData::NpcSpawn(NpcSpawn::default()), + ), ( ServerZoneIpcType::StatusEffectList, ServerZoneIpcData::StatusEffectList(StatusEffectList::default()), @@ -419,10 +450,6 @@ mod tests { ServerZoneIpcType::WeatherChange, ServerZoneIpcData::WeatherChange(WeatherChange::default()), ), - ( - ServerZoneIpcType::ActorControl, - ServerZoneIpcData::ActorControl(ActorControl::default()), - ), ( ServerZoneIpcType::ItemInfo, ServerZoneIpcData::ItemInfo(ItemInfo::default()), @@ -440,12 +467,16 @@ mod tests { ServerZoneIpcData::EventStart(EventStart::default()), ), ( - ServerZoneIpcType::ActionResult, - ServerZoneIpcData::ActionResult(ActionResult::default()), + ServerZoneIpcType::UpdateHpMpTp, + ServerZoneIpcData::UpdateHpMpTp { + hp: 0, + mp: 0, + unk: 0, + }, ), ( - ServerZoneIpcType::ActorMove, - ServerZoneIpcData::ActorMove(ActorMove::default()), + ServerZoneIpcType::ActionResult, + ServerZoneIpcData::ActionResult(ActionResult::default()), ), ];