From 412693ac70e237591335de18fc93b6113b96b42a Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Wed, 12 Oct 2005 22:13:41 +0000 Subject: Patch from wjp #1325224 "Fix for Gobliiins 1 EGA crash on game-over" which fixes bug #1324814 "GOB1 ega: lock up when game is over" svn-id: r19056 --- gob/goblin.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) (limited to 'gob') diff --git a/gob/goblin.cpp b/gob/goblin.cpp index 7a4168e631..be1b20a921 100644 --- a/gob/goblin.cpp +++ b/gob/goblin.cpp @@ -2387,6 +2387,7 @@ void gob_interFunc(void) { int16 layer; int16 state; int32 *retVarPtr; + bool objDescSet = false; retVarPtr = (int32 *)VAR_ADDRESS(59); @@ -2395,12 +2396,14 @@ void gob_interFunc(void) { if (cmd > 0 && cmd < 17) { extraData = inter_load16(); objDesc = gob_objects[extraData]; + objDescSet = true; extraData = inter_load16(); } if (cmd > 90 && cmd < 107) { extraData = inter_load16(); objDesc = gob_goblins[extraData]; + objDescSet = true; extraData = inter_load16(); cmd -= 90; } @@ -2408,13 +2411,25 @@ void gob_interFunc(void) { if (cmd > 110 && cmd < 128) { extraData = inter_load16(); objDesc = gob_goblins[extraData]; + objDescSet = true; cmd -= 90; } else if (cmd > 20 && cmd < 38) { extraData = inter_load16(); objDesc = gob_objects[extraData]; + objDescSet = true; } - if (cmd < 40 && objDesc == 0) +/* + NB: The original gobliiins engine did not initialize the objDesc + variable, so we manually check if objDesc is properly set before + checking if it is zero. If it was not set, we do not return. This + fixes a crash in the EGA version if the life bar is depleted, because + gob_interFunc is called multiple times with cmd == 39. + Bug #1324814 +*/ + + + if (cmd < 40 && objDescSet && objDesc == 0) return; debug(5, "cmd = %d", cmd); -- cgit v1.2.3