[Scummvm-git-logs] scummvm master -> 27e00993ce245625b3bdd530fe49a072b628ec04

sluicebox 22204938+sluicebox at users.noreply.github.com
Sat Mar 20 20:40:32 UTC 2021


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

Summary:
d52539435b SCI: Add PEPPER workaround for uninit read
27e00993ce SCI: Fix PEPPER glass jar bugs with script patch


Commit: d52539435b084ded90f36ce077836db442e42bee
    https://github.com/scummvm/scummvm/commit/d52539435b084ded90f36ce077836db442e42bee
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-03-20T13:37:37-07:00

Commit Message:
SCI: Add PEPPER workaround for uninit read

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


diff --git a/engines/sci/engine/workarounds.cpp b/engines/sci/engine/workarounds.cpp
index 9bc1e712a8..295610f9de 100644
--- a/engines/sci/engine/workarounds.cpp
+++ b/engines/sci/engine/workarounds.cpp
@@ -485,6 +485,7 @@ const SciWorkaroundEntry uninitializedReadWorkarounds[] = {
 	{ GID_MOTHERGOOSEHIRES,-1,64950, -1,               "View", "handleEvent",                     NULL,     0,     0, { WORKAROUND_FAKE,   0 } }, // see above
 	{ GID_PEPPER,         -1,   894,  0,            "Package", "doVerb",                          NULL,     3,     3, { WORKAROUND_FAKE,   0 } }, // using the hand on the book in the inventory - bug #5154
 	{ GID_PEPPER,        150,   928,  0,           "Narrator", "startText",                       NULL,     0,     0, { WORKAROUND_FAKE,   0 } }, // happens during the non-interactive demo of Pepper
+	{ GID_PEPPER,        260,   260,  0,            "glutton", "doVerb",                          NULL,     0,     0, { WORKAROUND_FAKE,   0 } }, // using tomato on General Lee
 	{ GID_PHANTASMAGORIA, -1, 64921, -1,              "Print", "addEdit",                         NULL,     1,     1, { WORKAROUND_FAKE,   0 } }, // When trying to use the game debugger's flag setting command
 	{ GID_PQ4,            -1,    25,  0,         "iconToggle", "select",                          NULL,     1,     1, { WORKAROUND_FAKE,   0 } }, // when toggling the icon bar to auto-hide or not
 	{ GID_PQ4,           170,   170, -1,        "hideAndSeek", "handleEvent",                     NULL,     1,     1, { WORKAROUND_FAKE,   0 } }, // when clicking to move right while still moving left during the Emo shootout - bug #9847


Commit: 27e00993ce245625b3bdd530fe49a072b628ec04
    https://github.com/scummvm/scummvm/commit/27e00993ce245625b3bdd530fe49a072b628ec04
Author: sluicebox (22204938+sluicebox at users.noreply.github.com)
Date: 2021-03-20T13:37:37-07:00

Commit Message:
SCI: Fix PEPPER glass jar bugs with script patch

Fixes the remaining script bugs and cleans up kMessage

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


diff --git a/engines/sci/engine/kstring.cpp b/engines/sci/engine/kstring.cpp
index c837eb2ae2..60630be1d6 100644
--- a/engines/sci/engine/kstring.cpp
+++ b/engines/sci/engine/kstring.cpp
@@ -499,31 +499,6 @@ reg_t kMessage(EngineState *s, int argc, reg_t *argv) {
 	if (argc >= 6)
 		tuple = MessageTuple(argv[2].toUint16(), argv[3].toUint16(), argv[4].toUint16(), argv[5].toUint16());
 
-	// WORKAROUND for a script bug in Pepper. When using objects together,
-	// there is code inside script 894 that shows appropriate messages.
-	// In the case of the jar of cabbage (noun 26), the relevant message
-	// shown when using any object with it is missing. This leads to the
-	// script code being triggered, which modifies the jar's noun and
-	// message selectors, and renders it useless. Thus, when using any
-	// object with the jar of cabbage, it's effectively corrupted, and
-	// can't be used on the goat to empty it, therefore the game reaches
-	// an unsolvable state. It's almost impossible to patch the offending
-	// script, as it is used in many cases. But we can prevent the
-	// corruption of the jar here: if the message is found, the offending
-	// code is never reached and the jar is never corrupted. To do this,
-	// we substitute all verbs on the cabbage jar with the default verb,
-	// which shows the "Cannot use this object with the jar" message, and
-	// never triggers the offending script code that corrupts the object.
-	// This only affects the jar of cabbage - any other object, including
-	// the empty jar has a different noun, thus it's unaffected.
-	// Fixes bug #6232.
-	// NOTE: To fix a corrupted jar object, type "send Glass_Jar message 52"
-	// in the debugger.
-	if (g_sci->getGameId() == GID_PEPPER && func == 0 && argc >= 6 && module == 894 &&
-		tuple.noun == 26 && tuple.cond == 0 && tuple.seq == 1 &&
-		!s->_msgState->getMessage(module, tuple, NULL_REG))
-		tuple.verb = 0;
-
 	switch (func) {
 	case K_MESSAGE_GET:
 		return make_reg(0, s->_msgState->getMessage(module, tuple, (argc == 7 ? argv[6] : NULL_REG)));
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index dd81149367..69178bb546 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -10596,8 +10596,84 @@ static const SciScriptPatcherEntry phantasmagoria2Signatures[] = {
 // ===========================================================================
 // Pepper's Adventures in Time
 
+// Using items on the jar of cabbage leaves it in a broken state that prevents
+//  feeding it to the goat and completing the game.
+//
+// As the jar progresses through states to become a Leyden jar, its noun and
+//  message (verb) properties change. When a non-Leyden item is used on the jar,
+//  Glass Jar:doVerb tests to see if a message resource exists for the current
+//  noun and incoming verb. If there's no such message then the jar's noun is
+//  set to 30 and its message property is set to 125, a verb that no screens
+//  respond to. The jar can no longer be clicked on anything, but the damage is
+//  limited until the next time the player returns to the inventory screen and
+//  Glass Jar:show recalculates the properties that it should have already had.
+//  This recalculation fails to take into account the initial state so if the
+//  jar has cabbage then it is permanently broken instead of just temporarily.
+//
+// We fix this so that the jar is never placed in a broken state. The existing
+//  code attempts to fall back on message resources for noun 30 which refer the
+//  unfinished Leyden jar. The problem is that it doesn't restore the noun after
+//  displaying the message, which can cause subsequent missing message errors,
+//  and it mangles the message property even though that doesn't affect which
+//  message it's about to display. We rewrite this so that noun 30 is only set
+//  temporarily, and only when the jar is an unfinished Leyden jar, and without
+//  altering the message (verb) property. This also fixes several messages.
+//
+// Applies to: All versions
+// Responsible method: Glass Jar:doVerb
+// Fixes bug: #6232
+static const uint16 pepperSignatureGlassJar[] = {
+	SIG_MAGICDWORD,
+	0x31, 0x08,                      // bnt 08 [ skip if message exists ]
+	0x35, 0x1e,                      // ldi 1e
+	0x65, 0x36,                      // aTop noun [ noun = 30 ]
+	0x35, 0x7d,                      // ldi 7d
+	0x65, 0x26,                      // aTop message [ message = 125 ]
+	0x38, SIG_SELECTOR16(doVerb),    // pushi doVerb
+	0x78,                            // push1
+	0x8f, 0x01,                      // lsp 01
+	0x59, 0x02,                      // &rest 02
+	0x57, 0x87, 0x06,                // super TWInvItem 06 [ super doVerb: param1 &rest ]
+	0x39, 0x04,                      // pushi 04
+	0x8f, 0x01,                      // lsp 01
+	0x39, 0x32,                      // pushi 32
+	0x39, 0x33,                      // pushi 33
+	0x39, 0x2f,                      // pushi 2f
+	0x46, SIG_UINT16(0x03e7),        // calle proc999_5 [ OneOf param1 50 51 47, always false ]
+	      SIG_UINT16(0x0005), 0x08,
+	0x31, 0x09,                      // bnt 09 [ branch always taken ]
+	SIG_END
+};
+
+static const uint16 pepperPatchGlassJar[] = {
+	0x67, 0x36,                      // pTos noun [ save noun ]
+	0x31, 0x16,                      // bnt 16 [ skip if message exists ]
+	0x3c,                            // dup
+	0x35, 0x1a,                      // ldi 1a
+	0x1a,                            // eq?
+	0x2f, 0x10,                      // bt 10 [ skip if noun == 26 (cabbage) ]
+	0x3c,                            // dup
+	0x35, 0x1d,                      // ldi 1d
+	0x1a,                            // eq?
+	0x2f, 0x0a,                      // bt 0a [ skip if noun == 29 (Leyden jar) ]
+	0x3c,                            // dup
+	0x35, 0x1b,                      // ldi 1b
+	0x1a,                            // eq?
+	0x2f, 0x04,                      // bt 04 [ skip if noun == 27 (charged Leyden jar) ]
+	0x35, 0x1e,                      // ldi 1e
+	0x65, 0x36,                      // aTop noun [ noun = 30 (unfinished Leyden jar) ]
+	0x38, PATCH_SELECTOR16(doVerb),  // pushi doVerb
+	0x76,                            // push0
+	0x59, 0x01,                      // &rest 01
+	0x57, 0x87, 0x04,                // super TWInvItem 04 [ super doVerb: &rest ]
+	0x69, 0x36,                      // sTop noun [ restore noun ]
+	0x33, 0x09,                      // jmp 09
+	PATCH_END
+};
+
 //          script, description,                                         signature                            patch
 static const SciScriptPatcherEntry pepperSignatures[] = {
+	{  true,   894, "glass jar fix",                                  1, pepperSignatureGlassJar,             pepperPatchGlassJar },
 	{  true,   928, "Narrator lockup fix",                            1, sciNarratorLockupSignature,          sciNarratorLockupPatch },
 	SCI_SIGNATUREENTRY_TERMINATOR
 };




More information about the Scummvm-git-logs mailing list