[Scummvm-git-logs] scummvm master -> 9d0b83e80aef1fde1904e92bb0052a4cd298ce13

AndywinXp noreply at scummvm.org
Sat Sep 23 15:02:12 UTC 2023


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

Summary:
35c4e87188 SWORD1: Mark walk skip as debug only and non-demo
61f33f6224 SWORD1: Don't crash the game if the target section is not open
9d0b83e80a SWORD1: Attempt at fixing bug #14638


Commit: 35c4e87188b4165783f75859e6aa9b787eadfcf0
    https://github.com/scummvm/scummvm/commit/35c4e87188b4165783f75859e6aa9b787eadfcf0
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-23T16:59:43+02:00

Commit Message:
SWORD1: Mark walk skip as debug only and non-demo

This is a useful tool but it should not be enabled outside of
debug mode.

Changed paths:
    engines/sword1/logic.cpp


diff --git a/engines/sword1/logic.cpp b/engines/sword1/logic.cpp
index 3741949d01b..96caf0cb570 100644
--- a/engines/sword1/logic.cpp
+++ b/engines/sword1/logic.cpp
@@ -1447,20 +1447,26 @@ int Logic::fnWalk(Object *cpt, int32 id, int32 x, int32 y, int32 dir, int32 stan
 	if ((routeRes == 1) || (routeRes == 2)) {
 		cpt->o_down_flag = 1; // 1 means okay.
 		// if both mouse buttons were pressed on an exit => skip george's walk
-		if ((id == GEORGE) && (_mouse->testEvent() == MOUSE_BOTH_BUTTONS)) {
-			int32 target = _scriptVars[CLICK_ID];
-			// exceptions: compacts that use hand pointers but are not actually exits
-			if ((target != LEFT_SCROLL_POINTER) && (target != RIGHT_SCROLL_POINTER) &&
-			        (target != FLOOR_63) && (target != ROOF_63) && (target != GUARD_ROOF_63) &&
-			        (target != LEFT_TREE_POINTER_71) && (target != RIGHT_TREE_POINTER_71)) {
-
-				target = _objMan->fetchObject(_scriptVars[CLICK_ID])->o_mouse_on;
-				if ((target >= SCR_exit0) && (target <= SCR_exit9)) {
-					fnStandAt(cpt, id, x, y, dir, stance, 0, 0);
-					return SCRIPT_STOP;
+		if (SwordEngine::_systemVars.debugMode) {
+			if ((id == GEORGE) && (_mouse->testEvent() == MOUSE_BOTH_BUTTONS) && !SwordEngine::_systemVars.isDemo) {
+				int32 target = _scriptVars[CLICK_ID];
+				// exceptions: compacts that use hand pointers but are not actually exits
+				if ((target != LEFT_SCROLL_POINTER) && (target != RIGHT_SCROLL_POINTER) &&
+					(target != FLOOR_63) && (target != ROOF_63) && (target != GUARD_ROOF_63) &&
+					(target != LEFT_TREE_POINTER_71) && (target != RIGHT_TREE_POINTER_71)) {
+
+					if (!_objMan->sectionAlive(_scriptVars[CLICK_ID] / ITM_PER_SEC))
+						_objMan->megaEntering(_scriptVars[CLICK_ID] / ITM_PER_SEC);
+
+					target = _objMan->fetchObject(_scriptVars[CLICK_ID])->o_mouse_on;
+					if ((target >= SCR_exit0) && (target <= SCR_exit9)) {
+						fnStandAt(cpt, id, x, y, dir, stance, 0, 0);
+						return SCRIPT_STOP;
+					}
 				}
 			}
 		}
+
 		cpt->o_logic = LOGIC_AR_animate;
 		return SCRIPT_STOP;
 	} else if (routeRes == 3)


Commit: 61f33f6224e9125f8705f578452a01a2fa22b35f
    https://github.com/scummvm/scummvm/commit/61f33f6224e9125f8705f578452a01a2fa22b35f
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-23T17:01:09+02:00

Commit Message:
SWORD1: Don't crash the game if the target section is not open

...just open the target section and everything will be fine :-)
After all, this is what the original does. Also, fixing this should
also fix some rare crashes when performing the walk skip.

Changed paths:
    engines/sword1/objectman.cpp


diff --git a/engines/sword1/objectman.cpp b/engines/sword1/objectman.cpp
index 7676d552357..2637fcf50d2 100644
--- a/engines/sword1/objectman.cpp
+++ b/engines/sword1/objectman.cpp
@@ -201,7 +201,8 @@ uint32 ObjectMan::lastTextNumber(int section) {
 Object *ObjectMan::fetchObject(uint32 id) {
 	uint8 *addr = _cptData[id / ITM_PER_SEC];
 	if (!addr)
-		error("fetchObject: section %d is not open", id / ITM_PER_SEC);
+		addr = _cptData[id / ITM_PER_SEC] = ((uint8 *)_resMan->cptResOpen(_objectList[id / ITM_PER_SEC])) + sizeof(Header);
+
 	id &= ITM_ID;
 	// DON'T do endian conversion here. it's already done.
 	return (Object *)(addr + * (uint32 *)(addr + (id + 1) * 4));


Commit: 9d0b83e80aef1fde1904e92bb0052a4cd298ce13
    https://github.com/scummvm/scummvm/commit/9d0b83e80aef1fde1904e92bb0052a4cd298ce13
Author: AndywinXp (andywinxp at gmail.com)
Date: 2023-09-23T17:01:55+02:00

Commit Message:
SWORD1: Attempt at fixing bug #14638

This should avoid race conditions when allocating resources.

Changed paths:
    engines/sword1/resman.cpp
    engines/sword1/resman.h


diff --git a/engines/sword1/resman.cpp b/engines/sword1/resman.cpp
index 1e4885bc7bc..a1c7da14afd 100644
--- a/engines/sword1/resman.cpp
+++ b/engines/sword1/resman.cpp
@@ -248,6 +248,7 @@ void *ResMan::cptResOpen(uint32 id) {
 }
 
 void ResMan::resOpen(uint32 id) {  // load resource ID into memory
+	Common::StackLock lock(_resourceAccessMutex);
 	MemHandle *memHandle = resHandle(id);
 
 	if (!memHandle)
diff --git a/engines/sword1/resman.h b/engines/sword1/resman.h
index bc0e8594bfe..0154e738748 100644
--- a/engines/sword1/resman.h
+++ b/engines/sword1/resman.h
@@ -27,6 +27,7 @@
 #include "common/file.h"
 #include "sword1/sworddefs.h"
 #include "common/endian.h"
+#include "common/mutex.h"
 
 namespace Sword1 {
 
@@ -126,6 +127,8 @@ private:
 	int  _openClus;
 	bool _isBigEndian;
 
+	Common::Mutex _resourceAccessMutex;
+
 	uint32 _srIdList[29] = {
 		// the file numbers differ for the control panel file IDs, so we need this array
 		OTHER_SR_FONT,    // SR_FONT




More information about the Scummvm-git-logs mailing list