]> granicus.if.org Git - nethack/commitdiff
zap.c non-zap buglets
authorPatR <rankin@nethack.org>
Mon, 23 May 2022 18:19:38 +0000 (11:19 -0700)
committerPatR <rankin@nethack.org>
Mon, 23 May 2022 18:19:38 +0000 (11:19 -0700)
A couple of things I noticed when trying--and failing, so far--to figure
out the revive panic:
1) revive() treated y==0 as out of map bounds (x==0 is out of bounds
   but y==0 isn't);
2) get_mon_location() might yield stale coordinates for steed (but
   moot since that's only used for mobile lights and no light emitting
   monster can wear a saddle; didn't affect light emitting objects
   carried or worn by monsters).

src/zap.c

index bc0d60d31a2c29ad36ac654db3d7eb8eea1f15ae..f7c0fc8447778e2809ddb45dd9dcd4a9182e2fe4 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1,4 +1,4 @@
-/* NetHack 3.7 zap.c   $NHDT-Date: 1651868824 2022/05/06 20:27:04 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.410 $ */
+/* NetHack 3.7 zap.c   $NHDT-Date: 1653329964 2022/05/23 18:19:24 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.415 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Robert Patrick Rankin, 2013. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -586,11 +586,12 @@ get_obj_location(struct obj *obj, xchar *xp, xchar *yp, int locflags)
 }
 
 boolean
-get_mon_location(struct monst *mon, xchar *xp, xchar *yp,
-                 int locflags) /* non-zero means get location even if monster
-                                  is buried */
+get_mon_location(
+    struct monst *mon,
+    xchar *xp, xchar *yp,
+    int locflags) /* non-zero means get location even if monster is buried */
 {
-    if (mon == &g.youmonst) {
+    if (mon == &g.youmonst || (u.usteed && mon == u.usteed)) {
         *xp = u.ux;
         *yp = u.uy;
         return TRUE;
@@ -819,7 +820,7 @@ revive(struct obj *corpse, boolean by_hero)
             break; /* x,y are 0 */
         }
     }
-    if (!x || !y
+    if (!x
         /* Rules for revival from containers:
          *  - the container cannot be locked
          *  - the container cannot be heavily nested (>2 is arbitrary)