diff options
author | Andrei Karas <akaras@inbox.ru> | 2015-11-16 22:17:15 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2015-11-16 22:17:15 +0300 |
commit | 5e8e53f6e795a84ab5ca6cfe0d08672878044707 (patch) | |
tree | 23f5a196c6a288ef52cea2742b02ddbc52b2db61 /src/net | |
parent | 0c063cf5b45a843485fe3343e5fb79a40141f88c (diff) | |
download | manaplus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.gz manaplus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.bz2 manaplus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.tar.xz manaplus-5e8e53f6e795a84ab5ca6cfe0d08672878044707.zip |
Convert InventoryType enum into strong typed.
Diffstat (limited to 'src/net')
-rw-r--r-- | src/net/ea/inventoryhandler.cpp | 10 | ||||
-rw-r--r-- | src/net/ea/inventoryhandler.h | 3 | ||||
-rw-r--r-- | src/net/ea/inventoryrecv.cpp | 2 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.cpp | 24 | ||||
-rw-r--r-- | src/net/eathena/inventoryhandler.h | 6 | ||||
-rw-r--r-- | src/net/inventoryhandler.h | 10 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 16 | ||||
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 6 |
8 files changed, 41 insertions, 36 deletions
diff --git a/src/net/ea/inventoryhandler.cpp b/src/net/ea/inventoryhandler.cpp index 8d3ad6c9f..b1aa87020 100644 --- a/src/net/ea/inventoryhandler.cpp +++ b/src/net/ea/inventoryhandler.cpp @@ -81,18 +81,18 @@ void InventoryHandler::openStorage(const int type A_UNUSED) const // Doesn't apply to eAthena, since opening happens through NPCs? } -size_t InventoryHandler::getSize(const int type) const +size_t InventoryHandler::getSize(const InventoryTypeT type) const { switch (type) { - case InventoryType::INVENTORY: + case InventoryType::Inventory: return 100; - case InventoryType::STORAGE: + case InventoryType::Storage: return 0; // Comes from server after items - case InventoryType::TRADE: + case InventoryType::Trade: return 12; // GUILD_STORAGE - case InventoryType::TYPE_END: + case InventoryType::TypeEnd: return 0; // Comes from server after items default: return 0; diff --git a/src/net/ea/inventoryhandler.h b/src/net/ea/inventoryhandler.h index 313485dd4..5c6f4258e 100644 --- a/src/net/ea/inventoryhandler.h +++ b/src/net/ea/inventoryhandler.h @@ -56,7 +56,8 @@ class InventoryHandler notfinal : public Net::InventoryHandler void openStorage(const int type) const override final; - size_t getSize(const int type) const override final A_WARN_UNUSED; + size_t getSize(const InventoryTypeT type) const override final + A_WARN_UNUSED; void pushPickup(const BeingId floorId); diff --git a/src/net/ea/inventoryrecv.cpp b/src/net/ea/inventoryrecv.cpp index 7a96e86cd..bda53bab3 100644 --- a/src/net/ea/inventoryrecv.cpp +++ b/src/net/ea/inventoryrecv.cpp @@ -148,7 +148,7 @@ void InventoryRecv::processPlayerStorageStatus(Net::MessageIn &msg) const int size = msg.readInt16("max size"); if (!mStorage) - mStorage = new Inventory(InventoryType::STORAGE, size); + mStorage = new Inventory(InventoryType::Storage, size); FOR_EACH (Ea::InventoryItems::const_iterator, it, mInventoryItems) { diff --git a/src/net/eathena/inventoryhandler.cpp b/src/net/eathena/inventoryhandler.cpp index 1b781c3be..05d8c77ca 100644 --- a/src/net/eathena/inventoryhandler.cpp +++ b/src/net/eathena/inventoryhandler.cpp @@ -119,38 +119,38 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const outMsg.writeInt16(static_cast<int16_t>(amount), "amount"); } -void InventoryHandler::closeStorage(const int type A_UNUSED) const +void InventoryHandler::closeStorage() const { createOutPacket(CMSG_CLOSE_STORAGE); } -void InventoryHandler::moveItem2(const int source, +void InventoryHandler::moveItem2(const InventoryTypeT source, const int slot, const int amount, - const int destination) const + const InventoryTypeT destination) const { int packet = 0; int offset = INVENTORY_OFFSET; - if (source == InventoryType::INVENTORY) + if (source == InventoryType::Inventory) { - if (destination == InventoryType::STORAGE) + if (destination == InventoryType::Storage) packet = CMSG_MOVE_TO_STORAGE; - else if (destination == InventoryType::CART) + else if (destination == InventoryType::Cart) packet = CMSG_MOVE_TO_CART; } - else if (source == InventoryType::STORAGE) + else if (source == InventoryType::Storage) { offset = STORAGE_OFFSET; - if (destination == InventoryType::INVENTORY) + if (destination == InventoryType::Inventory) packet = CMSG_MOVE_FROM_STORAGE; - else if (destination == InventoryType::CART) + else if (destination == InventoryType::Cart) packet = CMSG_MOVE_FROM_STORAGE_TO_CART; } - else if (source == InventoryType::CART) + else if (source == InventoryType::Cart) { - if (destination == InventoryType::INVENTORY) + if (destination == InventoryType::Inventory) packet = CMSG_MOVE_FROM_CART; - else if (destination == InventoryType::STORAGE) + else if (destination == InventoryType::Storage) packet = CMSG_MOVE_FROM_CART_TO_STORAGE; } diff --git a/src/net/eathena/inventoryhandler.h b/src/net/eathena/inventoryhandler.h index 924275757..a398fe2eb 100644 --- a/src/net/eathena/inventoryhandler.h +++ b/src/net/eathena/inventoryhandler.h @@ -46,12 +46,12 @@ class InventoryHandler final : public Ea::InventoryHandler void dropItem(const Item *const item, const int amount) const override final; - void closeStorage(const int type) const override final; + void closeStorage() const override final; - void moveItem2(const int source, + void moveItem2(const InventoryTypeT source, const int slot, const int amount, - const int destination) const override final; + const InventoryTypeT destination) const override final; void useCard(const Item *const item) override final; diff --git a/src/net/inventoryhandler.h b/src/net/inventoryhandler.h index a151e39da..c7153ee29 100644 --- a/src/net/inventoryhandler.h +++ b/src/net/inventoryhandler.h @@ -55,13 +55,15 @@ class InventoryHandler notfinal virtual void openStorage(const int type) const = 0; - virtual void closeStorage(const int type) const = 0; + virtual void closeStorage() const = 0; - virtual void moveItem2(const int source, const int slot, + virtual void moveItem2(const InventoryTypeT source, + const int slot, const int amount, - const int destination) const = 0; + const InventoryTypeT destination) const = 0; - virtual size_t getSize(const int type) const A_WARN_UNUSED = 0; + virtual size_t getSize(const InventoryTypeT type) const + A_WARN_UNUSED = 0; virtual Inventory *getStorage() const = 0; diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 3248ec8f6..f4af144ea 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -110,24 +110,26 @@ void InventoryHandler::dropItem(const Item *const item, const int amount) const outMsg.writeInt16(static_cast<int16_t>(amount), "amount"); } -void InventoryHandler::closeStorage(const int type A_UNUSED) const +void InventoryHandler::closeStorage() const { createOutPacket(CMSG_CLOSE_STORAGE); } -void InventoryHandler::moveItem2(const int source, const int slot, - const int amount, const int destination) const +void InventoryHandler::moveItem2(const InventoryTypeT source, + const int slot, + const int amount, + const InventoryTypeT destination) const { - if (source == InventoryType::INVENTORY - && destination == InventoryType::STORAGE) + if (source == InventoryType::Inventory && + destination == InventoryType::Storage) { createOutPacket(CMSG_MOVE_TO_STORAGE); outMsg.writeInt16(static_cast<int16_t>(slot + INVENTORY_OFFSET), "index"); outMsg.writeInt32(amount, "amount"); } - else if (source == InventoryType::STORAGE - && destination == InventoryType::INVENTORY) + else if (source == InventoryType::Storage && + destination == InventoryType::Inventory) { createOutPacket(CMSG_MOVE_FROM_STORAGE); outMsg.writeInt16(static_cast<int16_t>(slot + STORAGE_OFFSET), diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index d0ccedab5..81e300bd3 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -46,12 +46,12 @@ class InventoryHandler final : public Ea::InventoryHandler void dropItem(const Item *const item, const int amount) const override final; - void closeStorage(const int type) const override final; + void closeStorage() const override final; - void moveItem2(const int source, + void moveItem2(const InventoryTypeT source, const int slot, const int amount, - const int destination) const override final; + const InventoryTypeT destination) const override final; void useCard(const Item *const item) override final; |