From 876eed4935d7193f49f131ee11cc1ebf386700ca Mon Sep 17 00:00:00 2001 From: "nethack.rankin" Date: Sun, 13 May 2007 02:39:25 +0000 Subject: [PATCH] #vanquished (trunk only) Add #vanquished command to show the vanquished monsters list during play. At present it's only available in wizard mode. Slash'em has it as a regular mode command, and I found it handy sometimes: when I managed to kill an unfamiliar monster, I could immediately get an idea of how the game ranked its difficulty compared to other monsters. But having this command available might encourage extinctionism. On the other hand, it might stop some existing extinctionists from cycles of save+copy+restore+quit to view disclosure data for their current game. This also makes merging the wizard mode extended commands into other extended commands be more robust. It will panic instead of going out of array bounds if someone adds entries to debug_extcmdlist[] without also expanding extcmdlist[] to make room. --- doc/fixes35.0 | 1 + include/extern.h | 1 + src/cmd.c | 41 ++++++++++++++++++++++++----------------- src/end.c | 15 +++++++++++++-- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/doc/fixes35.0 b/doc/fixes35.0 index b54d74b06..d7ad63329 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -333,6 +333,7 @@ doppelgangers can take on the shape of alternate roles' quest guardians pile_limit option to control when to switch to "there are objects here" vs listing objects on floor when hero goes over objects while moving some monsters will use fire to prevent selves being turned into green slime +add `#vanquished' debug mode command Platform- and/or Interface-Specific New Features diff --git a/include/extern.h b/include/extern.h index 3a80f0bdd..1b75c11a1 100644 --- a/include/extern.h +++ b/include/extern.h @@ -628,6 +628,7 @@ E void VDECL(panic, (const char *,...)) PRINTF_F(1,2); E void FDECL(done, (int)); E void FDECL(container_contents, (struct obj *,BOOLEAN_P,BOOLEAN_P,BOOLEAN_P)); E void FDECL(terminate, (int)); +E int NDECL(dovanquished); E int NDECL(num_genocides); E void FDECL(delayed_killer, (int, int, const char*)); E struct kinfo *FDECL(find_delayed_killer, (int)); diff --git a/src/cmd.c b/src/cmd.c index ddc0b1d4b..d31f2ce52 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -54,6 +54,7 @@ extern int NDECL(dofire); /**/ extern int NDECL(dothrow); /**/ extern int NDECL(doeat); /**/ extern int NDECL(done2); /**/ +extern int NDECL(vanquished); /**/ extern int NDECL(doengrave); /**/ extern int NDECL(dopickup); /**/ extern int NDECL(ddoinv); /**/ @@ -1777,33 +1778,35 @@ struct ext_func_tab extcmdlist[] = { * There must be a blank entry here for every entry in the table * below. */ - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* levelchange */ + {(char *)0, (char *)0, donull, TRUE}, /* lightsources */ #ifdef DEBUG_MIGRATING_MONS - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* migratemons */ #endif - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* monpolycontrol */ + {(char *)0, (char *)0, donull, TRUE}, /* panic */ + {(char *)0, (char *)0, donull, TRUE}, /* polyself */ #ifdef PORT_DEBUG - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* portdebug */ #endif - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* seenv */ + {(char *)0, (char *)0, donull, TRUE}, /* stats */ + {(char *)0, (char *)0, donull, TRUE}, /* terrain */ + {(char *)0, (char *)0, donull, TRUE}, /* timeout */ + {(char *)0, (char *)0, donull, TRUE}, /* vanquished */ + {(char *)0, (char *)0, donull, TRUE}, /* vision */ + {(char *)0, (char *)0, donull, TRUE}, /* wizsmell */ #ifdef DEBUG - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* wizdebug */ #endif - {(char *)0, (char *)0, donull, TRUE}, - {(char *)0, (char *)0, donull, TRUE}, + {(char *)0, (char *)0, donull, TRUE}, /* wizrumorcheck */ + {(char *)0, (char *)0, donull, TRUE}, /* wmode */ #endif {(char *)0, (char *)0, donull, TRUE} /* sentinel */ }; -#if defined(WIZARD) +#ifdef WIZARD +/* there must be a placeholder in the table above for every entry here */ static const struct ext_func_tab debug_extcmdlist[] = { {"levelchange", "change experience level", wiz_level_change, TRUE}, {"lightsources", "show mobile light sources", wiz_light_sources, TRUE}, @@ -1820,6 +1823,7 @@ static const struct ext_func_tab debug_extcmdlist[] = { {"stats", "show memory statistics", wiz_show_stats, TRUE}, {"terrain", "show map topology", wiz_map_terrain, TRUE}, {"timeout", "look at timeout queue", wiz_timeout_queue, TRUE}, + {"vanquished", "list vanquished monsters", dovanquished, TRUE}, {"vision", "show vision array", wiz_show_vision, TRUE}, {"wizsmell", "smell monster", wiz_smell, TRUE}, #ifdef DEBUG @@ -1847,6 +1851,9 @@ add_debug_extended_commands() ; for (i = 0; debug_extcmdlist[i].ef_txt; i++) { + /* need enough room for "?" entry plus terminator */ + if (n + 2 >= SIZE(extcmdlist)) + panic("Too many debugging commands!"); for (j = 0; j < n; j++) if (strcmp(debug_extcmdlist[i].ef_txt, extcmdlist[j].ef_txt) < 0) break; diff --git a/src/end.c b/src/end.c index 1f7e0587b..92a335b85 100644 --- a/src/end.c +++ b/src/end.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)end.c 3.5 2007/02/28 */ +/* SCCS Id: @(#)end.c 3.5 2007/05/12 */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1061,6 +1061,14 @@ int status; nethack_exit(status); } +/* #vanquished command */ +int +dovanquished() +{ + list_vanquished('a', FALSE); + return 0; +} + STATIC_OVL void list_vanquished(defquery, ask) char defquery; @@ -1087,7 +1095,7 @@ boolean ask; c = ask ? yn_function("Do you want an account of creatures vanquished?", ynqchars, defquery) : defquery; if (c == 'q') done_stopprint++; - if (c == 'y') { + if (c == 'y' || c == 'a') { klwin = create_nhwindow(NHW_MENU); putstr(klwin, 0, "Vanquished creatures:"); putstr(klwin, 0, ""); @@ -1132,6 +1140,9 @@ boolean ask; display_nhwindow(klwin, TRUE); destroy_nhwindow(klwin); } + } else if (defquery == 'a') { + /* #dovanquished rather than final disclosure, so pline() is ok */ + pline("No monsters have been vanquished."); } }