new 'sortvanquished' option

Allow the preferred sort order for the vanquished monsters list to
be specified in the run-time config file
|OPTIONS=sortvanquished:X
where X is t, d, a, c, n, or z.  It can also be set to 'A' or 'C'
but those aren't documented and aren't offered as choices when
setting the value interactively, which can be done via 'm O' or by
using 'm #vanquished'.

Guidebook.mn has been updated but Guidebook.tex is lagging again.
This commit is contained in:
PatR
2022-12-26 14:56:12 -08:00
parent a294fdf179
commit 249e431e46
11 changed files with 163 additions and 46 deletions

View File

@@ -3460,8 +3460,10 @@ optfn_sortdiscoveries(
}
static int
optfn_sortloot(int optidx, int req, boolean negated UNUSED,
char *opts, char *op)
optfn_sortloot(
int optidx, int req,
boolean negated UNUSED,
char *opts, char *op)
{
int i;
@@ -3504,6 +3506,62 @@ optfn_sortloot(int optidx, int req, boolean negated UNUSED,
return optn_ok;
}
static int
optfn_sortvanquished(
int optidx, int req,
boolean negated,
char *opts, char *op)
{
extern const char *const vanqorders[][3]; /* insight.c */
static const char vanqmodes[] = "tdaACcnz";
const char *optname = allopt[optidx].name;
if (req == do_init) {
flags.vanq_sortmode = VANQ_MLVL_MNDX; /* 0 => 't' */
return optn_ok;
}
if (req == do_set) {
op = string_for_env_opt(allopt[optidx].name, opts, FALSE);
if (negated) {
flags.vanq_sortmode = VANQ_MLVL_MNDX; /* 0 => 't' */
} else if (op != empty_optstr) {
const char *p;
int vndx = 0;
if ((p = strchr(vanqmodes, *op)) != 0) {
vndx = (int) (p - vanqmodes);
} else if (strchr("01234567", *op)) {
vndx = *op - '0';
} else {
config_error_add("Unknown %s parameter '%s'", optname, op);
return optn_silenterr;
}
flags.vanq_sortmode = (uchar) vndx;
} else
return optn_err;
return optn_ok;
}
if (req == get_val || req == get_cnf_val) {
Strcpy(opts, vanqorders[flags.vanq_sortmode][0]);
if (req == get_val)
Sprintf(eos(opts), ": %s", vanqorders[flags.vanq_sortmode][1]);
return optn_ok;
}
if (req == do_handler) {
uchar prev_sortmode = flags.vanq_sortmode;
/* return handler_sortvanquished(); */
(void) set_vanq_order(); /* insight.c */
pline("'%s' %s \"%s: %s\".", optname,
(flags.vanq_sortmode == prev_sortmode)
? "not changed, still"
: "changed to",
vanqorders[flags.vanq_sortmode][0],
vanqorders[flags.vanq_sortmode][1]);
}
return optn_ok;
}
static int
optfn_statushilites(
int optidx UNUSED,