- 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
This commit is contained in:
Johannes Schickel 2009-06-01 21:03:44 +00:00
parent 5f7515162a
commit bdea557d7f
3 changed files with 61 additions and 4 deletions

View file

@ -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() {

View file

@ -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;
}
}

View file

@ -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;
}