aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorMartin Kiewitz2017-02-24 00:54:40 +0100
committerMartin Kiewitz2017-02-24 00:54:40 +0100
commitbe763b59aa44c126ace6f0b8854d3ebc2ff62d37 (patch)
treec93af4749469dbb3e580b72b52809efdef443ac3 /engines
parent9dd0cd51d5b243700ccbd154e1d91ddb84c307c2 (diff)
downloadscummvm-rg350-be763b59aa44c126ace6f0b8854d3ebc2ff62d37.tar.gz
scummvm-rg350-be763b59aa44c126ace6f0b8854d3ebc2ff62d37.tar.bz2
scummvm-rg350-be763b59aa44c126ace6f0b8854d3ebc2ff62d37.zip
AGI: act on exitAllLogics in testIfCode (fixes bug #9707)
Thanks waltervn for finding this one. Was a regression caused by the timer heuristic for detecting bad script code. When the heuristic identified being in an inner timer loop, it told ScummVM to sleep + process events. During that time a restore can get triggered by the user via GMM. When that happens, the restore is executed immediately. When still being inside testIfCode(), it may happen that execution goes beyond the end of the current logic incl. error/crash. TODO: maybe better change GMM as a whole for AGI, that restores are always processed in a delayed way after main loop got processed once?
Diffstat (limited to 'engines')
-rw-r--r--engines/agi/agi.h2
-rw-r--r--engines/agi/op_test.cpp17
2 files changed, 13 insertions, 6 deletions
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 46d0a341df..2294593427 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -867,7 +867,7 @@ public:
void unloadLogic(int16 logicNr);
int runLogic(int16 logicNr);
void debugConsole(int, int, const char *);
- int testIfCode(int);
+ bool testIfCode(int16 logicNr);
void executeAgiCommand(uint8, uint8 *);
private:
diff --git a/engines/agi/op_test.cpp b/engines/agi/op_test.cpp
index b4bf38b8a2..6afddf844a 100644
--- a/engines/agi/op_test.cpp
+++ b/engines/agi/op_test.cpp
@@ -376,7 +376,7 @@ uint8 AgiEngine::testSaid(uint8 nwords, uint8 *cc) {
return true;
}
-int AgiEngine::testIfCode(int lognum) {
+bool AgiEngine::testIfCode(int16 logicNr) {
AgiGame *state = &_game;
uint8 op;
uint8 p[16];
@@ -387,8 +387,8 @@ int AgiEngine::testIfCode(int lognum) {
int result = true;
while (!(shouldQuit() || _restartGame) && !endTest) {
- if (_debug.enabled && (_debug.logic0 || lognum))
- debugConsole(lognum, lTEST_MODE, NULL);
+ if (_debug.enabled && (_debug.logic0 || logicNr))
+ debugConsole(logicNr, lTEST_MODE, NULL);
op = *(code + ip++);
memmove(p, (code + ip), 16);
@@ -419,6 +419,13 @@ int AgiEngine::testIfCode(int lognum) {
default:
// Evaluate the command and skip the rest of the instruction
_opCodesCond[op].functionPtr(state, this, p);
+ if (state->exitAllLogics) {
+ // required even here, because of at least the timer heuristic
+ // which when triggered waits a bit and processes ScummVM events and user may therefore restore a saved game
+ // fixes bug #9707
+ // TODO: maybe delay restoring the game instead, when GMM is used?
+ return true;
+ }
skipInstruction(op);
// NOT mode is enabled only for one instruction
@@ -457,8 +464,8 @@ int AgiEngine::testIfCode(int lognum) {
else
ip += READ_LE_UINT16(code + ip) + 2;
- if (_debug.enabled && (_debug.logic0 || lognum))
- debugConsole(lognum, 0xFF, result ? "=true" : "=false");
+ if (_debug.enabled && (_debug.logic0 || logicNr))
+ debugConsole(logicNr, 0xFF, result ? "=true" : "=false");
return result;
}