summaryrefslogtreecommitdiff
path: root/src/net/manaserv/inventoryhandler.cpp
diff options
context:
space:
mode:
authorYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:37:09 +0200
committerYohann Ferreira <yohann_dot_ferreira_at_orange_dot_efer>2011-08-19 02:37:09 +0200
commit27114fa2694318f2a1c56cb828a3b79731efcb74 (patch)
treeaad31af84a5932bf8fda83e367dfa1ac78fec1c3 /src/net/manaserv/inventoryhandler.cpp
parent36239b2d689b862a951a65a9be7376a500f1ace9 (diff)
downloadmana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.gz
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.bz2
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.tar.xz
mana-27114fa2694318f2a1c56cb828a3b79731efcb74.zip
Fixed visible equipment updates, and made it based on equip.xml.
Diffstat (limited to 'src/net/manaserv/inventoryhandler.cpp')
-rw-r--r--src/net/manaserv/inventoryhandler.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/net/manaserv/inventoryhandler.cpp b/src/net/manaserv/inventoryhandler.cpp
index a5875e08..1a74f732 100644
--- a/src/net/manaserv/inventoryhandler.cpp
+++ b/src/net/manaserv/inventoryhandler.cpp
@@ -62,6 +62,7 @@ extern Connection *gameServerConnection;
EquipBackend::EquipBackend()
{
listen(Event::ClientChannel);
+ mVisibleSlots = 0;
}
Item *EquipBackend::getEquipment(int slotIndex) const
@@ -208,6 +209,7 @@ void EquipBackend::readEquipFile()
// The current client slot index
unsigned int slotIndex = 0;
+ mVisibleSlots = 0;
for_each_xml_child_node(childNode, rootNode)
{
@@ -218,6 +220,11 @@ void EquipBackend::readEquipFile()
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);
+
+ if (XML::getBoolProperty(childNode, "visible", false))
+ ++mVisibleSlots;
if (slot.slotTypeId > 0 && capacity > 0)
{
@@ -245,6 +252,28 @@ void EquipBackend::readEquipFile()
}
}
+bool EquipBackend::isWeaponSlot(int slotTypeId) const
+{
+ for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end();
+ it != it_end; ++it)
+ {
+ if (it->second.slotTypeId == (unsigned)slotTypeId)
+ return it->second.weaponSlot;
+ }
+ return false;
+}
+
+bool EquipBackend::isAmmoSlot(int slotTypeId) const
+{
+ for (Slots::const_iterator it = mSlots.begin(), it_end = mSlots.end();
+ it != it_end; ++it)
+ {
+ if (it->second.slotTypeId == (unsigned)slotTypeId)
+ return it->second.ammoSlot;
+ }
+ return false;
+}
+
InventoryHandler::InventoryHandler()
{
static const Uint16 _messages[] = {