Skip to content

Commit

Permalink
Fix guards disappearing when the player (re-)enters the currently sho…
Browse files Browse the repository at this point in the history
…wn room.
  • Loading branch information
NagyD committed Dec 23, 2022
1 parent f4279dd commit 0ae137b
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 1 deletion.
9 changes: 9 additions & 0 deletions src/config.h
Expand Up @@ -286,6 +286,15 @@ The authors of this program may be contacted at https://forum.princed.org
// See also: https://github.com/NagyD/SDLPoP/pull/274
#define FIX_FALLING_THROUGH_FLOOR_DURING_SWORD_STRIKE

// When the player (re-)enters the currently shown room, the guard disappears from the screen.
// This can happen when:
// * A room is linked to itself (broken link).
// * The player used the "show other room" cheat.
// * A teleport and its pair are in the same room.
// There are two fixes for this:
//#define FIX_DISAPPEARING_GUARD_A // Inserts a black screen.
//#define FIX_DISAPPEARING_GUARD_B // Doesn't insert a black screen.

#endif // ifndef DISABLE_ALL_FIXES

// Prince can jump 2 stories up in feather fall mode
Expand Down
7 changes: 7 additions & 0 deletions src/seg002.c
Expand Up @@ -335,6 +335,9 @@ void exit_room() {
}
savekid();
next_room = Char.room;
#ifdef FIX_DISAPPEARING_GUARD_B
if (next_room == drawn_room) return;
#endif
if (Guard.direction == dir_56_none) return;
if (Guard.alive < 0 && Guard.sword == sword_2_drawn) {
short kid_room_m1 = Kid.room - 1;
Expand Down Expand Up @@ -379,6 +382,10 @@ void exit_room() {
} else {
follow_guard();
}

#ifdef FIX_DISAPPEARING_GUARD_A
if (next_room == drawn_room) drawn_room = 0;
#endif
}

// seg002:0486
Expand Down
10 changes: 9 additions & 1 deletion src/seg005.c
Expand Up @@ -1131,7 +1131,15 @@ void teleport() {
Char.y = y_land[Char.curr_row + 1];
next_room = Char.room;
clear_coll_rooms(); // Without this, the prince will sometimes end up at the wrong place.
leave_guard();
#ifdef FIX_DISAPPEARING_GUARD_B
if (next_room != drawn_room)
#endif
{
leave_guard();
}
#ifdef FIX_DISAPPEARING_GUARD_A
if (next_room == drawn_room) drawn_room = 0;
#endif
seqtbl_offset_char(seq_5_turn);
play_sound(sound_45_jump_through_mirror);
} else {
Expand Down

1 comment on commit 0ae137b

@dstarosta
Copy link
Contributor

Choose a reason for hiding this comment

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

I had a similar fix for a super high jump issue. Yours is probably better and can be combined. If you super high jump up from row 1 and the room above has no floor, the guard in the room would disappear.

#ifdef USE_SUPER_HIGH_JUMP

Please sign in to comment.