AGI: Fix regression from stringWordWrap rewrite

Space at the end of the string was handled inaccurately
Fixes kq1 text scrolling bug #7021
Rewrite was done in commit efb65324688f20cc534a25312f558f9264125762
This commit is contained in:
Martin Kiewitz 2016-02-07 00:23:46 +01:00
parent 3e90a83aa4
commit c43ee3a7a5

View File

@ -941,8 +941,17 @@ 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
while (originalText[curReadPos]) {
// Try to find out length of next word
// If first character is a space, skip it, so that we process at least this space
if (originalText[curReadPos] == ' ')
curReadPos++;
while (originalText[curReadPos]) {
if (originalText[curReadPos] == ' ')
break;
@ -1005,10 +1014,6 @@ char *TextMgr::stringWordWrap(const char *originalText, int16 maxWidth, int16 *c
}
wordStartPos = curReadPos;
// Last word ended with a space, skip this space for reading the next word
if (wordEndChar == ' ')
curReadPos++;
}
resultWrappedBuffer[curWritePos] = 0;