|
@ -6,7 +6,7 @@ use libpso::packet::ship::*; |
|
|
use libpso::packet::messages::*;
|
|
|
use libpso::packet::messages::*;
|
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
use crate::common::leveltable::CharacterLevelTable;
|
|
|
use crate::common::serverstate::ClientId;
|
|
|
use crate::common::serverstate::ClientId;
|
|
|
use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms, ItemShops, TradeItem};
|
|
|
|
|
|
|
|
|
use crate::ship::ship::{SendShipPacket, ShipError, Clients, Rooms, ItemShops, TradeItem, TradeState, TradeStatus};
|
|
|
use crate::ship::location::{ClientLocation, ClientLocationError};
|
|
|
use crate::ship::location::{ClientLocation, ClientLocationError};
|
|
|
use crate::ship::drops::ItemDrop;
|
|
|
use crate::ship::drops::ItemDrop;
|
|
|
use crate::ship::items::{ItemManager, ItemManagerError, ClientItemId, TriggerCreateItem, FloorItem, FloorType};
|
|
|
use crate::ship::items::{ItemManager, ItemManagerError, ClientItemId, TriggerCreateItem, FloorItem, FloorType};
|
|
@ -86,7 +86,11 @@ where |
|
|
.collect::<Result<Vec<_>, anyhow::Error>>()?;
|
|
|
.collect::<Result<Vec<_>, anyhow::Error>>()?;
|
|
|
|
|
|
|
|
|
// TODO: check room in inventory for items
|
|
|
// TODO: check room in inventory for items
|
|
|
client.trade = Some((trade_partner.client, trade_items));
|
|
|
|
|
|
|
|
|
client.trade = Some(TradeState {
|
|
|
|
|
|
other_client: trade_partner.client,
|
|
|
|
|
|
items: trade_items,
|
|
|
|
|
|
status: TradeStatus::Unconfirmed
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
Ok(Box::new(vec![(trade_partner.client, SendShipPacket::AcknowledgeTrade(AcknowledgeTrade {}))].into_iter()))
|
|
|
Ok(Box::new(vec![(trade_partner.client, SendShipPacket::AcknowledgeTrade(AcknowledgeTrade {}))].into_iter()))
|
|
|
}
|
|
|
}
|
|
@ -107,8 +111,8 @@ where |
|
|
Err(err) => {
|
|
|
Err(err) => {
|
|
|
let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let client = clients.get(&id).ok_or(ShipError::ClientNotFound(id))?;
|
|
|
let trade_partner = client.trade.as_ref()
|
|
|
let trade_partner = client.trade.as_ref()
|
|
|
.and_then(|(trade_partner, _)| {
|
|
|
|
|
|
client_location.get_local_client(*trade_partner).ok()
|
|
|
|
|
|
|
|
|
.and_then(|trade_state| {
|
|
|
|
|
|
client_location.get_local_client(trade_state.other_client).ok()
|
|
|
})
|
|
|
})
|
|
|
.map(|trade_partner| {
|
|
|
.map(|trade_partner| {
|
|
|
(trade_partner.client, SendShipPacket::CancelTrade(CancelTrade {}))
|
|
|
(trade_partner.client, SendShipPacket::CancelTrade(CancelTrade {}))
|
|
|