status condition options

Option parsing rejected
|OPTIONS=!cond_X
for all valid X.

Using the menu to unselect all condition options treated that as not
having made any choice and didn't make any changes.  That would be
reasonable if nothing was preselected, but things are so unselecting
all of them is a choice.  (A bizarre one, but still should be viable.)

Mostly this deals with including cond_X options when #saveoptions is
used to write a new RC file.  It now produces something like
|OPTIONS=!cond_barehanded,cond_blind,!cond_busy,cond_conf,!cond_deaf,\
|        cond_iron,cond_fly,cond_foodPois,!cond_glowhands,cond_grab,\
|        cond_hallucinat,!cond_held,!cond_ice,cond_lava,cond_levitate,\
|        !cond_paralyzed,cond_ride,!cond_sleep,cond_slime,!cond_slip,\
|        cond_stone,cond_strngl,cond_stun,!cond_submerged,cond_termIll,\
|        !cond_tethered,!cond_trap,!cond_unconscious,!cond_woundedlegs,\
|        !cond_holding
after the last alphabetical option and before the bound keys, menu
colors, and others which aren't simple OPTIONS=X settings.  This only
happens if there is already one or more OPTIONS=cond_X entries in the
old file when it was read or if 'mO' gets used to make any changes.

Not fixed:  after my RC had something similar to the above and before
I changed status conditions to accept negation, I was getting several
"the cond_ option may not both have a value and be negated" messages
written to stdout instead of the config file error handler.  So they
vanished when the screen was initialized without providing a --More--
prompt to acknowledge that they have been seen.
This commit is contained in:
PatR
2022-10-31 00:53:10 -07:00
parent ad23b4e8e1
commit 220726f7ba
4 changed files with 114 additions and 27 deletions

View File

@@ -1134,13 +1134,46 @@ cond_menu(void)
}
} while (showmenu);
if (res > 0) {
if (res >= 0) {
for (i = 0; i < CONDITION_COUNT; ++i)
if (condtests[i].enabled != condtests[i].choice) {
condtests[i].enabled = condtests[i].choice;
g.context.botl = TRUE;
}
}
return;
}
/* called by all_options_conds() to get value for next cond_xyz option
so that #saveoptions can collect it and write the set into new RC file */
boolean
opt_next_cond(int indx, char *outbuf)
{
*outbuf = '\0';
if (indx >= CONDITION_COUNT)
return FALSE;
/*
* The entries are returned in internal order which requires the
* least code. It would be easy to sort them into alphabetic order
* (just sort all over again for every requested entry:
* int i, sequence[CONDITION_COUNT]
* for (i = 0; i < CONDITION_COUNT; ++i) sequence[i] = i;
* qsort(sequence, ..., menualpha_cmp);
* indx = sequence[indx];
* Sprintf(outbuf, ...);
* with no need to hang on to 'sequence[]' between calls).
*
* But using 'severity order' isn't feasible unless the player has
* used 'mO' on conditions in this session. Even then, they would
* revert to the default order (whether internal or alphabetical)
* if #saveoptions got used in some later session where doset()
* wasn't used to choose their preferred order.
*/
Sprintf(outbuf, "%scond_%s", condtests[indx].enabled ? "" : "!",
condtests[indx].useroption);
return TRUE;
}
static boolean