add --dumpmongen to view mongen_order[] array

This commit is contained in:
nhmall
2025-02-14 09:38:29 -05:00
parent 027bf78f28
commit f1be2eaffa
6 changed files with 47 additions and 2 deletions

View File

@@ -1444,6 +1444,7 @@ extern void mkmonmoney(struct monst *, long) NONNULLARG1;
extern int bagotricks(struct obj *, boolean, int *); extern int bagotricks(struct obj *, boolean, int *);
extern boolean propagate(int, boolean, boolean); extern boolean propagate(int, boolean, boolean);
extern void summon_furies(int); extern void summon_furies(int);
extern void dump_mongen(void);
/* ### mcastu.c ### */ /* ### mcastu.c ### */

View File

@@ -441,6 +441,7 @@ enum earlyarg {
, ARG_DUMPENUMS , ARG_DUMPENUMS
#endif #endif
, ARG_DUMPGLYPHIDS , ARG_DUMPGLYPHIDS
, ARG_DUMPMONGEN
#ifdef WIN32 #ifdef WIN32
, ARG_WINDOWS , ARG_WINDOWS
#endif #endif

View File

@@ -937,6 +937,7 @@ static const struct early_opt earlyopts[] = {
{ ARG_DUMPENUMS, "dumpenums", 9, FALSE }, { ARG_DUMPENUMS, "dumpenums", 9, FALSE },
#endif #endif
{ ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE }, { ARG_DUMPGLYPHIDS, "dumpglyphids", 12, FALSE },
{ ARG_DUMPMONGEN, "dumpmongen", 10, FALSE },
#ifdef WIN32 #ifdef WIN32
{ ARG_WINDOWS, "windows", 4, TRUE }, { ARG_WINDOWS, "windows", 4, TRUE },
#endif #endif
@@ -1038,6 +1039,9 @@ argcheck(int argc, char *argv[], enum earlyarg e_arg)
case ARG_DUMPGLYPHIDS: case ARG_DUMPGLYPHIDS:
dump_glyphids(); dump_glyphids();
return 2; return 2;
case ARG_DUMPMONGEN:
dump_mongen();
return 2;
#ifdef CRASHREPORT #ifdef CRASHREPORT
case ARG_BIDSHOW: case ARG_BIDSHOW:
crashreport_bidshow(); crashreport_bidshow();

View File

@@ -1809,6 +1809,41 @@ init_mongen_order(void)
#endif #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. /* Make one of the multiple types of a given monster class.
The second parameter specifies a special casing bit mask 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); return mkclass_aligned(class, spc, A_NONE);
} }
#define MONSi(i) (mongen_order[i])
/* mkclass() with alignment restrictions; used by ndemon() */ /* mkclass() with alignment restrictions; used by ndemon() */
struct permonst * struct permonst *
mkclass_aligned(char class, int spc, /* special mons[].geno handling */ mkclass_aligned(char class, int spc, /* special mons[].geno handling */

View File

@@ -659,6 +659,9 @@ early_options(int *argc_p, char ***argv_p, char **hackdir_p)
opt_terminate(); opt_terminate();
/*NOTREACHED*/ /*NOTREACHED*/
#endif #endif
} else if (argcheck(argc, argv, ARG_DUMPMONGEN) == 2) {
opt_terminate();
/*NOTREACHED*/
} else { } else {
#ifdef CHDIR #ifdef CHDIR
oldargc = argc; oldargc = argc;

View File

@@ -484,6 +484,9 @@ early_options(int argc, char *argv[])
} }
#endif #endif
#endif #endif
if (argcheck(argc, argv, ARG_DUMPMONGEN) == 2) {
nethack_exit(EXIT_SUCCESS);
}
if (argcheck(argc, argv, ARG_DEBUG) == 1) { if (argcheck(argc, argv, ARG_DEBUG) == 1) {
argc--; argc--;
argv++; argv++;