#define BETA /* development or beta testing [MRS] */
+#define DEBUG
+
/*
* Files expected to exist in the playground directory.
*/
#include "config.h"
#endif
-/* For debugging beta code. */
-#ifdef BETA
-#define Dpline pline
+#ifdef DEBUG
+/* due to strstr(), mon.c matches makemon.c */
+# define showdebug() (sysopt.debugfiles && \
+ ((sysopt.debugfiles[0] == '*') || \
+ (strstr( __FILE__ , sysopt.debugfiles))))
+
+/* GCC understands this syntax */
+# ifdef __GNUC__
+/* ... but whines about it anyway without these pragmas. */
+# pragma GCC diagnostic push
+# pragma GCC diagnostic ignored "-Wvariadic-macros"
+# define debugpline(args...) \
+ do { if (showdebug()) pline( args ); } while(0);
+# pragma GCC diagnostic pop
+# endif
+
+/* and Visual Studio understands this one */
+# ifdef _MSC_VER
+# define debugpline(...) \
+ do { if (showdebug()) pline(__VA_ARGS__); } while(0);
+# endif
+
+#else
+# define showdebug() (0)
+# define debugpline(...)
#endif
#define TELL 1
char *recover; /* how to run recover - may be overridden by win port */
char *wizards;
char *shellers; /* like wizards, for ! command (-DSHELL) */
+ char *debugfiles; /* files to show debugplines in. '*' is all. */
int maxplayers;
/* record file */
int persmax;
char monnambuf[BUFSZ], carriedby[BUFSZ];
if (!figurine) {
-#ifdef DEBUG
- pline("null figurine in fig_transform()");
-#endif
+ debugpline("null figurine in fig_transform()");
return;
}
silent = (timeout != monstermoves); /* happened while away */
#include "hack.h"
#include <ctype.h>
-/* #define DEBUG */ /* uncomment for debugging info */
-
/* part of the output on gain or loss of attribute */
static
const char * const plusattr[] = {
int i;
boolean inc_or_dec;
{
-#ifdef DEBUG
- pline("Exercise:");
-#endif
+ debugpline("Exercise:");
if (i == A_INT || i == A_CHA) return; /* can't exercise these */
/* no physical exercise while polymorphed; the body's temporary */
* Note: *YES* ACURR is the right one to use.
*/
AEXE(i) += (inc_or_dec) ? (rn2(19) > ACURR(i)) : -rn2(2);
-#ifdef DEBUG
- pline("%s, %s AEXE = %d",
+ debugpline("%s, %s AEXE = %d",
(i == A_STR) ? "Str" : (i == A_WIS) ? "Wis" :
(i == A_DEX) ? "Dex" : "Con",
(inc_or_dec) ? "inc" : "dec", AEXE(i));
-#endif
}
if (moves > 0 && (i == A_STR || i == A_CON)) (void)encumber_msg();
}
(u.uhunger > 50) ? HUNGRY :
(u.uhunger > 0) ? WEAK : FAINTING;
-#ifdef DEBUG
- pline("exerper: Hunger checks");
-#endif
+ debugpline("exerper: Hunger checks");
switch (hs) {
case SATIATED: exercise(A_DEX, FALSE);
if (Role_if(PM_MONK))
}
/* Encumberance Checks */
-#ifdef DEBUG
- pline("exerper: Encumber checks");
-#endif
+ debugpline("exerper: Encumber checks");
switch (near_capacity()) {
case MOD_ENCUMBER: exercise(A_STR, TRUE); break;
case HVY_ENCUMBER: exercise(A_STR, TRUE);
/* status checks */
if(!(moves % 5)) {
-#ifdef DEBUG
- pline("exerper: Status checks");
-#endif
+ debugpline("exerper: Status checks");
if ((HClairvoyant & (INTRINSIC|TIMEOUT)) &&
!BClairvoyant) exercise(A_WIS, TRUE);
if (HRegeneration) exercise(A_STR, TRUE);
/* Check out the periodic accumulations */
exerper();
-#ifdef DEBUG
if(moves >= context.next_attrib_check)
- pline("exerchk: ready to test. multi = %d.", multi);
-#endif
+ debugpline("exerchk: ready to test. multi = %d.", multi);
/* Are we ready for a test? */
if(moves >= context.next_attrib_check && !multi) {
-#ifdef DEBUG
- pline("exerchk: testing.");
-#endif
+ debugpline("exerchk: testing.");
/*
* Law of diminishing returns (Part II):
*
exercise/abuse gradually wears off without impact then */
if (Upolyd && i != A_WIS) goto nextattrib;
-#ifdef DEBUG
- pline("exerchk: testing %s (%d).",
+ debugpline("exerchk: testing %s (%d).",
(i == A_STR) ? "Str" : (i == A_INT) ? "Int?" :
(i == A_WIS) ? "Wis" : (i == A_DEX) ? "Dex" :
(i == A_CON) ? "Con" : (i == A_CHA) ? "Cha?" : "???",
ax);
-#endif
/*
* Law of diminishing returns (Part III):
*
if (rn2(AVAL) > ((i != A_WIS) ? (abs(ax) * 2 / 3) : abs(ax)))
goto nextattrib;
-#ifdef DEBUG
- pline("exerchk: changing %d.", i);
-#endif
+ debugpline("exerchk: changing %d.", i);
if(adjattrib(i, mod_val, -1)) {
-#ifdef DEBUG
- pline("exerchk: changed %d.", i);
-#endif
+ debugpline("exerchk: changed %d.", i);
/* if you actually changed an attrib - zero accumulation */
AEXE(i) = ax = 0;
/* then print an explanation */
AEXE(i) = (abs(ax) / 2) * mod_val;
}
context.next_attrib_check += rn1(200,800);
-#ifdef DEBUG
- pline("exerchk: next check at %ld.", context.next_attrib_check);
-#endif
+ debugpline("exerchk: next check at %ld.", context.next_attrib_check);
}
}
for(mtmp = fmon; mtmp; mtmp = mtmp->nmon) {
if (has_mname(mtmp)) sanitize_name(MNAME(mtmp));
if (mtmp->mhpmax == DEFUNCT_MONSTER) {
-#if defined(DEBUG)
if (wizard)
- pline("Removing defunct monster %s from bones.",
+ debugpline("Removing defunct monster %s from bones.",
mtmp->data->mname);
-#endif
mongone(mtmp);
} else
/* to correctly reset named artifacts on the level */
#include "hack.h"
#include "func_tab.h"
-/* #define DEBUG */ /* uncomment for debugging */
#ifdef ALTMETA
STATIC_VAR boolean alt_esc = FALSE;
#define CMD_CLICKLOOK (char)0x8F
#ifdef DEBUG
-/*
- * only one "wiz_debug_cmd" routine should be available (in whatever
- * module you are trying to debug) or things are going to get rather
- * hard to link :-)
- */
-extern int NDECL(wiz_debug_cmd);
+extern int NDECL(wiz_debug_cmd_bury);
+extern int NDECL(wiz_debug_cmd_traveldisplay);
#endif
#ifdef DUMB /* stuff commented out in extern.h, but needed here */
Sprintf(fmtstr, "%%-%ds", biggest + 15);
}
if (++i > MAX_EXT_CMD) {
-# if defined(DEBUG) || defined(BETA)
+# if defined(BETA)
impossible(
"Exceeded %d extended commands in doextcmd() menu; 'extmenu' disabled.",
MAX_EXT_CMD);
-# endif /* DEBUG || BETA */
+# endif /* BETA */
iflags.extmenu = 0;
return -1;
}
if (n == 1) {
if (matchlevel > (QBUFSZ - 2)) {
free((genericptr_t)pick_list);
-# if defined(DEBUG) || defined(BETA)
+# if defined(BETA)
impossible("Too many chars (%d) entered in extcmd_via_menu()",
matchlevel);
# endif
{(char *)0, (char *)0, donull, TRUE}, /* vision */
{(char *)0, (char *)0, donull, TRUE}, /* wizsmell */
#ifdef DEBUG
- {(char *)0, (char *)0, donull, TRUE}, /* wizdebug */
+ {(char *)0, (char *)0, donull, TRUE}, /* wizdebug_traveldisplay */
+ {(char *)0, (char *)0, donull, TRUE}, /* wizdebug_bury */
#endif
{(char *)0, (char *)0, donull, TRUE}, /* wizrumorcheck */
{(char *)0, (char *)0, donull, TRUE}, /* wmode */
{"vision", "show vision array", wiz_show_vision, TRUE},
{"wizsmell", "smell monster", wiz_smell, TRUE},
#ifdef DEBUG
- {"wizdebug", "wizard debug command", wiz_debug_cmd, TRUE},
+ {"wizdebug_traveldisplay", "wizard debug: toggle travel display", wiz_debug_cmd_traveldisplay, TRUE},
+ {"wizdebug_bury", "wizard debug: bury objs under and around you", wiz_debug_cmd_bury, TRUE},
#endif
{"wizrumorcheck", "verify rumor boundaries", wiz_rumor_check, TRUE},
{"wmode", "show wall modes", wiz_show_wmodes, TRUE},
STATIC_DCL void FDECL(u_to_e, (struct entity *));
STATIC_DCL void FDECL(set_entity, (int, int, struct entity *));
STATIC_DCL const char *FDECL(e_nam, (struct entity *));
-#ifdef D_DEBUG
-static const char *FDECL(Enam, (struct entity *)); /* unused */
-#endif
STATIC_DCL const char *FDECL(E_phrase, (struct entity *, const char *));
STATIC_DCL boolean FDECL(e_survives_at, (struct entity *, int, int));
STATIC_DCL void FDECL(e_died, (struct entity *, int, int));
(occupants[entitycnt].ex == x) &&
(occupants[entitycnt].ey == y))
break;
+ debugpline("entitycnt = %d", entitycnt);
#ifdef D_DEBUG
- pline("entitycnt = %d", entitycnt);
wait_synch();
#endif
return((entitycnt == ENTITIES)?
return(is_u(etmp)? "you" : mon_nam(etmp->emon));
}
-#ifdef D_DEBUG
-/*
- * Enam is another unused utility routine: E_phrase is preferable.
- */
-
-static const char *
-Enam(etmp)
-struct entity *etmp;
-{
- return(is_u(etmp)? "You" : Monnam(etmp->emon));
-}
-#endif /* D_DEBUG */
-
/*
* Generates capitalized entity name, makes 2nd -> 3rd person conversion on
* verb, where necessary.
{
int misses;
-#ifdef D_DEBUG
if (chunks)
- pline("Do chunks miss?");
-#endif
+ debugpline("Do chunks miss?");
if (automiss(etmp))
return(TRUE);
if (is_db_wall(etmp->ex, etmp->ey))
misses -= 3; /* less airspace */
-#ifdef D_DEBUG
- pline("Miss chance = %d (out of 8)", misses);
-#endif
+ debugpline("Miss chance = %d (out of 8)", misses);
return((boolean)((misses >= rnd(8))? TRUE : FALSE));
}
if (is_db_wall(etmp->ex, etmp->ey))
tmp -= 2; /* less room to maneuver */
-#ifdef D_DEBUG
- pline("%s to jump (%d chances in 10)", E_phrase(etmp, "try"), tmp);
-#endif
+ debugpline("%s to jump (%d chances in 10)", E_phrase(etmp, "try"), tmp);
return((boolean)((tmp >= rnd(10))? TRUE : FALSE));
}
if (at_portcullis)
pline_The("portcullis misses %s!",
e_nam(etmp));
-#ifdef D_DEBUG
else
- pline_The("drawbridge misses %s!",
+ debugpline("The drawbridge misses %s!",
e_nam(etmp));
-#endif
if (e_survives_at(etmp, oldx, oldy))
return;
else {
-#ifdef D_DEBUG
- pline("Mon can't survive here");
-#endif
+ debugpline("Mon can't survive here");
if (at_portcullis)
must_jump = TRUE;
else
if (at_portcullis) {
if (e_jumps(etmp)) {
relocates = TRUE;
-#ifdef D_DEBUG
- pline("Jump succeeds!");
-#endif
+ debugpline("Jump succeeds!");
} else {
if (e_inview)
pline("%s crushed by the falling portcullis!",
}
} else { /* tries to jump off bridge to original square */
relocates = !e_jumps(etmp);
-#ifdef D_DEBUG
- pline("Jump %s!", (relocates)? "fails" : "succeeds");
-#endif
+ debugpline("Jump %s!", (relocates)? "fails" : "succeeds");
}
}
* would be inaccessible (i.e. etmp started on drawbridge square) or
* unnecessary (i.e. etmp started here) in such a situation.
*/
-#ifdef D_DEBUG
- pline("Doing relocation.");
-#endif
+ debugpline("Doing relocation.");
newx = oldx;
newy = oldy;
(void)find_drawbridge(&newx, &newy);
if ((newx == oldx) && (newy == oldy))
get_wall_for_db(&newx, &newy);
-#ifdef D_DEBUG
- pline("Checking new square for occupancy.");
-#endif
+ debugpline("Checking new square for occupancy.");
if (relocates && (e_at(newx, newy))) {
/*
struct entity *other;
other = e_at(newx, newy);
-#ifdef D_DEBUG
- pline("New square is occupied by %s", e_nam(other));
-#endif
+ debugpline("New square is occupied by %s", e_nam(other));
if (e_survives_at(other, newx, newy) && automiss(other)) {
relocates = FALSE; /* "other" won't budge */
-#ifdef D_DEBUG
- pline("%s suicide.", E_phrase(etmp, "commit"));
-#endif
+ debugpline("%s suicide.", E_phrase(etmp, "commit"));
} else {
-#ifdef D_DEBUG
- pline("Handling %s", e_nam(other));
-#endif
+ debugpline("Handling %s", e_nam(other));
while ((e_at(newx, newy) != 0) &&
(e_at(newx, newy) != etmp))
do_entity(other);
+ debugpline("Checking existence of %s", e_nam(etmp));
#ifdef D_DEBUG
- pline("Checking existence of %s", e_nam(etmp));
wait_synch();
#endif
if (e_at(oldx, oldy) != etmp) {
-#ifdef D_DEBUG
- pline("%s moved or died in recursion somewhere",
+ debugpline("%s moved or died in recursion somewhere",
E_phrase(etmp, "have"));
+#ifdef D_DEBUG
wait_synch();
#endif
return;
}
}
if (relocates && !e_at(newx, newy)) {/* if e_at() entity = worm tail */
-#ifdef D_DEBUG
- pline("Moving %s", e_nam(etmp));
-#endif
+ debugpline("Moving %s", e_nam(etmp));
if (!is_u(etmp)) {
remove_monster(etmp->ex, etmp->ey);
place_monster(etmp->emon, newx, newy);
etmp->ey = newy;
e_inview = e_canseemon(etmp);
}
+ debugpline("Final disposition of %s", e_nam(etmp));
#ifdef D_DEBUG
- pline("Final disposition of %s", e_nam(etmp));
wait_synch();
#endif
if (is_db_wall(etmp->ex, etmp->ey)) {
+ debugpline("%s in portcullis chamber", E_phrase(etmp, "are"));
#ifdef D_DEBUG
- pline("%s in portcullis chamber", E_phrase(etmp, "are"));
wait_synch();
#endif
if (e_inview) {
e_died(etmp, 0, CRUSHING); /* no message */
return;
}
-#ifdef D_DEBUG
- pline("%s in here", E_phrase(etmp, "survive"));
-#endif
+ debugpline("%s in here", E_phrase(etmp, "survive"));
} else {
-#ifdef D_DEBUG
- pline("%s on drawbridge square", E_phrase(etmp, "are"));
-#endif
+ debugpline("%s on drawbridge square", E_phrase(etmp, "are"));
if (is_pool(etmp->ex, etmp->ey) && !e_inview)
if (!Deaf)
You_hear("a splash.");
E_phrase(etmp, "fall"));
return;
}
-#ifdef D_DEBUG
- pline("%s cannot survive on the drawbridge square",Enam(etmp));
-#endif
+ debugpline("%s cannot survive on the drawbridge square",E_phrase(etmp, NULL));
if (is_pool(etmp->ex, etmp->ey) || is_lava(etmp->ex, etmp->ey))
if (e_inview && !is_u(etmp)) {
/* drown() will supply msgs if nec. */
if (etmp1->edata) {
e_inview = e_canseemon(etmp1);
if (e_missed(etmp1, TRUE)) {
-#ifdef D_DEBUG
- pline("%s spared!", E_phrase(etmp1, "are"));
-#endif
+ debugpline("%s spared!", E_phrase(etmp1, "are"));
/* if there is water or lava here, fall in now */
if (is_u(etmp1))
spoteffects(FALSE);
} else {
if (!Deaf && !is_u(etmp1) && !is_pool(x,y))
You_hear("a crushing sound.");
-#ifdef D_DEBUG
else
- pline("%s from shrapnel",
+ debugpline("%s from shrapnel",
E_phrase(etmp1, "die"));
-#endif
}
killer.format = KILLED_BY_AN;
Strcpy(killer.name, "collapsing drawbridge");
#include "hack.h"
-/* #define DEBUG */ /* turn on for diagnostics */
-
static NEARDATA boolean did_dig_msg;
STATIC_DCL boolean NDECL(rm_waslit);
struct obj *otmp2;
boolean under_ice;
-#ifdef DEBUG
- pline("bury_an_obj: %s", xname(otmp));
-#endif
+ debugpline("bury_an_obj: %s", xname(otmp));
if (otmp == uball) {
unpunish();
u.utrap = rn1(50,20);
{
struct obj *otmp, *otmp2;
-#ifdef DEBUG
if(level.objects[x][y] != (struct obj *)0)
- pline("bury_objs: at %d, %d", x, y);
-#endif
+ debugpline("bury_objs: at %d, %d", x, y);
for (otmp = level.objects[x][y]; otmp; otmp = otmp2)
otmp2 = bury_an_obj(otmp);
struct obj *otmp, *otmp2, *bball;
coord cc;
-#ifdef DEBUG
- pline("unearth_objs: at %d, %d", x, y);
-#endif
+ debugpline("unearth_objs: at %d, %d", x, y);
cc.x = x; cc.y = y;
bball = buried_ball(&cc);
for (otmp = level.buriedobjlist; otmp; otmp = otmp2) {
bury_monst(mtmp)
struct monst *mtmp;
{
-#ifdef DEBUG
- pline("bury_monst: %s", mon_nam(mtmp));
-#endif
+ debugpline("bury_monst: %s", mon_nam(mtmp));
if(canseemon(mtmp)) {
if(is_flyer(mtmp->data) || is_floater(mtmp->data)) {
pline_The("%s opens up, but %s is not swallowed!",
void
bury_you()
{
-#ifdef DEBUG
- pline("bury_you");
-#endif
+ debugpline("bury_you");
if (!Levitation && !Flying) {
if(u.uswallow)
You_feel("a sensation like falling into a trap!");
void
unearth_you()
{
-#ifdef DEBUG
- pline("unearth_you");
-#endif
+ debugpline("unearth_you");
u.uburied = FALSE;
under_ground(0);
if(!uamul || uamul->otyp != AMULET_OF_STRANGULATION)
void
escape_tomb()
{
-#ifdef DEBUG
- pline("escape_tomb");
-#endif
+ debugpline("escape_tomb");
if ((Teleportation || can_teleport(youmonst.data)) &&
(Teleport_control || rn2(3) < Luck+2)) {
You("attempt a teleport spell.");
struct obj *otmp;
{
-#ifdef DEBUG
- pline("bury_obj");
-#endif
+ debugpline("bury_obj");
if(cansee(otmp->ox, otmp->oy))
pline_The("objects on the %s tumble into a hole!",
surface(otmp->ox, otmp->oy));
#ifdef DEBUG
int
-wiz_debug_cmd() /* in this case, bury everything at your loc and around */
+wiz_debug_cmd_bury() /* in this case, bury everything at your loc and around */
{
int x, y;
s_level *x;
branch *br;
+ if (!showdebug()) return;
+
for(i = 0; i < n_dgns; i++) {
fprintf(stderr, "\n#%d \"%s\" (%s):\n", i,
DD.dname, DD.proto);
#include "hack.h"
-/* #define DEBUG */ /* uncomment to enable new eat code debugging */
-
-#ifdef DEBUG
-#define debugpline if (wizard) pline
-#endif
-
STATIC_PTR int NDECL(eatmdone);
STATIC_PTR int NDECL(eatfood);
STATIC_PTR void FDECL(costly_tin, (int));
{
struct obj *piece = context.victual.piece;
-#ifdef DEBUG
debugpline("Old weight = %d", piece->owt);
debugpline("Used time = %d, Req'd time = %d",
context.victual.usedtime, context.victual.reqtime);
-#endif
piece->owt = weight(piece);
-#ifdef DEBUG
debugpline("New weight = %d", piece->owt);
-#endif
}
void
* the round is spent eating.
*/
if(context.victual.eating && !context.victual.doreset) {
-#ifdef DEBUG
debugpline("reset_eat...");
-#endif
context.victual.doreset = TRUE;
}
return;
(void) splitobj(otmp, otmp->quan - 1L);
else
otmp = splitobj(otmp, 1L);
-#ifdef DEBUG
debugpline("split object,");
-#endif
}
if (!otmp->oeaten) {
STATIC_OVL void
do_reset_eat()
{
-#ifdef DEBUG
debugpline("do_reset_eat...");
-#endif
if (context.victual.piece) {
context.victual.o_id = 0;
context.victual.piece = touchfood(context.victual.piece);
switch (type) {
case FIRE_RES:
res = (ptr->mconveys & MR_FIRE) != 0;
-#ifdef DEBUG
if (res) debugpline("can get fire resistance");
-#endif
break;
case SLEEP_RES:
res = (ptr->mconveys & MR_SLEEP) != 0;
-#ifdef DEBUG
if (res) debugpline("can get sleep resistance");
-#endif
break;
case COLD_RES:
res = (ptr->mconveys & MR_COLD) != 0;
-#ifdef DEBUG
if (res) debugpline("can get cold resistance");
-#endif
break;
case DISINT_RES:
res = (ptr->mconveys & MR_DISINT) != 0;
-#ifdef DEBUG
if (res) debugpline("can get disintegration resistance");
-#endif
break;
case SHOCK_RES: /* shock (electricity) resistance */
res = (ptr->mconveys & MR_ELEC) != 0;
-#ifdef DEBUG
if (res) debugpline("can get shock resistance");
-#endif
break;
case POISON_RES:
res = (ptr->mconveys & MR_POISON) != 0;
-#ifdef DEBUG
if (res) debugpline("can get poison resistance");
-#endif
break;
case TELEPORT:
res = can_teleport(ptr);
-#ifdef DEBUG
if (res) debugpline("can get teleport");
-#endif
break;
case TELEPORT_CONTROL:
res = control_teleport(ptr);
-#ifdef DEBUG
if (res) debugpline("can get teleport control");
-#endif
break;
case TELEPAT:
res = telepathic(ptr);
-#ifdef DEBUG
if (res) debugpline("can get telepathy");
-#endif
break;
default:
/* res stays 0 */
{
register int chance;
-#ifdef DEBUG
debugpline("Attempting to give intrinsic %d", type);
-#endif
/* some intrinsics are easier to get than others */
switch (type) {
case POISON_RES:
switch (type) {
case FIRE_RES:
-#ifdef DEBUG
debugpline("Trying to give fire resistance");
-#endif
if(!(HFire_resistance & FROMOUTSIDE)) {
You(Hallucination ? "be chillin'." :
"feel a momentary chill.");
}
break;
case SLEEP_RES:
-#ifdef DEBUG
debugpline("Trying to give sleep resistance");
-#endif
if(!(HSleep_resistance & FROMOUTSIDE)) {
You_feel("wide awake.");
HSleep_resistance |= FROMOUTSIDE;
}
break;
case COLD_RES:
-#ifdef DEBUG
debugpline("Trying to give cold resistance");
-#endif
if(!(HCold_resistance & FROMOUTSIDE)) {
You_feel("full of hot air.");
HCold_resistance |= FROMOUTSIDE;
}
break;
case DISINT_RES:
-#ifdef DEBUG
debugpline("Trying to give disintegration resistance");
-#endif
if(!(HDisint_resistance & FROMOUTSIDE)) {
You_feel(Hallucination ?
"totally together, man." :
}
break;
case SHOCK_RES: /* shock (electricity) resistance */
-#ifdef DEBUG
debugpline("Trying to give shock resistance");
-#endif
if(!(HShock_resistance & FROMOUTSIDE)) {
if (Hallucination)
You_feel("grounded in reality.");
}
break;
case POISON_RES:
-#ifdef DEBUG
debugpline("Trying to give poison resistance");
-#endif
if(!(HPoison_resistance & FROMOUTSIDE)) {
You_feel(Poison_resistance ?
"especially healthy." : "healthy.");
}
break;
case TELEPORT:
-#ifdef DEBUG
debugpline("Trying to give teleport");
-#endif
if(!(HTeleportation & FROMOUTSIDE)) {
You_feel(Hallucination ? "diffuse." :
"very jumpy.");
}
break;
case TELEPORT_CONTROL:
-#ifdef DEBUG
debugpline("Trying to give teleport control");
-#endif
if(!(HTeleport_control & FROMOUTSIDE)) {
You_feel(Hallucination ?
"centered in your personal space." :
}
break;
case TELEPAT:
-#ifdef DEBUG
debugpline("Trying to give telepathy");
-#endif
if(!(HTelepat & FROMOUTSIDE)) {
You_feel(Hallucination ?
"in touch with the cosmos." :
}
break;
default:
-#ifdef DEBUG
debugpline("Tried to give an impossible intrinsic");
-#endif
break;
}
}
case PM_DISENCHANTER:
/* picks an intrinsic at random and removes it; there's
no feedback if hero already lacks the chosen ability */
-#ifdef DEBUG
debugpline("using attrcurse to strip an intrinsic");
-#endif
attrcurse();
break;
case PM_MIND_FLAYER:
if (conveys_STR) {
count = 1;
tmp = -1; /* use -1 as fake prop index for STR */
-#ifdef DEBUG
debugpline("\"Intrinsic\" strength, %d", tmp);
-#endif
}
for (i = 1; i <= LAST_PROP; i++) {
if (!intrinsic_possible(i, ptr)) continue;
of keeping the old choice (note that 1 in 1 and
0 in 1 are what we want for the first candidate) */
if (!rn2(count)) {
-#ifdef DEBUG
debugpline("Intrinsic %d replacing %d", i, tmp);
-#endif
tmp = i;
}
}
{
const char *old_nomovemsg, *save_nomovemsg;
-#ifdef DEBUG
debugpline("start_eating: %lx (victual = %lx)", otmp, context.victual.piece);
debugpline("reqtime = %d", context.victual.reqtime);
debugpline("(original reqtime = %d)", objects[otmp->otyp].oc_delay);
debugpline("nmod = %d", context.victual.nmod);
debugpline("oeaten = %d", otmp->oeaten);
-#endif
context.victual.fullwarn = context.victual.doreset = FALSE;
context.victual.eating = TRUE;
if (otmp->otyp == CORPSE) basenutrit = mons[otmp->corpsenm].cnutrit;
else basenutrit = objects[otmp->otyp].oc_nutrition;
-#ifdef DEBUG
debugpline("before rounddiv: context.victual.reqtime == %d", context.victual.reqtime);
debugpline("oeaten == %d, basenutrit == %d", otmp->oeaten, basenutrit);
-#endif
context.victual.reqtime = (basenutrit == 0 ? 0 :
rounddiv(context.victual.reqtime * (long)otmp->oeaten, basenutrit));
-#ifdef DEBUG
debugpline("after rounddiv: context.victual.reqtime == %d", context.victual.reqtime);
-#endif
/* calculate the modulo value (nutrit. units per round eating)
* note: this isn't exact - you actually lose a little nutrition
* due to this method.
{
/* See comments in newuhs() for discussion on force_save_hs */
boolean iseating = (occupation == eatfood) || force_save_hs;
-#ifdef DEBUG
debugpline("lesshungry(%d)", num);
-#endif
u.uhunger += num;
if(u.uhunger >= 2000) {
if (!iseating || context.victual.canchoke) {
} else if (src == SET_IN_SYS && match_varname(buf, "SHELLERS", 8)) {
if (sysopt.shellers) free(sysopt.shellers);
sysopt.shellers = dupstr(bufp);
+ } else if (src == SET_IN_SYS && match_varname(buf, "DEBUGFILES", 5)) {
+ if (sysopt.debugfiles) free(sysopt.debugfiles);
+ sysopt.debugfiles = dupstr(bufp);
} else if (src == SET_IN_SYS && match_varname(buf, "SUPPORT", 7)) {
if (sysopt.support) free(sysopt.support);
sysopt.support = dupstr(bufp);
static boolean trav_debug = FALSE;
int
-wiz_debug_cmd() /* in this case, toggle display of travel debug info */
+wiz_debug_cmd_traveldisplay() /* in this case, toggle display of travel debug info */
{
trav_debug = !trav_debug;
return 0;
otmp = ls->id.a_obj;
ls->id = zeroany;
ls->id.a_uint = otmp->o_id;
-#ifdef DEBUG
- if (find_oid((unsigned)ls->id) != otmp)
- panic("write_ls: can't find obj #%u!", ls->id.a_uint);
-#endif
+ if (find_oid((unsigned)ls->id.a_uint) != otmp)
+ debugpline("write_ls: can't find obj #%u!", ls->id.a_uint);
} else { /* ls->type == LS_MONSTER */
mtmp = (struct monst *)ls->id.a_monst;
ls->id = zeroany;
ls->id.a_uint = mtmp->m_id;
-#ifdef DEBUG
- if (find_mid((unsigned)ls->id, FM_EVERYWHERE) != mtmp)
- panic("write_ls: can't find mon #%u!", ls->x_id);
-#endif
+ if (find_mid((unsigned)ls->id.a_uint, FM_EVERYWHERE) != mtmp)
+ debugpline("write_ls: can't find mon #%u!", ls->id.a_uint);
}
ls->flags |= LSF_NEEDS_FIXUP;
bwrite(fd, (genericptr_t)ls, sizeof(light_source));
int cnttmp,cntdiv;
cnttmp = cnt;
-# ifdef DEBUG
- pline("init group call x=%d,y=%d,n=%d,cnt=%d.", x, y, n, cnt);
-# endif
+ debugpline("init group call x=%d,y=%d,n=%d,cnt=%d.", x, y, n, cnt);
cntdiv = ((u.ulevel < 3) ? 4 : (u.ulevel < 5) ? 2 : 1);
#endif
/* Tuning: cut down on swarming at low character levels [mrs] */
mvitals[mndx].born++;
if ((int) mvitals[mndx].born >= lim && !(mons[mndx].geno & G_NOGEN) &&
!(mvitals[mndx].mvflags & G_EXTINCT)) {
-#ifdef DEBUG
- if (wizard) pline("Automatically extinguished %s.",
+ if (wizard) debugpline("Automatically extinguished %s.",
makeplural(mons[mndx].mname));
-#endif
mvitals[mndx].mvflags |= G_EXTINCT;
reset_rndmonst(mndx);
}
/* if you are to make a specific monster and it has
already been genocided, return */
if (mvitals[mndx].mvflags & G_GENOD) return((struct monst *) 0);
-#ifdef DEBUG
if (wizard && (mvitals[mndx].mvflags & G_EXTINCT))
- pline("Explicitly creating extinct monster %s.",
+ debugpline("Explicitly creating extinct monster %s.",
mons[mndx].mname);
-#endif
} else {
/* make a random (common) monster that can survive here.
* (the special levels ask for random monsters at specific
do {
if(!(ptr = rndmonst())) {
-#ifdef DEBUG
- pline("Warning: no monster.");
-#endif
+ debugpline("Warning: no monster.");
return((struct monst *) 0); /* no more monsters! */
}
fakemon.data = ptr; /* set up for goodpos */
}
if (mndx == SPECIAL_PM) {
/* evidently they've all been exterminated */
-#ifdef DEBUG
- pline("rndmonst: no common mons!");
-#endif
+ debugpline("rndmonst: no common mons!");
return (struct permonst *)0;
} /* else `mndx' now ready for use below */
zlevel = level_difficulty();
if (rndmonst_state.choice_count <= 0) {
/* maybe no common mons left, or all are too weak or too strong */
-#ifdef DEBUG
- Norep("rndmonst: choice_count=%d", rndmonst_state.choice_count);
-#endif
+ debugpline("rndmonst: choice_count=%d", rndmonst_state.choice_count);
return (struct permonst *)0;
}
/* NetHack may be freely redistributed. See license for details. */
#include "hack.h"
-/* #define DEBUG */ /* uncomment to enable code debugging */
-
-#ifdef DEBUG
-#define debugpline if (wizard) pline
-#endif
/* for UNIX, Rand #def'd to (long)lrand48() or (long)random() */
/* croom->lx etc are schar (width <= int), so % arith ensures that */
/* make a secret treasure vault, not connected to the rest */
if(do_vault()) {
xchar w,h;
-#ifdef DEBUG
debugpline("trying to make a vault...");
-#endif
w = 1;
h = 1;
if (check_room(&vault_x, &w, &vault_y, &h, TRUE)) {
*source = u.uz;
insert_branch(br, TRUE);
-#ifdef DEBUG
- pline("Made knox portal.");
-#endif
+ debugpline("Made knox portal.");
place_branch(br, x, y);
}
int x_range = x_maze_max - x_maze_min - 2*INVPOS_X_MARGIN - 1,
y_range = y_maze_max - y_maze_min - 2*INVPOS_Y_MARGIN - 1;
-#ifdef DEBUG
if (x_range <= INVPOS_X_MARGIN || y_range <= INVPOS_Y_MARGIN ||
(x_range * y_range) <= (INVPOS_DISTANCE * INVPOS_DISTANCE))
- panic("inv_pos: maze is too small! (%d x %d)",
+ debugpline("inv_pos: maze is too small! (%d x %d)",
x_maze_max, y_maze_max);
-#endif
inv_pos.x = inv_pos.y = 0; /*{occupied() => invocation_pos()}*/
do {
x = rn1(x_range, x_maze_min + INVPOS_X_MARGIN + 1);
impossible("portal on top of portal??");
return;
}
-#ifdef DEBUG
- pline("mkportal: at (%d,%d), to %s, level %d",
+ debugpline("mkportal: at (%d,%d), to %s, level %d",
x, y, dungeons[todnum].dname, todlevel);
-#endif
ttmp->dst.dnum = todnum;
ttmp->dst.dlevel = todlevel;
return;
(struct obj *,const char *,const char *,struct monst *));
STATIC_DCL void FDECL(check_contained, (struct obj *,const char *));
-/*#define DEBUG_EFFECTS*/ /* show some messages for debugging */
-
struct icp {
int iprob; /* probability of an item type */
char iclass; /* item class */
/* Adjust the age; must be same as obj_timer_checks() for off ice*/
age = monstermoves - otmp->age;
retval += age * (ROT_ICE_ADJUSTMENT-1) / ROT_ICE_ADJUSTMENT;
-#ifdef DEBUG_EFFECTS
- pline_The("%s age has ice modifications:otmp->age = %ld, returning %ld.",
+ debugpline("The %s age has ice modifications:otmp->age = %ld, returning %ld.",
s_suffix(doname(otmp)),otmp->age, retval);
- pline("Effective age of corpse: %ld.",
+ debugpline("Effective age of corpse: %ld.",
monstermoves - retval);
-#endif
}
return retval;
}
/* mark the corpse as being on ice */
otmp->on_ice = 1;
-#ifdef DEBUG_EFFECTS
- pline("%s is now on ice at %d,%d.", The(xname(otmp)),x,y);
-#endif
+ debugpline("%s is now on ice at %d,%d.", The(xname(otmp)),x,y);
/* Adjust the time remaining */
tleft *= ROT_ICE_ADJUSTMENT;
restart_timer = TRUE;
long age;
otmp->on_ice = 0;
-#ifdef DEBUG_EFFECTS
- pline("%s is no longer on ice at %d,%d.", The(xname(otmp)),x,y);
-#endif
+ debugpline("%s is no longer on ice at %d,%d.", The(xname(otmp)),x,y);
/* Adjust the remaining time */
tleft /= ROT_ICE_ADJUSTMENT;
restart_timer = TRUE;
/* transfer the monster's inventory */
for (otmp = mtmp2->minvent; otmp; otmp = otmp->nobj) {
-#ifdef DEBUG
if (otmp->where != OBJ_MINVENT || otmp->ocarry != mtmp)
- panic("replmon: minvent inconsistency");
-#endif
+ debugpline("replmon: minvent inconsistency");
otmp->ocarry = mtmp2;
}
mtmp->minvent = 0;
(*pick_list)->item.a_int = curr->oclass;
return 1;
} else {
-#ifdef DEBUG
- impossible("query_category: no single object match");
-#endif
+ debugpline("query_category: no single object match");
}
return 0;
}
#define QTEXT_FILE "quest.dat"
-/* #define DEBUG */ /* uncomment for debugging */
-
/* from sp_lev.c, for deliver_splev_message() */
extern char *lev_message;
struct qtmsg *msg;
long size;
+ if (!showdebug()) return;
+
for (msg = qt_list.chrole; msg->msgnum > 0; msg++) {
pline("msgnum %d: delivery %c",
msg->msgnum, msg->delivery);
deliver_by_window(msg, NHW_TEXT);
}
}
-#endif /* DEBUG */
+#else
+static void
+dump_qtlist() { }
+#endif /* !DEBUG */
static void
Fread(ptr, size, nitems, stream)
if (!qt_list.common || !qt_list.chrole)
impossible("load_qtlist: cannot load quest text.");
-#ifdef DEBUG
dump_qtlist();
-#endif
return; /* no ***DON'T*** close the msg_file */
}
++msgcount;
}
if (msgcount) putmsghistory((char *)0, TRUE);
-#ifdef DEBUG_MSGCOUNT
- pline("Read %d messages from savefile.", msgcount);
-#endif
+ debugpline("Read %d messages from savefile.", msgcount);
}
/* Clear all structures for object and monster ID mapping. */
#include "hack.h"
-#if defined(BETA) && !defined(DEBUG) && !defined(NODEBUG)
-#define DEBUG
-#endif
-
/* "Rand()"s definition is determined by [OS]conf.h */
#if defined(LINT) && defined(UNIX) /* rand() is long... */
extern int NDECL(rand);
rn2(x) /* 0 <= rn2(x) < x */
register int x;
{
-#ifdef DEBUG
+#ifdef BETA
if (x <= 0) {
- impossible("rn2(%d) attempted", x);
+ debugpline("rn2(%d) attempted", x);
return(0);
}
x = RND(x);
{
register int i, adjustment;
-#ifdef DEBUG
+#ifdef BETA
if (x <= 0) {
- impossible("rnl(%d) attempted", x);
+ debugpline("rnl(%d) attempted", x);
return(0);
}
#endif
rnd(x) /* 1 <= rnd(x) <= x */
register int x;
{
-#ifdef DEBUG
+#ifdef BETA
if (x <= 0) {
- impossible("rnd(%d) attempted", x);
+ debugpline("rnd(%d) attempted", x);
return(1);
}
x = RND(x)+1;
{
register int tmp = n;
-#ifdef DEBUG
+#ifdef BETA
if (x < 0 || n < 0 || (x == 0 && n != 0)) {
- impossible("d(%d,%d) attempted", n, x);
+ debugpline("d(%d,%d) attempted", n, x);
return(1);
}
#endif
}
bwrite(fd, (genericptr_t) &minusone, sizeof(int));
}
-#ifdef DEBUG_MSGCOUNT
- pline("Stored %d messages into savefile.", msgcount);
-#endif
+ debugpline("Stored %d messages into savefile.", msgcount);
/* note: we don't attempt to handle release_data() here */
}
#include "hack.h"
-/*#define DEBUG*/
-
#define PAY_SOME 2
#define PAY_BUY 1
#define PAY_CANT 0 /* too poor */
}
if(!shkp) {
-#ifdef DEBUG
- pline("dopay: null shkp.");
-#endif
+ debugpline("dopay: null shkp.");
return(0);
}
proceed:
#include "hack.h"
#include "dlb.h"
-/* #define DEBUG */ /* uncomment to enable code debugging */
-
-#ifdef DEBUG
-#define debugpline if (wizard) pline
-#endif
#include "sp_lev.h"
lev = &levl[x][y];
for (; y <= ymax; y++) {
if (lev++->typ) {
-#ifdef DEBUG
if(!vault)
debugpline("strange area [%d,%d] in check_room.",x,y);
-#endif
if (!rn2(3)) return FALSE;
if (x < *lowx)
*lowx = x + xlim + 1;
r1 = rnd_rect(); /* Get a random rectangle */
if (!r1) { /* No more free rectangles ! */
-#ifdef DEBUG
debugpline("No more rects...");
-#endif
return FALSE;
}
hx = r1->hx;
if (xx <= 0 || yy <= 0 || tx <= 0 || ty <= 0 ||
xx > COLNO-1 || tx > COLNO-1 ||
yy > ROWNO-1 || ty > ROWNO-1) {
-#ifdef DEBUG
debugpline("dig_corridor: bad coords : (%d,%d) (%d,%d).",
xx,yy,tx,ty);
-#endif
return FALSE;
}
if (tx > xx) dx = 1;
register struct obj *otmp;
{
int freed_otmp;
+ boolean snuff_otmp = FALSE;
/* if monster is acquiring a thrown or kicked object, the throwing
or kicking code shouldn't continue to track and place it */
if (otmp == thrownobj) thrownobj = 0;
else if (otmp == kickedobj) kickedobj = 0;
- boolean snuff_otmp = FALSE;
/* don't want hidden light source inside the monster; assumes that
engulfers won't have external inventories; whirly monsters cause
the light to be extinguished rather than letting it shine thru */
#else
sysopt.wizards = WIZARD_NAME;
#endif
+ sysopt.debugfiles = NULL;
sysopt.shellers = NULL;
sysopt.maxplayers = 0; /* XXX eventually replace MAX_NR_OF_PLAYERS */
struct monst fakemon; /* dummy monster */
if (!mdat) {
-#ifdef DEBUG
- pline("enexto() called with mdat==0");
-#endif
+ debugpline("enexto() called with mdat==0");
/* default to player's original monster type */
mdat = &mons[u.umonster];
}
if (context.bypasses)
return 0;
else {
-#ifdef DEBUG
- pline("%s for a moment.", Tobjnam(obj, "pulsate"));
-#endif
+ debugpline("%s for a moment.", Tobjnam(obj, "pulsate"));
obj->bypass = 0;
}
}
resist(mon, type < ZT_SPELL(0) ? WAND_CLASS : '\0', 0, NOTELL))
tmp /= 2;
if (tmp < 0) tmp = 0; /* don't allow negative damage */
-#ifdef WIZ_PATCH_DEBUG
- pline("zapped monster hp = %d (= %d - %d)", mon->mhp-tmp,mon->mhp,tmp);
-#endif
+ debugpline("zapped monster hp = %d (= %d - %d)", mon->mhp-tmp,mon->mhp,tmp);
mon->mhp -= tmp;
return(tmp);
}
# Uses the same syntax as the WIZARDS option above.
#SHELLERS=
+# Show debugging information originating from these source files.
+# Use '*' for all, or list source files separated by spaces.
+# Only available if game has been compiled with DEBUG.
+#DEBUGFILES=*
+
# Limit the number of simultaneous games (see also nethack.sh).
MAXPLAYERS=10
case NHW_TEXT: s = "[text window]"; break;
case NHW_BASE: s = "[base window]"; break;
}
- impossible("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
+ debugpline("bad curs positioning win %d %s (%d,%d)", window, s, x, y);
return;
}
#endif