]> granicus.if.org Git - nethack/commitdiff
flags.sortloot tweaks
authorPatR <rankin@nethack.org>
Tue, 19 Apr 2016 21:40:59 +0000 (14:40 -0700)
committerPatR <rankin@nethack.org>
Tue, 19 Apr 2016 21:40:59 +0000 (14:40 -0700)
flags.sortloot was changed from boolean to xchar, but proper type
is plain char.  (Presumeably it was originally off or on, then got
changed to 'n' for off, 'l' for on, plus 'f' for super-on.)

Also, make the sortloot menu for 'O' mark the current value as
preselected when interactively setting the value.  (I've been
meaning to do this for various other options but haven't gotten
around to it.  The need to workaround PICK_ONE+MENU_SELECTED menu
behavior is a nuisance.)

include/flag.h
src/options.c

index b9cd17f6bcbd4078f35b5cb8f82070a7e1d083b7..f34dfa71f468a2dc31b6f1774b985f67a574be4d 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 flag.h  $NHDT-Date: 1457207000 2016/03/05 19:43:20 $  $NHDT-Branch: chasonr $:$NHDT-Revision: 1.101 $ */
+/* NetHack 3.6 flag.h  $NHDT-Date: 1461102045 2016/04/19 21:40:45 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.103 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -48,7 +48,7 @@ struct flag {
     boolean showexp;         /* show experience points */
     boolean showscore;       /* show score */
     boolean silent;          /* whether the bell rings or not */
-    xchar sortloot;          /* sort items alphabetically when looting */
+    char    sortloot; /* 'n'=none, 'l'=loot (pickup), 'f'=full ('l'+invent) */
     boolean sortpack;        /* sorted inventory */
     boolean sparkle;         /* show "resisting" special FX (Scott Bigham) */
     boolean standout;        /* use standout for --More-- */
index 7b7e0c6578f970f763fc633240ad492e67b92eba..8cfb4e3fd9bd1f6a934afc47a76bc59678731bf3 100644 (file)
@@ -1,4 +1,4 @@
-/* NetHack 3.6 options.c       $NHDT-Date: 1459987581 2016/04/07 00:06:21 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.267 $ */
+/* NetHack 3.6 options.c       $NHDT-Date: 1461102048 2016/04/19 21:40:48 $  $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.268 $ */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -3926,7 +3926,7 @@ boolean setinitial, setfromfile;
 {
     winid tmpwin;
     anything any;
-    int i;
+    int i, n;
     char buf[BUFSZ];
 
     /* Special handling of menustyle, pickup_burden, pickup_types,
@@ -4185,11 +4185,17 @@ boolean setinitial, setfromfile;
             sortl_name = sortltype[i];
             any.a_char = *sortl_name;
             add_menu(tmpwin, NO_GLYPH, &any, *sortl_name, 0, ATR_NONE,
-                     sortl_name, MENU_UNSELECTED);
+                     sortl_name, (flags.sortloot == *sortl_name)
+                                    ? MENU_SELECTED : MENU_UNSELECTED);
         }
         end_menu(tmpwin, "Select loot sorting type:");
-        if (select_menu(tmpwin, PICK_ONE, &sortl_pick) > 0) {
-            flags.sortloot = sortl_pick->item.a_char;
+        n = select_menu(tmpwin, PICK_ONE, &sortl_pick);
+        if (n > 0) {
+            char c = sortl_pick[0].item.a_char;
+
+            if (n > 1 && c == flags.sortloot)
+                c = sortl_pick[1].item.a_char;
+            flags.sortloot = c;
             free((genericptr_t) sortl_pick);
         }
         destroy_nhwindow(tmpwin);