aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWalter van Niftrik2017-01-27 10:06:05 +0100
committerWalter van Niftrik2017-01-27 23:14:19 +0100
commit5a79b9956471247392e47014a28a53ab0eeede1e (patch)
treeef662f728799f6945cde8f24e9d8aeaea679a74e
parent280bcb9c7d3a49282e5bdbaa8741d0dbe94d1835 (diff)
downloadscummvm-rg350-5a79b9956471247392e47014a28a53ab0eeede1e.tar.gz
scummvm-rg350-5a79b9956471247392e47014a28a53ab0eeede1e.tar.bz2
scummvm-rg350-5a79b9956471247392e47014a28a53ab0eeede1e.zip
ADL: Fix word wrapping when last line is full
-rw-r--r--engines/adl/adl_v2.cpp27
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'));