aboutsummaryrefslogtreecommitdiff
path: root/engines/sci
diff options
context:
space:
mode:
authorFilippos Karapetis2018-10-26 03:41:03 +0300
committerFilippos Karapetis2018-10-26 03:42:48 +0300
commitaceb52806823c3bf7fca7f4847d46244e47ec350 (patch)
treee8539ad70287929a1035be3ad3ea459b2616e0dc /engines/sci
parentd0480e2dadba65722cca9c84ff62366b2362fe71 (diff)
downloadscummvm-rg350-aceb52806823c3bf7fca7f4847d46244e47ec350.tar.gz
scummvm-rg350-aceb52806823c3bf7fca7f4847d46244e47ec350.tar.bz2
scummvm-rg350-aceb52806823c3bf7fca7f4847d46244e47ec350.zip
SCI32: Correct fix for the TRAP machine in QFG4
Properly fixes bug #10766.
Diffstat (limited to 'engines/sci')
-rw-r--r--engines/sci/engine/klists.cpp15
-rw-r--r--engines/sci/engine/script_patches.cpp20
2 files changed, 20 insertions, 15 deletions
diff --git a/engines/sci/engine/klists.cpp b/engines/sci/engine/klists.cpp
index e103a13443..9427b29475 100644
--- a/engines/sci/engine/klists.cpp
+++ b/engines/sci/engine/klists.cpp
@@ -820,21 +820,6 @@ reg_t kArrayNew(EngineState *s, int argc, reg_t *argv) {
uint16 size = argv[0].toUint16();
SciArrayType type = (SciArrayType)argv[1].toUint16();
- // WORKAROUND: QFG4 floppy has a different Array class in script 64920 than
- // the CD version. Script 380 (the trap machine outside of Dr. Cranium's
- // lab) creates 3 integer arrays, and the largest one is used to hold
- // messages from the machine. In the CD version, the type of that array is
- // correctly changed to 2 (a byte array), but in the floppy version, the type
- // remains 0 (an array of 16-bit integers) inside the Array class.
- // I haven't found a reliable way to patch the array creation in the game
- // scripts, so we set the large array in the floppy version to be initialized
- // with the same parameters as in the same way as in the CD version. This
- // fixes the trap machine's messages in the floppy version.
- if (g_sci->getGameId() == GID_QFG4 && !g_sci->isCD() && s->currentRoomNumber() == 380 && size == 128 && type == kArrayTypeInt16) {
- size = 256;
- type = kArrayTypeByte;
- }
-
if (type == kArrayTypeString) {
++size;
}
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index d5b33a8226..c378e4f840 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -6738,6 +6738,25 @@ static const uint16 qfg4TrapArrayTypePatch[] = {
PATCH_END
};
+// The 'Trap::init' code incorrectly creates an int array for string data.
+// Applies to at least: English floppy
+static const uint16 qfg4TrapArrayTypeFloppySignature[] = {
+ 0x38, SIG_SELECTOR16(new), // pushi new
+ 0x78, // push1
+ 0x38, SIG_UINT16(0x80), // pushi $80 (128)
+ SIG_MAGICDWORD,
+ 0x51, 0x0a, // class $a (IntArray)
+ 0x4a, SIG_UINT16(0x06), // send 6
+ SIG_END
+};
+
+static const uint16 qfg4TrapArrayTypeFloppyPatch[] = {
+ PATCH_ADDTOOFFSET(+4), // pushi $92 (new), push1
+ 0x38, PATCH_UINT16(0x100), // pushi $100 (256)
+ 0x51, 0x0c, // class $c (ByteArray)
+ PATCH_END
+};
+
// QFG4 has custom video benchmarking code inside a subroutine, which is called
// by 'glryInit::init', that needs to be disabled; see sci2BenchmarkSignature
// Applies to at least: English CD, German Floppy
@@ -6880,6 +6899,7 @@ static const SciScriptPatcherEntry qfg4Signatures[] = {
{ true, 1, "disable volume reset on startup", 1, sci2VolumeResetSignature, sci2VolumeResetPatch },
{ true, 1, "disable video benchmarking", 1, qfg4BenchmarkSignature, qfg4BenchmarkPatch },
{ true, 83, "fix incorrect array type", 1, qfg4TrapArrayTypeSignature, qfg4TrapArrayTypePatch },
+ { true, 83, "fix incorrect array type (floppy)", 1, qfg4TrapArrayTypeFloppySignature, qfg4TrapArrayTypeFloppyPatch },
{ true, 320, "fix pathfinding at the inn", 1, qg4InnPathfindingSignature, qg4InnPathfindingPatch },
{ true, 803, "fix sliding down slope", 1, qfg4SlidingDownSlopeSignature, qfg4SlidingDownSlopePatch },
{ true, 64990, "increase number of save games (1/2)", 1, sci2NumSavesSignature1, sci2NumSavesPatch1 },