mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-17 10:47:44 +00:00
Skip sending empty UpdateItems on first login
There's no reason to do this, the client has no pre-existing inventory state so we're just wasting bytes.
This commit is contained in:
parent
cca0f8c0e5
commit
c0daf7b06b
3 changed files with 19 additions and 9 deletions
|
@ -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 {
|
||||
|
|
|
@ -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" => {
|
||||
|
|
|
@ -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];
|
||||
|
|
Loading…
Add table
Reference in a new issue