summaryrefslogtreecommitdiff
path: root/src/being.cpp
diff options
context:
space:
mode:
authorIra Rice <irarice@gmail.com>2009-01-20 11:57:14 -0700
committerIra Rice <irarice@gmail.com>2009-01-20 11:57:14 -0700
commitf404997629d9a34f5a15261073536903a59a604c (patch)
treec13676b9762f0c52c89ad9dc4048a731b77889ba /src/being.cpp
parent1cd00ac68dca25c942c8db0cbaa8110d4a6a2f7a (diff)
downloadmana-client-f404997629d9a34f5a15261073536903a59a604c.tar.gz
mana-client-f404997629d9a34f5a15261073536903a59a604c.tar.bz2
mana-client-f404997629d9a34f5a15261073536903a59a604c.tar.xz
mana-client-f404997629d9a34f5a15261073536903a59a604c.zip
Trim displayed speech to not show links.
Signed-off-by: Ira Rice <irarice@gmail.com>
Diffstat (limited to 'src/being.cpp')
-rw-r--r--src/being.cpp34
1 files changed, 33 insertions, 1 deletions
diff --git a/src/being.cpp b/src/being.cpp
index 98aaeec2..3e621295 100644
--- a/src/being.cpp
+++ b/src/being.cpp
@@ -171,7 +171,39 @@ void Being::setSpeech(const std::string &text, Uint32 time)
{
mSpeech = text;
- mSpeechTime = 500;
+ // Trim whitespace
+ while (mSpeech[0] == ' ')
+ {
+ mSpeech = mSpeech.substr(1, mSpeech.size());
+ }
+ while (mSpeech[mSpeech.size()] == ' ')
+ {
+ mSpeech = mSpeech.substr(0, mSpeech.size() - 1);
+ }
+
+ // check for links
+ const std::string::size_type start = mSpeech.find('[');
+ const std::string::size_type end = mSpeech.find(']', start);
+
+ if (start != std::string::npos && end != std::string::npos)
+ {
+ mSpeech.erase(end);
+ std::string::size_type pos = mSpeech.find('@');
+
+ while (pos != std::string::npos)
+ {
+ mSpeech.erase(pos, 2);
+ pos = mSpeech.find('@');
+ }
+
+ pos = mSpeech.find('|');
+
+ if (pos != std::string::npos)
+ mSpeech = mSpeech.substr(pos + 1, mSpeech.size());
+ }
+
+ if (mSpeech != "")
+ mSpeechTime = 500;
}
void Being::takeDamage(int amount)