From 3a10de502ae0019ef73758e4066dec8ca4bac0b7 Mon Sep 17 00:00:00 2001 From: jake Date: Sun, 12 Dec 2021 22:33:58 -0700 Subject: [PATCH] tell other players you don't have meseta when you drop it --- src/ship/packet/builder/message.rs | 9 +++++++++ src/ship/packet/handler/message.rs | 17 +++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/ship/packet/builder/message.rs b/src/ship/packet/builder/message.rs index 01c434c..1361b1d 100644 --- a/src/ship/packet/builder/message.rs +++ b/src/ship/packet/builder/message.rs @@ -156,6 +156,15 @@ pub fn player_no_longer_has_item(area_client: AreaClient, item_id: ClientItemId, } } +pub fn player_no_longer_has_meseta(area_client: AreaClient, amount: u32) -> PlayerNoLongerHasItem { + PlayerNoLongerHasItem { + client: area_client.local_client.id(), + target: 0, + item_id: 0xFFFFFFFF, + amount, + } +} + pub fn shop_list(shop_type: u8, items: &[I]) -> ShopList { let items = items.iter() .enumerate() diff --git a/src/ship/packet/handler/message.rs b/src/ship/packet/handler/message.rs index 39d3717..882c3e0 100644 --- a/src/ship/packet/handler/message.rs +++ b/src/ship/packet/handler/message.rs @@ -135,13 +135,26 @@ where let dropped_meseta = item_manager.player_drops_meseta_on_shared_floor(entity_gateway, &mut client.character, drop_location, no_longer_has_item.amount as u32).await?; let dropped_meseta_pkt = builder::message::drop_split_meseta_stack(area_client, &dropped_meseta)?; + let no_longer_has_meseta_pkt = builder::message::player_no_longer_has_meseta(area_client, no_longer_has_item.amount as u32); client.item_drop_location = None; let clients_in_area = client_location.get_clients_in_room(room_id).map_err(|err| -> ClientLocationError { err.into() })?; Ok(Box::new(clients_in_area.into_iter() .map(move |c| { - (c.client, SendShipPacket::Message(Message::new(GameMessage::DropSplitStack(dropped_meseta_pkt.clone())))) - }))) + std::iter::once((c.client, SendShipPacket::Message(Message::new(GameMessage::DropSplitStack(dropped_meseta_pkt.clone()))))) + .chain( + if c.client != id { + Box::new(std::iter::once( + (c.client, SendShipPacket::Message(Message::new(GameMessage::PlayerNoLongerHasItem(no_longer_has_meseta_pkt.clone())))) + )) as Box + Send> + } + else { + Box::new(std::iter::empty()) as Box + Send> + } + ) + }) + .flatten() + )) } else { let dropped_item = item_manager.player_drops_partial_stack_on_shared_floor(entity_gateway, &client.character, drop_location.item_id, drop_location, no_longer_has_item.amount as usize).await?;