summaryrefslogtreecommitdiff
path: root/src/net/manaserv/inventoryhandler.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/net/manaserv/inventoryhandler.cpp')
-rw-r--r--src/net/manaserv/inventoryhandler.cpp40
1 files changed, 32 insertions, 8 deletions
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index 1a74f732..94494319 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -211,19 +211,19 @@ void EquipBackend::readEquipFile()
unsigned int slotIndex = 0;
mVisibleSlots = 0;
- for_each_xml_child_node(childNode, rootNode)
+ for_each_xml_child_node(slotNode, rootNode)
{
- if (!xmlStrEqual(childNode->name, BAD_CAST "slot"))
+ if (!xmlStrEqual(slotNode->name, BAD_CAST "slot"))
continue;
Slot slot;
- slot.slotTypeId = XML::getProperty(childNode, "id", 0);
- std::string name = XML::getProperty(childNode, "name", std::string());
- const int capacity = XML::getProperty(childNode, "capacity", 1);
- slot.weaponSlot = XML::getBoolProperty(childNode, "weapon", false);
- slot.ammoSlot = XML::getBoolProperty(childNode, "ammo", false);
+ slot.slotTypeId = XML::getProperty(slotNode, "id", 0);
+ std::string name = XML::getProperty(slotNode, "name", std::string());
+ const int capacity = XML::getProperty(slotNode, "capacity", 1);
+ slot.weaponSlot = XML::getBoolProperty(slotNode, "weapon", false);
+ slot.ammoSlot = XML::getBoolProperty(slotNode, "ammo", false);
- if (XML::getBoolProperty(childNode, "visible", false))
+ if (XML::getBoolProperty(slotNode, "visible", false))
++mVisibleSlots;
if (slot.slotTypeId > 0 && capacity > 0)
@@ -249,6 +249,23 @@ void EquipBackend::readEquipFile()
++slotIndex;
}
}
+
+ // Read the box properties
+ readBoxNode(slotNode);
+ }
+}
+
+void EquipBackend::readBoxNode(xmlNodePtr slotNode)
+{
+ for_each_xml_child_node(boxNode, slotNode)
+ {
+ if (!xmlStrEqual(boxNode->name, BAD_CAST "box"))
+ continue;
+
+ int x = XML::getProperty(boxNode, "x" , 0);
+ int y = XML::getProperty(boxNode, "y" , 0);
+
+ mBoxesPositions.push_back(Position(x, y));
}
}
@@ -274,6 +291,13 @@ bool EquipBackend::isAmmoSlot(int slotTypeId) const
return false;
}
+Position EquipBackend::getBoxPosition(unsigned int slotIndex) const
+{
+ if (slotIndex < mBoxesPositions.size())
+ return mBoxesPositions.at(slotIndex);
+ return Position(0, 0);
+}
+
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {