]> granicus.if.org Git - nethack/commitdiff
polearm context
authorPatR <rankin@nethack.org>
Sat, 5 Sep 2020 18:35:28 +0000 (11:35 -0700)
committerPatR <rankin@nethack.org>
Sat, 5 Sep 2020 18:35:28 +0000 (11:35 -0700)
Move clearing of polearm context from migrate_to_lev() to lower
level relmon().  Add missing transfer of polearm context from
old mon to new mon in replmon().  These days it seems to only be
used for creating a monster from saved traits, so polearm context
in it should be moot.

src/dog.c
src/mon.c

index 44ef538ff2596bc51fa6855439fc9a87a6f374e2..14a6b19921247e8be990b1c6b3f77ed00d0d4ac0 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 dog.c   $NHDT-Date: 1596498159 2020/08/03 23:42:39 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.103 $ */
+/* NetHack 3.7 dog.c   $NHDT-Date: 1599330917 2020/09/05 18:35:17 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.104 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2011. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -726,8 +726,6 @@ coord *cc;   /* optional destination coordinates */
     mtmp->mux = new_lev.dnum;
     mtmp->muy = new_lev.dlevel;
     mtmp->mx = mtmp->my = 0; /* this implies migration */
-    if (mtmp == g.context.polearm.hitmon)
-        g.context.polearm.hitmon = (struct monst *) 0;
 }
 
 /* return quality of food; the lower the better */
index a4c0f6f90aef431efcdc1824553c4ad02509e1d5..83e28ebbc83b7d39a62fc3a04a74fe2480a2e0f7 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 mon.c   $NHDT-Date: 1598575089 2020/08/28 00:38:09 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.344 $ */
+/* NetHack 3.7 mon.c   $NHDT-Date: 1599330921 2020/09/05 18:35:21 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.345 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -1809,6 +1809,9 @@ struct monst *mtmp, *mtmp2;
         otmp->ocarry = mtmp2;
     }
     mtmp->minvent = 0;
+    /* before relmon(mtmp), because it could clear polearm.hitmon */
+    if (g.context.polearm.hitmon == mtmp)
+        g.context.polearm.hitmon = mtmp2;
 
     /* remove the old monster from the map and from `fmon' list */
     relmon(mtmp, (struct monst **) 0);
@@ -1853,6 +1856,9 @@ struct monst **monst_list; /* &g.migrating_mons or &g.mydogs or null */
     if (!fmon)
         panic("relmon: no fmon available.");
 
+    if (mon == g.context.polearm.hitmon)
+        g.context.polearm.hitmon = (struct monst *) 0;
+
     if (unhide) {
         /* can't remain hidden across level changes (exception: wizard
            clone can continue imitating some other monster form); also,