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

@@ -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();

View File

@@ -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 */