mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-24 13:13:58 +00:00
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. svn-id: r55071
This commit is contained in:
parent
c9330fb79e
commit
f96c8f6e39
@ -38,6 +38,7 @@ byte *additionalBgTable[9];
|
||||
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 loadCtFW(const char *ctName) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -53,9 +53,10 @@ Sound *g_sound = 0;
|
||||
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 @@ void CineEngine::initialize() {
|
||||
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.
|
||||
|
@ -217,9 +217,10 @@ enum {
|
||||
};
|
||||
|
||||
enum {
|
||||
kCineDebugScript = 1 << 0,
|
||||
kCineDebugPart = 1 << 1,
|
||||
kCineDebugSound = 1 << 2
|
||||
kCineDebugScript = 1 << 0,
|
||||
kCineDebugPart = 1 << 1,
|
||||
kCineDebugSound = 1 << 2,
|
||||
kCineDebugCollision = 1 << 3
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -1915,6 +1915,7 @@ int16 getZoneFromPositionRaw(byte *page, int16 x, int16 y, int16 width) {
|
||||
}
|
||||
|
||||
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;
|
||||
|
Loading…
x
Reference in New Issue
Block a user