From 0bc81cb39f48fdade13cf964702072cd9a7e324d Mon Sep 17 00:00:00 2001 From: Jan-Fabian Humann Date: Tue, 10 May 2005 15:17:17 +0000 Subject: fixing a bug which occured when ItemManager's constructor calls logger (for example if items.xml is missing) --- src/gui/buy.cpp | 6 +++--- src/gui/equipment.cpp | 4 ++-- src/gui/inventory.cpp | 4 ++-- src/gui/itemcontainer.cpp | 4 ++-- src/gui/sell.cpp | 2 +- src/main.cpp | 5 ++++- src/main.h | 2 +- 7 files changed, 15 insertions(+), 12 deletions(-) (limited to 'src') diff --git a/src/gui/buy.cpp b/src/gui/buy.cpp index e55866fb..79f21227 100644 --- a/src/gui/buy.cpp +++ b/src/gui/buy.cpp @@ -113,7 +113,7 @@ void BuyDialog::addItem(short id, int price) ITEM_SHOP item_shop; sprintf(item_shop.name, "%s %i gp", - itemDb.getItemInfo(id)->getName().c_str(), price); + itemDb->getItemInfo(id)->getName().c_str(), price); item_shop.price = price; item_shop.id = id; @@ -173,9 +173,9 @@ void BuyDialog::mouseClick(int x, int y, int button, int count) if (selectedItem > -1) { itemNameLabel->setCaption("Name: " + - itemDb.getItemInfo(shopInventory[selectedItem].id)->getName()); + itemDb->getItemInfo(shopInventory[selectedItem].id)->getName()); itemDescLabel->setCaption("Description: " + - itemDb.getItemInfo(shopInventory[selectedItem].id)->getDescription()); + itemDb->getItemInfo(shopInventory[selectedItem].id)->getDescription()); } } diff --git a/src/gui/equipment.cpp b/src/gui/equipment.cpp index 8ca23833..802b1e46 100644 --- a/src/gui/equipment.cpp +++ b/src/gui/equipment.cpp @@ -60,7 +60,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) for (int i = 0; i < 8; i++) { if (equipments[i].id > 0) { - itemset->spriteset[itemDb.getItemInfo( + itemset->spriteset[itemDb->getItemInfo( equipments[i].id)->getImage() - 1]->draw( screen, x + 24 * (i % 4) + 10, y + 24 * (i / 4) + 25); } @@ -71,7 +71,7 @@ void EquipmentWindow::draw(gcn::Graphics *graphics) graphics->setColor(gcn::Color(0, 0, 0)); graphics->drawRectangle(gcn::Rectangle(110, 25, 20, 20)); if (arrows) { - itemset->spriteset[itemDb.getItemInfo(arrows)->getImage() - 1]->draw( + itemset->spriteset[itemDb->getItemInfo(arrows)->getImage() - 1]->draw( screen, x + 110, y + 25); std::stringstream n; n << arrowsNumber; diff --git a/src/gui/inventory.cpp b/src/gui/inventory.cpp index 5082e7cb..38537eb7 100644 --- a/src/gui/inventory.cpp +++ b/src/gui/inventory.cpp @@ -183,10 +183,10 @@ void InventoryWindow::mouseClick(int x, int y, int button, int count) // Show Name and Description std::string SomeText; - SomeText = "Name: " + itemDb.getItemInfo(items->getId())->getName(); + SomeText = "Name: " + itemDb->getItemInfo(items->getId())->getName(); itemNameLabel->setCaption(SomeText); itemNameLabel->adjustSize(); - SomeText = "Description: " + itemDb.getItemInfo(items->getId())->getDescription(); + SomeText = "Description: " + itemDb->getItemInfo(items->getId())->getDescription(); itemDescriptionLabel->setCaption(SomeText); itemDescriptionLabel->adjustSize(); } diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index fd3020d4..67bae9b0 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -80,8 +80,8 @@ void ItemContainer::draw(gcn::Graphics* graphics) itemX -= itemX % 24; if (items[i].quantity > 0) { - if (itemDb.getItemInfo(items[i].id)->getImage() > 0) { - itemset->spriteset[itemDb.getItemInfo( + 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 e12b61ed..f2e1677f 100644 --- a/src/gui/sell.cpp +++ b/src/gui/sell.cpp @@ -94,7 +94,7 @@ void SellDialog::addItem(short index, int price) ITEM_SHOP item_shop; sprintf(item_shop.name, "%s %i gp", - itemDb.getItemInfo(id)->getName().c_str(), price); + itemDb->getItemInfo(id)->getName().c_str(), price); item_shop.price = price; item_shop.index = index; item_shop.id = id; diff --git a/src/main.cpp b/src/main.cpp index ce45b460..5a1b1318 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -74,7 +74,7 @@ Music *bgm; Configuration config; /**< Xml file configuration reader */ Logger *logger; /**< Log object */ -ItemManager itemDb; /**< Item database object */ +ItemManager *itemDb; /**< Item database object */ /** * Listener used for responding to map start error dialog. @@ -258,6 +258,9 @@ void init_engine() //vfmt Pixel format of the video device + // Initialize item manager + itemDb = new ItemManager(); + // Create the graphics context graphics = new Graphics(); diff --git a/src/main.h b/src/main.h index 58aa3f7e..944e755b 100644 --- a/src/main.h +++ b/src/main.h @@ -109,7 +109,7 @@ extern Map *tiledMap; extern Logger *logger; extern int screenW, screenH, bitDepth, displayFlags; extern bool useOpenGL; -extern ItemManager itemDb; +extern ItemManager *itemDb; extern char *homeDir; #endif -- cgit v1.2.3-70-g09d2