[Scummvm-cvs-logs] scummvm master -> 81fdf2c10306fa8d449476f6c77afb8299b93f4d

bluegr md5 at scummvm.org
Mon Sep 26 00:02:49 CEST 2011


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:
81fdf2c103 AGI: Fixed bug #3074570 - "AGI LSL1: TAB stops working after restart"


Commit: 81fdf2c10306fa8d449476f6c77afb8299b93f4d
    https://github.com/scummvm/scummvm/commit/81fdf2c10306fa8d449476f6c77afb8299b93f4d
Author: Filippos Karapetis (md5 at scummvm.org)
Date: 2011-09-25T14:56:10-07:00

Commit Message:
AGI: Fixed bug #3074570 - "AGI LSL1: TAB stops working after restart"

Applied eriktorbjorn's patch from that bug tracker item (slightly
modified), which is what NAGI does, and which fixes restarting in LSL1
and PQ1 (bug #2823762), and other AGI games that do not reset the
controller keys when restarting.

Changed paths:
    engines/agi/agi.cpp
    engines/agi/agi.h
    engines/agi/cycle.cpp
    engines/agi/keyboard.cpp
    engines/agi/op_cmd.cpp



diff --git a/engines/agi/agi.cpp b/engines/agi/agi.cpp
index 3a79f02..49b4335 100644
--- a/engines/agi/agi.cpp
+++ b/engines/agi/agi.cpp
@@ -578,11 +578,7 @@ AgiEngine::AgiEngine(OSystem *syst, const AGIGameDescription *gameDesc) : AgiBas
 	_predictiveDictLineCount = 0;
 	_firstSlot = 0;
 
-	// NOTE: On game reload the keys do not get set again,
-	// thus it is incorrect to reset it in agiInit(). Fixes bug #2823762
-	_game.lastController = 0;
-	for (int i = 0; i < MAX_DIRS; i++)
-		_game.controllerOccured[i] = false;
+	resetControllers();
 
 	setupOpcodes();
 	_game._curLogic = NULL;
diff --git a/engines/agi/agi.h b/engines/agi/agi.h
index 189eb7d..4037fae 100644
--- a/engines/agi/agi.h
+++ b/engines/agi/agi.h
@@ -614,7 +614,6 @@ struct AgiGame {
 
 	bool controllerOccured[MAX_DIRS];  /**< keyboard keypress events */
 	AgiController controllers[MAX_CONTROLLERS];
-	int lastController;
 
 	char strings[MAX_STRINGS + 1][MAX_STRINGLEN]; /**< strings */
 
diff --git a/engines/agi/cycle.cpp b/engines/agi/cycle.cpp
index e6f122f..9cbab1f 100644
--- a/engines/agi/cycle.cpp
+++ b/engines/agi/cycle.cpp
@@ -384,7 +384,6 @@ int AgiEngine::runGame() {
 
 		if (_restartGame) {
 			setflag(fRestartGame, true);
-			_game.lastController = 0;
 			setvar(vTimeDelay, 2);	// "normal" speed
 			_restartGame = false;
 		}
diff --git a/engines/agi/keyboard.cpp b/engines/agi/keyboard.cpp
index d899a6e..4ac0849 100644
--- a/engines/agi/keyboard.cpp
+++ b/engines/agi/keyboard.cpp
@@ -114,7 +114,7 @@ int AgiEngine::handleController(int key) {
 
 	debugC(3, kDebugLevelInput, "key = %04x", key);
 
-	for (i = 0; i < _game.lastController; i++) {
+	for (i = 0; i < MAX_CONTROLLERS; i++) {
 		if (_game.controllers[i].keycode == key) {
 			debugC(3, kDebugLevelInput, "event %d: key press", _game.controllers[i].controller);
 			_game.controllerOccured[_game.controllers[i].controller] = true;
diff --git a/engines/agi/op_cmd.cpp b/engines/agi/op_cmd.cpp
index d1db956..15f7ac6 100644
--- a/engines/agi/op_cmd.cpp
+++ b/engines/agi/op_cmd.cpp
@@ -1516,20 +1516,25 @@ void cmdSetCursorChar(AgiGame *state, uint8 *p) {
 }
 
 void cmdSetKey(AgiGame *state, uint8 *p) {
-	int key;
+	int key = 256 * p1 + p0;
+	int slot = -1;
 
-	if (state->lastController >= MAX_CONTROLLERS) {
+	for (int i = 0; i < MAX_CONTROLLERS; i++) {
+		if (slot == -1 && !state->controllers[i].keycode)
+			slot = i;
+
+		if (state->controllers[i].keycode == key && state->controllers[i].controller == p2)
+			return;
+	}
+
+	if (slot == -1) {
 		warning("Number of set.keys exceeded %d", MAX_CONTROLLERS);
 		return;
 	}
 
-	debugC(4, kDebugLevelScripts, "%d %d %d", p0, p1, p2);
-
-	key = 256 * p1 + p0;
-
-	state->controllers[state->lastController].keycode = key;
-	state->controllers[state->lastController].controller = p2;
-	state->lastController++;
+	debugC(4, kDebugLevelScripts, "cmdSetKey: %d %d %d", p0, p1, p2);
+	state->controllers[slot].keycode = key;
+	state->controllers[slot].controller = p2;
 
 	state->controllerOccured[p2] = false;
 }






More information about the Scummvm-git-logs mailing list