place_monster() debugging
Show more information if place_monster() detects something wrong. I don't know whether it will actually be useful.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1573869062 2019/11/16 01:51:02 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.740 $ */
|
||||
/* NetHack 3.6 extern.h $NHDT-Date: 1573940539 2019/11/16 21:42:19 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.741 $ */
|
||||
/* Copyright (c) Steve Creps, 1988. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -450,6 +450,7 @@ E char *FDECL(Amonnam, (struct monst *));
|
||||
E char *FDECL(a_monnam, (struct monst *));
|
||||
E char *FDECL(distant_monnam, (struct monst *, int, char *));
|
||||
E char *FDECL(mon_nam_too, (struct monst *, struct monst *));
|
||||
E char *FDECL(minimal_monnam, (struct monst *, BOOLEAN_P));
|
||||
E char *FDECL(rndmonnam, (char *));
|
||||
E const char *FDECL(hcolor, (const char *));
|
||||
E const char *NDECL(rndcolor);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 do_name.c $NHDT-Date: 1560611967 2019/06/15 15:19:27 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.149 $ */
|
||||
/* NetHack 3.6 do_name.c $NHDT-Date: 1573940540 2019/11/16 21:42:20 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.150 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/*-Copyright (c) Pasi Kallinen, 2018. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
@@ -1978,6 +1978,42 @@ struct monst *mon, *other_mon;
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
/* for debugging messages, where data might be suspect and we aren't
|
||||
taking what the hero does or doesn't know into consideration */
|
||||
char *
|
||||
minimal_monnam(mon, ckloc)
|
||||
struct monst *mon;
|
||||
boolean ckloc;
|
||||
{
|
||||
struct permonst *ptr;
|
||||
char *outbuf = nextmbuf();
|
||||
|
||||
if (!mon) {
|
||||
Strcpy(outbuf, "[Null monster]");
|
||||
} else if ((ptr = mon->data) == 0) {
|
||||
Strcpy(outbuf, "[Null mon->data]");
|
||||
} else if (ptr < &mons[0]) {
|
||||
Sprintf(outbuf, "[Invalid mon->data %s < %s]",
|
||||
fmt_ptr((genericptr_t) mon->data),
|
||||
fmt_ptr((genericptr_t) &mons[0]));
|
||||
} else if (ptr >= &mons[NUMMONS]) {
|
||||
Sprintf(outbuf, "[Invalid mon->data %s >= %s]",
|
||||
fmt_ptr((genericptr_t) mon->data),
|
||||
fmt_ptr((genericptr_t) &mons[NUMMONS]));
|
||||
} else if (ckloc && ptr == &mons[PM_LONG_WORM]
|
||||
&& level.monsters[mon->mx][mon->my] != mon) {
|
||||
Sprintf(outbuf, "%s <%d,%d>",
|
||||
mons[PM_LONG_WORM_TAIL].mname, mon->mx, mon->my);
|
||||
} else {
|
||||
Sprintf(outbuf, "%s%s <%d,%d>",
|
||||
mon->mtame ? "tame " : mon->mpeaceful ? "peaceful " : "",
|
||||
mon->data->mname, mon->mx, mon->my);
|
||||
if (mon->cham != NON_PM)
|
||||
Sprintf(eos(outbuf), "{%s}", mons[mon->cham].mname);
|
||||
}
|
||||
return outbuf;
|
||||
}
|
||||
|
||||
/* fake monsters used to be in a hard-coded array, now in a data file */
|
||||
STATIC_OVL char *
|
||||
bogusmon(buf, code)
|
||||
|
||||
16
src/steed.c
16
src/steed.c
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 steed.c $NHDT-Date: 1559670610 2019/06/04 17:50:10 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.66 $ */
|
||||
/* NetHack 3.6 steed.c $NHDT-Date: 1573940541 2019/11/16 21:42:21 $ $NHDT-Branch: NetHack-3.6 $:$NHDT-Revision: 1.67 $ */
|
||||
/* Copyright (c) Kevin Hugo, 1998-1999. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -742,6 +742,8 @@ place_monster(mon, x, y)
|
||||
struct monst *mon;
|
||||
int x, y;
|
||||
{
|
||||
struct monst *othermon;
|
||||
const char *monnm, *othnm;
|
||||
char buf[QBUFSZ];
|
||||
|
||||
buf[0] = '\0';
|
||||
@@ -749,8 +751,8 @@ int x, y;
|
||||
vault guards (either living or dead) are parked at <0,0> */
|
||||
if (!isok(x, y) && (x != 0 || y != 0 || !mon->isgd)) {
|
||||
describe_level(buf);
|
||||
impossible("trying to place monster at <%d,%d> mstate:%lx on %s",
|
||||
x, y, mon->mstate, buf);
|
||||
impossible("trying to place %s at <%d,%d> mstate:%lx on %s",
|
||||
minimal_monnam(mon, TRUE), x, y, mon->mstate, buf);
|
||||
x = y = 0;
|
||||
}
|
||||
if (mon == u.usteed
|
||||
@@ -762,10 +764,12 @@ int x, y;
|
||||
mon->mstate, buf);
|
||||
return;
|
||||
}
|
||||
if (level.monsters[x][y]) {
|
||||
if ((othermon = level.monsters[x][y]) != 0) {
|
||||
describe_level(buf);
|
||||
impossible("placing monster over another at <%d,%d>, mstates:%lx %lx on %s?",
|
||||
x, y, level.monsters[x][y]->mstate, mon->mstate, buf);
|
||||
monnm = minimal_monnam(mon, FALSE);
|
||||
othnm = (mon != othermon) ? minimal_monnam(othermon, TRUE) : "itself";
|
||||
impossible("placing %s over %s at <%d,%d>, mstates:%lx %lx on %s?",
|
||||
monnm, othnm, x, y, othermon->mstate, mon->mstate, buf);
|
||||
}
|
||||
mon->mx = x, mon->my = y;
|
||||
level.monsters[x][y] = mon;
|
||||
|
||||
Reference in New Issue
Block a user