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.cpp | |
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.cpp')
-rw-r--r-- | src/net/tmwa/inventoryhandler.cpp | 24 |
1 files changed, 6 insertions, 18 deletions
diff --git a/src/net/tmwa/inventoryhandler.cpp b/src/net/tmwa/inventoryhandler.cpp index 0bc1f9c0..0fd4e933 100644 --- a/src/net/tmwa/inventoryhandler.cpp +++ b/src/net/tmwa/inventoryhandler.cpp @@ -30,8 +30,6 @@ #include "localplayer.h" #include "log.h" -#include "gui/equipmentwindow.h" - #include "net/tmwa/messagein.h" #include "net/tmwa/messageout.h" #include "net/tmwa/protocol.h" @@ -104,9 +102,6 @@ InventoryHandler::InventoryHandler() handledMessages = _messages; inventoryHandler = this; - mStorage = nullptr; - mStorageWindow = nullptr; - listen(Event::ItemChannel); } @@ -127,7 +122,6 @@ void InventoryHandler::handleMessage(MessageIn &msg) int index, amount, itemId, equipType; int identified, cards[4], itemType; Inventory *inventory = PlayerInfo::getInventory(); - PlayerInfo::getEquipment()->setBackend(&mEquips); switch (msg.getId()) { @@ -172,8 +166,8 @@ void InventoryHandler::handleMessage(MessageIn &msg) if (msg.getId() == SMSG_PLAYER_INVENTORY) inventory->setItem(index, itemId, amount); else - mInventoryItems.push_back(InventoryItem(index, itemId, - amount, false)); + mInventoryItems.push_back( + InventoryItem { index, itemId, amount, false }); } break; @@ -203,8 +197,8 @@ void InventoryHandler::handleMessage(MessageIn &msg) cards[0], cards[1], cards[2], cards[3]); } - mInventoryItems.push_back(InventoryItem(index, itemId, amount, - false)); + mInventoryItems.push_back( + InventoryItem { index, itemId, amount, false }); } break; @@ -309,10 +303,8 @@ void InventoryHandler::handleMessage(MessageIn &msg) if (!mStorage) mStorage = new Inventory(Inventory::STORAGE, size); - auto it = mInventoryItems.begin(); - auto it_end = mInventoryItems.end(); - for (; it != it_end; it++) - mStorage->setItem((*it).slot, (*it).id, (*it).quantity); + for (auto &item : mInventoryItems) + mStorage->setItem(item.slot, item.id, item.quantity); mInventoryItems.clear(); if (!mStorageWindow) @@ -385,10 +377,6 @@ void InventoryHandler::handleMessage(MessageIn &msg) { mEquips.setEquipment(getSlot(equipType), index); } - - // Load the equipment boxes - if (equipmentWindow) - equipmentWindow->loadEquipBoxes(); } break; |