Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCI32: Fix QFG4 peering at absent bats #1429

Merged
merged 1 commit into from Mar 2, 2019

Conversation

Vhati
Copy link
Contributor

@Vhati Vhati commented Nov 30, 2018

Fixes castle doors when all bats have been killed, bug #10789

One patch for the lower door.

// In the room (644) connected to the lower door of the bat-infested stairway,
// peering through the keyhole *always* reports bats.
//
// As you kill the bats, global plot flags are set. Normally flags 331-334
// would be checked via proc0_4(). They're in a bitmask, among other flags, so
// we can check all simultaneously (0000000000011110).
//
// global[520] & 30 == 30
//
// Room 644 has an IF-ELSE deciding between largely redundant calls to
// gloryMessager::say(). We make room by combining them.

Three for the upper door.

// In the crest bookshelf room (663) connected to the upper door of the
// bat-infested stairway, peering through the keyhole *always* reports bats.
//
// As you kill the bats, global plot flags are set. Normally flags 331-334
// would be checked via proc0_4(). They're in a bitmask, among other flags, so
// we can check all simultaneously (0000000000011110).
//
// global[520] & 30 == 30
//
// Patch 1: There was no space for this in the responsible method. Instead, we
//  rewrite a different method that became obsolete after the crest bookshelf
//  patch: sCloseSecretDoor::changeState().
//
// Patch 2: We modify sPeepingTom to call our rewritten sCloseSecretDoor. This
//  has two variants, toggled to match the detected edition with enablePatch()
//  below. Aside from the patched lofsa value, they are identical.
//
// Requires patch: qfg4CrestBookshelf (CD or Floppy)

To test...

  • Create a new character.
    • Rogues can't open castle doors unless they have lockpicks (send hero get 24).
    • Other classes are unhindered.
  • Optional: To enter 663 via the secret passage, Spoof being in room 661 before teleporting there.
    • vv g 11 661
  • Teleport: "room 644" or "room 663".
  • Click HAND on the right door. Peer through the keyhole.
  • Go east. Kill bats (click on them as they swoop).
  • Return, and peer again.

@Vhati Vhati force-pushed the qfg4_peeping_bats branch 3 times, most recently from 89955bf to f6ddae5 Compare December 1, 2018 05:32
Copy link
Contributor

@raziel- raziel- left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know how to comment to a specific line, but the very last one:
{ true, 644, "fix peer bats, lower door", 1, qfg4LowerPeerBatsSignature, qfg4LowerPeerBatsPatch },

Shouldn't it come after room 633 in the next line?

@Vhati
Copy link
Contributor Author

Vhati commented Dec 1, 2018

@raziel:

I don't know how to comment to a specific line

I believe you do that by looking at the code, and a blue plus appears beside the line numbers. Click that.

Shouldn't [644] come after room 633 in the next line?

Yep. Thanks for noticing.

@Vhati Vhati force-pushed the qfg4_peeping_bats branch 2 times, most recently from 2d93fc1 to 7c589c5 Compare December 2, 2018 01:34
@Vhati
Copy link
Contributor Author

Vhati commented Dec 2, 2018

Fixed the upper room.

@Vhati Vhati force-pushed the qfg4_peeping_bats branch 4 times, most recently from e12891b to 4598537 Compare December 4, 2018 05:41
@Vhati
Copy link
Contributor Author

Vhati commented Dec 4, 2018

Switched to UINT16 for a couple large pushi values (>127).
I just learned 8bit pushi ops can wind up negative.

They'd worked here, but I prefer to avoid that ambiguity.

op 0x39: pushi B data (2 bytes)

Sign extension for 0x39 is performed where required.

@Vhati Vhati force-pushed the qfg4_peeping_bats branch 2 times, most recently from 6a75462 to a24b51e Compare December 16, 2018 21:14
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 5 times, most recently from 306eab4 to a027a3c Compare December 25, 2018 00:30
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 3 times, most recently from dbdf4a7 to 4f02c54 Compare January 3, 2019 14:48
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 3 times, most recently from 296be11 to 513d37c Compare January 9, 2019 07:50
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 2 times, most recently from c0a3be1 to 8babbe9 Compare January 15, 2019 16:49
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 2 times, most recently from d994694 to f67d02e Compare January 19, 2019 22:16
@Vhati Vhati force-pushed the qfg4_peeping_bats branch 2 times, most recently from ab99d97 to 851e4c4 Compare February 3, 2019 20:13
Fixes castle doors when all bats have been killed, bug #10789
@bluegr
Copy link
Member

bluegr commented Mar 2, 2019

I finally found some time to review this. Well done, rewriting a now unused function to save bytes is quite clever :)

Merging

@bluegr bluegr merged commit 0def174 into scummvm:master Mar 2, 2019
@Vhati Vhati deleted the qfg4_peeping_bats branch March 5, 2019 03:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants