]> granicus.if.org Git - nethack/commitdiff
display_pickinv
authorPatR <rankin@nethack.org>
Sun, 7 Feb 2021 22:58:08 +0000 (14:58 -0800)
committerPatR <rankin@nethack.org>
Sun, 7 Feb 2021 22:58:08 +0000 (14:58 -0800)
A formatting bit that grew a little.  An end of line comment that
spans on two or more lines
  foo(); /* call
            foo() */
will confuse clang-format if the continuation lines don't begin
with an asterisk
  foo(); /* call
          * foo() */
Instead of just doing that, I changed display_pickinv() to add a
comment for each of its arguments.

src/invent.c

index 9cd60dc40d21e08bf873caae20430fbe8ca36387..38199e98a022d5f3002ac00bd78636c46d99d5f1 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.7 invent.c        $NHDT-Date: 1608846067 2020/12/24 21:41:07 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.310 $ */
+/* NetHack 3.7 invent.c        $NHDT-Date: 1612738685 2021/02/07 22:58:05 $  $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.318 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /*-Copyright (c) Derek S. Ray, 2015. */
 /* NetHack may be freely redistributed.  See license for details. */
@@ -2420,14 +2420,15 @@ free_pickinv_cache(void)
 
 /*
  * Internal function used by display_inventory and getobj that can display
- * inventory and return a count as well as a letter. If out_cnt is not null,
- * any count returned from the menu selection is placed here.
+ * inventory and return a count as well as a letter.
  */
 static char
-display_pickinv(register const char *lets,
-                const char *xtra_choice, /* "fingers", pick hands rather than
-                                            an object */
-                const char *query, boolean want_reply, long *out_cnt)
+display_pickinv(
+    const char *lets,        /* non-compacted list of invlet values */
+    const char *xtra_choice, /* non-object "bare hands" or "fingers" */
+    const char *query,       /* optional; prompt string for menu */
+    boolean want_reply,      /* True: select an item, False: just display */
+    long *out_cnt) /* optional; count player entered when selecting an item */
 {
     static const char not_carrying_anything[] = "Not carrying anything";
     struct obj *otmp, wizid_fakeobj;
@@ -2475,7 +2476,7 @@ display_pickinv(register const char *lets,
     /* for xtra_choice, there's another 'item' not included in initial 'n';
        for !lets (full g.invent) and for override_ID (wizard mode identify),
        skip message_menu handling of single item even if item count was 1 */
-    if (xtra_choice || (n == 1 && (!lets || iflags.override_ID)))
+    if (xtra_choice || (n == 1 && (!lets || wizid)))
         ++n;
 
     if (n == 0) {
@@ -2521,7 +2522,7 @@ display_pickinv(register const char *lets,
 
     start_menu(win, MENU_BEHAVE_STANDARD);
     any = cg.zeroany;
-    if (wizard && iflags.override_ID) {
+    if (wizid) {
         int unid_cnt;
         char prompt[QBUFSZ];
 
@@ -2565,6 +2566,7 @@ display_pickinv(register const char *lets,
                  xtra_choice, MENU_ITEMFLAGS_NONE);
         gotsomething = TRUE;
     }
+
  nextclass:
     classcount = 0;
     for (srtinv = sortedinvent; (otmp = srtinv->obj) != 0; ++srtinv) {
@@ -2626,7 +2628,7 @@ display_pickinv(register const char *lets,
                  not_carrying_anything, MENU_ITEMFLAGS_NONE);
         want_reply = FALSE;
     }
-    end_menu(win, query && *query ? query : (char *) 0);
+    end_menu(win, (query && *query) ? query : (char *) 0);
 
     n = select_menu(win,
                     wizid ? PICK_ANY : want_reply ? PICK_ONE : PICK_NONE,