summaryrefslogtreecommitdiff
path: root/src/gui/widgets/chattab.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-23 13:11:40 +0200
committerBjørn Lindeijer <bjorn@lindeijer.nl>2009-05-23 13:16:11 +0200
commit2a9f8e05312c210ec204e09861f47c3d017706eb (patch)
treea3aceadb77f5d54dd065f69fa348969a0c31eac2 /src/gui/widgets/chattab.cpp
parent4deff8569279d5cf23a73fdc1c986592ca4f7ed2 (diff)
downloadmana-2a9f8e05312c210ec204e09861f47c3d017706eb.tar.gz
mana-2a9f8e05312c210ec204e09861f47c3d017706eb.tar.bz2
mana-2a9f8e05312c210ec204e09861f47c3d017706eb.tar.xz
mana-2a9f8e05312c210ec204e09861f47c3d017706eb.zip
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.
Diffstat (limited to 'src/gui/widgets/chattab.cpp')
-rw-r--r--src/gui/widgets/chattab.cpp22
1 files changed, 8 insertions, 14 deletions
diff --git a/src/gui/widgets/chattab.cpp b/src/gui/widgets/chattab.cpp
index 85353bf7..ad0911c9 100644
--- a/src/gui/widgets/chattab.cpp
+++ b/src/gui/widgets/chattab.cpp
@@ -215,7 +215,7 @@ void ChatTab::chatInput(std::string &msg)
while (start != std::string::npos && msg[start+1] != '@')
{
std::string::size_type end = msg.find(']', start);
- if (start+1 != end && end != std::string::npos)
+ if (start + 1 != end && end != std::string::npos)
{
// Catch multiple embeds and ignore them
// so it doesn't crash the client.
@@ -227,22 +227,16 @@ void ChatTab::chatInput(std::string &msg)
std::string temp = msg.substr(start + 1, end - start - 1);
- // Do not parse an empty string (it crashes the client)
- if (!temp.empty())
+ const ItemInfo itemInfo = ItemDB::get(temp);
+ if (itemInfo.getId() != 0)
{
- toLower(trim(temp));
-
- const ItemInfo itemInfo = ItemDB::get(temp);
- if (itemInfo.getName() != _("Unknown item"))
- {
- msg.insert(end, "@@");
- msg.insert(start+1, "|");
- msg.insert(start+1, toString(itemInfo.getId()));
- msg.insert(start+1, "@@");
- }
+ msg.insert(end, "@@");
+ msg.insert(start + 1, "|");
+ msg.insert(start + 1, toString(itemInfo.getId()));
+ msg.insert(start + 1, "@@");
}
}
- start = msg.find('[', start + 1);
+ start = msg.find('[', start + 1);
}
// Prepare ordinary message