jevsnes.git / third-party / c / patches / 0014-door-with-no-vestibule-in-room-0089.patch
0014-door-with-no-vestibule-in-room-0089.patch41 lines · 2.5 KB · raw
1diff --git a/third-party/c/zbanks-alttp/ap_map.c b/third-party/c/zbanks-alttp/ap_map.c
2index e481fe75..839d5fec 100644
3--- a/third-party/c/zbanks-alttp/ap_map.c
4+++ b/third-party/c/zbanks-alttp/ap_map.c
5@@ -3078,7 +3078,35 @@ ap_map_add_nodes_to_screen(struct ap_screen * screen) {
6                     }
7                 }
8 
9-                struct xy dxy = XYOP1(dir_dxy[new_node->adjacent_direction], * -24);
10+                // Carried patch (jev): every door's approach point is
11+                // offset 24px past its own tile, in its own direction, on
12+                // the assumption that a few pixels of floor stand between
13+                // "in front of the door" and the room the door leads to.
14+                // Room $0089's own north door (tile_attr 0x4b) has none:
15+                // crossing its tile is an instant transition (confirmed
16+                // headless - a raw ZB_HUMAN walk south from north of it
17+                // lands in a different room within 20 frames, no vestibule
18+                // to stand in), so the generic -24 offset places the
19+                // registered goal on the FAR side of that instant line -
20+                // reachable only by having already crossed it, which
21+                // `ap_pathfind_local` correctly and permanently reports as
22+                // unsatisfiable. This door has no safe "near side" offset in
23+                // either direction (24px north undershoots into geometry a
24+                // separate multi-cell-quadrant read showed disconnected from
25+                // Link's own screen) - the destination has to be the door
26+                // tile itself. Zero offset is safe generically: a door
27+                // tile's own cost is already treated as passable within 3
28+                // grid-cells of Link's start (`ap_pathfind_local`'s
29+                // `XYL1DIST(...) <= 3` exemption above), which is exactly
30+                // what lets a plain "walk up to it" goal succeed once
31+                // Link is close, with no assumption about which side has
32+                // clearance. Evidence: research/zbanks-alttp.md, "A door
33+                // with no vestibule ($0089)".
34+                int door_offset_px = -24;
35+                if (*ap_ram.dungeon_room == 0x0089 && attr == 0x4b) {
36+                    door_offset_px = 0;
37+                }
38+                struct xy dxy = XYOP1(dir_dxy[new_node->adjacent_direction], * door_offset_px);
39                 new_node->tl = XYOP2(new_node->tl, +, dxy);
40                 new_node->br = XYOP2(new_node->br, +, dxy);
41