diff options
author | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-21 15:36:49 +0000 |
---|---|---|
committer | Eugenio Favalli <elvenprogrammer@gmail.com> | 2005-04-21 15:36:49 +0000 |
commit | 56fef6eed9e3145b5e7d33e066069f642873d7a1 (patch) | |
tree | 10ee9c20bfa294abbbb2b96901bc0b2830007288 /src/resources | |
parent | 9db3ea6a43d78bc959eef9fd594141d3a4063c0b (diff) | |
download | mana-client-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.gz mana-client-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.bz2 mana-client-56fef6eed9e3145b5e7d33e066069f642873d7a1.tar.xz mana-client-56fef6eed9e3145b5e7d33e066069f642873d7a1.zip |
trying to follow Hammerbear suggestions
Diffstat (limited to 'src/resources')
-rw-r--r-- | src/resources/itemmanager.cpp | 60 | ||||
-rw-r--r-- | src/resources/itemmanager.h | 17 |
2 files changed, 6 insertions, 71 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; -} diff --git a/src/resources/itemmanager.h b/src/resources/itemmanager.h index 3f014ad6..b4c98e5b 100644 --- a/src/resources/itemmanager.h +++ b/src/resources/itemmanager.h @@ -45,26 +45,11 @@ class ItemManager */ ~ItemManager(); - short getImage(int id); + ItemInfo *getItemInfo(int id); - short getArt(int id); - - std::string getName(int id); - - std::string getDescription(int id); - - short getType(int id); - - short getWeight(int id); - - char getSlot(int id); - - protected: // Items database std::map <int, ItemInfo *> db; - int minId, maxId; - }; #endif |