From e5672e91f20200d78a430e1c85b4323e1c0c51e4 Mon Sep 17 00:00:00 2001 From: Joshua Goins Date: Fri, 18 Apr 2025 13:20:25 -0400 Subject: [PATCH] Show the currently equipped weapon on your character Oops, I was turning u64 model ids into u16 and then changing it to either a u32/u16. That's stupid, but now it's fixed and we can display weapons! --- src/common/gamedata.rs | 4 ++-- src/world/connection.rs | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/common/gamedata.rs b/src/common/gamedata.rs index 983a838..f8579bd 100644 --- a/src/common/gamedata.rs +++ b/src/common/gamedata.rs @@ -107,7 +107,7 @@ impl GameData { } /// Gets the primary model ID for a given item ID - pub fn get_primary_model_id(&mut self, item_id: u32) -> Option { + pub fn get_primary_model_id(&mut self, item_id: u32) -> Option { for page in &self.item_pages { if let Some(row) = page.read_row(&self.item_exh, item_id) { let item_row = &row[0]; @@ -116,7 +116,7 @@ impl GameData { panic!("Unexpected type!"); }; - return Some(*id as u16); + return Some(*id); } } diff --git a/src/world/connection.rs b/src/world/connection.rs index 3808ceb..141ddba 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -621,7 +621,9 @@ impl ZoneConnection { op_code: ServerZoneIpcType::Equip, timestamp: timestamp_secs(), data: ServerZoneIpcData::Equip(Equip { - main_weapon_id: 0, + main_weapon_id: game_data + .get_primary_model_id(equipped.main_hand.id) + .unwrap_or(0), sub_weapon_id: 0, crest_enable: 0, pattern_invalid: 0, @@ -797,6 +799,9 @@ impl ZoneConnection { object_kind: ObjectKind::Player(PlayerSubKind::Player), look: chara_details.chara_make.customize, display_flags: DisplayFlag::UNK, + main_weapon_model: game_data + .get_primary_model_id(equipped.main_hand.id) + .unwrap_or(0), models: [ game_data .get_primary_model_id(equipped.head.id)