diff --git a/src/common/serverstate.rs b/src/common/serverstate.rs index ba9caa6..4d272ce 100644 --- a/src/common/serverstate.rs +++ b/src/common/serverstate.rs @@ -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 { diff --git a/src/entity/character.rs b/src/entity/character.rs index 7c1572e..d6d4e3c 100644 --- a/src/entity/character.rs +++ b/src/entity/character.rs @@ -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)] diff --git a/src/entity/item/mod.rs b/src/entity/item/mod.rs index 611c579..ff722dd 100644 --- a/src/entity/item/mod.rs +++ b/src/entity/item/mod.rs @@ -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); diff --git a/src/ship/items/manager.rs b/src/ship/items/manager.rs index f669309..143fd26 100644 --- a/src/ship/items/manager.rs +++ b/src/ship/items/manager.rs @@ -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), ItemTransactionAction(Box), + #[error("invalid trade")] InvalidTrade, } diff --git a/src/ship/items/mod.rs b/src/ship/items/mod.rs index 7a259ae..37de948 100644 --- a/src/ship/items/mod.rs +++ b/src/ship/items/mod.rs @@ -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 diff --git a/src/ship/location.rs b/src/ship/location.rs index a40f858..efba55f 100644 --- a/src/ship/location.rs +++ b/src/ship/location.rs @@ -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), diff --git a/src/ship/ship.rs b/src/ship/ship.rs index 0b97463..6ee71fe 100644 --- a/src/ship/ship.rs +++ b/src/ship/ship.rs @@ -42,11 +42,12 @@ pub type Rooms = [Option; MAX_ROOMS]; pub type Clients = HashMap; #[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), } diff --git a/src/ship/trade.rs b/src/ship/trade.rs index eb88edc..a3a3b0a 100644 --- a/src/ship/trade.rs +++ b/src/ship/trade.rs @@ -102,7 +102,7 @@ pub enum TradeStateError { MismatchedTrade(ClientId, ClientId), } -#[derive(Default)] +#[derive(Default, Debug)] pub struct TradeState { trades: HashMap>, }