summaryrefslogtreecommitdiff
path: root/src/resources/itemmanager.cpp
diff options
context:
space:
mode:
authorEugenio Favalli <elvenprogrammer@gmail.com>2005-04-21 15:36:49 +0000
committerEugenio Favalli <elvenprogrammer@gmail.com>2005-04-21 15:36:49 +0000
commit56fef6eed9e3145b5e7d33e066069f642873d7a1 (patch)
tree10ee9c20bfa294abbbb2b96901bc0b2830007288 /src/resources/itemmanager.cpp
parent9db3ea6a43d78bc959eef9fd594141d3a4063c0b (diff)
downloadmana-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.gz
mana-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.bz2
mana-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.xz
mana-56fef6eed9e3145b5e7d33e066069f642873d7a1.zip
trying to follow Hammerbear suggestions
Diffstat (limited to 'src/resources/itemmanager.cpp')
-rw-r--r--src/resources/itemmanager.cpp60
1 files changed, 5 insertions, 55 deletions
diff --git a/src/resources/itemmanager.cpp b/src/resources/itemmanager.cpp
index 4bb6555b..eb75321d 100644
--- a/src/resources/itemmanager.cpp
+++ b/src/resources/itemmanager.cpp
@@ -36,8 +36,7 @@
#define xmlFree(x) ;
#endif
-ItemManager::ItemManager() :
- minId(10000), maxId(0)
+ItemManager::ItemManager()
{
// Check that file exists before trying to parse it
std::fstream dbFile;
@@ -63,8 +62,6 @@ ItemManager::ItemManager() :
xmlChar *prop;
prop = xmlGetProp(node, BAD_CAST "id");
int id = atoi((const char*)prop);
- if (id < minId) minId = id;
- if (id > maxId) maxId = id;
xmlFree(prop);
prop = xmlGetProp(node, BAD_CAST "image");
int image = atoi((const char*)prop);
@@ -116,58 +113,11 @@ ItemManager::~ItemManager()
{
}
-short ItemManager::getImage(int id)
+ItemInfo *ItemManager::getItemInfo(int id)
{
- if (id >= minId && id <= maxId)
- return db[id]->getImage();
+ if (db.find(id) != db.end())
+ return db[id];
else
- return 0;
+ return NULL;
}
-short ItemManager::getArt(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getArt();
- else
- return 0;
-}
-
-std::string ItemManager::getName(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getName();
- else
- return "Unknown";
-}
-
-std::string ItemManager::getDescription(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getDescription();
- else
- return "";
-}
-
-short ItemManager::getType(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getType();
- else
- return 0;
-}
-
-short ItemManager::getWeight(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getWeight();
- else
- return 0;
-}
-
-char ItemManager::getSlot(int id)
-{
- if (id >= minId && id <= maxId)
- return db[id]->getSlot();
- else
- return 0;
-}