Make initoptions() call initoptions_init() if that hasn't already happened.

This commit is contained in:
nhkeni
2024-02-23 20:14:03 -05:00
parent 77916d5d73
commit 5f64dd3f1b
2 changed files with 12 additions and 5 deletions

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 options.c $NHDT-Date: 1708124177 2024/02/16 22:56:17 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.707 $ */ /* NetHack 3.7 options.c $NHDT-Date: 1708737173 2024/02/24 01:12:53 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.709 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Michael Allison, 2008. */ /*-Copyright (c) Michael Allison, 2008. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -96,7 +96,7 @@ enum requests {
}; };
/* these aren't the same as set_xxx in optlist.h */ /* these aren't the same as set_xxx in optlist.h */
enum option_phases { enum option_phases {
builtin_opt, /* compiled-in default value of an option */ builtin_opt=1,/* compiled-in default value of an option */
syscf_opt, /* sysconf setting of an option, overrides builtin */ syscf_opt, /* sysconf setting of an option, overrides builtin */
rc_file_opt, /* player's run-time config file setting, overrides syscf */ rc_file_opt, /* player's run-time config file setting, overrides syscf */
environ_opt, /* player's environment NETHACKOPTIONS, overrides rc_file */ environ_opt, /* player's environment NETHACKOPTIONS, overrides rc_file */
@@ -6707,6 +6707,15 @@ initoptions(void)
{ {
int i; int i;
/*
* Most places that call initoptions_init()/initoptions() would
* have the calls next to each other, so instead of adding
* initoptions_init() everywhere, just add it where it's needed in
* a non-adjacent place and call it here for all the other cases.
*/
if(go.opt_phase != builtin_opt)
initoptions_init();
/* /*
* Call each option function with an init flag and give it a chance * Call each option function with an init flag and give it a chance
* to make any preparations that it might require. We do this * to make any preparations that it might require. We do this

View File

@@ -1,4 +1,4 @@
/* NetHack 3.7 unixmain.c $NHDT-Date: 1704043695 2023/12/31 17:28:15 $ $NHDT-Branch: keni-luabits2 $:$NHDT-Revision: 1.124 $ */ /* NetHack 3.7 unixmain.c $NHDT-Date: 1708737183 2024/02/24 01:13:03 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.126 $ */
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
/*-Copyright (c) Robert Patrick Rankin, 2011. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -150,7 +150,6 @@ main(int argc, char *argv[])
check_linux_console(); check_linux_console();
#endif #endif
initoptions_init();
initoptions(); initoptions();
#ifdef PANICTRACE #ifdef PANICTRACE
ARGV0 = gh.hname; /* save for possible stack trace */ ARGV0 = gh.hname; /* save for possible stack trace */
@@ -786,7 +785,6 @@ opt_showpaths(const char *dir)
nhUse(dir); nhUse(dir);
#endif #endif
iflags.initoptions_noterminate = TRUE; iflags.initoptions_noterminate = TRUE;
initoptions_init();
initoptions(); initoptions();
iflags.initoptions_noterminate = FALSE; iflags.initoptions_noterminate = FALSE;
reveal_paths(); reveal_paths();