]> granicus.if.org Git - nethack/commitdiff
#vanquished (trunk only)
authornethack.rankin <nethack.rankin>
Sun, 13 May 2007 02:39:25 +0000 (02:39 +0000)
committernethack.rankin <nethack.rankin>
Sun, 13 May 2007 02:39:25 +0000 (02:39 +0000)
      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
include/extern.h
src/cmd.c
src/end.c

index b54d74b0682f5d761c710c960d1a36003f2ed63b..d7ad633298977423f9c1d34f377dd8add6038419 100644 (file)
@@ -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
index 3a80f0bdd3a1249ba6d84fbaa29cd9d2dfe01b0f..1b75c11a157fecc8e14a47ae151191e5c4e1a08e 100644 (file)
@@ -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));
index ddc0b1d4b611b60253952a5c9718f31b03074e98..d31f2ce520c88ba8cecba9ab6bbdacdc3ec20c2d 100644 (file)
--- 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;
 
index 1f7e0587b2a1f53a9b60daffc3e64ca968d51610..92a335b85b6b34acdd7896433268d3b047f7d87b 100644 (file)
--- 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.");
     }
 }