diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/adl/adl_v2.cpp | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/engines/adl/adl_v2.cpp b/engines/adl/adl_v2.cpp index c3e82117d8..e78366ff63 100644 --- a/engines/adl/adl_v2.cpp +++ b/engines/adl/adl_v2.cpp @@ -183,30 +183,29 @@ Common::String AdlEngine_v2::loadMessage(uint idx) const { void AdlEngine_v2::printString(const Common::String &str) { Common::String s(str); uint endPos = TEXT_WIDTH - 1; + uint startPos = 0; uint pos = 0; - while (true) { - while (pos <= endPos && pos != s.size()) { - s.setChar(APPLECHAR(s[pos]), pos); - ++pos; - } + while (pos < s.size()) { + s.setChar(APPLECHAR(s[pos]), pos); - if (pos == s.size()) - break; + if (pos == endPos) { + while (s[pos] != APPLECHAR(' ') && s[pos] != APPLECHAR('\r')) { + if (pos-- == startPos) + error("Word wrapping failed"); + } - while (s[pos] != APPLECHAR(' ') && s[pos] != APPLECHAR('\r')) - --pos; + s.setChar(APPLECHAR('\r'), pos); + endPos = pos + TEXT_WIDTH; + startPos = pos + 1; + } - s.setChar(APPLECHAR('\r'), pos); - endPos = pos + TEXT_WIDTH; ++pos; } - pos = 0; - while (pos != s.size()) { + for (pos = 0; pos < s.size(); ++pos) { checkTextOverflow(s[pos]); _display->printChar(s[pos]); - ++pos; } checkTextOverflow(APPLECHAR('\r')); |