[Scummvm-git-logs] scummvm master -> 9504ecd74e8cc48a86c577617c6b9b226170949b

dreammaster dreammaster at scummvm.org
Tue Mar 20 02:26:07 CET 2018


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:
9504ecd74e XEEN: Fix whether events are checked after openGrate calls


Commit: 9504ecd74e8cc48a86c577617c6b9b226170949b
    https://github.com/scummvm/scummvm/commit/9504ecd74e8cc48a86c577617c6b9b226170949b
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2018-03-19T21:25:59-04:00

Commit Message:
XEEN: Fix whether events are checked after openGrate calls

Changed paths:
    engines/xeen/interface.cpp
    engines/xeen/scripts.cpp
    engines/xeen/scripts.h


diff --git a/engines/xeen/interface.cpp b/engines/xeen/interface.cpp
index 11e0ee7..aa58f25 100644
--- a/engines/xeen/interface.cpp
+++ b/engines/xeen/interface.cpp
@@ -285,28 +285,24 @@ void Interface::perform() {
 		switch (lookupId) {
 		case 1:
 			if (!map._isOutdoors) {
-				scripts.openGrate(13, 1);
-				eventsFlag = _buttonValue != 0;
+				eventsFlag = !scripts.openGrate(13, 1);
 			}
 			break;
 		case 6:
 			// Open grate being closed
 			if (!map._isOutdoors) {
-				scripts.openGrate(9, 0);
-				eventsFlag = _buttonValue != 0;
+				eventsFlag = !scripts.openGrate(9, 0);
 			}
 			break;
 		case 9:
 			// Closed grate being opened
 			if (!map._isOutdoors) {
-				scripts.openGrate(6, 0);
-				eventsFlag = _buttonValue != 0;
+				eventsFlag = !scripts.openGrate(6, 0);
 			}
 			break;
 		case 13:
 			if (!map._isOutdoors) {
-				scripts.openGrate(1, 1);
-				eventsFlag = _buttonValue != 0;
+				eventsFlag = !scripts.openGrate(1, 1);
 			}
 			break;
 		default:
diff --git a/engines/xeen/scripts.cpp b/engines/xeen/scripts.cpp
index cc42081..3b989ab 100644
--- a/engines/xeen/scripts.cpp
+++ b/engines/xeen/scripts.cpp
@@ -269,7 +269,7 @@ int Scripts::checkEvents() {
 	return _scriptResult;
 }
 
-void Scripts::openGrate(int wallVal, int action) {
+bool Scripts::openGrate(int wallVal, int action) {
 	Combat &combat = *_vm->_combat;
 	FileManager &files = *_vm->_files;
 	Interface &intf = *_vm->_interface;
@@ -278,60 +278,62 @@ void Scripts::openGrate(int wallVal, int action) {
 	Sound &sound = *_vm->_sound;
 	int ccNum = files._ccNum;
 
-	if ((wallVal != 13 || map._currentGrateUnlocked) && (!ccNum || wallVal != 9 ||
-			map.mazeData()._wallKind != 2)) {
-		if (wallVal != 9 && !map._currentGrateUnlocked) {
-			int charIndex = WhoWill::show(_vm, 13, action, false) - 1;
-			if (charIndex < 0) {
-				intf.draw3d(true);
-				return;
-			}
-
-			// There is a 1 in 4 chance the character will receive damage
-			if (_vm->getRandomNumber(1, 4) == 1) {
-				combat.giveCharDamage(map.mazeData()._trapDamage,
-					(DamageType)_vm->getRandomNumber(0, 6), charIndex);
-			}
+	if (!((wallVal != 13 || map._currentGrateUnlocked) && (!ccNum || wallVal != 9 ||
+			map.mazeData()._wallKind != 2)))
+		return false;
 
-			// Check whether character can unlock the door
-			Character &c = party._activeParty[charIndex];
-			if ((c.getThievery() + _vm->getRandomNumber(1, 20)) <
-					map.mazeData()._difficulties._unlockDoor)
-				return;
+	if (wallVal != 9 && !map._currentGrateUnlocked) {
+		int charIndex = WhoWill::show(_vm, 13, action, false) - 1;
+		if (charIndex < 0) {
+			intf.draw3d(true);
+			return true;
+		}
 
-			c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel();
+		// There is a 1 in 4 chance the character will receive damage
+		if (_vm->getRandomNumber(1, 4) == 1) {
+			combat.giveCharDamage(map.mazeData()._trapDamage,
+				(DamageType)_vm->getRandomNumber(0, 6), charIndex);
 		}
 
-		// Flag the grate as unlocked, and the wall the grate is on
-		map.setCellSurfaceFlags(party._mazePosition, 0x80);
-		map.setWall(party._mazePosition, party._mazeDirection, wallVal);
+		// Check whether character can unlock the door
+		Character &c = party._activeParty[charIndex];
+		if ((c.getThievery() + _vm->getRandomNumber(1, 20)) <
+				map.mazeData()._difficulties._unlockDoor)
+			return true;
 
-		// Set the grate as opened and the wall on the other side of the grate
-		Common::Point pt = party._mazePosition;
-		Direction dir = (Direction)((int)party._mazeDirection ^ 2);
-		switch (party._mazeDirection) {
-		case DIR_NORTH:
-			pt.y++;
-			break;
-		case DIR_EAST:
-			pt.x++;
-			break;
-		case DIR_SOUTH:
-			pt.y--;
-			break;
-		case DIR_WEST:
-			pt.x--;
-			break;
-		default:
-			break;
-		}
+		c._experience += map.mazeData()._difficulties._unlockDoor * c.getCurrentLevel();
+	}
 
-		map.setCellSurfaceFlags(pt, 0x80);
-		map.setWall(pt, dir, wallVal);
+	// Flag the grate as unlocked, and the wall the grate is on
+	map.setCellSurfaceFlags(party._mazePosition, 0x80);
+	map.setWall(party._mazePosition, party._mazeDirection, wallVal);
 
-		sound.playFX(10);
-		intf.draw3d(true);
+	// Set the grate as opened and the wall on the other side of the grate
+	Common::Point pt = party._mazePosition;
+	Direction dir = (Direction)((int)party._mazeDirection ^ 2);
+	switch (party._mazeDirection) {
+	case DIR_NORTH:
+		pt.y++;
+		break;
+	case DIR_EAST:
+		pt.x++;
+		break;
+	case DIR_SOUTH:
+		pt.y--;
+		break;
+	case DIR_WEST:
+		pt.x--;
+		break;
+	default:
+		break;
 	}
+
+	map.setCellSurfaceFlags(pt, 0x80);
+	map.setWall(pt, dir, wallVal);
+
+	sound.playFX(10);
+	intf.draw3d(true);
+	return true;
 }
 
 bool Scripts::doOpcode(MazeEvent &event) {
diff --git a/engines/xeen/scripts.h b/engines/xeen/scripts.h
index 40564f3..f35aece 100644
--- a/engines/xeen/scripts.h
+++ b/engines/xeen/scripts.h
@@ -563,8 +563,9 @@ public:
 
 	/**
 	 * Handles opening grates
+	 * @returns		If true, no further event checking should be done
 	 */
-	void openGrate(int wallVal, int action);
+	bool openGrate(int wallVal, int action);
 };
 
 } // End of namespace Xeen





More information about the Scummvm-git-logs mailing list