summaryrefslogtreecommitdiff
path: root/src/resources
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-05-19 00:51:19 +0300
committerAndrei Karas <akaras@inbox.ru>2014-05-19 00:51:19 +0300
commit29a93440367af32463f285ae5f0bd2aa23aadc92 (patch)
treef04bcf2f82649a5eb6b729399c49d431959d032c /src/resources
parent495b746d928f28ce3e13ff95f26e8cddff2fb06e (diff)
downloadplus-29a93440367af32463f285ae5f0bd2aa23aadc92.tar.gz
plus-29a93440367af32463f285ae5f0bd2aa23aadc92.tar.bz2
plus-29a93440367af32463f285ae5f0bd2aa23aadc92.tar.xz
plus-29a93440367af32463f285ae5f0bd2aa23aadc92.zip
Move itemtype into separate file.
Diffstat (limited to 'src/resources')
-rw-r--r--src/resources/db/itemdb.cpp68
-rw-r--r--src/resources/iteminfo.cpp2
-rw-r--r--src/resources/iteminfo.h30
-rw-r--r--src/resources/itemtype.h52
4 files changed, 91 insertions, 61 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index 32b724de9..234225fb0 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -108,76 +108,76 @@ void ItemDB::setStatsList(const std::vector<ItemDB::Stat> &stats)
extraStats = stats;
}
-static ItemType itemTypeFromString(const std::string &name)
+static ItemType::Type itemTypeFromString(const std::string &name)
{
if (name == "generic" || name == "other")
{
- return ITEM_UNUSABLE;
+ return ItemType::UNUSABLE;
}
else if (name == "usable")
{
- return ITEM_USABLE;
+ return ItemType::USABLE;
}
else if (name == "equip-1hand")
{
- return ITEM_EQUIPMENT_ONE_HAND_WEAPON;
+ return ItemType::EQUIPMENT_ONE_HAND_WEAPON;
}
else if (name == "equip-2hand")
{
- return ITEM_EQUIPMENT_TWO_HANDS_WEAPON;
+ return ItemType::EQUIPMENT_TWO_HANDS_WEAPON;
}
else if (name == "equip-torso")
{
- return ITEM_EQUIPMENT_TORSO;
+ return ItemType::EQUIPMENT_TORSO;
}
else if (name == "equip-arms")
{
- return ITEM_EQUIPMENT_ARMS;
+ return ItemType::EQUIPMENT_ARMS;
}
else if (name == "equip-head")
{
- return ITEM_EQUIPMENT_HEAD;
+ return ItemType::EQUIPMENT_HEAD;
}
else if (name == "equip-legs")
{
- return ITEM_EQUIPMENT_LEGS;
+ return ItemType::EQUIPMENT_LEGS;
}
else if (name == "equip-shield")
{
- return ITEM_EQUIPMENT_SHIELD;
+ return ItemType::EQUIPMENT_SHIELD;
}
else if (name == "equip-ring")
{
- return ITEM_EQUIPMENT_RING;
+ return ItemType::EQUIPMENT_RING;
}
else if (name == "equip-charm")
{
- return ITEM_EQUIPMENT_CHARM;
+ return ItemType::EQUIPMENT_CHARM;
}
else if (name == "equip-necklace" || name == "equip-neck")
{
- return ITEM_EQUIPMENT_NECKLACE;
+ return ItemType::EQUIPMENT_NECKLACE;
}
else if (name == "equip-feet")
{
- return ITEM_EQUIPMENT_FEET;
+ return ItemType::EQUIPMENT_FEET;
}
else if (name == "equip-ammo")
{
- return ITEM_EQUIPMENT_AMMO;
+ return ItemType::EQUIPMENT_AMMO;
}
else if (name == "racesprite")
{
- return ITEM_SPRITE_RACE;
+ return ItemType::SPRITE_RACE;
}
else if (name == "hairsprite")
{
- return ITEM_SPRITE_HAIR;
+ return ItemType::SPRITE_HAIR;
}
else
{
logger->log("Unknown item type: " + name);
- return ITEM_UNUSABLE;
+ return ItemType::UNUSABLE;
}
}
@@ -353,27 +353,27 @@ void ItemDB::loadXmlFile(const std::string &fileName, int &tagNum)
switch (itemInfo->getType())
{
- case ITEM_USABLE:
+ case ItemType::USABLE:
itemInfo->addTag(mTags["Usable"]);
break;
- case ITEM_UNUSABLE:
+ case ItemType::UNUSABLE:
itemInfo->addTag(mTags["Unusable"]);
break;
default:
- case ITEM_EQUIPMENT_ONE_HAND_WEAPON:
- case ITEM_EQUIPMENT_TWO_HANDS_WEAPON:
- case ITEM_EQUIPMENT_TORSO:
- case ITEM_EQUIPMENT_ARMS:
- case ITEM_EQUIPMENT_HEAD:
- case ITEM_EQUIPMENT_LEGS:
- case ITEM_EQUIPMENT_SHIELD:
- case ITEM_EQUIPMENT_RING:
- case ITEM_EQUIPMENT_NECKLACE:
- case ITEM_EQUIPMENT_FEET:
- case ITEM_EQUIPMENT_AMMO:
- case ITEM_EQUIPMENT_CHARM:
- case ITEM_SPRITE_RACE:
- case ITEM_SPRITE_HAIR:
+ case ItemType::EQUIPMENT_ONE_HAND_WEAPON:
+ case ItemType::EQUIPMENT_TWO_HANDS_WEAPON:
+ case ItemType::EQUIPMENT_TORSO:
+ case ItemType::EQUIPMENT_ARMS:
+ case ItemType::EQUIPMENT_HEAD:
+ case ItemType::EQUIPMENT_LEGS:
+ case ItemType::EQUIPMENT_SHIELD:
+ case ItemType::EQUIPMENT_RING:
+ case ItemType::EQUIPMENT_NECKLACE:
+ case ItemType::EQUIPMENT_FEET:
+ case ItemType::EQUIPMENT_AMMO:
+ case ItemType::EQUIPMENT_CHARM:
+ case ItemType::SPRITE_RACE:
+ case ItemType::SPRITE_HAIR:
itemInfo->addTag(mTags["Equipment"]);
break;
}
diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp
index e6b56c43b..c4af7d30a 100644
--- a/src/resources/iteminfo.cpp
+++ b/src/resources/iteminfo.cpp
@@ -43,7 +43,7 @@ ItemInfo::ItemInfo() :
mName(),
mDescription(),
mEffect(),
- mType(ITEM_UNUSABLE),
+ mType(ItemType::UNUSABLE),
mWeight(0),
mView(0),
mId(0),
diff --git a/src/resources/iteminfo.h b/src/resources/iteminfo.h
index 8d8d18845..8d25ff8f2 100644
--- a/src/resources/iteminfo.h
+++ b/src/resources/iteminfo.h
@@ -26,6 +26,7 @@
#include "being/gender.h"
#include "resources/cursor.h"
+#include "resources/itemtype.h"
#include "resources/soundinfo.h"
#include "resources/spritedef.h"
@@ -36,29 +37,6 @@ namespace ColorDB
class ItemColor;
}
-/**
- * Enumeration of available Item types.
- */
-enum ItemType
-{
- ITEM_UNUSABLE = 0,
- ITEM_USABLE,
- ITEM_EQUIPMENT_ONE_HAND_WEAPON,
- ITEM_EQUIPMENT_TWO_HANDS_WEAPON,
- ITEM_EQUIPMENT_TORSO,
- ITEM_EQUIPMENT_ARMS, // 5
- ITEM_EQUIPMENT_HEAD,
- ITEM_EQUIPMENT_LEGS,
- ITEM_EQUIPMENT_SHIELD,
- ITEM_EQUIPMENT_RING,
- ITEM_EQUIPMENT_NECKLACE, // 10
- ITEM_EQUIPMENT_FEET,
- ITEM_EQUIPMENT_AMMO,
- ITEM_EQUIPMENT_CHARM,
- ITEM_SPRITE_RACE,
- ITEM_SPRITE_HAIR // 15
-};
-
// sprite, <itemfrom, itemto>
typedef std::map<int, std::map<int, int> > SpriteToItemMap;
typedef SpriteToItemMap::const_iterator SpriteToItemMapCIter;
@@ -115,10 +93,10 @@ class ItemInfo final
const std::string &getEffect() const A_WARN_UNUSED
{ return mEffect; }
- void setType(const ItemType type)
+ void setType(const ItemType::Type type)
{ mType = type; }
- ItemType getType() const A_WARN_UNUSED
+ ItemType::Type getType() const A_WARN_UNUSED
{ return mType; }
void setWeight(const int weight)
@@ -289,7 +267,7 @@ class ItemInfo final
std::string mName;
std::string mDescription; /**< Short description. */
std::string mEffect; /**< Description of effects. */
- ItemType mType; /**< Item type. */
+ ItemType::Type mType; /**< Item type. */
int mWeight; /**< Weight in grams. */
int mView; /**< Item ID of how this item looks. */
int mId; /**< Item ID */
diff --git a/src/resources/itemtype.h b/src/resources/itemtype.h
new file mode 100644
index 000000000..8cb8af0ad
--- /dev/null
+++ b/src/resources/itemtype.h
@@ -0,0 +1,52 @@
+/*
+ * The ManaPlus Client
+ * Copyright (C) 2004-2009 The Mana World Development Team
+ * Copyright (C) 2009-2010 The Mana Developers
+ * Copyright (C) 2011-2014 The ManaPlus Developers
+ *
+ * This file is part of The ManaPlus Client.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef RESOURCES_ITEMTYPE_H
+#define RESOURCES_ITEMTYPE_H
+
+namespace ItemType
+{
+ /**
+ * Enumeration of available Item types.
+ */
+ enum Type
+ {
+ UNUSABLE = 0,
+ USABLE,
+ EQUIPMENT_ONE_HAND_WEAPON,
+ EQUIPMENT_TWO_HANDS_WEAPON,
+ EQUIPMENT_TORSO,
+ EQUIPMENT_ARMS, // 5
+ EQUIPMENT_HEAD,
+ EQUIPMENT_LEGS,
+ EQUIPMENT_SHIELD,
+ EQUIPMENT_RING,
+ EQUIPMENT_NECKLACE, // 10
+ EQUIPMENT_FEET,
+ EQUIPMENT_AMMO,
+ EQUIPMENT_CHARM,
+ SPRITE_RACE,
+ SPRITE_HAIR // 15
+ };
+} // namespace ItemType
+
+#endif // RESOURCES_ITEMTYPE_H