|
|
@ -6,7 +6,7 @@ use crate::common::serverstate::ClientId; |
|
|
|
use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms, ItemShops};
|
|
|
|
use crate::ship::location::{ClientLocation, ClientLocationError};
|
|
|
|
use crate::ship::drops::ItemDrop;
|
|
|
|
use crate::ship::items::{ItemManager, ClientItemId, TriggerCreateItem, FloorItem};
|
|
|
|
use crate::ship::items::{ItemManager, ClientItemId, TriggerCreateItem, FloorItem, FloorType};
|
|
|
|
use crate::entity::gateway::EntityGateway;
|
|
|
|
use libpso::utf8_to_utf16_array;
|
|
|
|
use crate::ship::packet::builder;
|
|
|
@ -124,7 +124,7 @@ where |
|
|
|
let clients_in_area = client_location.get_clients_in_room(room_id).map_err(|err| -> ClientLocationError { err.into() })?;
|
|
|
|
|
|
|
|
// TODO: should not need to fetch the item here to construct this packet
|
|
|
|
let item = item_manager.get_floor_item_by_id(&client.character, ClientItemId(pickup_item.item_id))?;
|
|
|
|
let (item, floor_type) = item_manager.get_floor_item_by_id(&client.character, ClientItemId(pickup_item.item_id))?;
|
|
|
|
let remove_item = builder::message::remove_item_from_floor(area_client, &item)?;
|
|
|
|
let create_item = match item {
|
|
|
|
FloorItem::Meseta(_) => None,
|
|
|
@ -133,11 +133,19 @@ where |
|
|
|
|
|
|
|
match item_manager.character_picks_up_item(entity_gateway, &mut client.character, ClientItemId(pickup_item.item_id)).await {
|
|
|
|
Ok(trigger_create_item) => {
|
|
|
|
Ok(Box::new(Vec::new().into_iter()
|
|
|
|
.chain(clients_in_area.clone().into_iter()
|
|
|
|
.map(move |c| {
|
|
|
|
(c.client, SendShipPacket::Message(Message::new(GameMessage::RemoveItemFromFloor(remove_item.clone()))))
|
|
|
|
}))
|
|
|
|
let remove_packets: Box<dyn Iterator<Item=(ClientId, SendShipPacket)> + Send> = match floor_type {
|
|
|
|
FloorType::Local => {
|
|
|
|
Box::new(vec![(id, SendShipPacket::Message(Message::new(GameMessage::RemoveItemFromFloor(remove_item.clone()))))].into_iter())
|
|
|
|
},
|
|
|
|
FloorType::Shared => {
|
|
|
|
Box::new(clients_in_area.clone().into_iter()
|
|
|
|
.map(move |c| {
|
|
|
|
(c.client, SendShipPacket::Message(Message::new(GameMessage::RemoveItemFromFloor(remove_item.clone()))))
|
|
|
|
}))
|
|
|
|
},
|
|
|
|
};
|
|
|
|
|
|
|
|
Ok(Box::new(remove_packets
|
|
|
|
.chain(clients_in_area.into_iter().
|
|
|
|
filter_map(move |c| {
|
|
|
|
match trigger_create_item {
|
|
|
@ -145,8 +153,7 @@ where |
|
|
|
_ => None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
)))
|
|
|
|
)
|
|
|
|
))))
|
|
|
|
},
|
|
|
|
Err(err) => {
|
|
|
|
warn!("character {:?} could not pick up item: {:?}", client.character.id, err);
|
|
|
|