From be1ab48a57d45315941c5b8396357aa65bf2dd0b Mon Sep 17 00:00:00 2001 From: Travis Howell Date: Thu, 23 Sep 2004 05:02:15 +0000 Subject: Fix array pointer overflows in HE80+ games. Some arrays are nuked in startScene. svn-id: r15239 --- scumm/intern.h | 2 +- scumm/script.cpp | 8 ++++---- scumm/script_v6he.cpp | 2 +- scumm/scumm.cpp | 4 +++- scumm/scumm.h | 2 +- 5 files changed, 10 insertions(+), 8 deletions(-) diff --git a/scumm/intern.h b/scumm/intern.h index 3f54b7545f..b8ecf0aefa 100644 --- a/scumm/intern.h +++ b/scumm/intern.h @@ -572,7 +572,7 @@ protected: virtual void executeOpcode(byte i); virtual const char *getOpcodeDesc(byte i); - void localizeArray(int slot, int script); + void localizeArray(int slot, byte script); void redimArray(int arrayId, int newX, int newY, int d); int readFileToArray(int slot, int32 size); void writeFileFromArray(int slot, int resID); diff --git a/scumm/script.cpp b/scumm/script.cpp index 040ccf9591..1c0b39dd87 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -348,14 +348,14 @@ void ScummEngine::updateScriptPtr() { } /* Nuke arrays based on script */ -void ScummEngine::nukeArrays(int script) { +void ScummEngine::nukeArrays(byte script) { int i; - if (_heversion < 60 || !script) + if (_heversion < 60 || script == 0) return; - //FIXME Nukes wrong arrays in other - if (_gameId != GID_PUTTMOON) + //FIXME Nukes wrong arrays + if (_gameId == GID_FBEAR) return; for (i = 1; i < _numArray; i++) { diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 3b34e8dce8..63c8a45f4a 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -1154,7 +1154,7 @@ void ScummEngine_v60he::o60_soundOps() { } } -void ScummEngine_v60he::localizeArray(int slot, int script) { +void ScummEngine_v60he::localizeArray(int slot, byte script) { if (slot >= _numArray) error("o60_localizeArray(%d): array slot out of range", slot); diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 8c6041148a..3b423472b1 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -1769,12 +1769,14 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) { stopCycle(0); _sound->processSoundQues(); - if (_heversion >= 70 && _wizPolygons) { + if (_heversion >= 71 && _wizPolygons) { memset(_wizPolygons, 0, _wizNumPolygons * sizeof(WizPolygon)); } + // For HE80+ games for (i = 0; i < _numRoomVariables; i++) _roomVars[i] = 0; + nukeArrays(0xFFFFFFFF); for (i = 1; i < _numActors; i++) { _actors[i].hideActor(); diff --git a/scumm/scumm.h b/scumm/scumm.h index a5f69b285a..b0ca63b037 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -592,7 +592,7 @@ protected: public: void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr); void stopScript(int script); - void nukeArrays(int script); + void nukeArrays(byte script); protected: void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1); -- cgit v1.2.3