From c6d75d9aad1775e60cc63516e844cf54623a3974 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Tue, 20 Jan 2009 18:05:26 -0700 Subject: Added the ability to parse multiple item links, as well as removing extra spaces before or after the [] tags. Signed-off-by: Ira Rice --- src/being.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/being.cpp') 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 != "") -- cgit v1.2.3-60-g2f50