aboutsummaryrefslogtreecommitdiff
path: root/engines/agi/text.cpp
diff options
context:
space:
mode:
authorMartin Kiewitz2016-02-19 15:56:00 +0100
committerMartin Kiewitz2016-02-19 15:56:00 +0100
commit4a204af5b71ad000ec8f2952f8343ac0328d45cd (patch)
treedc047dcba3778c33d9f1891456f84054aefbb284 /engines/agi/text.cpp
parent453a8ac11d5b29d38d6c89cdc7ff2ae9775d7a25 (diff)
downloadscummvm-rg350-4a204af5b71ad000ec8f2952f8343ac0328d45cd.tar.gz
scummvm-rg350-4a204af5b71ad000ec8f2952f8343ac0328d45cd.tar.bz2
scummvm-rg350-4a204af5b71ad000ec8f2952f8343ac0328d45cd.zip
AGI: Fix a tiny inaccuracy in string word wrapper
Fixes one message box in Gold Rush during Stagecoach path, that wasn't wrapped correctly.
Diffstat (limited to 'engines/agi/text.cpp')
-rw-r--r--engines/agi/text.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/engines/agi/text.cpp b/engines/agi/text.cpp
index 7c8594b62a..611bd135eb 100644
--- a/engines/agi/text.cpp
+++ b/engines/agi/text.cpp
@@ -943,8 +943,9 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
//memset(resultWrappedBuffer, 0, sizeof(resultWrappedBuffer)); for debugging
// Good testcases:
- // King's Quest 1 intro: the scrolling text is filled up with spaces, so that old lines are erased
- // Apple IIgs restart system UI: spaces used to make the window larger
+ // King's Quest 1 intro: the scrolling text is filled up with spaces, so that old lines are erased
+ // Apple IIgs restart system UI: spaces used to make the window larger
+ // Gold Rush Stagecoach path room 60: " Lake Michigan!", with max length 9 -> should get split into " Lake" / "Michigan!"
while (originalText[curReadPos]) {
// Try to find out length of next word
@@ -967,6 +968,15 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
if (wordLen >= lineWidthLeft) {
// Not enough space left
+
+ // If first character right after the new line is a space, skip over it
+ if (wordLen) {
+ if (originalText[wordStartPos] == ' ') {
+ wordStartPos++;
+ wordLen--;
+ }
+ }
+
if (wordLen > maxWidth) {
// Word way too long, split it in half
curReadPos = curReadPos - (wordLen - maxWidth);
@@ -983,14 +993,6 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
// Reached absolute maximum? -> exit now
if (boxHeight >= HEIGHT_MAX)
break;
-
- // If first character right after the new line is a space, skip over it
- if (wordLen) {
- if (originalText[wordStartPos] == ' ') {
- wordStartPos++;
- wordLen--;
- }
- }
}
// Copy current word over