fix #K4025 - #saveoptions vs cond_ options

Confusion between 'o_status_cond' and 'pfx_cond_'.  Still confusing
but I think now working as intended and expected.

If any cond_xyz option has been loaded from the RC file or changed via
'm O', #saveoptions still saves the full set rather than just the ones
that are different from their default value.
This commit is contained in:
PatR
2023-10-31 01:19:20 -07:00
parent f25b5c4627
commit 6303141f1d
4 changed files with 24 additions and 14 deletions

View File

@@ -1710,6 +1710,10 @@ applying a wielded lump of royal jelly but not picking something to rub it on
"addinv: null obj after quiver merge" (like applying lit potion of oil)
ceiling hider could become hidden when there was no ceiling, triggering a
warning if sanity_check was On
experimental #saveoptions wasn't saving the set of cond_xyz options correctly;
if player viewed the 'm O' submenu for status conditions, they would
get saved even if not changed; otherwise, ones that came in from the
old RC file wouldn't be included in the new one
Fixes to 3.7.0-x Platform and/or Interface Problems Exposed Via git Repository

View File

@@ -199,7 +199,7 @@ extern int stat_hunger_indx(void);
extern const char *bl_idx_to_fldname(int);
extern void condopt(int, boolean *, boolean);
extern int parse_cond_option(boolean, char *);
extern void cond_menu(void);
extern boolean cond_menu(void);
extern boolean opt_next_cond(int, char *);
#ifdef STATUS_HILITES
extern void status_eval_next_unhilite(void);

View File

@@ -1043,8 +1043,7 @@ condopt(int idx, boolean *addr, boolean negated)
condtests[idx].enabled = negated ? FALSE : TRUE;
condtests[idx].choice = condtests[idx].enabled;
/* avoid lingering false positives if test is no longer run */
if (!condtests[idx].enabled)
condtests[idx].test = FALSE;
condtests[idx].test = FALSE;
}
}
@@ -1090,7 +1089,9 @@ parse_cond_option(boolean negated, char *opts)
return 1; /* !0 indicates error */
}
void
/* display a menu of all available status condition options and let player
toggled them on or off; returns True iff any changes are made */
boolean
cond_menu(void)
{
static const char *const menutitle[2] = {
@@ -1104,6 +1105,7 @@ cond_menu(void)
char mbuf[QBUFSZ];
boolean showmenu = TRUE;
int clr = 0;
boolean changed = FALSE;
do {
for (i = 0; i < CONDITION_COUNT; ++i) {
@@ -1164,10 +1166,11 @@ cond_menu(void)
for (i = 0; i < CONDITION_COUNT; ++i)
if (condtests[i].enabled != condtests[i].choice) {
condtests[i].enabled = condtests[i].choice;
gc.context.botl = TRUE;
condtests[idx].test = FALSE;
gc.context.botl = changed = TRUE;
}
}
return;
return changed;
}
/* called by all_options_conds() to get value for next cond_xyz option

View File

@@ -4699,7 +4699,7 @@ optfn_windowtype(int optidx, int req, boolean negated UNUSED,
static int
pfxfn_cond_(
int optidx,
int optidx UNUSED,
int req,
boolean negated,
char *opts,
@@ -4714,7 +4714,7 @@ pfxfn_cond_(
switch (reslt) {
case 0:
opt_set_in_config[optidx] = TRUE;
opt_set_in_config[pfx_cond_] = TRUE;
break;
case 3:
config_error_add("Ambiguous condition option %s", opts);
@@ -4737,8 +4737,8 @@ pfxfn_cond_(
opts[0] = '\0';
return optn_ok;
}
if (req == do_handler) {
cond_menu(); /* in botl.c */
if (req == do_handler) { /* not used */
(void) cond_menu(); /* in botl.c */
return optn_ok;
}
return optn_ok;
@@ -8339,7 +8339,8 @@ optfn_o_status_cond(
; /* handled inline by all_options_strbuf() via all_options_conds() */
}
if (req == do_handler) {
cond_menu();
if (cond_menu())
opt_set_in_config[pfx_cond_] = TRUE;
return optn_ok;
}
return optn_ok;
@@ -8574,7 +8575,7 @@ doset_simple_menu(void)
reslt = (*allopt[k].optfn)(allopt[k].idx, do_handler, FALSE,
empty_optstr, empty_optstr);
/* if player eventually saves options, include this one */
if (reslt == optn_ok)
if (reslt == optn_ok && allopt[k].idx != pfx_cond_)
opt_set_in_config[k] = TRUE;
} else {
Sprintf(buf, "Set %s to what?", allopt[k].name);
@@ -9564,8 +9565,10 @@ all_options_strbuf(strbuf_t *sbuf)
}
/* cond_xyz are closer to regular options than the other 'other opts'
so put them next */
if (opt_set_in_config[opt_o_status_cond])
so put them next; [pfx_cond_] will be set if any cond_Foo were
present when RC file was read in or if player made any changes via
status conditions menu; ignore opt_set_in_config[opt_o_status_cond] */
if (opt_set_in_config[pfx_cond_])
all_options_conds(sbuf);
get_changed_key_binds(sbuf);