summaryrefslogtreecommitdiff
path: root/src/resources/db
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2014-07-03 14:43:03 +0300
committerAndrei Karas <akaras@inbox.ru>2014-07-03 14:43:03 +0300
commit284acf8f76bd2201bd64b847a2564206f77a4278 (patch)
treed562014465ae69782a7a081689ee5917812a5e55 /src/resources/db
parent5ccaffe607662610eb34d5a9043fb5fb7e068039 (diff)
downloadplus-284acf8f76bd2201bd64b847a2564206f77a4278.tar.gz
plus-284acf8f76bd2201bd64b847a2564206f77a4278.tar.bz2
plus-284acf8f76bd2201bd64b847a2564206f77a4278.tar.xz
plus-284acf8f76bd2201bd64b847a2564206f77a4278.zip
Move item type mapping into separate file.
Diffstat (limited to 'src/resources/db')
-rw-r--r--src/resources/db/itemdb.cpp75
1 files changed, 8 insertions, 67 deletions
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index c41fc07a5..f40fdbbd6 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -29,6 +29,7 @@
#include "resources/beingcommon.h"
#include "resources/iteminfo.h"
+#include "resources/itemtypemapdata.h"
#include "resources/spritedirection.h"
#include "resources/spritereference.h"
@@ -114,75 +115,15 @@ void ItemDB::setStatsList(const std::vector<ItemDB::Stat> &stats)
static ItemType::Type itemTypeFromString(const std::string &name)
{
- if (name == "generic" || name == "other")
+ const size_t sz = sizeof(itemTypeMap) / sizeof(itemTypeMap[0]);
+ for (size_t f = 0; f < sz; f ++)
{
- return ItemType::UNUSABLE;
- }
- else if (name == "usable")
- {
- return ItemType::USABLE;
- }
- else if (name == "equip-1hand")
- {
- return ItemType::EQUIPMENT_ONE_HAND_WEAPON;
- }
- else if (name == "equip-2hand")
- {
- return ItemType::EQUIPMENT_TWO_HANDS_WEAPON;
- }
- else if (name == "equip-torso")
- {
- return ItemType::EQUIPMENT_TORSO;
- }
- else if (name == "equip-arms")
- {
- return ItemType::EQUIPMENT_ARMS;
- }
- else if (name == "equip-head")
- {
- return ItemType::EQUIPMENT_HEAD;
- }
- else if (name == "equip-legs")
- {
- return ItemType::EQUIPMENT_LEGS;
- }
- else if (name == "equip-shield")
- {
- return ItemType::EQUIPMENT_SHIELD;
- }
- else if (name == "equip-ring")
- {
- return ItemType::EQUIPMENT_RING;
- }
- else if (name == "equip-charm")
- {
- return ItemType::EQUIPMENT_CHARM;
- }
- else if (name == "equip-necklace" || name == "equip-neck")
- {
- return ItemType::EQUIPMENT_NECKLACE;
- }
- else if (name == "equip-feet")
- {
- return ItemType::EQUIPMENT_FEET;
- }
- else if (name == "equip-ammo")
- {
- return ItemType::EQUIPMENT_AMMO;
- }
- else if (name == "racesprite")
- {
- return ItemType::SPRITE_RACE;
- }
- else if (name == "hairsprite")
- {
- return ItemType::SPRITE_HAIR;
- }
- else
- {
- logger->log("Unknown item type: " + name);
- return ItemType::UNUSABLE;
+ const ItemTypeMap &type = itemTypeMap[f];
+ if (type.name == name)
+ return type.type;
}
+ logger->log("Unknown item type: " + name);
+ return ItemType::UNUSABLE;
}
static void initStatic()