From: Eric S. Raymond Date: Wed, 29 Mar 2023 20:18:34 +0000 (-0400) Subject: Implement -d option. X-Git-Url: https://jxself.org/git/?a=commitdiff_plain;h=d388877c1b1eea7df89c4a688f7de5c118d59f4b;p=open-adventure.git Implement -d option. --- diff --git a/main.c b/main.c index 558edcf..bfc4a12 100644 --- a/main.c +++ b/main.c @@ -42,6 +42,7 @@ long ABBNUM, ACTSPK[36], AMBER, ATTACK, AXE, BACK, BATTER, BEAR, BIRD, BLOOD, BO WZDARK = false, ZZWORD; FILE *logfp; bool oldstyle = false; +int debug; lcg_state lcgstate; extern void initialise(); @@ -67,8 +68,11 @@ int main(int argc, char *argv[]) { /* Options. */ - while ((ch = getopt(argc, argv, "l:o")) != EOF) { + while ((ch = getopt(argc, argv, "dl:o")) != EOF) { switch (ch) { + case 'd': + debug += 1; + break; case 'l': logfp = fopen(optarg, "w+"); if (logfp == NULL) diff --git a/main.h b/main.h index 184acee..8489fa4 100644 --- a/main.h +++ b/main.h @@ -13,4 +13,5 @@ extern long ABB[], ATAB[], ATLOC[], BLKLIN, DFLAG, DLOC[], FIXED[], HOLDNG, extern signed char rawbuf[LINESIZE], INLINE[LINESIZE+1], MAP1[], MAP2[]; extern FILE *logfp; extern bool oldstyle; +extern int debug; extern lcg_state lcgstate; diff --git a/misc.c b/misc.c index e717b3f..4ee0f2b 100644 --- a/misc.c +++ b/misc.c @@ -770,6 +770,9 @@ unsigned long get_next_lcg_value(void) /* Return the LCG's current value, and then iterate it. */ unsigned long old_x = lcgstate.x; lcgstate.x = (lcgstate.a * lcgstate.x + lcgstate.c) % lcgstate.m; + if (debug) { + printf("# random %lu\n", old_x); + } return(old_x); }