diff options
author | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-22 17:58:31 +0200 |
---|---|---|
committer | Thorbjørn Lindeijer <bjorn@lindeijer.nl> | 2024-08-25 22:09:32 +0200 |
commit | 221d67c4774bf41e6f2f0f73fb6914030e33bdde (patch) | |
tree | 6fbb4de64d172c196ed617176d5346dd4d774c49 /src/net/tmwa/inventoryhandler.h | |
parent | 9e313b385bae45a88338a2dbfb008af7a9e38e7a (diff) | |
download | mana-221d67c4774bf41e6f2f0f73fb6914030e33bdde.tar.gz mana-221d67c4774bf41e6f2f0f73fb6914030e33bdde.tar.bz2 mana-221d67c4774bf41e6f2f0f73fb6914030e33bdde.tar.xz mana-221d67c4774bf41e6f2f0f73fb6914030e33bdde.zip |
Fixed initialization of equipment backend
For new characters (and in general, when logging in with a character
that had nothing equipped), the equipment backend wasn't being
initialized. This resulted in the equipment not being visible in the
Equipment window.
Fixes #83
Diffstat (limited to 'src/net/tmwa/inventoryhandler.h')
-rw-r--r-- | src/net/tmwa/inventoryhandler.h | 40 |
1 files changed, 17 insertions, 23 deletions
diff --git a/src/net/tmwa/inventoryhandler.h b/src/net/tmwa/inventoryhandler.h index 2df5a699..51a0fe51 100644 --- a/src/net/tmwa/inventoryhandler.h +++ b/src/net/tmwa/inventoryhandler.h @@ -22,7 +22,6 @@ #ifndef NET_TA_INVENTORYHANDLER_H #define NET_TA_INVENTORYHANDLER_H -#include "equipment.h" #include "eventlistener.h" #include "inventory.h" #include "log.h" @@ -128,8 +127,7 @@ class EquipBackend final : public Equipment::Backend void triggerUnequip(int slotIndex) const override { - Item *item = getEquipment(slotIndex); - if (item) + if (Item *item = getEquipment(slotIndex)) item->doEvent(Event::DoUnequip); } @@ -143,21 +141,12 @@ class EquipBackend final : public Equipment::Backend /** * Used to cache storage data until we get size data for it. */ -class InventoryItem +struct InventoryItem { - public: - int slot; - int id; - int quantity; - bool equip; - - InventoryItem(int slot, int id, int quantity, bool equip) - { - this->slot = slot; - this->id = id; - this->quantity = quantity; - this->equip = equip; - } + int slot; + int id; + int quantity; + bool equip; }; class InventoryHandler final : public MessageHandler, public Net::InventoryHandler, @@ -184,20 +173,25 @@ class InventoryHandler final : public MessageHandler, public Net::InventoryHandl // Note the slot type id is equal to the slot Index for tA. bool isWeaponSlot(unsigned int slotTypeId) const override { - return (slotTypeId == EQUIP_FIGHT1_SLOT - || slotTypeId == EQUIP_FIGHT1_SLOT); + return (slotTypeId == EQUIP_FIGHT1_SLOT || + slotTypeId == EQUIP_FIGHT1_SLOT); } bool isAmmoSlot(unsigned int slotTypeId) const override { - return (slotTypeId == EQUIP_PROJECTILE_SLOT); + return slotTypeId == EQUIP_PROJECTILE_SLOT; + } + + Equipment::Backend *getEquipmentBackend() override + { + return &mEquips; } private: EquipBackend mEquips; - std::list<InventoryItem> mInventoryItems; - Inventory *mStorage; - InventoryWindow *mStorageWindow; + std::vector<InventoryItem> mInventoryItems; + Inventory *mStorage = nullptr; + InventoryWindow *mStorageWindow = nullptr; }; } // namespace TmwAthena |