parent
3b7dcd0295
commit
6d2753d082
src
@ -1,7 +1,7 @@
|
|||||||
use libpso::PacketParseError;
|
use libpso::PacketParseError;
|
||||||
use libpso::crypto::PSOCipher;
|
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 struct ClientId(pub usize);
|
||||||
|
|
||||||
pub enum OnConnect<S: SendServerPacket> {
|
pub enum OnConnect<S: SendServerPacket> {
|
||||||
|
@ -272,7 +272,7 @@ pub struct CharacterMaterials {
|
|||||||
pub tp: u32,
|
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);
|
pub struct CharacterEntityId(pub u32);
|
||||||
|
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
|
@ -17,7 +17,7 @@ use crate::ship::drops::ItemDropType;
|
|||||||
pub struct ItemEntityId(pub u32);
|
pub struct ItemEntityId(pub u32);
|
||||||
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
#[derive(Hash, PartialEq, Eq, Debug, Clone)]
|
||||||
pub struct ItemId(u32);
|
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);
|
pub struct BankName(pub String);
|
||||||
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord, Serialize, Deserialize)]
|
||||||
pub struct TradeId(pub u32);
|
pub struct TradeId(pub u32);
|
||||||
|
@ -34,33 +34,46 @@ pub enum TriggerCreateItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[error("")]
|
#[error("itemmanager")]
|
||||||
pub enum ItemManagerError {
|
pub enum ItemManagerError {
|
||||||
|
#[error("gateway")]
|
||||||
EntityGatewayError,
|
EntityGatewayError,
|
||||||
|
#[error("no such item id {0}")]
|
||||||
NoSuchItemId(ClientItemId),
|
NoSuchItemId(ClientItemId),
|
||||||
NoCharacter(CharacterEntityId),
|
NoCharacter(CharacterEntityId),
|
||||||
NoRoom(RoomId),
|
NoRoom(RoomId),
|
||||||
CouldNotAddToInventory(ClientItemId),
|
CouldNotAddToInventory(ClientItemId),
|
||||||
//ItemBelongsToOtherPlayer,
|
//ItemBelongsToOtherPlayer,
|
||||||
|
#[error("shrug")]
|
||||||
Idunnoman,
|
Idunnoman,
|
||||||
CouldNotSplitItem(ClientItemId),
|
CouldNotSplitItem(ClientItemId),
|
||||||
|
#[error("could not drop meseta")]
|
||||||
CouldNotDropMeseta,
|
CouldNotDropMeseta,
|
||||||
InvalidBankName(BankName),
|
InvalidBankName(BankName),
|
||||||
|
#[error("not enough tools")]
|
||||||
NotEnoughTools(Tool, usize, usize), // have, expected
|
NotEnoughTools(Tool, usize, usize), // have, expected
|
||||||
InventoryItemConsumeError(#[from] InventoryItemConsumeError),
|
InventoryItemConsumeError(#[from] InventoryItemConsumeError),
|
||||||
|
#[error("bank full")]
|
||||||
BankFull,
|
BankFull,
|
||||||
WrongItemType(ClientItemId),
|
WrongItemType(ClientItemId),
|
||||||
UseItemError(#[from] use_tool::UseItemError),
|
UseItemError(#[from] use_tool::UseItemError),
|
||||||
|
#[error("could not buy item")]
|
||||||
CouldNotBuyItem,
|
CouldNotBuyItem,
|
||||||
|
#[error("could not add bought item to inventory")]
|
||||||
CouldNotAddBoughtItemToInventory,
|
CouldNotAddBoughtItemToInventory,
|
||||||
ItemIdNotInInventory(ClientItemId),
|
ItemIdNotInInventory(ClientItemId),
|
||||||
|
#[error("cannot get mut item")]
|
||||||
CannotGetMutItem,
|
CannotGetMutItem,
|
||||||
|
#[error("cannot get individual item")]
|
||||||
CannotGetIndividualItem,
|
CannotGetIndividualItem,
|
||||||
InvalidSlot(u8, u8), // slots available, slot attempted
|
InvalidSlot(u8, u8), // slots available, slot attempted
|
||||||
|
#[error("no armor equipped")]
|
||||||
NoArmorEquipped,
|
NoArmorEquipped,
|
||||||
GatewayError(#[from] GatewayError),
|
GatewayError(#[from] GatewayError),
|
||||||
|
#[error("stacked item")]
|
||||||
StackedItemError(Vec<ItemEntity>),
|
StackedItemError(Vec<ItemEntity>),
|
||||||
ItemTransactionAction(Box<dyn std::error::Error + Send + Sync>),
|
ItemTransactionAction(Box<dyn std::error::Error + Send + Sync>),
|
||||||
|
#[error("invalid trade")]
|
||||||
InvalidTrade,
|
InvalidTrade,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ mod transaction;
|
|||||||
pub mod use_tool;
|
pub mod use_tool;
|
||||||
use serde::{Serialize, Deserialize};
|
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);
|
pub struct ClientItemId(pub u32);
|
||||||
|
|
||||||
// TODO: remove these and fix use statements in the rest of the codebase
|
// 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)]
|
#[derive(Debug, Copy, Clone, PartialEq)]
|
||||||
pub struct LobbyId(pub usize);
|
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);
|
pub struct RoomId(pub usize);
|
||||||
|
|
||||||
impl LobbyId {
|
impl LobbyId {
|
||||||
@ -26,7 +26,7 @@ impl LobbyId {
|
|||||||
|
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("create room")]
|
||||||
pub enum CreateRoomError {
|
pub enum CreateRoomError {
|
||||||
NoOpenSlots,
|
NoOpenSlots,
|
||||||
ClientInAreaAlready,
|
ClientInAreaAlready,
|
||||||
@ -34,7 +34,7 @@ pub enum CreateRoomError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("join room")]
|
||||||
pub enum JoinRoomError {
|
pub enum JoinRoomError {
|
||||||
RoomDoesNotExist,
|
RoomDoesNotExist,
|
||||||
RoomFull,
|
RoomFull,
|
||||||
@ -42,7 +42,7 @@ pub enum JoinRoomError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("join lobby")]
|
||||||
pub enum JoinLobbyError {
|
pub enum JoinLobbyError {
|
||||||
LobbyDoesNotExist,
|
LobbyDoesNotExist,
|
||||||
LobbyFull,
|
LobbyFull,
|
||||||
@ -50,7 +50,7 @@ pub enum JoinLobbyError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("get area")]
|
||||||
pub enum GetAreaError {
|
pub enum GetAreaError {
|
||||||
NotInRoom,
|
NotInRoom,
|
||||||
NotInLobby,
|
NotInLobby,
|
||||||
@ -58,28 +58,28 @@ pub enum GetAreaError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("client removal")]
|
||||||
pub enum ClientRemovalError {
|
pub enum ClientRemovalError {
|
||||||
ClientNotInArea,
|
ClientNotInArea,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("get clients")]
|
||||||
pub enum GetClientsError {
|
pub enum GetClientsError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("get neighbor")]
|
||||||
pub enum GetNeighborError {
|
pub enum GetNeighborError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("get leader")]
|
||||||
pub enum GetLeaderError {
|
pub enum GetLeaderError {
|
||||||
InvalidClient,
|
InvalidClient,
|
||||||
InvalidArea,
|
InvalidArea,
|
||||||
@ -87,7 +87,7 @@ pub enum GetLeaderError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq)]
|
#[derive(Error, Debug, PartialEq)]
|
||||||
#[error("")]
|
#[error("clientlocation")]
|
||||||
pub enum ClientLocationError {
|
pub enum ClientLocationError {
|
||||||
CreateRoomError(#[from] CreateRoomError),
|
CreateRoomError(#[from] CreateRoomError),
|
||||||
JoinRoomError(#[from] JoinRoomError),
|
JoinRoomError(#[from] JoinRoomError),
|
||||||
|
@ -42,11 +42,12 @@ pub type Rooms = [Option<room::RoomState>; MAX_ROOMS];
|
|||||||
pub type Clients = HashMap<ClientId, ClientState>;
|
pub type Clients = HashMap<ClientId, ClientState>;
|
||||||
|
|
||||||
#[derive(Error, Debug)]
|
#[derive(Error, Debug)]
|
||||||
#[error("shiperror")]
|
#[error("shiperror {0:?}")]
|
||||||
pub enum ShipError {
|
pub enum ShipError {
|
||||||
ClientNotFound(ClientId),
|
ClientNotFound(ClientId),
|
||||||
NoCharacterInSlot(ClientId, u32),
|
NoCharacterInSlot(ClientId, u32),
|
||||||
InvalidSlot(ClientId, u32),
|
InvalidSlot(ClientId, u32),
|
||||||
|
#[error("")]
|
||||||
TooManyClients,
|
TooManyClients,
|
||||||
ClientLocationError(#[from] ClientLocationError),
|
ClientLocationError(#[from] ClientLocationError),
|
||||||
GetNeighborError(#[from] GetNeighborError),
|
GetNeighborError(#[from] GetNeighborError),
|
||||||
@ -57,10 +58,12 @@ pub enum ShipError {
|
|||||||
InvalidRoom(u32),
|
InvalidRoom(u32),
|
||||||
MonsterAlreadyDroppedItem(ClientId, u16),
|
MonsterAlreadyDroppedItem(ClientId, u16),
|
||||||
SliceError(#[from] std::array::TryFromSliceError),
|
SliceError(#[from] std::array::TryFromSliceError),
|
||||||
|
#[error("")]
|
||||||
ItemError, // TODO: refine this
|
ItemError, // TODO: refine this
|
||||||
PickUpInvalidItemId(u32),
|
PickUpInvalidItemId(u32),
|
||||||
DropInvalidItemId(u32),
|
DropInvalidItemId(u32),
|
||||||
ItemManagerError(#[from] items::ItemManagerError),
|
ItemManagerError(#[from] items::ItemManagerError),
|
||||||
|
#[error("")]
|
||||||
ItemDropLocationNotSet,
|
ItemDropLocationNotSet,
|
||||||
BoxAlreadyDroppedItem(ClientId, u16),
|
BoxAlreadyDroppedItem(ClientId, u16),
|
||||||
InvalidQuestCategory(u32),
|
InvalidQuestCategory(u32),
|
||||||
@ -68,12 +71,14 @@ pub enum ShipError {
|
|||||||
InvalidQuestFilename(String),
|
InvalidQuestFilename(String),
|
||||||
IoError(#[from] std::io::Error),
|
IoError(#[from] std::io::Error),
|
||||||
NotEnoughMeseta(ClientId, u32),
|
NotEnoughMeseta(ClientId, u32),
|
||||||
|
#[error("")]
|
||||||
ShopError,
|
ShopError,
|
||||||
GatewayError(#[from] GatewayError),
|
GatewayError(#[from] GatewayError),
|
||||||
UnknownMonster(crate::ship::monster::MonsterType),
|
UnknownMonster(crate::ship::monster::MonsterType),
|
||||||
InvalidShip(usize),
|
InvalidShip(usize),
|
||||||
InvalidBlock(usize),
|
InvalidBlock(usize),
|
||||||
InvalidItem(items::ClientItemId),
|
InvalidItem(items::ClientItemId),
|
||||||
|
#[error("tradeerror {0}")]
|
||||||
TradeError(#[from] crate::ship::packet::handler::trade::TradeError),
|
TradeError(#[from] crate::ship::packet::handler::trade::TradeError),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ pub enum TradeStateError {
|
|||||||
MismatchedTrade(ClientId, ClientId),
|
MismatchedTrade(ClientId, ClientId),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default, Debug)]
|
||||||
pub struct TradeState {
|
pub struct TradeState {
|
||||||
trades: HashMap<ClientId, RefCell<ClientTradeState>>,
|
trades: HashMap<ClientId, RefCell<ClientTradeState>>,
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user