From 2a9f8e05312c210ec204e09861f47c3d017706eb Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sat, 23 May 2009 13:11:40 +0200 Subject: Fixed the empty item link crash differently The crash was due to an assertion which shouldn't have been there, so I removed the assertion instead. I've also made sure the unknown item has its id initialized to 0, so that it can be used to check against instead of the item name. Normalization of item names was moved within the item database. --- src/resources/itemdb.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/resources/itemdb.cpp') diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 99907ca7..5dda2bfd 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -243,7 +243,7 @@ void ItemDB::unload() mLoaded = false; } -const ItemInfo& ItemDB::get(int id) +const ItemInfo &ItemDB::get(int id) { assert(mLoaded); @@ -251,30 +251,30 @@ const ItemInfo& ItemDB::get(int id) if (i == mItemInfos.end()) { - logger->log("ItemDB: Error, unknown item ID# %d", id); + logger->log("ItemDB: Warning, unknown item ID# %d", id); return *mUnknown; } - else - { - return *(i->second); - } + + return *(i->second); } -const ItemInfo& ItemDB::get(const std::string &name) +const ItemInfo &ItemDB::get(const std::string &name) { - assert(mLoaded && !name.empty()); + assert(mLoaded); NamedItemInfos::const_iterator i = mNamedItemInfos.find(name); if (i == mNamedItemInfos.end()) { - logger->log("ItemDB: Error, unknown item name %s", name.c_str()); + if (!name.empty()) + { + logger->log("ItemDB: Warning, unknown item name \"%s\"", + name.c_str()); + } return *mUnknown; } - else - { - return *(i->second); - } + + return *(i->second); } void loadSpriteRef(ItemInfo *itemInfo, xmlNodePtr node) -- cgit v1.2.3-70-g09d2