]> granicus.if.org Git - nethack/commitdiff
unseen pet drowning
authorPatR <rankin@nethack.org>
Thu, 13 Feb 2020 23:38:59 +0000 (15:38 -0800)
committerPatR <rankin@nethack.org>
Thu, 13 Feb 2020 23:38:59 +0000 (15:38 -0800)
The "you have a sad feeling for a moment" message was only given when
one monster kills another (and the latter is an unseen pet).  Give it
for drowning too.  There are probably a bunch of other circumstances
which warrant it as well but I've settled for handling minliquid().

doc/fixes37.0
include/flag.h
src/mon.c

index 7efd6d5615067ed551912ce89239eef2f4b7324d..4a2f297f6dc9135cd21e61112f6edaf6ae392574 100644 (file)
@@ -1,4 +1,4 @@
-$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.94 $ $NHDT-Date: 1581210469 2020/02/09 01:07:49 $
+$NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.98 $ $NHDT-Date: 1581637124 2020/02/13 23:38:44 $
 
 General Fixes and Modified Features
 -----------------------------------
@@ -55,6 +55,7 @@ allow defining #wizgenesis quantity in the prompt
 digging through iron bars from an adjacent pit made a pit on top of the bars
 give feedback if controlled level teleport attempt fails because hero is
        already on the bottom level and player tries to go even deeper
+unseen pet that drowned didn't give "you have a sad feeling" message
 
 
 Fixes to 3.7.0-x Problems that Were Exposed Via git Repository
index 1379ebce847d13bce92e4fb524a0d4155cbbb02b..7d06e50ffc5bb67104703bbbb473591a8e79ccc1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 flag.h  $NHDT-Date: 1580434522 2020/01/31 01:35:22 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.175 $ */
+/* NetHack 3.7 flag.h  $NHDT-Date: 1581637124 2020/02/13 23:38:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.176 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Michael Allison, 2006. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -213,6 +213,7 @@ struct instance_flags {
     boolean defer_plname;  /* X11 hack: askname() might not set g.plname */
     boolean herecmd_menu;  /* use menu when mouseclick on yourself */
     boolean invis_goldsym; /* gold symbol is ' '? */
+    boolean sad_feeling;   /* unseen pet is dying */
     int at_midnight;       /* only valid during end of game disclosure */
     int at_night;          /* also only valid during end of game disclosure */
     int failing_untrap;    /* move_into_trap() -> spoteffects() -> dotrap() */
index d528a911cc70c29e510339b9068f2836af7ad189..0e22e93077c419c09089388d2a9cc775f658ea68 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 mon.c   $NHDT-Date: 1581322664 2020/02/10 08:17:44 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.321 $ */
+/* NetHack 3.6 mon.c   $NHDT-Date: 1581637127 2020/02/13 23:38:47 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.322 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -24,6 +24,7 @@ static boolean FDECL(isspecmon, (struct monst *));
 static boolean FDECL(validspecmon, (struct monst *, int));
 static struct permonst *FDECL(accept_newcham_form, (struct monst *, int));
 static struct obj *FDECL(make_corpse, (struct monst *, unsigned));
+static int FDECL(minliquid_core, (struct monst *));
 static void FDECL(m_detach, (struct monst *, struct permonst *));
 static void FDECL(lifesaved_monster, (struct monst *));
 static void FDECL(migrate_mon, (struct monst *, XCHAR_P, XCHAR_P));
@@ -436,8 +437,8 @@ unsigned corpseflags;
         }
         free_mname(mtmp);
         return obj;
-    default_1:
     default:
+ default_1:
         if (g.mvitals[mndx].mvflags & G_NOCORPSE) {
             return (struct obj *) 0;
         } else {
@@ -487,7 +488,22 @@ unsigned corpseflags;
 /* check mtmp and water/lava for compatibility, 0 (survived), 1 (died) */
 int
 minliquid(mtmp)
-register struct monst *mtmp;
+struct monst *mtmp;
+{
+    int res;
+
+    /* set up flag for mondead() and xkilled() */
+    iflags.sad_feeling = (mtmp->mtame && !canseemon(mtmp));
+    res = minliquid_core(mtmp);
+    /* always clear the flag */
+    iflags.sad_feeling = FALSE;
+    return res;
+}
+
+/* guts of minliquid() */
+static int
+minliquid_core(mtmp)
+struct monst *mtmp;
 {
     boolean inpool, inlava, infountain;
 
@@ -1930,8 +1946,13 @@ mondead(mtmp)
 register struct monst *mtmp;
 {
     struct permonst *mptr;
+    boolean be_sad;
     int tmp;
 
+    /* potential pet message; always clear global flag */
+    be_sad = iflags.sad_feeling;
+    iflags.sad_feeling = FALSE;
+
     mtmp->mhp = 0; /* in case caller hasn't done this */
     lifesaved_monster(mtmp);
     if (!DEADMONSTER(mtmp))
@@ -2002,6 +2023,9 @@ register struct monst *mtmp;
         }
     }
 
+    if (be_sad)
+        You("have a sad feeling for a moment, then it passes.");
+
     /* dead vault guard is actually kept at coordinate <0,0> until
        his temporary corridor to/from the vault has been removed;
        need to do this after life-saving and before m_detach() */
@@ -2274,15 +2298,13 @@ struct monst *mdef;
 const char *fltxt;
 int how;
 {
-    boolean be_sad = FALSE; /* true if unseen pet is killed */
-
     if ((mdef->wormno ? worm_known(mdef) : cansee(mdef->mx, mdef->my))
         && fltxt)
         pline("%s is %s%s%s!", Monnam(mdef),
               nonliving(mdef->data) ? "destroyed" : "killed",
               *fltxt ? " by the " : "", fltxt);
     else
-        be_sad = (mdef->mtame != 0);
+        iflags.sad_feeling = (mdef->mtame != 0);
 
     /* no corpses if digested or disintegrated */
     g.disintegested = (how == AD_DGST || how == -AD_RBRE);
@@ -2290,9 +2312,6 @@ int how;
         mondead(mdef);
     else
         mondied(mdef);
-
-    if (be_sad && DEADMONSTER(mdef))
-        You("have a sad feeling for a moment, then it passes.");
 }
 
 void
@@ -2335,12 +2354,17 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
     struct permonst *mdat;
     struct obj *otmp;
     struct trap *t;
+    boolean be_sad;
     boolean wasinside = u.uswallow && (u.ustuck == mtmp),
             burycorpse = FALSE,
             nomsg = (xkill_flags & XKILL_NOMSG) != 0,
             nocorpse = (xkill_flags & XKILL_NOCORPSE) != 0,
             noconduct = (xkill_flags & XKILL_NOCONDUCT) != 0;
 
+    /* potential pet message; always clear global flag */
+    be_sad = iflags.sad_feeling;
+    iflags.sad_feeling = FALSE;
+
     mtmp->mhp = 0; /* caller will usually have already done this */
     if (!noconduct) /* KMH, conduct */
         u.uconduct.killer++;
@@ -2403,6 +2427,9 @@ int xkill_flags; /* 1: suppress message, 2: suppress corpse, 4: pacifist */
         return;
     }
 
+    if (be_sad)
+        You("have a sad feeling for a moment, then it passes.");
+
     mdat = mtmp->data; /* note: mondead can change mtmp->data */
     mndx = monsndx(mdat);