diff options
author | Travis Howell | 2004-08-01 13:57:00 +0000 |
---|---|---|
committer | Travis Howell | 2004-08-01 13:57:00 +0000 |
commit | d60973b05e9c607b46edaa45b56b86953d7d079d (patch) | |
tree | bae645298b3f647fe29ee8991ac1cc49812c0b2c /scumm | |
parent | ea694ffd68a5071fda937b3d23d6796c3abb3ba3 (diff) | |
download | scummvm-rg350-d60973b05e9c607b46edaa45b56b86953d7d079d.tar.gz scummvm-rg350-d60973b05e9c607b46edaa45b56b86953d7d079d.tar.bz2 scummvm-rg350-d60973b05e9c607b46edaa45b56b86953d7d079d.zip |
HE games use different method to clear some arrays resources.
svn-id: r14423
Diffstat (limited to 'scumm')
-rw-r--r-- | scumm/resource.cpp | 1 | ||||
-rw-r--r-- | scumm/script.cpp | 20 | ||||
-rw-r--r-- | scumm/script_v6.cpp | 1 | ||||
-rw-r--r-- | scumm/script_v6he.cpp | 8 | ||||
-rw-r--r-- | scumm/scumm.cpp | 2 | ||||
-rw-r--r-- | scumm/scumm.h | 2 |
6 files changed, 30 insertions, 4 deletions
diff --git a/scumm/resource.cpp b/scumm/resource.cpp index 0a9f253311..f9529c75a3 100644 --- a/scumm/resource.cpp +++ b/scumm/resource.cpp @@ -2406,6 +2406,7 @@ void ScummEngine::allocateArrays() { _scummVars = (int32 *)calloc(_numVariables, sizeof(int32)); _bitVars = (byte *)calloc(_numBitVariables >> 3, 1); _images = (uint16 *)calloc(_numImages, sizeof(uint16)); + _arraySlot = (byte *)calloc(_numArray, 1); allocResTypeData(rtCostume, (_features & GF_NEW_COSTUMES) ? MKID('AKOS') : MKID('COST'), _numCostumes, "costume", 1); diff --git a/scumm/script.cpp b/scumm/script.cpp index 27e8c456c6..fccb581ebf 100644 --- a/scumm/script.cpp +++ b/scumm/script.cpp @@ -215,6 +215,7 @@ void ScummEngine::stopScript(int script) { error("Script %d stopped with active cutscene/override", script); ss->number = 0; ss->status = ssDead; + nukeArrays(script); if (_currentScript == i) _currentScript = 0xFF; } @@ -226,6 +227,7 @@ void ScummEngine::stopScript(int script) { while (num > 0) { if (nest->number == script && (nest->where == WIO_GLOBAL || nest->where == WIO_LOCAL)) { + nukeArrays(script); nest->number = 0xFF; nest->slot = 0xFF; nest->where = 0xFF; @@ -252,6 +254,7 @@ void ScummEngine::stopObjectScript(int script) { error("Object %d stopped with active cutscene/override", script); ss->number = 0; ss->status = ssDead; + nukeArrays(script); if (_currentScript == i) _currentScript = 0xFF; } @@ -263,6 +266,7 @@ void ScummEngine::stopObjectScript(int script) { while (num > 0) { if (nest->number == script && (nest->where == WIO_ROOM || nest->where == WIO_INVENTORY || nest->where == WIO_FLOBJECT)) { + nukeArrays(script); nest->number = 0xFF; nest->slot = 0xFF; nest->where = 0xFF; @@ -341,6 +345,19 @@ void ScummEngine::updateScriptPtr() { vm.slot[_currentScript].offs = _scriptPointer - _scriptOrgPointer; } +/* Nuke arrays based on script */ +void ScummEngine::nukeArrays(int script) { + int i; + + if (!_heversion || !script) + return; + + for (i = 1; i < _numArray; i++) { + if (_arraySlot[i] == script) + nukeResource(rtString, i); + } +} + /* Get the code pointer to a script */ void ScummEngine::getScriptBaseAddress() { ScriptSlot *ss; @@ -673,6 +690,7 @@ void ScummEngine::stopObjectCode() { } ss->number = 0; ss->status = ssDead; + nukeArrays(_currentScript); _currentScript = 0xFF; } @@ -828,6 +846,7 @@ void ScummEngine::killScriptsAndResources() { warning("Object %d stopped with active cutscene/override in exit", ss->number); ss->cutsceneOverride = 0; } + nukeArrays(i); ss->status = ssDead; } else if (ss->where == WIO_LOCAL) { // Earlier games only checked global scripts at this point @@ -835,6 +854,7 @@ void ScummEngine::killScriptsAndResources() { warning("Script %d stopped with active cutscene/override in exit", ss->number); ss->cutsceneOverride = 0; } + nukeArrays(i); ss->status = ssDead; } } diff --git a/scumm/script_v6.cpp b/scumm/script_v6.cpp index dfa5cc3187..024b6c91e1 100644 --- a/scumm/script_v6.cpp +++ b/scumm/script_v6.cpp @@ -465,6 +465,7 @@ void ScummEngine_v6::nukeArray(int a) { if (data) nukeResource(rtString, data); + _arraySlot[a] = 0; writeVar(a, 0); } diff --git a/scumm/script_v6he.cpp b/scumm/script_v6he.cpp index 712be5b040..ca81970d47 100644 --- a/scumm/script_v6he.cpp +++ b/scumm/script_v6he.cpp @@ -1124,12 +1124,12 @@ void ScummEngine_v6he::o6_soundOps() { } void ScummEngine_v6he::o6_localizeArray() { - int stringID = pop(); + int slot = pop(); - if (stringID < _numArray) { - _baseArrays[stringID][0] = (byte)_currentScript; + if (slot < _numArray) { + _arraySlot[slot] = vm.slot[_currentScript].number; } else { - warning("o6_localizeArray(%d): too big scriptID", stringID); + warning("o6_localizeArray(%d): array slot out of range", slot); } } diff --git a/scumm/scumm.cpp b/scumm/scumm.cpp index 412b52445e..ee36e5cbbc 100644 --- a/scumm/scumm.cpp +++ b/scumm/scumm.cpp @@ -2165,6 +2165,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) { if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) { if (ss->cutsceneOverride != 0) error("Object %d stopped with active cutscene/override in exit", ss->number); + nukeArrays(_currentScript); _currentScript = 0xFF; } else if (ss->where == WIO_LOCAL) { if (ss->cutsceneOverride != 0) { @@ -2172,6 +2173,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) { if (_version >= 5) error("Script %d stopped with active cutscene/override in exit", ss->number); } + nukeArrays(_currentScript); _currentScript = 0xFF; } } diff --git a/scumm/scumm.h b/scumm/scumm.h index ec6317201c..a8ccc77eb4 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -443,6 +443,7 @@ protected: Actor *_actors; // Has _numActors elements + byte *_arraySlot; uint16 *_inventory; uint16 *_newNames; uint16 *_images; @@ -572,6 +573,7 @@ public: void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr); void stopScript(int script); bool isScriptRunning(int script) const; // FIXME - should be protected, used by Sound::startTalkSound + void nukeArrays(int script); protected: void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1); |