summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/being.cpp9
-rw-r--r--src/gui/chat.cpp19
-rw-r--r--src/resources/itemdb.cpp8
3 files changed, 27 insertions, 9 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 7643c91b..c5a98a2d 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -182,10 +182,10 @@ void Being::setSpeech(const std::string &text, Uint32 time)
}
// check for links
- const std::string::size_type start = mSpeech.find('[');
- const std::string::size_type end = mSpeech.find(']', start);
+ std::string::size_type start = mSpeech.find('[');
+ std::string::size_type end = mSpeech.find(']', start);
- if (start != std::string::npos && end != std::string::npos)
+ while (start != std::string::npos && end != std::string::npos)
{
std::string::size_type position = mSpeech.find('|');
mSpeech.erase(end, 1);
@@ -197,6 +197,9 @@ void Being::setSpeech(const std::string &text, Uint32 time)
mSpeech.erase(position, 2);
position = mSpeech.find('@');
}
+
+ start = mSpeech.find('[', start + 1);
+ end = mSpeech.find(']', start);
}
if (mSpeech != "")
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 4c03f618..ef625753 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -358,27 +358,34 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
// check for item link
std::string::size_type start = msg.find('[');
- if (start != std::string::npos && msg[start+1] != '@')
+ while (start != std::string::npos && msg[start+1] != '@')
{
std::string::size_type end = msg.find(']', start);
if (end != std::string::npos)
{
- std::string temp = msg.substr(start+1, end-1);
+ std::string temp = msg.substr(start+1, end - start - 1);
+
+ while (temp[0] == ' ')
+ {
+ temp = temp.substr(1, temp.size());
+ }
+ while (temp[temp.size()] == ' ')
+ {
+ temp = temp.substr(0, temp.size() - 1);
+ }
for (unsigned int i = 0; i < temp.size(); i++)
{
temp[i] = (char) tolower(temp[i]);
}
- std::cout << temp << std::endl;
-
- ItemInfo itemInfo = ItemDB::get(temp);
+ const ItemInfo itemInfo = ItemDB::get(temp);
msg.insert(end, "@@");
msg.insert(start+1, "|");
msg.insert(start+1, toString(itemInfo.getId()));
msg.insert(start+1, "@@");
-
}
+ start = msg.find('[', start + 1);
}
// Prepare ordinary message
diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp
index d27ad23d..cb9fadab 100644
--- a/src/resources/itemdb.cpp
+++ b/src/resources/itemdb.cpp
@@ -125,6 +125,14 @@ void ItemDB::load()
if (itr == mNamedItemInfos.end())
{
std::string temp = name;
+ while (temp[0] == ' ')
+ {
+ temp = temp.substr(1, temp.size());
+ }
+ while (temp[temp.size()] == ' ')
+ {
+ temp = temp.substr(0, temp.size() - 1);
+ }
for (unsigned int i = 0; i < temp.size(); i++)
{