From: Pasi Kallinen Date: Fri, 25 Feb 2022 16:33:50 +0000 (+0200) Subject: Split movement out of bounds check out of domove X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86bc0a2633e85a0e5590cc8da15e37cb199c206a;p=nethack Split movement out of bounds check out of domove --- diff --git a/src/hack.c b/src/hack.c index 540571b61..47eddfeda 100644 --- a/src/hack.c +++ b/src/hack.c @@ -23,6 +23,7 @@ static boolean domove_fight_empty(xchar, xchar); static boolean air_turbulence(void); static void slippery_ice_fumbling(void); static boolean impaired_movement(xchar *, xchar *); +static boolean move_out_of_bounds(xchar x, xchar y); static boolean carrying_too_much(void); static void domove_core(void); static void maybe_smudge_engr(int, int, int, int); @@ -1996,6 +1997,32 @@ impaired_movement(xchar *x, xchar *y) return FALSE; } +static boolean +move_out_of_bounds(xchar x, xchar y) +{ + if (!isok(x, y)) { + if (flags.mention_walls) { + int dx = u.dx, dy = u.dy; + + if (dx && dy) { /* diagonal */ + /* only as far as possible diagonally if in very + corner; otherwise just report whichever of the + cardinal directions has reached its limit */ + if (isok(x, u.uy)) + dx = 0; + else if (isok(u.ux, y)) + dy = 0; + } + You("have already gone as far %s as possible.", + directionname(xytod(dx, dy))); + } + nomul(0); + g.context.move = 0; + return TRUE; + } + return FALSE; +} + /* carrying too much to be able to move? */ static boolean carrying_too_much(void) @@ -2075,26 +2102,9 @@ domove_core(void) if (water_turbulence(&x, &y)) return; - if (!isok(x, y)) { - if (flags.mention_walls) { - int dx = u.dx, dy = u.dy; - - if (dx && dy) { /* diagonal */ - /* only as far as possible diagonally if in very - corner; otherwise just report whichever of the - cardinal directions has reached its limit */ - if (isok(x, u.uy)) - dx = 0; - else if (isok(u.ux, y)) - dy = 0; - } - You("have already gone as far %s as possible.", - directionname(xytod(dx, dy))); - } - nomul(0); - g.context.move = 0; + if (move_out_of_bounds(x,y)) return; - } + if (((trap = t_at(x, y)) && trap->tseen) || (Blind && !Levitation && !Flying && !is_clinger(g.youmonst.data) && is_pool_or_lava(x, y) && levl[x][y].seenv)) {