Compare commits
2 Commits
71ba3c3c3d
...
6d2753d082
Author | SHA1 | Date | |
---|---|---|---|
6d2753d082 | |||
3b7dcd0295 |
@ -1,7 +1,7 @@
|
||||
use libpso::PacketParseError;
|
||||
use libpso::crypto::PSOCipher;
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, derive_more::Display)]
|
||||
pub struct ClientId(pub usize);
|
||||
|
||||
pub enum OnConnect<S: SendServerPacket> {
|
||||
|
@ -272,7 +272,7 @@ pub struct CharacterMaterials {
|
||||
pub tp: u32,
|
||||
}
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize, Default, derive_more::Display)]
|
||||
pub struct CharacterEntityId(pub u32);
|
||||
|
||||
#[derive(Clone)]
|
||||
|
@ -17,7 +17,7 @@ use crate::ship::drops::ItemDropType;
|
||||
pub struct ItemEntityId(pub u32);
|
||||
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
||||
pub struct ItemId(u32);
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize, derive_more::Display)]
|
||||
pub struct BankName(pub String);
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||
pub struct TradeId(pub u32);
|
||||
|
@ -34,33 +34,46 @@ pub enum TriggerCreateItem {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("")]
|
||||
#[error("itemmanager")]
|
||||
pub enum ItemManagerError {
|
||||
#[error("gateway")]
|
||||
EntityGatewayError,
|
||||
#[error("no such item id {0}")]
|
||||
NoSuchItemId(ClientItemId),
|
||||
NoCharacter(CharacterEntityId),
|
||||
NoRoom(RoomId),
|
||||
CouldNotAddToInventory(ClientItemId),
|
||||
//ItemBelongsToOtherPlayer,
|
||||
#[error("shrug")]
|
||||
Idunnoman,
|
||||
CouldNotSplitItem(ClientItemId),
|
||||
#[error("could not drop meseta")]
|
||||
CouldNotDropMeseta,
|
||||
InvalidBankName(BankName),
|
||||
#[error("not enough tools")]
|
||||
NotEnoughTools(Tool, usize, usize), // have, expected
|
||||
InventoryItemConsumeError(#[from] InventoryItemConsumeError),
|
||||
#[error("bank full")]
|
||||
BankFull,
|
||||
WrongItemType(ClientItemId),
|
||||
UseItemError(#[from] use_tool::UseItemError),
|
||||
#[error("could not buy item")]
|
||||
CouldNotBuyItem,
|
||||
#[error("could not add bought item to inventory")]
|
||||
CouldNotAddBoughtItemToInventory,
|
||||
ItemIdNotInInventory(ClientItemId),
|
||||
#[error("cannot get mut item")]
|
||||
CannotGetMutItem,
|
||||
#[error("cannot get individual item")]
|
||||
CannotGetIndividualItem,
|
||||
InvalidSlot(u8, u8), // slots available, slot attempted
|
||||
#[error("no armor equipped")]
|
||||
NoArmorEquipped,
|
||||
GatewayError(#[from] GatewayError),
|
||||
#[error("stacked item")]
|
||||
StackedItemError(Vec<ItemEntity>),
|
||||
ItemTransactionAction(Box<dyn std::error::Error + Send + Sync>),
|
||||
#[error("invalid trade")]
|
||||
InvalidTrade,
|
||||
}
|
||||
|
||||
|
@ -6,7 +6,7 @@ mod transaction;
|
||||
pub mod use_tool;
|
||||
use serde::{Serialize, Deserialize};
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, Serialize, Deserialize, derive_more::Display)]
|
||||
pub struct ClientItemId(pub u32);
|
||||
|
||||
// TODO: remove these and fix use statements in the rest of the codebase
|
||||
|
@ -15,7 +15,7 @@ pub enum AreaType {
|
||||
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||
pub struct LobbyId(pub usize);
|
||||
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Copy, Clone, Hash, PartialEq, Eq, derive_more::Display)]
|
||||
pub struct RoomId(pub usize);
|
||||
|
||||
impl LobbyId {
|
||||
@ -26,7 +26,7 @@ impl LobbyId {
|
||||
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("create room")]
|
||||
pub enum CreateRoomError {
|
||||
NoOpenSlots,
|
||||
ClientInAreaAlready,
|
||||
@ -34,7 +34,7 @@ pub enum CreateRoomError {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("join room")]
|
||||
pub enum JoinRoomError {
|
||||
RoomDoesNotExist,
|
||||
RoomFull,
|
||||
@ -42,7 +42,7 @@ pub enum JoinRoomError {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("join lobby")]
|
||||
pub enum JoinLobbyError {
|
||||
LobbyDoesNotExist,
|
||||
LobbyFull,
|
||||
@ -50,7 +50,7 @@ pub enum JoinLobbyError {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("get area")]
|
||||
pub enum GetAreaError {
|
||||
NotInRoom,
|
||||
NotInLobby,
|
||||
@ -58,28 +58,28 @@ pub enum GetAreaError {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("client removal")]
|
||||
pub enum ClientRemovalError {
|
||||
ClientNotInArea,
|
||||
InvalidArea,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("get clients")]
|
||||
pub enum GetClientsError {
|
||||
InvalidClient,
|
||||
InvalidArea,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("get neighbor")]
|
||||
pub enum GetNeighborError {
|
||||
InvalidClient,
|
||||
InvalidArea,
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("get leader")]
|
||||
pub enum GetLeaderError {
|
||||
InvalidClient,
|
||||
InvalidArea,
|
||||
@ -87,7 +87,7 @@ pub enum GetLeaderError {
|
||||
}
|
||||
|
||||
#[derive(Error, Debug, PartialEq)]
|
||||
#[error("")]
|
||||
#[error("clientlocation")]
|
||||
pub enum ClientLocationError {
|
||||
CreateRoomError(#[from] CreateRoomError),
|
||||
JoinRoomError(#[from] JoinRoomError),
|
||||
|
@ -270,7 +270,6 @@ where
|
||||
{
|
||||
Ok(trades
|
||||
.with(&id, |this, other| -> Result<Box<dyn Iterator<Item = (ClientId, SendShipPacket)> + Send>, anyhow::Error> {
|
||||
println!("statuses {:?} {:?}", this.status, other.status);
|
||||
if status_is_not(&this.status, &[TradeStatus::FinalConfirm]) || status_is_not(&other.status, &[TradeStatus::FinalConfirm, TradeStatus::ItemsChecked]) {
|
||||
//if this.status != TradeStatus::FinalConfirm || (other.status != TradeStatus::FinalConfirm || other.status != TradeStatus::ItemsChecked) {
|
||||
return Err(TradeError::MismatchedStatus.into())
|
||||
@ -292,7 +291,6 @@ where
|
||||
.unwrap();
|
||||
match real_item {
|
||||
InventoryItem::Individual(individual_inventory_item) => {
|
||||
println!("real indiv item: {:?} {:?} ==? {:?}", real_item, real_item.as_client_bytes(), trade_item_bytes);
|
||||
if real_item.as_client_bytes() == trade_item_bytes {
|
||||
Ok(TradeItem::Individual(individual_inventory_item.item_id))
|
||||
}
|
||||
@ -301,7 +299,6 @@ where
|
||||
}
|
||||
},
|
||||
InventoryItem::Stacked(stacked_inventory_item) => {
|
||||
println!("real stack item: {:?} {:?} ==? {:?}", real_item, real_item.as_client_bytes(), trade_item_bytes);
|
||||
if real_item.as_client_bytes()[0..4] == trade_item_bytes[0..4] {
|
||||
let amount = trade_item_bytes[5] as usize;
|
||||
if amount <= stacked_inventory_item.entity_ids.len() {
|
||||
@ -323,7 +320,6 @@ where
|
||||
Ok(Box::new(std::iter::once((other.client(), SendShipPacket::AcknowledgeTrade(AcknowledgeTrade {})))))
|
||||
})?
|
||||
.unwrap_or_else(|err| {
|
||||
println!("asdf {:?}", err);
|
||||
log::warn!("trade error: {:?}", err);
|
||||
let (this, other) = trades.remove_trade(&id);
|
||||
Box::new(client_location.get_all_clients_by_client(id).unwrap().into_iter()
|
||||
@ -351,7 +347,6 @@ where
|
||||
Ok(p) => Ok(p),
|
||||
Err(err) => {
|
||||
log::warn!("atrade error: {:?}", err);
|
||||
println!("qwer");
|
||||
let (this, other) = trades.remove_trade(&id);
|
||||
Ok(Box::new(client_location.get_all_clients_by_client(id)?.into_iter()
|
||||
.filter(move |client| other.as_ref().map(|other| client.client == other.client()).unwrap_or_else(|| false))
|
||||
|
@ -42,11 +42,12 @@ pub type Rooms = [Option<room::RoomState>; MAX_ROOMS];
|
||||
pub type Clients = HashMap<ClientId, ClientState>;
|
||||
|
||||
#[derive(Error, Debug)]
|
||||
#[error("shiperror")]
|
||||
#[error("shiperror {0:?}")]
|
||||
pub enum ShipError {
|
||||
ClientNotFound(ClientId),
|
||||
NoCharacterInSlot(ClientId, u32),
|
||||
InvalidSlot(ClientId, u32),
|
||||
#[error("")]
|
||||
TooManyClients,
|
||||
ClientLocationError(#[from] ClientLocationError),
|
||||
GetNeighborError(#[from] GetNeighborError),
|
||||
@ -57,10 +58,12 @@ pub enum ShipError {
|
||||
InvalidRoom(u32),
|
||||
MonsterAlreadyDroppedItem(ClientId, u16),
|
||||
SliceError(#[from] std::array::TryFromSliceError),
|
||||
#[error("")]
|
||||
ItemError, // TODO: refine this
|
||||
PickUpInvalidItemId(u32),
|
||||
DropInvalidItemId(u32),
|
||||
ItemManagerError(#[from] items::ItemManagerError),
|
||||
#[error("")]
|
||||
ItemDropLocationNotSet,
|
||||
BoxAlreadyDroppedItem(ClientId, u16),
|
||||
InvalidQuestCategory(u32),
|
||||
@ -68,12 +71,14 @@ pub enum ShipError {
|
||||
InvalidQuestFilename(String),
|
||||
IoError(#[from] std::io::Error),
|
||||
NotEnoughMeseta(ClientId, u32),
|
||||
#[error("")]
|
||||
ShopError,
|
||||
GatewayError(#[from] GatewayError),
|
||||
UnknownMonster(crate::ship::monster::MonsterType),
|
||||
InvalidShip(usize),
|
||||
InvalidBlock(usize),
|
||||
InvalidItem(items::ClientItemId),
|
||||
#[error("tradeerror {0}")]
|
||||
TradeError(#[from] crate::ship::packet::handler::trade::TradeError),
|
||||
}
|
||||
|
||||
|
@ -102,7 +102,7 @@ pub enum TradeStateError {
|
||||
MismatchedTrade(ClientId, ClientId),
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
#[derive(Default, Debug)]
|
||||
pub struct TradeState {
|
||||
trades: HashMap<ClientId, RefCell<ClientTradeState>>,
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user