diff --git a/apps/openmw/mwgui/formatting.cpp b/apps/openmw/mwgui/formatting.cpp index c8b6f39833..f7188c8b60 100644 --- a/apps/openmw/mwgui/formatting.cpp +++ b/apps/openmw/mwgui/formatting.cpp @@ -21,7 +21,7 @@ namespace MWGui { /* BookTextParser */ BookTextParser::BookTextParser(const std::string & text) - : mIndex(-1), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) + : mIndex(0), mText(text), mIgnoreNewlineTags(true), mIgnoreLineEndings(true) { MWScript::InterpreterContext interpreterContext(NULL, MWWorld::Ptr()); // empty arguments, because there is no locals or actor mText = Interpreter::fixDefinesBook(mText, interpreterContext); @@ -47,16 +47,8 @@ namespace MWGui BookTextParser::Events BookTextParser::next() { - while (1) + while (mIndex < mText.size()) { - ++mIndex; - - if (mIndex >= mText.size()) - { - flushBuffer(); - return Event_EOF; - } - char ch = mText[mIndex]; if (ch == '<') { @@ -93,6 +85,7 @@ namespace MWGui mIgnoreNewlineTags = false; } + ++mIndex; return type; } } @@ -106,8 +99,11 @@ namespace MWGui } } - + ++mIndex; } + + flushBuffer(); + return Event_EOF; } void BookTextParser::flushBuffer() diff --git a/apps/openmw/mwgui/formatting.hpp b/apps/openmw/mwgui/formatting.hpp index 71e398f7f4..f119422c9c 100644 --- a/apps/openmw/mwgui/formatting.hpp +++ b/apps/openmw/mwgui/formatting.hpp @@ -49,7 +49,7 @@ namespace MWGui void parseTag(std::string tag); private: - int mIndex; + size_t mIndex; std::string mText; std::string mReadyText;