\#saveoptions fix

I hadn't ever used #saveoptions before and when I checked to see
whether the autounlock:none changes were being handled properly, I
discovered that options set via 'm O' weren't being handled at all.

This includes some miscellaneous reformatting of things noticed
while tracking down the problem.
This commit is contained in:
PatR
2022-10-13 13:19:58 -07:00
committed by nhmall
parent de2c9a42af
commit cb33b9ecc8
3 changed files with 17 additions and 8 deletions

View File

@@ -1410,6 +1410,8 @@ tipping contents of one container directly into another allowed transferring
prevent random traps from being created inside the shops in the tourist quest
if hero's steed got hit by knockback effect, impossible "no monster to remove"
would occur (plus more warnings if 'sanity_check' was On)
the #saveoptions command included options changed via doset_simple() but not
ones changed via full doset()
curses: 'msg_window' option wasn't functional for curses unless the binary
also included tty support

View File

@@ -2000,11 +2000,13 @@ do_write_config_file(void)
wait_synch();
pline("Some settings are not saved!");
wait_synch();
pline("All manual customization and comments are removed from the file!");
pline(
"All manual customization and comments are removed from the file!");
wait_synch();
}
#define overwrite_prompt "Overwrite config file %.*s?"
Sprintf(tmp, overwrite_prompt, (int)(BUFSZ - sizeof overwrite_prompt - 2), configfile);
Sprintf(tmp, overwrite_prompt,
(int) (BUFSZ - sizeof overwrite_prompt - 2), configfile);
#undef overwrite_prompt
if (!paranoid_query(TRUE, tmp))
return ECMD_OK;
@@ -2021,7 +2023,8 @@ do_write_config_file(void)
fclose(fp);
strbuf_empty(&buf);
if (wrote != len)
pline("An error occurred, wrote only partial data (%lu/%lu).", wrote, len);
pline("An error occurred, wrote only partial data (%lu/%lu).",
wrote, len);
}
return ECMD_OK;
}

View File

@@ -4879,8 +4879,8 @@ handler_autounlock(int optidx)
free((genericptr_t) window_pick);
} else if (n == 0) { /* nothing was picked but menu wasn't cancelled */
/* something that was preselected got unselected, leaving nothing;
treat that as picking 'none' (even though 'none' might be what
got unselected) */
treat that as picking 'none' (even though 'none' is no longer
among the choices) */
flags.autounlock = 0;
}
destroy_nhwindow(tmpwin);
@@ -5703,8 +5703,8 @@ handler_verbose(int optidx)
flags.verbose = !flags.verbose;
} else {
Sprintf(buf,
"Set verbose_suppressor[%d] (%ld) to what new decimal value ?",
j, verbosity_suppressions[j]);
"Set verbose_suppressor[%d] (%ld) to what new decimal value ?",
j, verbosity_suppressions[j]);
abuf[0] = '\0';
getlin(buf, abuf);
if (abuf[0] == '\033')
@@ -8330,6 +8330,9 @@ doset(void) /* changing options via menu by Per Liboriussen */
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)
opt_set_in_config[k] = TRUE;
} else {
char abuf[BUFSZ];
@@ -8992,7 +8995,8 @@ all_options_strbuf(strbuf_t *sbuf)
- verbose */
buf2 = get_option_value(name, TRUE);
if (buf2) {
Sprintf(tmp, "OPTIONS=%s:%s\n", name, buf2);
Snprintf(tmp, sizeof tmp - 1, "OPTIONS=%s:%s", name, buf2);
Strcat(tmp, "\n"); /* guaranteed to fit */
strbuf_append(sbuf, tmp);
}
break;