getScriptSlot() must start from slot 1, required for nukeArrays() in HE games.

svn-id: r17383
This commit is contained in:
Travis Howell 2005-04-05 11:06:03 +00:00
parent 23e4199699
commit aeec229615
6 changed files with 23 additions and 23 deletions

View file

@ -630,7 +630,7 @@ protected:
virtual void executeOpcode(byte i);
virtual const char *getOpcodeDesc(byte i);
void localizeArray(int slot, byte script);
void localizeArray(int slot, byte scriptSlot);
void redimArray(int arrayId, int newX, int newY, int d);
int readFileToArray(int slot, int32 size);
void writeFileFromArray(int slot, int resID);

View file

@ -224,7 +224,7 @@ void ScummEngine::stopScript(int script) {
error("Script %d stopped with active cutscene/override", script);
ss->number = 0;
ss->status = ssDead;
nukeArrays(script);
nukeArrays(i);
if (_currentScript == i)
_currentScript = 0xFF;
}
@ -236,7 +236,7 @@ void ScummEngine::stopScript(int script) {
while (num > 0) {
if (nest->number == script &&
(nest->where == WIO_GLOBAL || nest->where == WIO_LOCAL)) {
nukeArrays(script);
nukeArrays(nest->slot);
nest->number = 0xFF;
nest->slot = 0xFF;
nest->where = 0xFF;
@ -264,7 +264,7 @@ void ScummEngine::stopObjectScript(int script) {
error("Object %d stopped with active cutscene/override", script);
ss->number = 0;
ss->status = ssDead;
nukeArrays(script);
nukeArrays(i);
if (_currentScript == i)
_currentScript = 0xFF;
}
@ -276,7 +276,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);
nukeArrays(nest->slot);
nest->number = 0xFF;
nest->slot = 0xFF;
nest->where = 0xFF;
@ -288,12 +288,12 @@ void ScummEngine::stopObjectScript(int script) {
/* Return a free script slot */
int ScummEngine::getScriptSlot() {
ScriptSlot *ss;
ScriptSlot *s;
int i;
ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (ss->status == ssDead)
for (i = 1; i < NUM_SCRIPT_SLOT; i++) {
s = &vm.slot[i];
if (s->status == ssDead)
return i;
}
error("Too many scripts running, %d max", NUM_SCRIPT_SLOT);
@ -356,14 +356,14 @@ void ScummEngine::updateScriptPtr() {
}
/* Nuke arrays based on script */
void ScummEngine::nukeArrays(byte script) {
void ScummEngine::nukeArrays(byte scriptSlot) {
int i;
if (_heversion < 60 || script == 0)
if (_heversion < 60 || scriptSlot == 0)
return;
for (i = 1; i < _numArray; i++) {
if (_arraySlot[i] == script) {
if (_arraySlot[i] == scriptSlot) {
res.nukeResource(rtString, i);
_arraySlot[i] = 0;
}
@ -703,7 +703,7 @@ void ScummEngine::stopObjectCode() {
ss->cutsceneOverride = 0;
}
}
nukeArrays(ss->number);
nukeArrays(_currentScript);
ss->number = 0;
ss->status = ssDead;
_currentScript = 0xFF;

View file

@ -1179,16 +1179,16 @@ void ScummEngine_v60he::o60_soundOps() {
}
}
void ScummEngine_v60he::localizeArray(int slot, byte script) {
void ScummEngine_v60he::localizeArray(int slot, byte scriptSlot) {
if (slot >= _numArray)
error("o60_localizeArrayToScript(%d): array slot out of range", slot);
_arraySlot[slot] = script;
_arraySlot[slot] = scriptSlot;
}
void ScummEngine_v60he::o60_localizeArrayToScript() {
int slot = pop();
localizeArray(slot, vm.slot[_currentScript].number);
localizeArray(slot, _currentScript);
}
void ScummEngine_v60he::o60_seekFilePos() {

View file

@ -444,7 +444,7 @@ void ScummEngine_v80he::o80_getSoundVar() {
void ScummEngine_v80he::o80_localizeArrayToRoom() {
int slot = pop();
localizeArray(slot, (byte)0xFFFFFFFF);
localizeArray(slot, 0xFF);
}
void ScummEngine_v80he::o80_readConfigFile() {
@ -661,9 +661,9 @@ void ScummEngine_v80he::o80_pickVarRandom() {
if (readVar(value) == 0) {
defineArray(value, kDwordArray, 0, 0, 0, num);
if (value & 0x8000)
localizeArray(readVar(value), (byte)0xFFFFFFFF);
localizeArray(readVar(value), 0xFF);
else if (value & 0x4000)
localizeArray(readVar(value), vm.slot[_currentScript].number);
localizeArray(readVar(value), _currentScript);
if (num > 0) {
int16 counter = 0;

View file

@ -2136,13 +2136,13 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
if (ss->cutsceneOverride && _version >= 5)
error("Object %d stopped with active cutscene/override in exit", ss->number);
nukeArrays(ss->number);
nukeArrays(_currentScript);
_currentScript = 0xFF;
} else if (ss->where == WIO_LOCAL) {
if (ss->cutsceneOverride && _version >= 5)
error("Script %d stopped with active cutscene/override in exit", ss->number);
nukeArrays(ss->number);
nukeArrays(_currentScript);
_currentScript = 0xFF;
}
}
@ -2166,7 +2166,7 @@ void ScummEngine::startScene(int room, Actor *a, int objectNr) {
// For HE80+ games
for (i = 0; i < _numRoomVariables; i++)
_roomVars[i] = 0;
nukeArrays((byte)0xFFFFFFFF);
nukeArrays(0xFF);
for (i = 1; i < _numActors; i++) {
_actors[i].hideActor();

View file

@ -615,7 +615,7 @@ protected:
public:
void runScript(int script, bool freezeResistant, bool recursive, int *lvarptr, int cycle = 0);
void stopScript(int script);
void nukeArrays(byte script);
void nukeArrays(byte scriptSlot);
protected:
void runObjectScript(int script, int entry, bool freezeResistant, bool recursive, int *vars, int slot = -1, int cycle = 0);