diff options
-rw-r--r-- | ChangeLog | 3 | ||||
-rw-r--r-- | src/engine.cpp | 5 | ||||
-rw-r--r-- | src/gui/buy.cpp | 3 | ||||
-rw-r--r-- | src/gui/equipment.cpp | 3 | ||||
-rw-r--r-- | src/gui/itemcontainer.cpp | 5 | ||||
-rw-r--r-- | src/gui/sell.cpp | 3 | ||||
-rw-r--r-- | src/resources/itemmanager.cpp | 60 | ||||
-rw-r--r-- | src/resources/itemmanager.h | 17 |
8 files changed, 20 insertions, 79 deletions
@@ -1,6 +1,7 @@ 0.0.12 (? May 2005) +- Added XML item database - Fixed crash when map server is down -- New map (Shimris dungeon) +- New map (Shimris cave) - New monsters (yellow and red slime, black scorpion) - Dynamic loading of monstersets - New items (dagger, sharp knife, leather shirt, fancy hat) diff --git a/src/engine.cpp b/src/engine.cpp index 8a421041..85c737c9 100644 --- a/src/engine.cpp +++ b/src/engine.cpp @@ -341,8 +341,9 @@ void Engine::draw() int sy = y - camera_y; int absx = sx * 32 - offset_x; int absy = sy * 32 - offset_y; - if (itemDb.getImage(floorItem->id) > 0) { - itemset->spriteset[itemDb.getImage(floorItem->id) - 1]->draw(screen, + if (itemDb.getItemInfo(floorItem->id)->getImage() > 0) { + itemset->spriteset[itemDb.getItemInfo( + floorItem->id)->getImage() - 1]->draw(screen, absx, absy); } diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index c26be5d3..6876fb02 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -102,7 +102,8 @@ void BuyDialog::addItem(short id, int price) { ITEM_SHOP item_shop; - sprintf(item_shop.name, "%s %i gp", itemDb.getName(id).c_str(), price); + sprintf(item_shop.name, "%s %i gp", + itemDb.getItemInfo(id)->getName().c_str(), price); item_shop.price = price; item_shop.id = id; diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 1c559263..95e9998c 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -58,7 +58,8 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) for (int i = 0; i < 8; i++) { if (equipments[i].id > 0) { - itemset->spriteset[itemDb.getImage(equipments[i].id) - 1]->draw( + itemset->spriteset[itemDb.getItemInfo( + equipments[i].id)->getImage() - 1]->draw( screen, x + 22, y + 24 * i + 20); } graphics->setColor(gcn::Color(0, 0, 0)); diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 61dad053..bb10c5a9 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -75,8 +75,9 @@ void ItemContainer::draw(gcn::Graphics* graphics) int itemY = (((i - 2) * 24) / (getWidth() - 24)) * 24; itemX -= itemX % 24; if (items[i].quantity > 0) { - if (itemDb.getImage(items[i].id) > 0) { - itemset->spriteset[itemDb.getImage(items[i].id) - 1]->draw( + if (itemDb.getItemInfo(items[i].id)->getImage() > 0) { + itemset->spriteset[itemDb.getItemInfo( + items[i].id)->getImage() - 1]->draw( screen, x + itemX, y + itemY); } diff --git a/src/gui/sell.cpp b/src/gui/sell.cpp index 2c9e8745..711a417e 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -93,7 +93,8 @@ void SellDialog::addItem(short index, int price) int id = inventoryWindow->items->getId(index); ITEM_SHOP item_shop; - sprintf(item_shop.name, "%s %i gp", itemDb.getName(id).c_str(), price); + sprintf(item_shop.name, "%s %i gp", + itemDb.getItemInfo(id)->getName().c_str(), price); item_shop.price = price; item_shop.index = index; item_shop.id = id; 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 |