[Scummvm-git-logs] scummvm master -> 1c97fa435801193f420051d22dc86f5bb20ae3b1

sluicebox 22204938+sluicebox at users.noreply.github.com
Wed Nov 20 22:17:35 UTC 2019


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:
7423320e9d SCI: Fix comment typos
11065630c0 SCI: Fix CAMELOT menu items when restoring
1c97fa4358 SCI: Fix CAMELOT dropped events while sword is drawn


Commit: 7423320e9d57554c5f0e156eb8e6e3b79fb087ad
    https://github.com/scummvm/scummvm/commit/7423320e9d57554c5f0e156eb8e6e3b79fb087ad
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-11-20T13:40:29-08:00

Commit Message:
SCI: Fix comment typos

Changed paths:
    engines/sci/engine/script_patches.cpp
    engines/sci/graphics/frameout.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index b42b7c3..7e0567f 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -738,7 +738,7 @@ static const uint16 camelotSignatureSwordSheathing[] = {
 	0x32, SIG_UINT16(0x0085),           // jmp 0085 [ end of switch ]
 	0x3c,                               // dup
 	0x35, 0x02,                         // ldi 02
-	0x1a,                               // eq? [ sword-command == 2 (sheath) ]
+	0x1a,                               // eq? [ sword-command == 2 (sheathe) ]
 	0x30, SIG_UINT16(0x0013),           // bnt 0013
 	0x39, SIG_SELECTOR8(setScript),     // pushi setScript
 	0x78,                               // push1
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 6b75e2c..93c2716 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -285,7 +285,7 @@ void GfxFrameout::kernelAddPlane(const reg_t object) {
 		// kAddPlane is called several times, this detects the second call
 		//  which is for the import character dialog. If changeButton:value
 		//  is non-zero then the dialog is initializing. If the button isn't
-		//  disabled then we havent't displayed the message box yet. There
+		//  disabled then we haven't displayed the message box yet. There
 		//  are multiple changeButtons because the script clones the object.
 		SegManager *segMan = g_sci->getEngineState()->_segMan;
 		Common::Array<reg_t> changeDirButtons = _segMan->findObjectsByName("changeButton");


Commit: 11065630c0f7913d6023c92035641ffde1cb6a5f
    https://github.com/scummvm/scummvm/commit/11065630c0f7913d6023c92035641ffde1cb6a5f
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-11-20T14:12:54-08:00

Commit Message:
SCI: Fix CAMELOT menu items when restoring

Changed paths:
    engines/sci/engine/savegame.cpp
    engines/sci/engine/selector.cpp
    engines/sci/engine/selector.h


diff --git a/engines/sci/engine/savegame.cpp b/engines/sci/engine/savegame.cpp
index 6d0abf7..3423a01 100644
--- a/engines/sci/engine/savegame.cpp
+++ b/engines/sci/engine/savegame.cpp
@@ -1194,6 +1194,47 @@ extern void showScummVMDialog(const Common::String &message);
 
 void gamestate_afterRestoreFixUp(EngineState *s, int savegameId) {
 	switch (g_sci->getGameId()) {
+	case GID_CAMELOT: {
+		// WORKAROUND: CAMELOT depends on its dynamic menu state persisting. The menu items'
+		//  enabled states determines when the player can draw or sheathe their sword and
+		//  open a purse. If these aren't updated then the player may be unable to perform
+		//  necessary actions, or may be able to perform unexpected ones that break the game.
+		//  Since we don't persist menu state (yet) we need to recreate it from game state.
+		//
+		// - Action \ Open Purse: Enabled while one of the purses is in inventory.
+		// - Action \ Draw Sword: Enabled while flag 3 is set, unless disabled by room scripts.
+		// * The text "Draw Sword" toggles to "Sheathe Sword" depending on global 124,
+		//   but this is only cosmetic. Exported proc #1 in script 997 refreshes this
+		//   when the sword status or room changes.
+		//
+		// After evaluating all the scripts that disable the sword, we enforce the few
+		//  that prevent breaking the game: room 50 under the aqueduct and sitting with
+		//  the scholar while in room 82 (ego view 84).
+		//
+		// FIXME: Save and restore full menu state as SSCI did and don't apply these
+		//  workarounds when restoring saves that contain menu state.
+
+		// Action \ Open Purse
+		reg_t enablePurse = NULL_REG;
+		Common::Array<reg_t> purses = s->_segMan->findObjectsByName("purse");
+		reg_t ego = s->variables[VAR_GLOBAL][0];
+		for (uint i = 0; i < purses.size(); ++i) {
+			reg_t purseOwner = readSelector(s->_segMan, purses[i], SELECTOR(owner));
+			if (purseOwner == ego) {
+				enablePurse = TRUE_REG;
+				break;
+			}
+		}
+		g_sci->_gfxMenu->kernelSetAttribute(1281 >> 8, 1281 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, enablePurse);
+
+		// Action \ Draw Sword
+		bool hasSword = (s->variables[VAR_GLOBAL][250].getOffset() & 0x1000); // flag 3
+		bool underAqueduct = (s->variables[VAR_GLOBAL][11].getOffset() == 50);
+		bool sittingWithScholar = (readSelectorValue(s->_segMan, ego, SELECTOR(view)) == 84);
+		reg_t enableSword = (hasSword && !underAqueduct && !sittingWithScholar) ? TRUE_REG : NULL_REG;
+		g_sci->_gfxMenu->kernelSetAttribute(1283 >> 8, 1283 & 0xFF, SCI_MENU_ATTRIBUTE_ENABLED, enableSword);
+		break;
+	}
 	case GID_MOTHERGOOSE:
 		// WORKAROUND: Mother Goose SCI0
 		//  Script 200 / rm200::newRoom will set global C5h directly right after creating a child to the
diff --git a/engines/sci/engine/selector.cpp b/engines/sci/engine/selector.cpp
index 6fbccb8..6196495 100644
--- a/engines/sci/engine/selector.cpp
+++ b/engines/sci/engine/selector.cpp
@@ -169,6 +169,7 @@ void Kernel::mapSelectors() {
 	FIND_SELECTOR(setStep);
 	FIND_SELECTOR(setMotion);
 	FIND_SELECTOR(cycleSpeed);
+	FIND_SELECTOR(owner);
 
 #ifdef ENABLE_SCI32
 	FIND_SELECTOR(data);
diff --git a/engines/sci/engine/selector.h b/engines/sci/engine/selector.h
index fa2df8c..68b36b3 100644
--- a/engines/sci/engine/selector.h
+++ b/engines/sci/engine/selector.h
@@ -135,6 +135,7 @@ struct SelectorCache {
 	Selector setStep;
 	Selector setMotion;
 	Selector cycleSpeed;
+	Selector owner;
 
 #ifdef ENABLE_SCI32
 	Selector data; // Used by Array()/String()


Commit: 1c97fa435801193f420051d22dc86f5bb20ae3b1
    https://github.com/scummvm/scummvm/commit/1c97fa435801193f420051d22dc86f5bb20ae3b1
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2019-11-20T14:12:54-08:00

Commit Message:
SCI: Fix CAMELOT dropped events while sword is drawn

Fixes bug #11269

Changed paths:
    engines/sci/engine/script_patches.cpp


diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 7e0567f..753b256 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -812,10 +812,45 @@ static const uint16 camelotPatchSwordSheathing[] = {
 	PATCH_END
 };
 
+// When Arthur's sword is drawn, ARTHUR:doit calls kGetEvent a second time on
+//  each cycle to test if a shift key is pressed, causing input events to be
+//  frequently dropped. This is similar to Freddy Pharkas and QFG1VGA where this
+//  technique just happened to usually work in Sierra's interpreter. We fix this
+//  in the same way by using the current event instead of consuming a new one.
+//
+// Applies to: All versions
+// Responsible method: ARTHUR:doit
+// Fixes bug: #11269
+static const uint16 camelotSignatureSwordEvents[] = {
+	0x30, SIG_MAGICDWORD,               // bnt 0045
+	      SIG_UINT16(0x0045),
+	0x39, SIG_SELECTOR8(new),           // pushi new
+	0x76,                               // push0
+	0x51, 0x07,                         // class Event
+	0x4a, 0x04,                         // send 04 [ Event new: ]
+	0xa5, 0x01,                         // sat 01 [ temp1 = Event new: ]
+	SIG_ADDTOOFFSET(+53),
+	0x39, SIG_SELECTOR8(dispose),       // pushi dispose
+	0x76,                               // push0
+	0x85, 0x01,                         // lat 01
+	0x4a, 0x04,                         // send 04 [ temp1 dispose: ]
+	SIG_END
+};
+
+static const uint16 camelotPatchSwordEvents[] = {
+	0x31, 0x46,                         // bnt 46
+	0x38, PATCH_SELECTOR16(curEvent),   // pushi curEvent
+	0x76,                               // push0
+	0x51, 0x30,                         // class User [ User: curEvent ]
+	PATCH_ADDTOOFFSET(+57),
+	0x33, 0x05,                         // jmp 05 [ don't dispose event ]
+	PATCH_END
+};
 
 //         script, description,                                       signature                             patch
 static const SciScriptPatcherEntry camelotSignatures[] = {
 	{ true,     0, "fix sword sheathing",                          1, camelotSignatureSwordSheathing,       camelotPatchSwordSheathing },
+	{ true,     0, "fix sword events",                             1, camelotSignatureSwordEvents,          camelotPatchSwordEvents },
 	{ true,    11, "fix hunter missing points",                    1, camelotSignatureHunterMissingPoints,  camelotPatchHunterMissingPoints },
 	{ true,    62, "fix peepingTom Sierra bug",                    1, camelotSignaturePeepingTom,           camelotPatchPeepingTom },
 	{ true,    64, "fix Fatima room messages",                     2, camelotSignatureFatimaRoomMessages,   camelotPatchFatimaRoomMessages },




More information about the Scummvm-git-logs mailing list