From: Michael Meyer Date: Thu, 24 Dec 2020 19:52:59 +0000 (-0500) Subject: Prevent inappropriate diagonal dismounts X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e7e418c1ec723d6daa8e8136c7a58dfd9d941298;p=nethack Prevent inappropriate diagonal dismounts 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. --- diff --git a/src/steed.c b/src/steed.c index 44dd33e9f..941a2292f 100644 --- a/src/steed.c +++ b/src/steed.c @@ -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))) {