From f1be2eaffa59e7fb1ce8c8dfd063ecb53e21dffc Mon Sep 17 00:00:00 2001 From: nhmall Date: Fri, 14 Feb 2025 09:38:29 -0500 Subject: [PATCH] add --dumpmongen to view mongen_order[] array --- include/extern.h | 1 + include/hack.h | 1 + src/allmain.c | 4 ++++ src/makemon.c | 37 +++++++++++++++++++++++++++++++++++-- sys/unix/unixmain.c | 3 +++ sys/windows/windmain.c | 3 +++ 6 files changed, 47 insertions(+), 2 deletions(-) diff --git a/include/extern.h b/include/extern.h index b39db3219..c5b0b0af9 100644 --- a/include/extern.h +++ b/include/extern.h @@ -1444,6 +1444,7 @@ extern void mkmonmoney(struct monst *, long) NONNULLARG1; extern int bagotricks(struct obj *, boolean, int *); extern boolean propagate(int, boolean, boolean); extern void summon_furies(int); +extern void dump_mongen(void); /* ### mcastu.c ### */ diff --git a/include/hack.h b/include/hack.h index 3fb02f687..13e27653f 100644 --- a/include/hack.h +++ b/include/hack.h @@ -441,6 +441,7 @@ enum earlyarg { , ARG_DUMPENUMS #endif , ARG_DUMPGLYPHIDS + , ARG_DUMPMONGEN #ifdef WIN32 , ARG_WINDOWS #endif diff --git a/src/allmain.c b/src/allmain.c index 9ffb6dacc..f65ce13b2 100644 --- a/src/allmain.c +++ b/src/allmain.c @@ -937,6 +937,7 @@ static const struct early_opt earlyopts[] = { { ARG_DUMPENUMS, "dumpenums", 9, FALSE }, #endif { ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE }, + { ARG_DUMPMONGEN, "dumpmongen", 10, FALSE }, #ifdef WIN32 { ARG_WINDOWS, "windows", 4, TRUE }, #endif @@ -1038,6 +1039,9 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg) case ARG_DUMPGLYPHIDS: dump_glyphids(); return 2; + case ARG_DUMPMONGEN: + dump_mongen(); + return 2; #ifdef CRASHREPORT case ARG_BIDSHOW: crashreport_bidshow(); diff --git a/src/makemon.c b/src/makemon.c index 76e52a85e..f365d643f 100644 --- a/src/makemon.c +++ b/src/makemon.c @@ -1809,6 +1809,41 @@ init_mongen_order(void) #endif } +#define MONSi(i) (mongen_order[i]) + +extern struct enum_dump monsdump[]; /* allmain.c */ + +void +dump_mongen(void) +{ + char mlet, prev_mlet = 0; + int i, nmwidth = 27, special; + char nmbuf[80]; + + monst_globals_init(); + init_mongen_order(); + raw_printf("int mongen_order[] = {"); + for (i = LOW_PM; i < SPECIAL_PM; ++i) { + special = (mons[MONSi(i)].geno & (G_NOGEN | G_UNIQ)); + mlet = def_monsyms[(int) mons[MONSi(i)].mlet].sym; + if (prev_mlet && prev_mlet != mlet) + raw_print(""); + Snprintf(nmbuf, sizeof nmbuf, "PM_%s%s", + monsdump[MONSi(i)].nm, + (i == SPECIAL_PM - 1) ? "" : ","); + raw_printf(" %*s /* %c seq=%3d, idx=%3d, sym='%c', diff=%2d %s */", + -nmwidth, nmbuf, (i == MONSi(i)) ? ' ' : '.', i, MONSi(i), + mlet, (int) mons[MONSi(i)].difficulty, + (special == (G_NOGEN | G_UNIQ)) ? "(G_NOGEN | G_UNIQ)" + : (special == G_NOGEN) ? "(G_NOGEN)" + : (special == G_UNIQ) ? "(G_UNIQ)" + : ""); + prev_mlet = mlet; + } + raw_print("};"); + raw_print(""); + freedynamicdata(); +} /* Make one of the multiple types of a given monster class. The second parameter specifies a special casing bit mask @@ -1820,8 +1855,6 @@ mkclass(char class, int spc) return mkclass_aligned(class, spc, A_NONE); } -#define MONSi(i) (mongen_order[i]) - /* mkclass() with alignment restrictions; used by ndemon() */ struct permonst * mkclass_aligned(char class, int spc, /* special mons[].geno handling */ diff --git a/sys/unix/unixmain.c b/sys/unix/unixmain.c index 617a1ef06..154c7e15b 100644 --- a/sys/unix/unixmain.c +++ b/sys/unix/unixmain.c @@ -659,6 +659,9 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p) opt_terminate(); /*NOTREACHED*/ #endif + } else if (argcheck(argc, argv, ARG_DUMPMONGEN) == 2) { + opt_terminate(); + /*NOTREACHED*/ } else { #ifdef CHDIR oldargc = argc; diff --git a/sys/windows/windmain.c b/sys/windows/windmain.c index eaef359b9..c622a707e 100644 --- a/sys/windows/windmain.c +++ b/sys/windows/windmain.c @@ -484,6 +484,9 @@ early_options(int argc, char *argv[]) } #endif #endif + if (argcheck(argc, argv, ARG_DUMPMONGEN) == 2) { + nethack_exit(EXIT_SUCCESS); + } if (argcheck(argc, argv, ARG_DEBUG) == 1) { argc--; argv++;