[Scummvm-git-logs] scummvm master -> 266288b6d0222a558450dba839583c284de17f35

elasota noreply at scummvm.org
Fri Dec 1 02:45:30 UTC 2023


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:
266288b6d0 VCRUISE: Fix crash when using the rail cart in Schizm rooms 61 and 62.


Commit: 266288b6d0222a558450dba839583c284de17f35
    https://github.com/scummvm/scummvm/commit/266288b6d0222a558450dba839583c284de17f35
Author: elasota (1137273+elasota at users.noreply.github.com)
Date: 2023-11-30T21:44:13-05:00

Commit Message:
VCRUISE: Fix crash when using the rail cart in Schizm rooms 61 and 62.

Changed paths:
    engines/vcruise/runtime_scriptexec.cpp
    engines/vcruise/script.cpp


diff --git a/engines/vcruise/runtime_scriptexec.cpp b/engines/vcruise/runtime_scriptexec.cpp
index 8c3431467af..a3d2ff062aa 100644
--- a/engines/vcruise/runtime_scriptexec.cpp
+++ b/engines/vcruise/runtime_scriptexec.cpp
@@ -1669,7 +1669,15 @@ void Runtime::scriptOpAnimChange(ScriptArg_t arg) {
 void Runtime::scriptOpScreenName(ScriptArg_t arg) {
 	const Common::String &scrName = _scriptSet->strings[arg];
 
-	uint roomNumber = _roomNumber;
+	uint roomNumber = 0;
+
+	if (_gameID == GID_SCHIZM) {
+		error("Screen numbers should be preprocessed in Schizm");
+
+		// ... absent that error, we would do roomNumber = _loadedRoomNumber probably.
+		// See the comment in optimizeScriptSet for explanation.
+	}
+
 	if (roomNumber < _roomDuplicationOffsets.size())
 		roomNumber -= _roomDuplicationOffsets[roomNumber];
 
diff --git a/engines/vcruise/script.cpp b/engines/vcruise/script.cpp
index 574dd4ce5c0..10359245b49 100644
--- a/engines/vcruise/script.cpp
+++ b/engines/vcruise/script.cpp
@@ -1425,6 +1425,15 @@ void optimizeScriptSet(ScriptSet &scriptSet) {
 
 	Common::Array<Script *> scriptCheckQueue;
 
+	ScreenNameMap_t screenNames;
+
+	// Find all screen names.
+	// There is one duplicate: START exists in room 1 and room 63.  In that case, we want to use the latter ID.
+	for (const RoomScriptSetMap_t::Node &rsNode : scriptSet.roomScripts) {
+		for (const ScreenNameMap_t::Node &snNode : rsNode._value->screenNames)
+			screenNames[snNode._key] = snNode._value;
+	}
+
 	for (const RoomScriptSetMap_t::Node &rsNode : scriptSet.roomScripts) {
 		for (const ScreenScriptSetMap_t::Node &ssNode : rsNode._value->screenScripts) {
 			if (ssNode._value->entryScript)
@@ -1453,6 +1462,23 @@ void optimizeScriptSet(ScriptSet &scriptSet) {
 					instr.arg = newIndex;
 				} else
 					instr.arg = funcIDIt->_value;
+			} else if (instr.op == ScriptOps::kScreenName) {
+				// In a few places, the screen number being transitioned to isn't valid in the target room.
+				//
+				// fnKOLEJKA_PRACOWNIA in room 61 and fnKOLEJKA_CIEMNO in room 62 both execute animF ops after changing room number,
+				// but reference a screen ID in the current room.  They then execute another animF op in the new room, which changes
+				// to a valid screen number.
+				//
+				// The way this appears to work is that screen IDs are applied based on the loaded room script
+				// instead of the active room.  We compensate for this by just resolving the screen name here.
+				const Common::String &screenNameStr = scriptSet.strings[instr.arg];
+
+				ScreenNameMap_t::const_iterator snIt = screenNames.find(screenNameStr);
+				if (snIt != screenNames.end()) {
+					instr.op = ScriptOps::kNumber;
+					instr.arg = snIt->_value;
+				} else
+					error("Couldn't resolve screen name %s to number", screenNameStr.c_str());
 			} else if (opArgIsStringIndex(instr.op)) {
 				uint strID = instr.arg;
 




More information about the Scummvm-git-logs mailing list