From: PatR Date: Thu, 11 Apr 2019 22:38:51 +0000 (-0700) Subject: fix #H8534 - thrown pick-axe vs "scum!" X-Git-Tag: NetHack-3.6.2_Released~19^2~3 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=86e5022293aaca4c54fe62d7087689faf13d0ed2;p=nethack fix #H8534 - thrown pick-axe vs "scum!" Change in meaning of mnearto()'s return value wasn't progagated to shkcatch(). Make it an int instead of boolean so that it can communicate both 'moved successfully' and 'moved but had to move another monster out of the way to do so'. --- diff --git a/doc/fixes36.2 b/doc/fixes36.2 index f234f0776..b550c2a06 100644 --- a/doc/fixes36.2 +++ b/doc/fixes36.2 @@ -1,4 +1,4 @@ -$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.300 $ $NHDT-Date: 1554841009 2019/04/09 20:16:49 $ +$NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.301 $ $NHDT-Date: 1555022325 2019/04/11 22:38:45 $ This fixes36.2 file is here to capture information about updates in the 3.6.x lineage following the release of 3.6.1 in April 2018. Please note, however, @@ -409,6 +409,8 @@ once a status highlight for a temporary rule ('up', 'down', 'changed') timed if a migrating long worm couldn't be placed, or some other monster was given an existing long worm's place and it couldn't be put somewhere else, a "trying to place monster at <0,0>" warning would occur +if hero throws a pick-axe into a shop and shopkeeper catches it, shk will say + "get out of my way, scum" even if there's no monster at pick-axe spot Fixes to Post-3.6.1 Problems that Were Exposed Via git Repository diff --git a/include/extern.h b/include/extern.h index ee4731ad3..ec4c6707d 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1,4 +1,4 @@ -/* NetHack 3.6 extern.h $NHDT-Date: 1554857123 2019/04/10 00:45:23 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.700 $ */ +/* NetHack 3.6 extern.h $NHDT-Date: 1555022327 2019/04/11 22:38:47 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.701 $ */ /* Copyright (c) Steve Creps, 1988. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1411,7 +1411,7 @@ E void FDECL(mon_to_stone, (struct monst *)); E void FDECL(m_into_limbo, (struct monst *)); E void FDECL(mnexto, (struct monst *)); E void FDECL(maybe_mnexto, (struct monst *)); -E boolean FDECL(mnearto, (struct monst *, XCHAR_P, XCHAR_P, BOOLEAN_P)); +E int FDECL(mnearto, (struct monst *, XCHAR_P, XCHAR_P, BOOLEAN_P)); E void FDECL(m_respond, (struct monst *)); E void FDECL(setmangry, (struct monst *, BOOLEAN_P)); E void FDECL(wakeup, (struct monst *, BOOLEAN_P)); diff --git a/src/mkmaze.c b/src/mkmaze.c index 863502baf..1b3959315 100644 --- a/src/mkmaze.c +++ b/src/mkmaze.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mkmaze.c $NHDT-Date: 1543185071 2018/11/25 22:31:11 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.67 $ */ +/* NetHack 3.6 mkmaze.c $NHDT-Date: 1555022325 2019/04/11 22:38:45 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.68 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2018. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1878,6 +1878,7 @@ boolean ini; case CONS_MON: { struct monst *mon = (struct monst *) cons->list; + (void) mnearto(mon, cons->x, cons->y, TRUE); break; } diff --git a/src/mon.c b/src/mon.c index d0a422f60..b3c1abaf3 100644 --- a/src/mon.c +++ b/src/mon.c @@ -1,4 +1,4 @@ -/* NetHack 3.6 mon.c $NHDT-Date: 1554580625 2019/04/06 19:57:05 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.280 $ */ +/* NetHack 3.6 mon.c $NHDT-Date: 1555022326 2019/04/11 22:38:46 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.281 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -2636,10 +2636,15 @@ struct monst *mtmp; /* mnearto() * Put monster near (or at) location if possible. * Returns: - * true if relocation was successful - * false otherwise + * 2 if another monster was moved out of this one's way; + * 1 if relocation was successful (without moving another one); + * 0 otherwise. + * Note: if already at the target spot, result is 1 rather than 0. + * + * Might be called recursively if 'move_other' is True; if so, that argument + * will be False on the nested call so there won't be any further recursion. */ -boolean +int mnearto(mtmp, x, y, move_other) register struct monst *mtmp; xchar x, y; @@ -2648,15 +2653,18 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */ struct monst *othermon = (struct monst *) 0; xchar newx, newy; coord mm; + int res = 1; if (mtmp->mx == x && mtmp->my == y && m_at(x, y) == mtmp) - return TRUE; + return res; if (move_other && (othermon = m_at(x, y)) != 0) { if (othermon->wormno) remove_worm(othermon); else remove_monster(x, y); + + othermon->mx = othermon->my = 0; /* 'othermon' is not on the map */ } newx = x; @@ -2667,28 +2675,21 @@ boolean move_other; /* make sure mtmp gets to x, y! so move m_at(x, y) */ * no end of trouble. */ if (!enexto(&mm, newx, newy, mtmp->data)) - return FALSE; + return 0; if (!isok(mm.x, mm.y)) - return FALSE; + return 0; newx = mm.x; newy = mm.y; } rloc_to(mtmp, newx, newy); if (move_other && othermon) { - xchar oldx = othermon->mx, oldy = othermon->my; - - othermon->mx = othermon->my = 0; - (void) mnearto(othermon, x, y, FALSE); - if (othermon->mx == 0 && othermon->my == 0) { - /* reloc failed */ - othermon->mx = oldx; - othermon->my = oldy; + res = 2; /* moving another monster out of the way */ + if (!mnearto(othermon, x, y, FALSE)) /* no 'move_other' this time */ m_into_limbo(othermon); - } } - return TRUE; + return res; } /* monster responds to player action; not the same as a passive attack;