MCPcopy Create free account
hub / github.com/NetHack/NetHack / list_genocided

Function list_genocided

src/insight.c:3006–3131  ·  view source on GitHub ↗

show genocided and extinct monster types for final disclosure/dumplog or for the #genocided command */

Source from the content-addressed store, hash-verified

3004/* show genocided and extinct monster types for final disclosure/dumplog
3005 or for the #genocided command */
3006void
3007list_genocided(char defquery, boolean ask)
3008{
3009 int i, mndx;
3010 int ngenocided, nextinct, ngone, mvflags, mindx[NUMMONS];
3011 char c;
3012 winid klwin;
3013 char buf[BUFSZ];
3014 boolean genoing, /* prompting for genocide or class genocide */
3015 dumping; /* for DUMPLOG; doesn't need to be conditional */
3016 boolean both = (program_state.gameover || wizard || discover);
3017
3018 dumping = (defquery == 'd');
3019 genoing = (defquery == 'g');
3020 if (dumping || genoing)
3021 defquery = 'y';
3022 if (genoing)
3023 both = FALSE; /* genocides only, not extinctions */
3024
3025 /* this goes through the whole monster list up to three times but will
3026 happen rarely and is simpler than a more general single pass check;
3027 extinctions are only revealed during end of game disclosure or when
3028 running in wizard or explore mode */
3029 ngenocided = num_genocides();
3030 nextinct = both ? num_extinct() : 0;
3031 mvflags = G_GENOD | (both ? G_EXTINCT : 0);
3032 ngone = num_gone(mvflags, mindx);
3033
3034 /* genocided or extinct species list */
3035 if (ngone > 0) {
3036 Sprintf(buf, "Do you want a list of %sspecies%s%s?",
3037 (nextinct && !ngenocided) ? "extinct " : "",
3038 (ngenocided) ? " genocided" : "",
3039 (nextinct && ngenocided) ? " and extinct" : "");
3040 c = ask ? yn_function(buf, (ngone > 1) ? "ynaq" : "ynq\033a",
3041 defquery, TRUE)
3042 : defquery;
3043 if (c == 'q')
3044 done_stopprint++;
3045 if (c == 'y' || c == 'a') {
3046 int save_sortmode;
3047 char mlet, prev_mlet = 0;
3048 boolean class_header = FALSE;
3049
3050 if (ngone > 1) {
3051 if (c == 'a') { /* ask player to choose sort order */
3052 /* #genocided shares #vanquished's sort order */
3053 if (set_vanq_order(FALSE) < 0)
3054 return;
3055 }
3056 /* sort orderings count-high-to-low or count-low-to-high
3057 don't make sense for genocides; if the preferred order
3058 to set to either of those, use alphabetical instead;
3059 note: the tie breaker for by-class is level-high-to-low
3060 or level-low-to-high rather than count so is ok as-is */
3061 save_sortmode = flags.vanq_sortmode;
3062 if (flags.vanq_sortmode == VANQ_COUNT_H_L
3063 || flags.vanq_sortmode == VANQ_COUNT_L_H)

Callers 5

dump_everythingFunction · 0.85
discloseFunction · 0.85
dogenocidedFunction · 0.85
do_class_genocideFunction · 0.85
do_genocideFunction · 0.85

Calls 9

num_genocidesFunction · 0.85
num_extinctFunction · 0.85
num_goneFunction · 0.85
yn_functionFunction · 0.85
set_vanq_orderFunction · 0.85
qsortFunction · 0.85
upstartFunction · 0.85
makepluralFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected