shop_keeper bit

This started as formatting cleanup but ended up adding a bit more
useful information if the impossible ever gets triggered.
This commit is contained in:
PatR
2016-05-18 18:13:01 -07:00
parent fccd29dfd4
commit 23f5526c35
+13 -11
View File
@@ -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. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -812,11 +812,11 @@ register struct monst *mtmp;
struct monst * struct monst *
shop_keeper(rmno) shop_keeper(rmno)
register char rmno; char rmno;
{ {
struct monst *shkp = struct monst *shkp;
rmno >= ROOMOFFSET ? rooms[rmno - ROOMOFFSET].resident : 0;
shkp = (rmno >= ROOMOFFSET) ? rooms[rmno - ROOMOFFSET].resident : 0;
if (shkp) { if (shkp) {
if (has_eshk(shkp)) { if (has_eshk(shkp)) {
if (NOTANGRY(shkp)) { if (NOTANGRY(shkp)) {
@@ -828,15 +828,17 @@ register char rmno;
} }
} else { } else {
/* would have segfaulted on ESHK dereference previously */ /* would have segfaulted on ESHK dereference previously */
impossible( impossible("%s? (rmno=%d, rtype=%d, mnum=%d, \"%s\")",
"shopkeeper career change? (rmno=%d, ROOMOFFSET=%d, mnum=%d, %s)", shkp->isshk ? "shopkeeper career change"
(int)rmno, ROOMOFFSET, shkp->mnum, : "shop resident not shopkeeper",
has_mname(shkp) ? MNAME(shkp) : "anonymous" (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 /* not sure if this is appropriate, because it does nothing to
correct the underlying rooms[].resident issue but... */ correct the underlying rooms[].resident issue but... */
return (struct monst *)0; return (struct monst *) 0;
} }
} }
return shkp; return shkp;