diff options
author | Johannes Schickel | 2009-06-01 21:03:44 +0000 |
---|---|---|
committer | Johannes Schickel | 2009-06-01 21:03:44 +0000 |
commit | bdea557d7f98b6aeba3b72efd57c4e4aa39c36be (patch) | |
tree | eb5f06088330421476f101ad48bb0d5618ececb7 /engines | |
parent | 5f7515162a77ea507444d456d696cf52fcdba18f (diff) | |
download | scummvm-rg350-bdea557d7f98b6aeba3b72efd57c4e4aa39c36be.tar.gz scummvm-rg350-bdea557d7f98b6aeba3b72efd57c4e4aa39c36be.tar.bz2 scummvm-rg350-bdea557d7f98b6aeba3b72efd57c4e4aa39c36be.zip |
- Fix some valgrind warnings
- Fix original bug in the Lands of Lore credits, which messed up some headings (the original didn't display them at all for some reason)
svn-id: r41111
Diffstat (limited to 'engines')
-rw-r--r-- | engines/kyra/lol.cpp | 2 | ||||
-rw-r--r-- | engines/kyra/screen.cpp | 6 | ||||
-rw-r--r-- | engines/kyra/sequences_lol.cpp | 57 |
3 files changed, 61 insertions, 4 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 8c969b2b33..e504fc5bad 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -242,6 +242,8 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy _timer3Para = 0; _scriptCharacterCycle = 0; _partyDeathFlag = -1; + + memset(&_itemScript, 0, sizeof(_itemScript)); } LoLEngine::~LoLEngine() { diff --git a/engines/kyra/screen.cpp b/engines/kyra/screen.cpp index 78dd4fd020..08b05a8da3 100644 --- a/engines/kyra/screen.cpp +++ b/engines/kyra/screen.cpp @@ -1004,6 +1004,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 while (1) { uint c = *str++; c &= 0xFF; + if (c == 0) { break; } else if (c == '\r') { @@ -1014,10 +1015,10 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 if (x + charWidth > SCREEN_W) { x = x_start; y += charHeight + _charOffset; - if (y >= SCREEN_H) { + if (y >= SCREEN_H) break; - } } + if (c <= 0x7F || !_useSJIS) { drawCharANSI(c, x, y); charHeight = charHeightFnt; @@ -1028,6 +1029,7 @@ void Screen::printText(const char *str, int x, int y, uint8 color1, uint8 color2 charHeight = SJIS_CHARSIZE >> 1; drawCharSJIS(c, x, y); } + x += charWidth; } } diff --git a/engines/kyra/sequences_lol.cpp b/engines/kyra/sequences_lol.cpp index 1f5a2c35ec..9463989b86 100644 --- a/engines/kyra/sequences_lol.cpp +++ b/engines/kyra/sequences_lol.cpp @@ -842,7 +842,7 @@ void LoLEngine::showOutro(int character, bool maxDifficulty) { void LoLEngine::showCredits() { for (int i = 0; i < 255; ++i) _outroShapeTable[i] = i; - _outroShapeTable[256] = 0; + _outroShapeTable[255] = 0; _sound->haltTrack(); _sound->loadSoundFile("LOREFINL"); @@ -860,6 +860,8 @@ void LoLEngine::showCredits() { _screen->copyRegion(0, 0, 0, 0, 320, 200, 2, 0, Screen::CR_NO_P_CHECK); + _screen->_charOffset = 0; + char *credits = (char *)_res->fileData("CREDITS.TXT", 0); processCredits(credits, 19, 4, 5); delete[] credits; @@ -913,7 +915,7 @@ void LoLEngine::processCredits(char *t, int dimState, int page, int delayTime) { uint8 code; uint8 height; uint8 alignment; - } strings[36]; + } strings[37]; memset(strings, 0, sizeof(strings)); int countStrings = 0; @@ -977,6 +979,57 @@ void LoLEngine::processCredits(char *t, int dimState, int page, int delayTime) { s.y = y; s.str = curString; + + // WORKAROUND: The original did supply some texts, which wouldn't fit on one line. + // To display them properly, we will break them into two separate entries. The original + // just did not display these lines at all. (At least not in LordHoto's tests with DOSBox). + if (s.x + _screen->getTextWidth(s.str) > Screen::SCREEN_W) { + char *nextLine = 0; + char *lastSeparator = 0; + + int backupX = s.x; + + while (s.x + _screen->getTextWidth(s.str) > Screen::SCREEN_W) { + char *sep = strrchr(s.str, ' '); + + if (lastSeparator) + *lastSeparator = ' '; + + lastSeparator = sep; + + if (lastSeparator) { + *lastSeparator = 0; + nextLine = lastSeparator + 1; + + s.x = MAX(((_screen->_curDim->w << 3) - _screen->getTextWidth(s.str)) / 2, 0); + } else { + // It seems we ca not find any whitespace, thus we are better safe and + // do not break up the line into two parts. (This is just paranoia) + nextLine = 0; + break; + } + } + + s.x = backupX; + + if (nextLine) { + ++countStrings; + + // Center old string + s.alignment = 0; + s.x = ((_screen->_curDim->w << 3) - _screen->getTextWidth(s.str)) / 2; + + // Add new string, also centered + CreditsString &n = strings[countStrings + 1]; + n.y = s.y + s.height + (s.height >> 3); + n.height = s.height; + n.alignment = 0; + n.code = s.code; + n.str = nextLine; + n.x = ((_screen->_curDim->w << 3) - _screen->getTextWidth(n.str)) / 2; + } + } + ++countStrings; } |