From 78013985901bb100cdaf52219005ae202d369a57 Mon Sep 17 00:00:00 2001 From: The Dax Date: Fri, 4 Jul 2025 13:10:12 -0400 Subject: [PATCH] Fix a small issue with the !equip command -It wasn't setting the item's condition, causing the game UI to behave strangely when looking at the item's tooltip -Added a constant for the maximum item durability --- src/inventory/item.rs | 3 ++- src/lib.rs | 3 +++ src/world/chat_handler.rs | 18 ++++++------------ 3 files changed, 11 insertions(+), 13 deletions(-) diff --git a/src/inventory/item.rs b/src/inventory/item.rs index 5c8f83f..5c4b35a 100644 --- a/src/inventory/item.rs +++ b/src/inventory/item.rs @@ -1,3 +1,4 @@ +use crate::ITEM_CONDITION_MAX; use serde::{Deserialize, Serialize}; /// Represents an item, or if the quanity is zero an empty slot. @@ -14,7 +15,7 @@ impl Item { Self { quantity, id, - condition: 30000, + condition: ITEM_CONDITION_MAX, ..Default::default() } } diff --git a/src/lib.rs b/src/lib.rs index 1b3104f..c48488d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -76,6 +76,9 @@ pub const AETHERYTE_UNLOCK_BITMASK_SIZE: usize = 30; /// The size of the completed quest bitmask. pub const COMPLETED_QUEST_BITMASK_SIZE: usize = 691; +/// The maximum durability of an item. +pub const ITEM_CONDITION_MAX: u16 = 30000; + /// The operation opcode/type when discarding an item from the inventory. pub const INVENTORY_ACTION_DISCARD: u8 = 145; diff --git a/src/world/chat_handler.rs b/src/world/chat_handler.rs index 3f74f07..22e92fd 100644 --- a/src/world/chat_handler.rs +++ b/src/world/chat_handler.rs @@ -1,4 +1,5 @@ use crate::{ + ITEM_CONDITION_MAX, common::ItemInfoQuery, inventory::{Item, Storage}, ipc::zone::{ChatMessage, GameMasterRank}, @@ -65,18 +66,11 @@ impl ChatHandler { .get_equipslot_category(item_info.equip_category) .unwrap(); - connection - .player_data - .inventory - .equipped - .get_slot_mut(slot) - .id = item_info.id; - connection - .player_data - .inventory - .equipped - .get_slot_mut(slot) - .quantity = 1; + let slot = connection.player_data.inventory.equipped.get_slot_mut(slot); + + slot.id = item_info.id; + slot.quantity = 1; + slot.condition = ITEM_CONDITION_MAX; } }