[Scummvm-cvs-logs] SF.net SVN: scummvm:[41111] scummvm/trunk/engines/kyra

lordhoto at users.sourceforge.net lordhoto at users.sourceforge.net
Mon Jun 1 23:03:44 CEST 2009


Revision: 41111
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41111&view=rev
Author:   lordhoto
Date:     2009-06-01 21:03:44 +0000 (Mon, 01 Jun 2009)

Log Message:
-----------
- 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)

Modified Paths:
--------------
    scummvm/trunk/engines/kyra/lol.cpp
    scummvm/trunk/engines/kyra/screen.cpp
    scummvm/trunk/engines/kyra/sequences_lol.cpp

Modified: scummvm/trunk/engines/kyra/lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/lol.cpp	2009-06-01 20:55:31 UTC (rev 41110)
+++ scummvm/trunk/engines/kyra/lol.cpp	2009-06-01 21:03:44 UTC (rev 41111)
@@ -242,6 +242,8 @@
 	_timer3Para = 0;
 	_scriptCharacterCycle = 0;
 	_partyDeathFlag = -1;
+
+	memset(&_itemScript, 0, sizeof(_itemScript));
 }
 
 LoLEngine::~LoLEngine() {

Modified: scummvm/trunk/engines/kyra/screen.cpp
===================================================================
--- scummvm/trunk/engines/kyra/screen.cpp	2009-06-01 20:55:31 UTC (rev 41110)
+++ scummvm/trunk/engines/kyra/screen.cpp	2009-06-01 21:03:44 UTC (rev 41111)
@@ -1004,6 +1004,7 @@
 	while (1) {
 		uint c = *str++;
 		c &= 0xFF;
+
 		if (c == 0) {
 			break;
 		} else if (c == '\r') {
@@ -1014,10 +1015,10 @@
 			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 @@
 				charHeight = SJIS_CHARSIZE >> 1;
 				drawCharSJIS(c, x, y);
 			}
+
 			x += charWidth;
 		}
 	}

Modified: scummvm/trunk/engines/kyra/sequences_lol.cpp
===================================================================
--- scummvm/trunk/engines/kyra/sequences_lol.cpp	2009-06-01 20:55:31 UTC (rev 41110)
+++ scummvm/trunk/engines/kyra/sequences_lol.cpp	2009-06-01 21:03:44 UTC (rev 41111)
@@ -842,7 +842,7 @@
 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 @@
 
 	_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 @@
 		uint8 code;
 		uint8 height;
 		uint8 alignment;
-	} strings[36];
+	} strings[37];
 	memset(strings, 0, sizeof(strings));
 
 	int countStrings = 0;
@@ -977,6 +979,57 @@
 
 			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;
 		}
 


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list