mirror of
https://github.com/redstrate/Kawari.git
synced 2025-07-17 18:47:46 +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);
|
database.find_chara_make(connection.player_data.content_id);
|
||||||
|
|
||||||
// Send inventory
|
// Send inventory
|
||||||
connection.send_inventory(false).await;
|
connection.send_inventory(false, true).await;
|
||||||
|
|
||||||
// set chara gear param
|
// set chara gear param
|
||||||
connection
|
connection
|
||||||
|
@ -347,7 +347,7 @@ async fn client_loop(
|
||||||
|
|
||||||
let chara_details = database.find_chara_make(connection.player_data.content_id);
|
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;
|
connection.send_stats(&chara_details).await;
|
||||||
|
|
||||||
let online_status = if connection.player_data.gm_rank == GameMasterRank::NormalUser {
|
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!
|
// TODO: send the proper response packets!
|
||||||
connection.player_data.inventory.currency.gil.quantity -= item_info.price_mid;
|
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.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.
|
// 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;
|
connection.send_message(&format!("You obtained one or more items: {} (id: {})!", item_info.name, item_info.id)).await;
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -74,7 +74,7 @@ impl ChatHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.send_inventory(true).await;
|
connection.send_inventory(true, false).await;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
"!item" => {
|
"!item" => {
|
||||||
|
@ -93,7 +93,7 @@ impl ChatHandler {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
connection.send_inventory(false).await;
|
connection.send_inventory(false, false).await;
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
"!reload" => {
|
"!reload" => {
|
||||||
|
|
|
@ -518,7 +518,7 @@ impl ZoneConnection {
|
||||||
self.spawn_index
|
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())
|
for (sequence, (container_type, container)) in (&self.player_data.inventory.clone())
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.enumerate()
|
.enumerate()
|
||||||
|
@ -526,6 +526,11 @@ impl ZoneConnection {
|
||||||
// currencies
|
// currencies
|
||||||
if container_type == ContainerType::Currency {
|
if container_type == ContainerType::Currency {
|
||||||
let mut send_currency = async |item: &Item| {
|
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 {
|
let ipc = ServerZoneIpcSegment {
|
||||||
op_code: ServerZoneIpcType::CurrencyCrystalInfo,
|
op_code: ServerZoneIpcType::CurrencyCrystalInfo,
|
||||||
timestamp: timestamp_secs(),
|
timestamp: timestamp_secs(),
|
||||||
|
@ -556,6 +561,11 @@ impl ZoneConnection {
|
||||||
// items
|
// items
|
||||||
|
|
||||||
let mut send_slot = async |slot_index: u16, item: &Item| {
|
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 {
|
let ipc = ServerZoneIpcSegment {
|
||||||
op_code: ServerZoneIpcType::UpdateItem,
|
op_code: ServerZoneIpcType::UpdateItem,
|
||||||
timestamp: timestamp_secs(),
|
timestamp: timestamp_secs(),
|
||||||
|
@ -783,11 +793,11 @@ impl ZoneConnection {
|
||||||
}
|
}
|
||||||
Task::AddGil { amount } => {
|
Task::AddGil { amount } => {
|
||||||
self.player_data.inventory.currency.get_slot_mut(0).quantity += *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 } => {
|
Task::RemoveGil { amount } => {
|
||||||
self.player_data.inventory.currency.get_slot_mut(0).quantity -= *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 } => {
|
Task::UnlockOrchestrion { id, on } => {
|
||||||
// id == 0 means "all"
|
// id == 0 means "all"
|
||||||
|
@ -815,7 +825,7 @@ impl ZoneConnection {
|
||||||
self.player_data
|
self.player_data
|
||||||
.inventory
|
.inventory
|
||||||
.add_in_next_free_slot(Item::new(1, *id));
|
.add_in_next_free_slot(Item::new(1, *id));
|
||||||
self.send_inventory(false).await;
|
self.send_inventory(false, false).await;
|
||||||
}
|
}
|
||||||
Task::CompleteAllQuests {} => {
|
Task::CompleteAllQuests {} => {
|
||||||
self.player_data.completed_quests = vec![0xFF; COMPLETED_QUEST_BITMASK_SIZE];
|
self.player_data.completed_quests = vec![0xFF; COMPLETED_QUEST_BITMASK_SIZE];
|
||||||
|
|
Loading…
Add table
Reference in a new issue