Skip to content

Commit 8cc9f04

Browse files
committed
Simplify logic of determining illegal level change in Gehennom
Furey was confused when reading through this logic. It was confusing to write, so I don't blame them. They correctly pointed out that part of the conditional was redundant and it didn't need to involve an at_stairs check. The reason it bothered checking at_stairs was the original intent of this block was to catch a downwards levelport in addition to other illegal moves, and there were some convolutions to capture the idea of "if the downward level change is happening off-stairs, it's illegal UNLESS they are falling AND did not anticipate the fall". As a comment notes, though, downwards levelport is already handled elsewhere, so this block doesn't need to take care of it.
1 parent 140bd97 commit 8cc9f04

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/do.c

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1471,16 +1471,19 @@ boolean at_stairs, falling, portal;
14711471
if (In_sokoban(newlevel)) {
14721472
tnnt_globals.u_entered_soko = TRUE;
14731473
}
1474-
/* track if we made an illegal move after entering hell
1475-
* if going up, or through a portal,
1476-
* or off the stairs, UNLESS falling and unforeseen
1477-
* downwards level teleport is not handled here because it passes no special
1478-
* flags, so it has its own handling for this */
1474+
/* Track if we made an illegal move after entering hell:
1475+
* going up, or through a portal, or falling down through a trap you already
1476+
* knew about.
1477+
* (Falling through a trap you DIDN'T know about is given an exception, even
1478+
* though it does technically break "used only downstairs to travel through
1479+
* Gehennom", because otherwise you'd either have to aggressively detect
1480+
* traps for thousands of squares of movement or gamble on hitting a trap
1481+
* door and breaking the challenge through no fault of your own.)
1482+
* Downwards level teleport is not handled here because it passes no special
1483+
* flags, so it has its own handling for this in level_tele(). */
14791484
if (Inhell) {
14801485
boolean expected_to_fall = falling && !tnnt_globals.unforeseen_fall;
1481-
/* if I'm off stairs AND I did not expect to fall, it is not illegal */
1482-
if (up || portal || expected_to_fall || (!at_stairs
1483-
&& expected_to_fall)) {
1486+
if (up || portal || expected_to_fall) {
14841487
tnnt_globals.non_downstairs_move_in_hell = TRUE;
14851488
}
14861489
}

0 commit comments

Comments
 (0)