diff --git a/src/inventory/currency.rs b/src/inventory/currency.rs index f30e8a3..fd88fc2 100644 --- a/src/inventory/currency.rs +++ b/src/inventory/currency.rs @@ -10,7 +10,7 @@ pub struct CurrencyStorage { impl Default for CurrencyStorage { fn default() -> Self { Self { - gil: Item { quantity: 0, id: 1 }, + gil: Item::new(0, 1), } } } diff --git a/src/inventory/item.rs b/src/inventory/item.rs index 0033187..5c8f83f 100644 --- a/src/inventory/item.rs +++ b/src/inventory/item.rs @@ -5,10 +5,25 @@ use serde::{Deserialize, Serialize}; pub struct Item { pub quantity: u32, pub id: u32, + pub condition: u16, + pub glamour_catalog_id: u32, } impl Item { pub fn new(quantity: u32, id: u32) -> Self { - Self { quantity, id } + Self { + quantity, + id, + condition: 30000, + ..Default::default() + } + } + + /// Returns the catalog ID of the glamour, if applicable. + pub fn apparent_id(&self) -> u32 { + if self.glamour_catalog_id > 0 { + return self.glamour_catalog_id; + } + self.id } } diff --git a/src/inventory/mod.rs b/src/inventory/mod.rs index 9029619..18e218e 100644 --- a/src/inventory/mod.rs +++ b/src/inventory/mod.rs @@ -258,41 +258,41 @@ impl Inventory { pub fn get_main_weapon_id(&self, game_data: &mut GameData) -> u64 { game_data - .get_primary_model_id(self.equipped.main_hand.id) + .get_primary_model_id(self.equipped.main_hand.apparent_id()) .unwrap_or(0) } pub fn get_model_ids(&self, game_data: &mut GameData) -> [u32; 10] { [ game_data - .get_primary_model_id(self.equipped.head.id) + .get_primary_model_id(self.equipped.head.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.body.id) + .get_primary_model_id(self.equipped.body.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.hands.id) + .get_primary_model_id(self.equipped.hands.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.legs.id) + .get_primary_model_id(self.equipped.legs.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.feet.id) + .get_primary_model_id(self.equipped.feet.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.ears.id) + .get_primary_model_id(self.equipped.ears.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.neck.id) + .get_primary_model_id(self.equipped.neck.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.wrists.id) + .get_primary_model_id(self.equipped.wrists.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.left_ring.id) + .get_primary_model_id(self.equipped.left_ring.apparent_id()) .unwrap_or(0) as u32, game_data - .get_primary_model_id(self.equipped.right_ring.id) + .get_primary_model_id(self.equipped.right_ring.apparent_id()) .unwrap_or(0) as u32, ] } diff --git a/src/world/chat_handler.rs b/src/world/chat_handler.rs index 9379c7a..102c633 100644 --- a/src/world/chat_handler.rs +++ b/src/world/chat_handler.rs @@ -88,7 +88,7 @@ impl ChatHandler { connection .player_data .inventory - .add_in_next_free_slot(Item { quantity: 1, id }); + .add_in_next_free_slot(Item::new(1, id)); } } diff --git a/src/world/connection.rs b/src/world/connection.rs index d178f56..8ca872b 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -524,7 +524,8 @@ impl ZoneConnection { slot: slot_index, quantity: item.quantity, catalog_id: item.id, - condition: 30000, + condition: item.condition, + glamour_catalog_id: item.glamour_catalog_id, ..Default::default() }), ..Default::default() @@ -768,10 +769,9 @@ impl ZoneConnection { } } Task::AddItem { id } => { - self.player_data.inventory.add_in_next_free_slot(Item { - id: *id, - quantity: 1, - }); + self.player_data + .inventory + .add_in_next_free_slot(Item::new(1, *id)); self.send_inventory(false).await; } } diff --git a/src/world/database.rs b/src/world/database.rs index beed42e..edf3d1e 100644 --- a/src/world/database.rs +++ b/src/world/database.rs @@ -86,7 +86,7 @@ impl WorldDatabase { struct InventoryItem { slot: i32, quantity: u32, - condition: i32, + condition: u16, id: u32, glamour_id: u32, } @@ -195,6 +195,8 @@ impl WorldDatabase { *target.get_slot_mut(item.slot as u16) = Item { quantity: item.quantity, id: item.id, + condition: item.condition, + glamour_catalog_id: item.glamour_id, }; } };