summaryrefslogtreecommitdiff
path: root/src/gui/chat.cpp
diff options
context:
space:
mode:
authorKess Vargavind <vargavind@gmail.com>2009-02-16 17:22:38 +0100
committerIra Rice <irarice@gmail.com>2009-03-10 07:31:37 -0600
commit3f322e9eec45751686c59ec89bee46d1da34c885 (patch)
tree83f134319521c06700a9b59fdf7a38faa5f63329 /src/gui/chat.cpp
parentec838fe4abf3d1003c654d3b6902a4f145d0fb5a (diff)
downloadmana-3f322e9eec45751686c59ec89bee46d1da34c885.tar.gz
mana-3f322e9eec45751686c59ec89bee46d1da34c885.tar.bz2
mana-3f322e9eec45751686c59ec89bee46d1da34c885.tar.xz
mana-3f322e9eec45751686c59ec89bee46d1da34c885.zip
Expand the scope where item links work
This patch makes item links work in any chatLog() message, not only chatSend() as before. I enabled it for the "You picked <nr> <item>" message by explicitly adding [] around the item name in the string.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r--src/gui/chat.cpp62
1 files changed, 31 insertions, 31 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp
index 9ae1be2c..fd2b05e4 100644
--- a/src/gui/chat.cpp
+++ b/src/gui/chat.cpp
@@ -221,6 +221,37 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord)
<< (int) ((t / 60) % 60)
<< "] ";
+ // Check for item link
+ std::string::size_type start = msg.find('[');
+ while (start != std::string::npos && msg[start+1] != '@')
+ {
+ std::string::size_type end = msg.find(']', start);
+ if (start+1 != end && end != std::string::npos)
+ {
+ // Catch multiple embeds and ignore them
+ // so it doesn't crash the client.
+ while ((msg.find('[', start + 1) != std::string::npos) &&
+ (msg.find('[', start + 1) < end))
+ {
+ start = msg.find('[', start + 1);
+ }
+
+ std::string temp = msg.substr(start + 1, end - start - 1);
+
+ 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, "@@");
+ }
+ }
+ start = msg.find('[', start + 1);
+ }
+
line = lineColor + timeStr.str() + tmp.nick + tmp.text;
// We look if the Vertical Scroll Bar is set at the max before
@@ -382,37 +413,6 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg)
return;
}
- // Check for item link
- std::string::size_type start = msg.find('[');
- while (start != std::string::npos && msg[start+1] != '@')
- {
- std::string::size_type end = msg.find(']', start);
- if (start+1 != end && end != std::string::npos)
- {
- // Catch multiple embeds and ignore them
- // so it doesn't crash the client.
- while ((msg.find('[', start + 1) != std::string::npos) &&
- (msg.find('[', start + 1) < end))
- {
- start = msg.find('[', start + 1);
- }
-
- std::string temp = msg.substr(start + 1, end - start - 1);
-
- 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, "@@");
- }
- }
- start = msg.find('[', start + 1);
- }
-
// Prepare ordinary message
if (msg.substr(0, 1) != "/")
{