diff --git a/src/bin/kawari-world.rs b/src/bin/kawari-world.rs index edf475c..6a981bb 100644 --- a/src/bin/kawari-world.rs +++ b/src/bin/kawari-world.rs @@ -259,7 +259,7 @@ async fn client_loop( database.find_chara_make(connection.player_data.content_id); // Send inventory - connection.send_inventory(false).await; + connection.send_inventory(false, true).await; // set chara gear param connection @@ -347,7 +347,7 @@ async fn client_loop( let chara_details = database.find_chara_make(connection.player_data.content_id); - connection.send_inventory(false).await; + connection.send_inventory(false, false).await; connection.send_stats(&chara_details).await; let online_status = if connection.player_data.gm_rank == GameMasterRank::NormalUser { @@ -884,7 +884,7 @@ async fn client_loop( // TODO: send the proper response packets! connection.player_data.inventory.currency.gil.quantity -= item_info.price_mid; connection.player_data.inventory.add_in_next_free_slot(Item::new(1, item_info.id)); - connection.send_inventory(false).await; + connection.send_inventory(false, false).await; // TODO: send an actual system notice, this is just a placeholder to provide feedback that the player actually bought something. connection.send_message(&format!("You obtained one or more items: {} (id: {})!", item_info.name, item_info.id)).await; } else { diff --git a/src/world/chat_handler.rs b/src/world/chat_handler.rs index 22e92fd..7d4dadc 100644 --- a/src/world/chat_handler.rs +++ b/src/world/chat_handler.rs @@ -74,7 +74,7 @@ impl ChatHandler { } } - connection.send_inventory(true).await; + connection.send_inventory(true, false).await; true } "!item" => { @@ -93,7 +93,7 @@ impl ChatHandler { } } - connection.send_inventory(false).await; + connection.send_inventory(false, false).await; true } "!reload" => { diff --git a/src/world/connection.rs b/src/world/connection.rs index 7a4778d..330e8cd 100644 --- a/src/world/connection.rs +++ b/src/world/connection.rs @@ -518,7 +518,7 @@ impl ZoneConnection { self.spawn_index } - pub async fn send_inventory(&mut self, send_appearance_update: bool) { + pub async fn send_inventory(&mut self, send_appearance_update: bool, first_update: bool) { for (sequence, (container_type, container)) in (&self.player_data.inventory.clone()) .into_iter() .enumerate() @@ -526,6 +526,11 @@ impl ZoneConnection { // currencies if container_type == ContainerType::Currency { let mut send_currency = async |item: &Item| { + // skip telling the client what they don't have + if item.quantity == 0 && first_update { + return; + } + let ipc = ServerZoneIpcSegment { op_code: ServerZoneIpcType::CurrencyCrystalInfo, timestamp: timestamp_secs(), @@ -556,6 +561,11 @@ impl ZoneConnection { // items let mut send_slot = async |slot_index: u16, item: &Item| { + // skip telling the client what they don't have + if item.quantity == 0 && first_update { + return; + } + let ipc = ServerZoneIpcSegment { op_code: ServerZoneIpcType::UpdateItem, timestamp: timestamp_secs(), @@ -783,11 +793,11 @@ impl ZoneConnection { } Task::AddGil { amount } => { self.player_data.inventory.currency.get_slot_mut(0).quantity += *amount; - self.send_inventory(false).await; + self.send_inventory(false, false).await; } Task::RemoveGil { amount } => { self.player_data.inventory.currency.get_slot_mut(0).quantity -= *amount; - self.send_inventory(false).await; + self.send_inventory(false, false).await; } Task::UnlockOrchestrion { id, on } => { // id == 0 means "all" @@ -815,7 +825,7 @@ impl ZoneConnection { self.player_data .inventory .add_in_next_free_slot(Item::new(1, *id)); - self.send_inventory(false).await; + self.send_inventory(false, false).await; } Task::CompleteAllQuests {} => { self.player_data.completed_quests = vec![0xFF; COMPLETED_QUEST_BITMASK_SIZE];