diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-18 20:14:23 +0100 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2009-02-18 20:16:53 +0100 |
commit | 7e43b82e3b7cda034fab34c15ecfaa97c1a99146 (patch) | |
tree | 71e24c3ef685d95b8fdf6c548a46b8516915d339 /src/gui/chat.cpp | |
parent | 9568a305878d0c035e027c1ed6c9a24147a0adea (diff) | |
download | mana-7e43b82e3b7cda034fab34c15ecfaa97c1a99146.tar.gz mana-7e43b82e3b7cda034fab34c15ecfaa97c1a99146.tar.bz2 mana-7e43b82e3b7cda034fab34c15ecfaa97c1a99146.tar.xz mana-7e43b82e3b7cda034fab34c15ecfaa97c1a99146.zip |
Introduced a toLower method and grouped string utils
The string utility methods are now grouped together in the stringutils.h
header. Also, a toLower method was added for convenience.
Diffstat (limited to 'src/gui/chat.cpp')
-rw-r--r-- | src/gui/chat.cpp | 23 |
1 files changed, 5 insertions, 18 deletions
diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index 89588cee..ac13355c 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -46,8 +46,7 @@ #include "../utils/gettext.h" #include "../utils/strprintf.h" -#include "../utils/tostring.h" -#include "../utils/trim.h" +#include "../utils/stringutils.h" ChatWindow::ChatWindow(Network * network): Window(""), mNetwork(network), mTmpVisible(false) @@ -338,15 +337,8 @@ void ChatWindow::whisper(const std::string &nick, std::string msg) std::string playerName = player_node->getName(); std::string tempNick = recvnick; - for (unsigned int i = 0; i < playerName.size(); i++) - { - playerName[i] = (char) tolower(playerName[i]); - } - - for (unsigned int i = 0; i < tempNick.size(); i++) - { - tempNick[i] = (char) tolower(tempNick[i]); - } + toLower(playerName); + toLower(tempNick); if (tempNick.compare(playerName) == 0 || msg.empty()) return; @@ -407,14 +399,9 @@ void ChatWindow::chatSend(const std::string &nick, std::string msg) start = msg.find('[', start + 1); } - std::string temp = msg.substr(start+1, end - start - 1); - - trim(temp); + std::string temp = msg.substr(start + 1, end - start - 1); - for (unsigned int i = 0; i < temp.size(); i++) - { - temp[i] = (char) tolower(temp[i]); - } + toLower(trim(temp)); const ItemInfo itemInfo = ItemDB::get(temp); if (itemInfo.getName() != _("Unknown item")) |