From 221d67c4774bf41e6f2f0f73fb6914030e33bdde Mon Sep 17 00:00:00 2001 From: Thorbjørn Lindeijer Date: Thu, 22 Aug 2024 17:58:31 +0200 Subject: 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 --- src/net/tmwa/inventoryhandler.h | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'src/net/tmwa/inventoryhandler.h') 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 mInventoryItems; - Inventory *mStorage; - InventoryWindow *mStorageWindow; + std::vector mInventoryItems; + Inventory *mStorage = nullptr; + InventoryWindow *mStorageWindow = nullptr; }; } // namespace TmwAthena -- cgit v1.2.3-70-g09d2