summaryrefslogtreecommitdiff
path: root/src/net/manaserv/inventoryhandler.cpp
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-08-22 17:58:31 +0200
committerThorbjørn Lindeijer <bjorn@lindeijer.nl>2024-08-25 22:09:32 +0200
commit221d67c4774bf41e6f2f0f73fb6914030e33bdde (patch)
tree6fbb4de64d172c196ed617176d5346dd4d774c49 /src/net/manaserv/inventoryhandler.cpp
parent9e313b385bae45a88338a2dbfb008af7a9e38e7a (diff)
downloadmana-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/manaserv/inventoryhandler.cpp')
-rw-r--r--src/net/manaserv/inventoryhandler.cpp22
1 files changed, 7 insertions, 15 deletions
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 8898db55..ac3e0f5b 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -24,8 +24,6 @@
#include "equipment.h"
#include "inventory.h"
#include "item.h"
-#include "itemshortcut.h"
-#include "localplayer.h"
#include "log.h"
#include "playerinfo.h"
@@ -37,8 +35,6 @@
#include "net/manaserv/messageout.h"
#include "net/manaserv/manaserv_protocol.h"
-#include "resources/iteminfo.h"
-
#include "utils/stringutils.h"
#define EQUIP_FILE "equip.xml"
@@ -279,20 +275,20 @@ void EquipBackend::readBoxNode(xmlNodePtr slotNode)
bool EquipBackend::isWeaponSlot(int slotTypeId) const
{
- for (const auto &slot : mSlots)
+ for (const auto &[_, slot] : mSlots)
{
- if (slot.second.slotTypeId == (unsigned)slotTypeId)
- return slot.second.weaponSlot;
+ if (slot.slotTypeId == (unsigned)slotTypeId)
+ return slot.weaponSlot;
}
return false;
}
bool EquipBackend::isAmmoSlot(int slotTypeId) const
{
- for (const auto &slot : mSlots)
+ for (const auto &[_, slot] : mSlots)
{
- if (slot.second.slotTypeId == (unsigned)slotTypeId)
- return slot.second.ammoSlot;
+ if (slot.slotTypeId == (unsigned)slotTypeId)
+ return slot.ammoSlot;
}
return false;
}
@@ -304,7 +300,7 @@ Position EquipBackend::getBoxPosition(unsigned int slotIndex) const
return Position(0, 0);
}
-const std::string& EquipBackend::getBoxBackground(unsigned int slotIndex) const
+const std::string &EquipBackend::getBoxBackground(unsigned int slotIndex) const
{
if (slotIndex < mBoxesBackgroundFile.size())
return mBoxesBackgroundFile.at(slotIndex);
@@ -332,7 +328,6 @@ void InventoryHandler::handleMessage(MessageIn &msg)
case GPMSG_INVENTORY_FULL:
{
PlayerInfo::clearInventory();
- PlayerInfo::getEquipment()->setBackend(&mEquipBackend);
int count = msg.readInt16();
while (count--)
{
@@ -374,9 +369,6 @@ void InventoryHandler::handleMessage(MessageIn &msg)
it->second.mAmountUsed,
it->first);
}
- // The backend is ready, we can setup the equipment window.
- if (equipmentWindow)
- equipmentWindow->loadEquipBoxes();
}
break;