]> granicus.if.org Git - nethack/commitdiff
Apply paxed's DEBUG patch to remove DEBUG/D_DEBUG.
authorPasi Kallinen <paxed@alt.org>
Mon, 9 Feb 2015 18:56:44 +0000 (20:56 +0200)
committerSean Hunt <scshunt@csclub.uwaterloo.ca>
Sat, 28 Feb 2015 00:33:45 +0000 (19:33 -0500)
    Move debugging output into couple preprocessor defines, which
    are no-op without DEBUG.  To show debugging output from a
    certain source files, use sysconf:

    DEBUGFILES=dungeon.c questpgr.c

    Also fix couple debug lines which did not compile.

This also includes fixes due to Derek Ray to depugpline to work better
on other platforms.

32 files changed:
include/global.h
include/hack.h
include/sys.h
src/apply.c
src/attrib.c
src/bones.c
src/cmd.c
src/dbridge.c
src/dig.c
src/dungeon.c
src/eat.c
src/files.c
src/hack.c
src/light.c
src/makemon.c
src/mklev.c
src/mkmaze.c
src/mkobj.c
src/mon.c
src/pickup.c
src/questpgr.c
src/restore.c
src/rnd.c
src/save.c
src/shk.c
src/sp_lev.c
src/steal.c
src/sys.c
src/teleport.c
src/zap.c
sys/unix/sysconf
win/tty/wintty.c

index 7e8acda381dfd88cace81af391f78cd2d60a4c73..985066520e96a41e89f2ac2306fc3e5b2715551b 100644 (file)
@@ -11,6 +11,8 @@
 
 #define BETA           /* development or beta testing [MRS] */
 
+#define DEBUG
+
 /*
  * Files expected to exist in the playground directory.
  */
index c88d8dd5639f4c7bb93197a0497c2418e3d02406..0ace170e5718dbfaf6b150c2c891d294e2690556 100644 (file)
 #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
index 227e68781baeee4b30020743eeada3a77f0b71e2..ac39239eecdbeee3c69564555c464451ca4c5e23 100644 (file)
@@ -15,6 +15,7 @@ struct sysopt {
        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;
index e92e6199f727be4e99cae8753649935c83cb2456..d2377b51e7f9e8e65335a88dd7b58e6530c19f44 100644 (file)
@@ -1773,9 +1773,7 @@ long timeout;
        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 */
index b2d5738b8cc4ba842c3b06bfdb6332c7ee5d7184..8bba3d61c1a8665e5a0cb0bc69b036964407e0e7 100644 (file)
@@ -8,8 +8,6 @@
 #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[] = {
@@ -349,9 +347,7 @@ exercise(i, inc_or_dec)
 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 */
@@ -368,12 +364,10 @@ boolean   inc_or_dec;
                 *      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();
 }
@@ -398,9 +392,7 @@ exerper()
                         (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))
@@ -416,9 +408,7 @@ exerper()
                }
 
                /* 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);
@@ -431,9 +421,7 @@ exerper()
 
        /* 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);
@@ -464,15 +452,11 @@ exerchk()
        /*      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):
             *
@@ -499,13 +483,11 @@ exerchk()
                   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):
                 *
@@ -515,13 +497,9 @@ exerchk()
                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 */
@@ -535,9 +513,7 @@ exerchk()
                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);
        }
 }
 
index 66a4d43f5a313ca648d12ec7955dfff6ab2b77cb..926b9079e5e948c362225043466ae5bb4579b1bf 100644 (file)
@@ -581,11 +581,9 @@ getbones()
                        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 */
index f07abb78c54f8f8239c3732802288f0d0b434379..1477eabdca70f9165dcb72b7e113717f7b526565 100644 (file)
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -5,7 +5,6 @@
 
 #include "hack.h"
 #include "func_tab.h"
-/* #define DEBUG */    /* uncomment for debugging */
 
 #ifdef ALTMETA
 STATIC_VAR boolean alt_esc = FALSE;
@@ -30,12 +29,8 @@ extern const char *enc_stat[];       /* encumbrance status from botl.c */
 #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 */
@@ -389,11 +384,11 @@ extcmd_via_menu() /* here after # - now show pick-list of possible commands */
                    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;
                }
@@ -454,7 +449,7 @@ extcmd_via_menu() /* here after # - now show pick-list of possible commands */
        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
@@ -2507,7 +2502,8 @@ struct ext_func_tab extcmdlist[] = {
        {(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 */
@@ -2534,7 +2530,8 @@ static const struct ext_func_tab debug_extcmdlist[] = {
        {"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},
index b63d2714ccb2f8d6b4e1e9a5238096afc74c3032..316b2707fd7837cb8311bb8c405a26c21e78b3ec 100644 (file)
@@ -26,9 +26,6 @@ STATIC_DCL void FDECL(m_to_e, (struct monst *, int, int, struct entity *));
 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));
@@ -253,8 +250,8 @@ int x, y;
                    (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)?
@@ -319,19 +316,6 @@ struct entity *etmp;
        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.
@@ -465,10 +449,8 @@ boolean chunks;
 {
        int misses;
 
-#ifdef D_DEBUG
        if (chunks)
-               pline("Do chunks miss?");
-#endif
+               debugpline("Do chunks miss?");
        if (automiss(etmp))
                return(TRUE);
 
@@ -488,9 +470,7 @@ boolean chunks;
        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));
 }
@@ -519,9 +499,7 @@ struct entity *etmp;
        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));
 }
 
@@ -554,17 +532,13 @@ struct entity *etmp;
                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
@@ -583,9 +557,7 @@ struct entity *etmp;
            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!",
@@ -598,9 +570,7 @@ struct entity *etmp;
                }
            } 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");
            }
        }
 
@@ -610,17 +580,13 @@ struct entity *etmp;
  * 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))) {
 
 /*
@@ -631,30 +597,24 @@ struct entity *etmp;
                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;
@@ -662,9 +622,7 @@ struct entity *etmp;
                }
        }
        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);
@@ -677,13 +635,13 @@ struct entity *etmp;
                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) {
@@ -703,13 +661,9 @@ struct entity *etmp;
                        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.");
@@ -720,9 +674,7 @@ struct entity *etmp;
                                      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. */
@@ -938,9 +890,7 @@ int x,y;
        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);
@@ -957,11 +907,9 @@ int x,y;
                        } 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");
index dee64940c4d72e32163b5f851c57c558a823cb47..00a60aabaaea05c823391b31e6ad8abf1affe20f 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -5,8 +5,6 @@
 
 #include "hack.h"
 
-/* #define DEBUG */    /* turn on for diagnostics */
-
 static NEARDATA boolean did_dig_msg;
 
 STATIC_DCL boolean NDECL(rm_waslit);
@@ -1692,9 +1690,7 @@ bury_an_obj(otmp)
        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);
@@ -1756,10 +1752,8 @@ int x, y;
 {
        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);
 
@@ -1776,9 +1770,7 @@ int x, y;
        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) {
@@ -1887,9 +1879,7 @@ void
 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!",
@@ -1908,9 +1898,7 @@ struct monst *mtmp;
 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!");
@@ -1927,9 +1915,7 @@ bury_you()
 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)
@@ -1940,9 +1926,7 @@ unearth_you()
 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.");
@@ -1974,9 +1958,7 @@ bury_obj(otmp)
 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));
@@ -1987,7 +1969,7 @@ struct obj *otmp;
 
 #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;
 
index ed6b726de2d966a2117b82720619059655770875..4c8e6beebf82f7ab2008a122ad2a6fdec222ad4e 100644 (file)
@@ -81,6 +81,8 @@ dumpit()
        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);
index 7259e6424b5db216816f7c65b0abed1bac114eeb..67e4b88b92bc7a6d944e7b08b92e54044457422f 100644 (file)
--- a/src/eat.c
+++ b/src/eat.c
@@ -5,12 +5,6 @@
 
 #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));
@@ -290,15 +284,11 @@ recalc_wt()
 {
        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
@@ -308,9 +298,7 @@ reset_eat()         /* called when eating interrupted by an event */
      * the round is spent eating.
      */
        if(context.victual.eating && !context.victual.doreset) {
-#ifdef DEBUG
            debugpline("reset_eat...");
-#endif
            context.victual.doreset = TRUE;
        }
        return;
@@ -325,9 +313,7 @@ register struct obj *otmp;
                (void) splitobj(otmp, otmp->quan - 1L);
            else
                otmp = splitobj(otmp, 1L);
-#ifdef DEBUG
            debugpline("split object,");
-#endif
        }
 
        if (!otmp->oeaten) {
@@ -388,9 +374,7 @@ struct obj *old_obj, *new_obj;
 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);
@@ -731,57 +715,39 @@ register struct permonst *ptr;
        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 */
@@ -800,9 +766,7 @@ register struct permonst *ptr;
 {
        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:
@@ -831,9 +795,7 @@ register struct permonst *ptr;
 
        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.");
@@ -841,27 +803,21 @@ register struct permonst *ptr;
                }
                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." :
@@ -870,9 +826,7 @@ register struct permonst *ptr;
                }
                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.");
@@ -882,9 +836,7 @@ register struct permonst *ptr;
                }
                break;
            case POISON_RES:
-#ifdef DEBUG
                debugpline("Trying to give poison resistance");
-#endif
                if(!(HPoison_resistance & FROMOUTSIDE)) {
                        You_feel(Poison_resistance ?
                                 "especially healthy." : "healthy.");
@@ -892,9 +844,7 @@ register struct permonst *ptr;
                }
                break;
            case TELEPORT:
-#ifdef DEBUG
                debugpline("Trying to give teleport");
-#endif
                if(!(HTeleportation & FROMOUTSIDE)) {
                        You_feel(Hallucination ? "diffuse." :
                            "very jumpy.");
@@ -902,9 +852,7 @@ register struct permonst *ptr;
                }
                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." :
@@ -913,9 +861,7 @@ register struct permonst *ptr;
                }
                break;
            case TELEPAT:
-#ifdef DEBUG
                debugpline("Trying to give telepathy");
-#endif
                if(!(HTelepat & FROMOUTSIDE)) {
                        You_feel(Hallucination ?
                            "in touch with the cosmos." :
@@ -926,9 +872,7 @@ register struct permonst *ptr;
                }
                break;
            default:
-#ifdef DEBUG
                debugpline("Tried to give an impossible intrinsic");
-#endif
                break;
        }
 }
@@ -1059,9 +1003,7 @@ register int pm;
            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:
@@ -1101,9 +1043,7 @@ register int pm;
                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;
@@ -1113,9 +1053,7 @@ register int pm;
                       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;
                    }
                }
@@ -1659,13 +1597,11 @@ start_eating(otmp)              /* called as you start to eat */
 {
        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;
 
@@ -2505,15 +2441,11 @@ doeat()         /* generic "eat" command funtion (see cmd.c) */
        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.
@@ -2615,9 +2547,7 @@ register int num;
 {
        /* 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) {
index 03b4d5ea369f5e550489fc41d700774434064eef..f45db8bceb26ee8c2eed319c30ed5a5a751e07e2 100644 (file)
@@ -2107,6 +2107,9 @@ int               src;
        } 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);
index fafff35b6896b367918548b795e1e04e8dc5eb66..1edfb9f4e5d95f700a118df3ad08cee8f9bcac07 100644 (file)
@@ -767,7 +767,7 @@ int mode;
 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;
index 244126021b67032b43eef533380c6bfb5380b0f7..f7d43eeeeb04bc836fd218bedcf20c7591635a96 100644 (file)
@@ -393,18 +393,14 @@ write_ls(fd, ls)
                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));
index 9b63c72ec904aaa93da56a9e668f53717b84746e..afaa0140af9989c61a0a63d33b7512f2fd0f9c57 100644 (file)
@@ -93,9 +93,7 @@ register int x, y, n;
        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] */
@@ -760,10 +758,8 @@ boolean ghostly;
                 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);
        }
@@ -906,11 +902,9 @@ register int       mmflags;
                /* 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
@@ -922,9 +916,7 @@ register int        mmflags;
 
                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 */
@@ -1260,9 +1252,7 @@ rndmonst()
            }           
            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();
@@ -1300,9 +1290,7 @@ rndmonst()
 
        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;
        }
 
index 43bccaf405b205b5c2178376cf3ad617bf98ad4c..2d489998454782e5b3dfa143a702c763a031c092 100644 (file)
@@ -4,11 +4,6 @@
 /* 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 */
@@ -689,9 +684,7 @@ makelevel()
        /* 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)) {
@@ -1567,9 +1560,7 @@ xchar x, y;
        *source = u.uz;
        insert_branch(br, TRUE);
 
-#ifdef DEBUG
-       pline("Made knox portal.");
-#endif
+       debugpline("Made knox portal.");
        place_branch(br, x, y);
 }
 
index 7f45368694466dd95223bf7dc8d1da44a489987b..0cfdbe35ab200189ff0d09040074f5e13f32efeb 100644 (file)
@@ -587,12 +587,10 @@ register const char *s;
            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);
@@ -879,10 +877,8 @@ register xchar x, y, todnum, todlevel;
                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;
index 47b6668e79624735ec8d5f88f8817240d8bda1be..08bb41bfb97e25b3aec53109d7625d24b3713f49 100644 (file)
@@ -17,8 +17,6 @@ STATIC_DCL void FDECL(insane_object,
                      (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 */
@@ -1526,12 +1524,10 @@ struct obj *otmp;
        /* 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;
 }
@@ -1560,9 +1556,7 @@ int force;        /* 0 = no force so do checks, <0 = force off, >0 force on */
            
            /* 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;
@@ -1588,9 +1582,7 @@ int force;        /* 0 = no force so do checks, <0 = force off, >0 force on */
                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;
index 0de59cf8a17df8838d923d0ca96ee7efe3750444..d3841462ed9751a71a91b34e46ff193eac96d64a 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1278,10 +1278,8 @@ register struct monst *mtmp, *mtmp2;
 
     /* 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;
index 30188e5f2b098c022e520cf13ec989df174cc6d0..ee0d91dc7c83d34509576d5b41f143a23db5df40 100644 (file)
@@ -903,9 +903,7 @@ int how;                    /* type of query */
                (*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;
        }
index 9f717754fc1d1ebb8098a9323ca3e3595ce3fd1e..e8587784090117e389fb0cf89142e0b7a059bcb9 100644 (file)
@@ -12,8 +12,6 @@
 
 #define QTEXT_FILE     "quest.dat"
 
-/* #define DEBUG */    /* uncomment for debugging */
-
 /* from sp_lev.c, for deliver_splev_message() */
 extern char *lev_message;
 
@@ -46,6 +44,8 @@ dump_qtlist() /* dump the character msg list to check appearance */
        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);
@@ -54,7 +54,10 @@ dump_qtlist()        /* dump the character msg list to check appearance */
                deliver_by_window(msg, NHW_TEXT);
        }
 }
-#endif /* DEBUG */
+#else
+static void
+dump_qtlist() { }
+#endif /* !DEBUG */
 
 static void
 Fread(ptr, size, nitems, stream)
@@ -133,9 +136,7 @@ load_qtlist()
 
        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 */
 }
 
index b4d4bb7fb76903cf409b67f3d0cd6ac12d35ad53..af974d147fcec97f93bef92b98f77e5b789bb473 100644 (file)
@@ -1153,9 +1153,7 @@ register int fd;
                ++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. */
index a2ce4568522eeb9bb4f7c71fbf03a4665a1738b6..662d1a275dbbe03cc908b4702826df603543e0e2 100644 (file)
--- a/src/rnd.c
+++ b/src/rnd.c
@@ -5,10 +5,6 @@
 
 #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);
@@ -26,9 +22,9 @@ int
 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);
@@ -44,9 +40,9 @@ register int x;       /* good luck approaches 0, bad luck approaches (x-1) */
 {
        register int i, adjustment;
 
-#ifdef DEBUG
+#ifdef BETA
        if (x <= 0) {
-               impossible("rnl(%d) attempted", x);
+               debugpline("rnl(%d) attempted", x);
                return(0);
        }
 #endif
@@ -83,9 +79,9 @@ int
 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;
@@ -101,9 +97,9 @@ register int n, x;
 {
        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
index 88db771e29cf714ae9c941a1d336b306452f5003..1fa51dfaa9bc0d86dfbee2b659556cea44132ca6 100644 (file)
@@ -1210,9 +1210,7 @@ int fd, mode;
            }
            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 */
 }
 
index 0fe0e94db2f53b27dd5e03fb56d5977c42997c85..12f22eb4017294879734aeb421740f1faa2f991e 100644 (file)
--- a/src/shk.c
+++ b/src/shk.c
@@ -5,8 +5,6 @@
 
 #include "hack.h"
 
-/*#define DEBUG*/
-
 #define PAY_SOME    2
 #define PAY_BUY     1
 #define PAY_CANT    0  /* too poor */
@@ -1207,9 +1205,7 @@ dopay()
        }
 
        if(!shkp) {
-#ifdef DEBUG
-               pline("dopay: null shkp.");
-#endif
+               debugpline("dopay: null shkp.");
                return(0);
        }
 proceed:
index f27637b9bdf6f3c140c0b48996c959a2f01517db..6be2c9713f7fe3fec17be0c5153f5cab051fd7cc 100644 (file)
 
 #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"
 
@@ -329,10 +324,8 @@ chk:
                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;
@@ -405,9 +398,7 @@ xchar       rtype, rlit;
                        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;
@@ -1320,10 +1311,8 @@ schar ftyp, btyp;
        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;
index 0812a79df36a6660e5605fac2590b2f470263d72..bf7238b012b561df7a333b504b4576d1867041c0 100644 (file)
@@ -424,12 +424,12 @@ register struct monst *mtmp;
 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 */
index 2f6c5fd87802c325eda712cc31b6afeca95429b5..b559c145071ded2b8e864b79ab07a533463f5d04 100644 (file)
--- a/src/sys.c
+++ b/src/sys.c
@@ -20,6 +20,7 @@ sys_early_init(){
 #else
        sysopt.wizards = WIZARD_NAME;
 #endif
+       sysopt.debugfiles = NULL;
        sysopt.shellers = NULL;
        sysopt.maxplayers = 0;  /* XXX eventually replace MAX_NR_OF_PLAYERS */
 
index ab8bb063e1a13be31935f680e84513ec66ebef76..cd179c1f1afae2c5044151b2ef5626615c02a70e 100644 (file)
@@ -121,9 +121,7 @@ unsigned entflags;
     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];
     }
index c4d98c33c96d75c111fbc0797b4df582cc17ce20..97fa65a15db8f47c1b3592d155249c536af6b049 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -1717,9 +1717,7 @@ struct obj *obj, *otmp;
                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;
                }
        }
@@ -3418,9 +3416,7 @@ struct obj **ootmp;       /* to return worn armor for caller to disintegrate */
                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);
 }
index 3eb07ecaaf6841a302894521df4a759f40af8fcd..74e7fb1ae90126864fd30123ecb8a3eefd25f5de 100644 (file)
@@ -14,6 +14,11 @@ WIZARDS=root games
 # 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
 
index 12ec044b3603fbef5b86922142dad0e26ad2c7bf..d4c921501ea23f3e3f6ffb12a5d94317784e5308 100644 (file)
@@ -1946,7 +1946,7 @@ register int x, y;        /* not xchar: perhaps xchar is unsigned and
        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