last? role/race/&c option values update

Keep track of how a role|race|gender|alignment option got its value
so that role:!Tourist in .nethackrc and role:!Priest in NETHACKOPTIONS
yield 'role:!Priest' rather than merging into 'role:!Priest !Tourist'.
It also doesn't write the value into new config file for #saveoptions
if that value comes from environment or command line (not applicable
since the command line arguments for role,&c don't go through options
handling).  Also, the old config file value takes precedence over
the current game's value file so that 'role:random' doesn't become
'role:Healer' or such in a new config after the random value gets
picked for play.

This only tracks the role, race, gender, and alignment options but the
concept could be extended to all options.  The data would need to be
saved and restored if values set interactively need to be retained in
restore sessions (doesn't apply to role,&c since those don't change
during play).
This commit is contained in:
PatR
2022-12-22 15:07:33 -08:00
parent 37f6eee147
commit 91e2ab13b2
7 changed files with 397 additions and 85 deletions

View File

@@ -115,16 +115,16 @@ static int optfn_##a(int, int, boolean, char *, char *);
No, Yes, No, No, NoAlias,
"your character's name (e.g., name:Merlin-W)")
NHOPTC(role, Advanced, PL_CSIZ, opt_in, set_gameview,
Yes, Yes, No, No, "character",
Yes, Yes, Yes, No, "character",
"your starting role (e.g., Barbarian, Valkyrie)")
NHOPTC(race, Advanced, PL_CSIZ, opt_in, set_gameview,
Yes, Yes, No, No, NoAlias,
Yes, Yes, Yes, No, NoAlias,
"your starting race (e.g., Human, Elf)")
NHOPTC(gender, Advanced, 8, opt_in, set_gameview,
Yes, Yes, No, No, NoAlias,
Yes, Yes, Yes, No, NoAlias,
"your starting gender (male or female)")
NHOPTC(alignment, Advanced, 8, opt_in, set_gameview,
Yes, Yes, No, No, "align",
Yes, Yes, Yes, No, "align",
"your starting alignment (lawful, neutral, or chaotic)")
/* end of special ordering; remainder of entries are in alphabetical order
*/