summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/progs/manaplus/client.cpp5
-rw-r--r--src/resources/db/itemdb.cpp10
-rw-r--r--src/resources/db/itemdb.h1
-rw-r--r--src/textcommand.cpp8
4 files changed, 20 insertions, 4 deletions
diff --git a/src/progs/manaplus/client.cpp b/src/progs/manaplus/client.cpp
index be5c7ca81..9bc4b03cb 100644
--- a/src/progs/manaplus/client.cpp
+++ b/src/progs/manaplus/client.cpp
@@ -1922,13 +1922,14 @@ void Client::loadData()
TranslationManager::loadDictionaryLang();
PlayerInfo::stateChange(mState);
+ AttributesEnum::init();
+ DbManager::loadDb();
+
delete spellManager;
spellManager = new SpellManager;
delete spellShortcut;
spellShortcut = new SpellShortcut;
- AttributesEnum::init();
- DbManager::loadDb();
EquipmentWindow::prepareSlotNames();
ActorSprite::load();
diff --git a/src/resources/db/itemdb.cpp b/src/resources/db/itemdb.cpp
index a98f0dad4..274b44bb2 100644
--- a/src/resources/db/itemdb.cpp
+++ b/src/resources/db/itemdb.cpp
@@ -801,6 +801,16 @@ bool ItemDB::exists(const int id)
return i != mItemInfos.end();
}
+bool ItemDB::exists(const std::string &name)
+{
+ if (!mLoaded)
+ return false;
+
+ const NamedItemInfos::const_iterator i = mNamedItemInfos.find(
+ normalize(name));
+ return i != mNamedItemInfos.end();
+}
+
const ItemInfo &ItemDB::get(const int id)
{
if (!mLoaded)
diff --git a/src/resources/db/itemdb.h b/src/resources/db/itemdb.h
index 96de60b6a..1515d3ba0 100644
--- a/src/resources/db/itemdb.h
+++ b/src/resources/db/itemdb.h
@@ -49,6 +49,7 @@ namespace ItemDB
const StringVect &getTags();
bool exists(const int id) A_WARN_UNUSED;
+ bool exists(const std::string &name) A_WARN_UNUSED;
const ItemInfo &get(const int id) A_WARN_UNUSED;
const ItemInfo &get(const std::string &name) A_WARN_UNUSED;
diff --git a/src/textcommand.cpp b/src/textcommand.cpp
index 8a5949613..320e295a2 100644
--- a/src/textcommand.cpp
+++ b/src/textcommand.cpp
@@ -125,10 +125,14 @@ void TextCommand::loadImage()
mImage = nullptr;
}
- if (getIcon().empty())
+ if (mIcon.empty() ||
+ !ItemDB::exists(mIcon))
+ {
return;
+ }
- const SpriteDisplay display = ItemDB::get(getIcon()).getDisplay();
+ const ItemInfo &info = ItemDB::get(mIcon);
+ const SpriteDisplay display = info.getDisplay();
mImage = Loader::getImage(pathJoin(paths.getStringValue("itemIcons"),
display.image));