]> granicus.if.org Git - nethack/commitdiff
Prevent inappropriate diagonal dismounts
authorMichael Meyer <me@entrez.cc>
Thu, 24 Dec 2020 19:52:59 +0000 (14:52 -0500)
committerPasi Kallinen <paxed@alt.org>
Thu, 7 Jan 2021 16:55:46 +0000 (18:55 +0200)
Dismounting a steed checked whether the target spot was accessible and
whether there was a monster on it, but not whether it could actually be
accessed by the hero through normal movement. As a result, dismounting
allowed the hero to pass between diagonal gaps that would normally cause
a "you are carrying too much to get through" pline; this could leave
them in a position where they are effectively stuck, unable to remount
their steed or move away without dropping their inventory.

This also could be abused by dismounting in Sokoban to squeeze between
boulders in a way that would normally be impossible.

Using a successful result test_move as one of the requirements for a
spot to be valid prevents this and limits valid dismount targets to
squares that would normally be accessible through standard movement.

src/steed.c

index 44dd33e9f83ef4201f4a390b3b187391b7de05dc..941a2292f5a74db9343026b1174801f186cb9414 100644 (file)
@@ -454,7 +454,8 @@ int forceit;
                 if (!isok(x, y) || (x == u.ux && y == u.uy))
                     continue;
 
-                if (accessible(x, y) && !MON_AT(x, y)) {
+                if (accessible(x, y) && !MON_AT(x, y)
+                    && test_move(u.ux, u.uy, x - u.ux, y - u.uy, TEST_MOVE)) {
                     distance = distu(x, y);
                     if (min_distance < 0 || distance < min_distance
                         || (distance == min_distance && rn2(2))) {