consistently index script slots with index 0 (not 1); this fixes bug #739463; made stopScriptNr match stopObjectScript more closely (we could merge them into one function one day)

svn-id: r7645
This commit is contained in:
Max Horn 2003-05-18 20:57:32 +00:00
parent 988ec14c5f
commit 6b7484f320

View file

@ -87,18 +87,17 @@ void Scumm::stopScriptNr(int script) {
if (script == 0) if (script == 0)
return; return;
ss = &vm.slot[1]; ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
for (i = 1; i < NUM_SCRIPT_SLOT; i++, ss++) { if (script == ss->number && ss->status != ssDead &&
if (script != ss->number || ss->where != WIO_GLOBAL && ss->where != WIO_LOCAL || ss->status == ssDead) (ss->where == WIO_GLOBAL && ss->where == WIO_LOCAL)) {
continue; if (ss->cutsceneOverride)
error("Script %d stopped with active cutscene/override", script);
if (ss->cutsceneOverride) ss->number = 0;
error("Script %d stopped with active cutscene/override", script); ss->status = ssDead;
ss->number = 0; if (_currentScript == i)
ss->status = ssDead; _currentScript = 0xFF;
if (_currentScript == i) }
_currentScript = 0xFF;
} }
if (_numNestedScripts == 0) if (_numNestedScripts == 0)
@ -108,7 +107,8 @@ void Scumm::stopScriptNr(int script) {
num = _numNestedScripts; num = _numNestedScripts;
do { do {
if (nest->number == script && (nest->where == WIO_GLOBAL || nest->where == WIO_LOCAL)) { if (nest->number == script &&
(nest->where == WIO_GLOBAL || nest->where == WIO_LOCAL)) {
nest->number = 0xFF; nest->number = 0xFF;
nest->slot = 0xFF; nest->slot = 0xFF;
nest->where = 0xFF; nest->where = 0xFF;
@ -125,9 +125,8 @@ void Scumm::stopObjectScript(int script) {
if (script == 0) if (script == 0)
return; return;
ss = &vm.slot[1]; ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
for (i = 1; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (script == ss->number && ss->status != ssDead && if (script == ss->number && ss->status != ssDead &&
(ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) { (ss->where == WIO_ROOM || ss->where == WIO_INVENTORY || ss->where == WIO_FLOBJECT)) {
if (ss->cutsceneOverride) if (ss->cutsceneOverride)
@ -159,9 +158,9 @@ void Scumm::stopObjectScript(int script) {
int Scumm::getScriptSlot() { int Scumm::getScriptSlot() {
ScriptSlot *ss; ScriptSlot *ss;
int i; int i;
ss = &vm.slot[1];
for (i = 1; i < NUM_SCRIPT_SLOT; i++, ss++) { ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (ss->status == ssDead) if (ss->status == ssDead)
return i; return i;
} }
@ -550,7 +549,7 @@ void Scumm::runHook(int i) {
void Scumm::freezeScripts(int flag) { void Scumm::freezeScripts(int flag) {
int i; int i;
for (i = 1; i < NUM_SCRIPT_SLOT; i++) { for (i = 0; i < NUM_SCRIPT_SLOT; i++) {
if (_currentScript != i && vm.slot[i].status != ssDead && (vm.slot[i].unk1 == 0 || flag >= 0x80)) { if (_currentScript != i && vm.slot[i].status != ssDead && (vm.slot[i].unk1 == 0 || flag >= 0x80)) {
vm.slot[i].status |= 0x80; vm.slot[i].status |= 0x80;
vm.slot[i].freezeCount++; vm.slot[i].freezeCount++;
@ -568,7 +567,7 @@ void Scumm::freezeScripts(int flag) {
void Scumm::unfreezeScripts() { void Scumm::unfreezeScripts() {
int i; int i;
for (i = 1; i < NUM_SCRIPT_SLOT; i++) { for (i = 0; i < NUM_SCRIPT_SLOT; i++) {
if (vm.slot[i].status & 0x80) { if (vm.slot[i].status & 0x80) {
if (!--vm.slot[i].freezeCount) { if (!--vm.slot[i].freezeCount) {
vm.slot[i].status &= 0x7F; vm.slot[i].status &= 0x7F;
@ -662,9 +661,8 @@ void Scumm::killScriptsAndResources() {
ScriptSlot *ss; ScriptSlot *ss;
int i; int i;
ss = &vm.slot[1]; ss = vm.slot;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
for (i = 1; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) { if (ss->where == WIO_ROOM || ss->where == WIO_FLOBJECT) {
if (ss->cutsceneOverride != 0) if (ss->cutsceneOverride != 0)
error("Object %d stopped with active cutscene/override in exit", ss->number); error("Object %d stopped with active cutscene/override in exit", ss->number);
@ -690,7 +688,7 @@ void Scumm::killScriptsAndResources() {
} }
void Scumm::killAllScriptsExceptCurrent() { void Scumm::killAllScriptsExceptCurrent() {
for (int i = 1; i < NUM_SCRIPT_SLOT; i++) { for (int i = 0; i < NUM_SCRIPT_SLOT; i++) {
if (i != _currentScript) if (i != _currentScript)
vm.slot[i].status = ssDead; vm.slot[i].status = ssDead;
} }
@ -794,7 +792,7 @@ void Scumm::runInputScript(int a, int cmd, int mode) {
} }
void Scumm::decreaseScriptDelay(int amount) { void Scumm::decreaseScriptDelay(int amount) {
ScriptSlot *ss = &vm.slot[0]; ScriptSlot *ss = vm.slot;
int i; int i;
for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) { for (i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (ss->status == ssPaused) { if (ss->status == ssPaused) {