]> granicus.if.org Git - nethack/commitdiff
shop_keeper bit
authorPatR <rankin@nethack.org>
Thu, 19 May 2016 01:13:01 +0000 (18:13 -0700)
committerPatR <rankin@nethack.org>
Thu, 19 May 2016 01:13:01 +0000 (18:13 -0700)
This started as formatting cleanup but ended up adding a bit more
useful information if the impossible ever gets triggered.

src/shk.c

index 3f5819cc4d3e266d357990bae690d8e4e45e3aea..3a6638e9c2284af58d53b1b9dec0bec35641d157 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -1,4 +1,4 @@
-/* NetHack 3.6 shk.c   $NHDT-Date: 1457392872 2016/03/07 23:21:12 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.125 $ */
+/* NetHack 3.6 shk.c   $NHDT-Date: 1463620377 2016/05/19 01:12:57 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.131 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -812,11 +812,11 @@ register struct monst *mtmp;
 
 struct monst *
 shop_keeper(rmno)
-register char rmno;
+char rmno;
 {
-    struct monst *shkp =
-        rmno >= ROOMOFFSET ? rooms[rmno - ROOMOFFSET].resident : 0;
+    struct monst *shkp;
 
+    shkp = (rmno >= ROOMOFFSET) ? rooms[rmno - ROOMOFFSET].resident : 0;
     if (shkp) {
         if (has_eshk(shkp)) {
             if (NOTANGRY(shkp)) {
@@ -828,15 +828,17 @@ register char rmno;
             }
         } else {
             /* would have segfaulted on ESHK dereference previously */
-            impossible(
-             "shopkeeper career change? (rmno=%d, ROOMOFFSET=%d, mnum=%d, %s)",
-                (int)rmno, ROOMOFFSET, shkp->mnum,
-                has_mname(shkp) ? MNAME(shkp) : "anonymous"
-            );
-
+            impossible("%s? (rmno=%d, rtype=%d, mnum=%d, \"%s\")",
+                       shkp->isshk ? "shopkeeper career change"
+                                   : "shop resident not shopkeeper",
+                       (int) rmno,
+                       (int) rooms[rmno - ROOMOFFSET].rtype,
+                       shkp->mnum,
+                       /* [real shopkeeper name is kept in ESHK, not MNAME] */
+                       has_mname(shkp) ? MNAME(shkp) : "anonymous");
             /* not sure if this is appropriate, because it does nothing to
                correct the underlying rooms[].resident issue but... */
-            return (struct monst *)0;
+            return (struct monst *) 0;
         }
     }
     return shkp;