Browse Source

create_item takes generic item rather than floor item

pbs
jake 4 years ago
parent
commit
b6ce6296d4
  1. 5
      src/ship/packet/builder/message.rs
  2. 4
      src/ship/packet/handler/direct_message.rs

5
src/ship/packet/builder/message.rs

@ -1,5 +1,6 @@
use libpso::packet::messages::*;
use libpso::packet::ship::*;
use crate::entity::item;
use crate::common::leveltable::CharacterStats;
use crate::ship::ship::{ShipError};
use crate::ship::items::{ClientItemId, InventoryItem, StackedFloorItem, FloorItem, CharacterBank};
@ -26,13 +27,13 @@ pub fn item_drop(client: u8, target: u8, item_drop: &FloorItem) -> Result<ItemDr
})
}
pub fn create_item(area_client: AreaClient, item: &FloorItem) -> Result<CreateItem, ShipError> {
pub fn create_item(area_client: AreaClient, item_id: ClientItemId, item: &item::ItemDetail) -> Result<CreateItem, ShipError> {
let bytes = item.as_client_bytes();
Ok(CreateItem {
client: area_client.local_client.id(),
target: 0,
item_data: bytes[0..12].try_into()?,
item_id: item.item_id().0,
item_id: item_id.0,
item_data2: bytes[12..16].try_into()?,
unknown: 0,
})

4
src/ship/packet/handler/direct_message.rs

@ -127,8 +127,10 @@ where
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::Individual(individual_floor_item) => Some(builder::message::create_item(area_client, item.item_id(), &individual_floor_item.item)?),
FloorItem::Stacked(stacked_floor_item) => Some(builder::message::create_item(area_client, item.item_id(), &item::ItemDetail::Tool(stacked_floor_item.tool))?),
FloorItem::Meseta(_) => None,
_ => Some(builder::message::create_item(area_client, &item)?),
//_ => Some(builder::message::create_item(area_client, &item)?),
};
match item_manager.character_picks_up_item(entity_gateway, &mut client.character, ClientItemId(pickup_item.item_id)).await {

Loading…
Cancel
Save