aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVhati2019-01-03 09:31:15 -0500
committerFilippos Karapetis2019-01-06 19:17:03 +0200
commitaac5ed1cae3d83fb84b8179956f75f96fcc43763 (patch)
treeb757e070c5cff3222d1f9756019377bbf23ebc56
parentb254618f32844b77ebaa1c575b2c2f5b4bca9c53 (diff)
downloadscummvm-rg350-aac5ed1cae3d83fb84b8179956f75f96fcc43763.tar.gz
scummvm-rg350-aac5ed1cae3d83fb84b8179956f75f96fcc43763.tar.bz2
scummvm-rg350-aac5ed1cae3d83fb84b8179956f75f96fcc43763.zip
SCI32: Fix QFG4 forest pathfinding
Adds workarounds for odd detours during entry, bugs #10857, #10858
-rw-r--r--engines/sci/engine/kpathing.cpp25
-rw-r--r--engines/sci/engine/script_patches.cpp30
2 files changed, 46 insertions, 9 deletions
diff --git a/engines/sci/engine/kpathing.cpp b/engines/sci/engine/kpathing.cpp
index 3d5ef4752b..fb1183e8d7 100644
--- a/engines/sci/engine/kpathing.cpp
+++ b/engines/sci/engine/kpathing.cpp
@@ -1407,15 +1407,22 @@ static void AStar(PathfindingState *s) {
// This difference might lead to problems, but none are
// known at the time of writing.
- // WORKAROUND: This check fails in QFG1VGA, room 81 (bug report #3568452).
- // However, it is needed in other SCI1.1 games, such as LB2. Therefore, we
- // add this workaround for that scene in QFG1VGA, until our algorithm matches
- // better what SSCI is doing. With this workaround, QFG1VGA no longer freezes
- // in that scene.
- bool qfg1VgaWorkaround = (g_sci->getGameId() == GID_QFG1VGA &&
- g_sci->getEngineState()->currentRoomNumber() == 81);
-
- if (s->pointOnScreenBorder(vertex->v) && !qfg1VgaWorkaround)
+ // WORKAROUND: This check is needed in SCI1.1 games, such as LB2. Until our
+ // algorithm matches better what SSCI is doing, we exempt certain rooms where
+ // the check fails.
+ bool penaltyWorkaround =
+ // QFG1VGA room 81 - Hero gets stuck when walking to the SE corner (bug #6140).
+ (g_sci->getGameId() == GID_QFG1VGA && g_sci->getEngineState()->currentRoomNumber() == 81) ||
+#ifdef ENABLE_SCI32
+ // QFG4 room 563 - Hero zig-zags into the room (bug #10858).
+ // Entering from the south (564) off-screen behind an obstacle, hero
+ // fails to turn at a point on the screen edge, passes the poly's corner,
+ // then approaches the destination from deeper in the room.
+ (g_sci->getGameId() == GID_QFG4 && g_sci->getEngineState()->currentRoomNumber() == 563) ||
+#endif
+ false;
+
+ if (s->pointOnScreenBorder(vertex->v) && !penaltyWorkaround)
new_dist += 10000;
if (new_dist < vertex->costG) {
diff --git a/engines/sci/engine/script_patches.cpp b/engines/sci/engine/script_patches.cpp
index 250aefb556..8f0b795d2e 100644
--- a/engines/sci/engine/script_patches.cpp
+++ b/engines/sci/engine/script_patches.cpp
@@ -9473,6 +9473,35 @@ static const uint16 qfg4PitRopeMagePatch2[] = {
PATCH_END
};
+// WORKAROUND: Script needed, because of differences in our pathfinding
+// algorithm.
+// When entering forest room 557 from the east (563), hero is supposed to move
+// only a short distance into the room. ScummVM's pathfinding sends hero off
+// course, to the middle of the room and back.
+//
+// There's an unwalkable stream in the SE corner, and hero's coords were within
+// its polygon. We lower the top two points to keep hero on the outside.
+//
+// Applies to at least: English CD, English floppy, German floppy
+// Responsible method: rm557::init() in script 557
+// Fixes bug: #10857
+static const uint16 qfg4Forest557PathfindingSignature[] = {
+ SIG_MAGICDWORD,
+ 0x38, SIG_UINT16(0x0119), // pushi 281d (point 3)
+ 0x38, SIG_UINT16(0x0087), // pushi 135d
+ 0x38, SIG_UINT16(0x013f), // pushi 319d (point 4)
+ 0x38, SIG_UINT16(0x0087), // pushi 135d
+ SIG_END
+};
+
+static const uint16 qfg4Forest557PathfindingPatch[] = {
+ PATCH_ADDTOOFFSET(+3),
+ 0x38, PATCH_UINT16(0x0089), // pushi 137d
+ PATCH_ADDTOOFFSET(+3),
+ 0x38, PATCH_UINT16(0x0089), // pushi 137d
+ PATCH_END
+};
+
// script, description, signature patch
static const SciScriptPatcherEntry qfg4Signatures[] = {
{ true, 0, "prevent autosave from deleting save games", 1, qfg4AutosaveSignature, qfg4AutosavePatch },
@@ -9501,6 +9530,7 @@ static const SciScriptPatcherEntry qfg4Signatures[] = {
{ true, 542, "fix setLooper calls (1/2)", 5, qfg4SetLooperSignature1, qfg4SetLooperPatch1 },
{ true, 543, "fix setLooper calls (1/2)", 5, qfg4SetLooperSignature1, qfg4SetLooperPatch1 },
{ true, 545, "fix setLooper calls (1/2)", 5, qfg4SetLooperSignature1, qfg4SetLooperPatch1 },
+ { true, 557, "fix forest 557 entry from east", 1, qfg4Forest557PathfindingSignature, qfg4Forest557PathfindingPatch },
{ true, 630, "fix great hall entry from barrel room", 1, qfg4GreatHallEntrySignature, qfg4GreatHallEntryPatch },
{ true, 633, "fix stairway pathfinding", 1, qfg4StairwayPathfindingSignature, qfg4StairwayPathfindingPatch },
{ true, 643, "fix iron safe's east door sending hero west", 1, qfg4SafeDoorEastSignature, qfg4SafeDoorEastPatch },