]> granicus.if.org Git - nethack/commitdiff
preserve menu sort between 'O' commands in same instance
authornhmall <nhmall@nethack.org>
Thu, 20 Feb 2020 21:56:05 +0000 (16:56 -0500)
committernhmall <nhmall@nethack.org>
Thu, 20 Feb 2020 21:56:05 +0000 (16:56 -0500)
Also, only execute the change settings loop when the
menu response was > 0

src/botl.c

index 8a2fe8e43f7f4098a8c609a847a993359f582cf2..5aedb928d446d8a58941af9bf1276953d9236e5c 100644 (file)
@@ -1031,13 +1031,14 @@ char *opts;
 void
 cond_menu(VOID_ARGS)
 {
-    int i, res, idx = 0, sortorder = 0;
+    static int sortorder = 0;
+    static const char *menutitle[2] = { "alphabetically", "by ranking"};
+    int i, res, idx = 0;
     int sequence[CONDITION_COUNT];
     winid tmpwin;
     anything any;
     menu_item *picks = (menu_item *) 0;
     char mbuf[QBUFSZ];
-    static const char *menutitle[2] = { "alphabetically", "by ranking"};
     boolean showmenu = TRUE;
 
     do {
@@ -1095,9 +1096,11 @@ cond_menu(VOID_ARGS)
         }
     } while (showmenu);
 
-    for (i = 0; i < CONDITION_COUNT; ++i) {
-        if (condtests[i].enabled != condtests[i].choice)
-            condtests[i].enabled = condtests[i].choice;
+    if (res > 0) {
+        for (i = 0; i < CONDITION_COUNT; ++i) {
+            if (condtests[i].enabled != condtests[i].choice)
+                condtests[i].enabled = condtests[i].choice;
+        }
     }
 }