[Scummvm-git-logs] scummvm master -> be763b59aa44c126ace6f0b8854d3ebc2ff62d37

m-kiewitz m_kiewitz at users.sourceforge.net
Fri Feb 24 00:54:51 CET 2017


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
be763b59aa AGI: act on exitAllLogics in testIfCode (fixes bug #9707)


Commit: be763b59aa44c126ace6f0b8854d3ebc2ff62d37
    https://github.com/scummvm/scummvm/commit/be763b59aa44c126ace6f0b8854d3ebc2ff62d37
Author: Martin Kiewitz (m_kiewitz at users.sourceforge.net)
Date: 2017-02-24T00:54:40+01:00

Commit Message:
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?

Changed paths:
    engines/agi/agi.h
    engines/agi/op_test.cpp


diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 46d0a34..2294593 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 b4bf38b..6afddf8 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;
 }





More information about the Scummvm-git-logs mailing list