From: PatR Date: Mon, 7 Dec 2020 20:46:46 +0000 (-0800) Subject: fix #3120,#3122 - dwarf pass_wall without digging X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=87818188e1960031fe3cd832784501342e4877a2;p=nethack fix #3120,#3122 - dwarf pass_wall without digging I couldn't reproduce this so can't confirm that this fix works, but inspection of the code reveals that something was missing in the unified mon movement flags code. I think what has been happening is that a dwarf without a pick-axe might not bother wielding that but movement behaved as if it had, then digging decided it wasn't. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 16a14abe6..3194adae7 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.376 $ $NHDT-Date: 1607252278 2020/12/06 10:57:58 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.377 $ $NHDT-Date: 1607373999 2020/12/07 20:46:39 $ General Fixes and Modified Features ----------------------------------- @@ -411,6 +411,7 @@ options help ('? g') listed all boolean options, then repeated them among the compound options; on OSX they showed a description of "(null)" but for other sprintf implementations they might cause a crash change name of #wizlevelflip to #wizfliplevel +dwarves could sometimes pass through walls without digging their way curses: 'msg_window' option wasn't functional for curses unless the binary also included tty support diff --git a/src/dogmove.c b/src/dogmove.c index e4f8f4513..363bbcd5c 100644 --- a/src/dogmove.c +++ b/src/dogmove.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 dogmove.c $NHDT-Date: 1596498159 2020/08/03 23:42:39 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.91 $ */ +/* NetHack 3.7 dogmove.c $NHDT-Date: 1607374000 2020/12/07 20:46:40 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.94 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2012. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1311,7 +1311,9 @@ xchar mx, my, fx, fy; if (dist2(i, j, fx, fy) >= dist) continue; if (IS_ROCK(levl[i][j].typ) && !passes_walls(mon->data) - && (!may_dig(i, j) || !tunnels(mon->data))) + && (!may_dig(i, j) || !tunnels(mon->data) + /* tunnelling monsters can't do that on the rogue level */ + || Is_rogue_level(&u.uz))) continue; if (IS_DOOR(levl[i][j].typ) && (levl[i][j].doormask & (D_CLOSED | D_LOCKED))) diff --git a/src/mon.c b/src/mon.c index e203e71d7..06a00a4a3 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 mon.c $NHDT-Date: 1606623308 2020/11/29 04:15:08 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.357 $ */ +/* NetHack 3.7 mon.c $NHDT-Date: 1607374002 2020/12/07 20:46:42 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.359 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1551,6 +1551,14 @@ struct monst *mtmp; boolean can_unlock = ((can_open && monhaskey(mtmp, TRUE)) || mtmp->iswiz || is_rider(mtmp->data)); boolean doorbuster = is_giant(mtmp->data); + /* don't tunnel if on rogue level or if hostile and close enough + to prefer a weapon; same criteria as in m_move() */ + boolean can_tunnel = (tunnels(mtmp->data) && !Is_rogue_level(&u.uz)); + + if (can_tunnel && needspick(mtmp->data) + && ((!mtmp->mpeaceful || Conflict) + && dist2(mtmp->mx, mtmp->my, mtmp->mux, mtmp->muy) <= 8)) + can_tunnel = FALSE; if (mtmp->mtame) allowflags |= ALLOW_M | ALLOW_TRAPS | ALLOW_SANCT | ALLOW_SSM; @@ -1568,8 +1576,7 @@ struct monst *mtmp; allowflags |= (ALLOW_ROCK | ALLOW_WALL); if (throws_rocks(mtmp->data)) allowflags |= ALLOW_ROCK; - if (tunnels(mtmp->data) - && !Is_rogue_level(&u.uz)) /* same restriction as m_move() */ + if (can_tunnel) allowflags |= ALLOW_DIG; if (doorbuster) allowflags |= BUSTDOOR;