From 456a87fdc67c39ba6d7d7c12c4cfc5ae69a29cf0 Mon Sep 17 00:00:00 2001 From: PatR Date: Sat, 24 Jun 2023 12:56:41 -0700 Subject: [PATCH] refine paranoid_confirm:Autoall If confirmation for menustyle:Full 'A' choice is on and player chooses 'A' but answers no at the "Really autoselect All?" prompt, just remove 'A' from the list of choices and act on the rest. If it was the only choice, the menu operation will behave as if no choices had been made. (That was the previous behavior even when other choices were also present.) But when other choices have been made along with 'A', use them without 'A': the normal second menu will be put up, listing objects matching the specified classes and not autoselecting anything. --- src/pickup.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/pickup.c b/src/pickup.c index 296c9de74..063d5be68 100644 --- a/src/pickup.c +++ b/src/pickup.c @@ -1355,14 +1355,20 @@ query_category( } end_menu(win, qstr); n = select_menu(win, how, pick_list); + /* handle ParanoidAutoAll by confirming 'A' choice if present */ if (n > 0 && verify_All) { - int i; + int i, j; for (i = 0; i < n; ++i) - if (pick_list[i]->item.a_int == 'A') { + if ((*pick_list)[i].item.a_int == 'A') { if (y_n("Really autoselect All?") != 'y') { - n = 0; - free((genericptr_t) *pick_list); + /* answer is "no", so take 'A' out of the list; + if it is the only entry, we'll return nothing, + otherwise go on to next menu without autoselect */ + for (j = i + 1; j < n; ++j) + (*pick_list)[j - 1] = (*pick_list)[j]; + if (!--n) + free((genericptr_t) *pick_list), *pick_list = 0; } break; /* goto query_done; */ } @@ -1370,7 +1376,7 @@ query_category( query_done: destroy_nhwindow(win); if (n < 0) - n = 0; /* caller's don't expect -1 */ + n = 0; /* callers don't expect -1 */ return n; }