SCUMM: MONKEY-VGA fix bug #10571, Object stopped with active cutscene

Also occurs in original

Script 68 contains the code for handling the mugs. The issue occurs when a mug
changes state. It will call setObjectName for the new state which in its turn
restarts objects in inventory. Some objects (kidnap note) can be in a cutscene state
what causes a crash if the object gets restarted. This workaroud waits for cutscenes
to end, preventing the crash.

Script #68
[0000] (DD) setClass(Local[0],[146]);
[0007] (28) if (!Bit[421]) {
[000C] (1A)   Bit[421] = 1;
[0011] (62)   stopScript(201);
[0013] (62)   stopScript(188);
[0015] (80)   breakHere();
[0016] (D8)   printEgo([Text(sound(0x612F889, 0xA) + "This stuff is eating right through the mug!")]);
[0054] (80)   breakHere();
[0055] (0A)   startScript(201,[]);
[0058] (**) }
[0058] (2E) delay(300);
[005C] (DD) setClass(Local[0],[147]);
[0063] (D4) setObjectName(Local[0],"melting mug");
[0072] (1A) Var[233] = 500;
[0077] (48) if (VAR_ROOM == 33) {
[007E] (3A)   Var[233] -= 2;
[0083] (48) } else if (VAR_ROOM == 35) {
[008D] (3A)   Var[233] -= 3;
[0092] (48) } else if (VAR_ROOM == 34) {
[009C] (3A)   Var[233] -= 5;
[00A1] (18) } else {
[00A4] (3A)   Var[233] -= 1;
[00A9] (**) }
[00A9] (80) breakHere();
[00AA] (78) unless (Var[233] < 1) goto 0077;
[00B1] (DD) setClass(Local[0],[134]);
[00B8] (D4) setObjectName(Local[0],"mug near death");
[00CA] (2E) delay(300);
[00CE] (DD) setClass(Local[0],[12]);
[00D5] (D4) setObjectName(Local[0],"pewter wad");
[00E3] (9A) Local[1] = VAR_ROOM;
[00E8] (80) breakHere();
[00E9] (C8) if (Local[1] == VAR_ROOM) {
[00F0] (18)   goto 00E8;
[00F3] (**) }
[00F3] (A9) setOwnerOf(Local[0],0);
[00F7] (A9) setOwnerOf(Local[0],15);
[00FB] (0A) startScript(11,[]);
[00FE] (0A) startScript(12,[]);
[0101] (DD) setClass(Local[0],[19,6,140]);
[010E] (0C) Resource.unlockScript(69);
[0111] (A0) stopObjectCode();
END
This commit is contained in:
Ben Castricum 2021-08-22 14:18:31 +02:00 committed by Filippos Karapetis
parent ccc7412c57
commit 9f44c5522a

View file

@ -2088,6 +2088,21 @@ void ScummEngine_v5::o5_setCameraAt() {
}
void ScummEngine_v5::o5_setObjectName() {
// WORKAROUND bug #10571 (also occurs in original) Object stopped with active cutscene
// Script 68 contains the code for handling the mugs. The issue occurs when a mug
// changes state. It will call setObjectName for the new state which in its turn
// restarts objects in inventory. Some objects (kidnap note) can be in a cutscene state
// what causes a crash if the object gets restarted. This workaroud waits for cutscenes
// to end, preventing the crash.
if (_game.id == GID_MONKEY && vm.slot[_currentScript].number == 68) {
ScriptSlot *ss = vm.slot;
for (int i = 0; i < NUM_SCRIPT_SLOT; i++, ss++) {
if (ss->status != ssDead && ss->where == WIO_INVENTORY && ss->cutsceneOverride) {
_scriptPointer--;
return o5_breakHere();
}
}
}
int obj = getVarOrDirectWord(PARAM_1);
setObjectName(obj);
}