mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-21 09:21:08 +00:00
HE games use different method to clear some arrays resources.
svn-id: r14423
This commit is contained in:
parent
ea694ffd68
commit
d60973b05e
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -465,6 +465,7 @@ void ScummEngine_v6::nukeArray(int a) {
|
||||
|
||||
if (data)
|
||||
nukeResource(rtString, data);
|
||||
_arraySlot[a] = 0;
|
||||
|
||||
writeVar(a, 0);
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user