[Scummvm-cvs-logs] SF.net SVN: scummvm:[55071] scummvm/trunk/engines/cine

tdhs at users.sourceforge.net tdhs at users.sourceforge.net
Fri Dec 31 10:14:50 CET 2010


Revision: 55071
          http://scummvm.svn.sourceforge.net/scummvm/?rev=55071&view=rev
Author:   tdhs
Date:     2010-12-31 09:14:49 +0000 (Fri, 31 Dec 2010)

Log Message:
-----------
CINE: Fix CollisionPage Uninitialised Reads in Operation Stealth.

The collisionPage is only initialised with values when loadCtFw() / loadCtOS() is called.
However, currently during the display of the Delphine Software Logo in Operation Stealth,
checkCollision() is called, but the collisionPage has not been loaded.
To fix the invalid reads, have added code to set the page to zero after allocation.
Shouldn't cause any issues to FW as this will load over the top anyway.

Have also added debug output around this behaviour so that if this is not sufficient i.e. a collision page load is actually missing, then this will aid investigation.

Modified Paths:
--------------
    scummvm/trunk/engines/cine/bg.cpp
    scummvm/trunk/engines/cine/cine.cpp
    scummvm/trunk/engines/cine/cine.h
    scummvm/trunk/engines/cine/script_fw.cpp

Modified: scummvm/trunk/engines/cine/bg.cpp
===================================================================
--- scummvm/trunk/engines/cine/bg.cpp	2010-12-31 09:07:44 UTC (rev 55070)
+++ scummvm/trunk/engines/cine/bg.cpp	2010-12-31 09:14:49 UTC (rev 55071)
@@ -38,6 +38,7 @@
 int16 currentAdditionalBgIdx = 0, currentAdditionalBgIdx2 = 0;
 
 byte loadCtFW(const char *ctName) {
+	debugC(1, kCineDebugCollision, "loadCtFW(\"%s\")", ctName);
 	uint16 header[32];
 	byte *ptr, *dataPtr;
 
@@ -71,12 +72,21 @@
 }
 
 byte loadCtOS(const char *ctName) {
+	debugC(1, kCineDebugCollision, "loadCtOS(\"%s\")", ctName);
 	byte *ptr, *dataPtr;
 
+	int16 foundFileIdx = findFileInBundle(ctName);
+	if (foundFileIdx == -1) {
+		warning("loadCtOS: Unable to find collision data file '%s'", ctName);
+		// FIXME: Rework this function's return value policy and return an appropriate value here.
+		// The return value isn't yet used for anything so currently it doesn't really matter.
+		return 0;
+	}
+
 	if (currentCtName != ctName)
 		strcpy(currentCtName, ctName);
 
-	ptr = dataPtr = readBundleFile(findFileInBundle(ctName));
+	ptr = dataPtr = readBundleFile(foundFileIdx);
 
 	uint16 bpp = READ_BE_UINT16(ptr);
 	ptr += 2;

Modified: scummvm/trunk/engines/cine/cine.cpp
===================================================================
--- scummvm/trunk/engines/cine/cine.cpp	2010-12-31 09:07:44 UTC (rev 55070)
+++ scummvm/trunk/engines/cine/cine.cpp	2010-12-31 09:14:49 UTC (rev 55071)
@@ -53,9 +53,10 @@
 CineEngine *g_cine = 0;
 
 CineEngine::CineEngine(OSystem *syst, const CINEGameDescription *gameDesc) : Engine(syst), _gameDescription(gameDesc) {
-	DebugMan.addDebugChannel(kCineDebugScript, "Script", "Script debug level");
-	DebugMan.addDebugChannel(kCineDebugPart,   "Part",   "Part debug level");
-	DebugMan.addDebugChannel(kCineDebugSound,  "Sound",  "Sound debug level");
+	DebugMan.addDebugChannel(kCineDebugScript,    "Script",    "Script debug level");
+	DebugMan.addDebugChannel(kCineDebugPart,      "Part",      "Part debug level");
+	DebugMan.addDebugChannel(kCineDebugSound,     "Sound",     "Sound debug level");
+	DebugMan.addDebugChannel(kCineDebugCollision, "Collision", "Collision debug level");
 	_console = new CineConsole(this);
 
 	// Setup mixer
@@ -161,6 +162,7 @@
 	renderer->initialize();
 
 	collisionPage = new byte[320 * 200];
+	memset(collisionPage, 0, 320 * 200);
 
 	// Clear part buffer as there's nothing loaded into it yet.
 	// Its size will change when loading data into it with the loadPart function.

Modified: scummvm/trunk/engines/cine/cine.h
===================================================================
--- scummvm/trunk/engines/cine/cine.h	2010-12-31 09:07:44 UTC (rev 55070)
+++ scummvm/trunk/engines/cine/cine.h	2010-12-31 09:14:49 UTC (rev 55071)
@@ -217,9 +217,10 @@
 };
 
 enum {
-	kCineDebugScript = 1 << 0,
-	kCineDebugPart   = 1 << 1,
-	kCineDebugSound  = 1 << 2
+	kCineDebugScript    = 1 << 0,
+	kCineDebugPart      = 1 << 1,
+	kCineDebugSound     = 1 << 2,
+	kCineDebugCollision = 1 << 3
 };
 
 enum {

Modified: scummvm/trunk/engines/cine/script_fw.cpp
===================================================================
--- scummvm/trunk/engines/cine/script_fw.cpp	2010-12-31 09:07:44 UTC (rev 55070)
+++ scummvm/trunk/engines/cine/script_fw.cpp	2010-12-31 09:14:49 UTC (rev 55071)
@@ -1915,6 +1915,7 @@
 }
 
 int16 checkCollision(int16 objIdx, int16 x, int16 y, int16 numZones, int16 zoneIdx) {
+	debugC(1, kCineDebugCollision, "checkCollision(objIdx: %d x: %d y:%d numZones:%d zoneIdx: %d)", objIdx, x, y, numZones, zoneIdx);
 	int16 lx = g_cine->_objectTable[objIdx].x + x;
 	int16 ly = g_cine->_objectTable[objIdx].y + y;
 	int16 idx;


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