February 2020 options.c overhaul

combine boolean and compound options into a single allopt[] array for
processing in options.c.

move the definitions of the options into new include/optlist.h file which
uses a set of macros to define them appropriately.

during compile of options.c each option described in include/optlist.h:
   1. automatically results in a function prototype for an optfn called
      optfn_xxxx (xxxx is the option name).
   2. automatically results in an opt_xxxx enum value for referencing
      its index throughout options.c (xxxx is the option name).
   3. is used to initialize an element of the allopt[] array at index
      opt_xxxx (xxxx is the option name) based on the settings in the
      NHOPTB, NHOPTC, NHOPTP macros. Those macros only live during the
      compilation of include/optlist.h.

each optfn_xxxx() function can be called with a req id of: do_init, do_set,
get_val or do_handler.

req do_init is called from options_init, and if initialization or memory
allocation or other initialization for that particular option is needed,
it can be done in response to the init req.

req do_set is called from parseoptions() for each option it encounters
and the optfn_xxxx() function is expected to react and set the option
based on the string values that parseoptions() passes to it.

req get_val expects each optfn_xxxx() function to write the current
option value into the buffer it is passed.

req do_handler is called during doset() operations in response to player
selections most likely from the 'O' option-setting menu, but only if the
option is identified as having do_handler support in the allopts[]
'has_handler' boolean flag. Not every optfn_xxxx() does.

function special_handling() is eliminated. It's code has been redistributed
to individual handler functions for the option or purpose that they serve.

moved reglyph_darkroom() function from options.c to display.c
This commit is contained in:
nhmall
2020-02-26 00:19:08 -05:00
parent a7c143c8f9
commit 68fdc3bbcb
21 changed files with 7042 additions and 4830 deletions

View File

@@ -499,10 +499,10 @@ HACKINCL = align.h amiconf.h artifact.h artilist.h attrib.h beconf.h botl.h \
func_tab.h global.h hack.h lint.h macconf.h mextra.h mfndpos.h \
micro.h mkroom.h \
monattk.h mondata.h monflag.h monst.h monsym.h obj.h objclass.h \
os2conf.h patchlevel.h pcconf.h permonst.h prop.h rect.h region.h \
rm.h sp_lev.h spell.h sys.h system.h tcap.h timeout.h tosconf.h \
tradstdc.h trampoli.h trap.h unixconf.h vision.h vmsconf.h wintty.h \
wincurs.h winX.h winprocs.h wintype.h you.h youprop.h
optlist.h os2conf.h patchlevel.h pcconf.h permonst.h prop.h rect.h \
region.h rm.h sp_lev.h spell.h sys.h system.h tcap.h timeout.h \
tosconf.h tradstdc.h trampoli.h trap.h unixconf.h vision.h vmsconf.h \
wintty.h wincurs.h winX.h winprocs.h wintype.h you.h youprop.h
HSOURCES = $(HACKINCL) date.h onames.h pm.h vis_tab.h dgn_file.h
@@ -1118,7 +1118,7 @@ objects.o: objects.c $(CONFIG_H) ../include/obj.h ../include/objclass.h \
../include/prop.h ../include/skills.h ../include/color.h
objnam.o: objnam.c $(HACK_H)
options.o: options.c $(CONFIG_H) ../include/objclass.h ../include/flag.h \
$(HACK_H) ../include/tcap.h
$(HACK_H) ../include/tcap.h ../include/optlist.h
pager.o: pager.c $(HACK_H) ../include/dlb.h
pickup.o: pickup.c $(HACK_H)
pline.o: pline.c $(HACK_H)

View File

@@ -158,7 +158,7 @@ mswin_init_nhwindows(int *argc, char **argv)
* non-console applications
*/
iflags.toptenwin = 1;
set_option_mod_status("toptenwin", SET_IN_FILE);
set_option_mod_status("toptenwin", set_in_config);
/* initialize map tiles bitmap */
initMapTiles();
@@ -176,14 +176,14 @@ mswin_init_nhwindows(int *argc, char **argv)
| WC_MAP_MODE | WC_FONT_MESSAGE | WC_FONT_STATUS | WC_FONT_MENU
| WC_FONT_TEXT | WC_FONTSIZ_MESSAGE | WC_FONTSIZ_STATUS
| WC_FONTSIZ_MENU | WC_FONTSIZ_TEXT | WC_VARY_MSGCOUNT,
SET_IN_GAME);
set_in_game);
/* WC2 options */
set_wc2_option_mod_status(WC2_FULLSCREEN | WC2_SOFTKEYBOARD, SET_IN_FILE);
set_wc2_option_mod_status(WC2_FULLSCREEN | WC2_SOFTKEYBOARD, set_in_config);
GetNHApp()->bFullScreen = iflags.wc2_fullscreen;
GetNHApp()->bUseSIP = iflags.wc2_softkeyboard;
set_wc2_option_mod_status(WC2_WRAPTEXT, SET_IN_GAME);
set_wc2_option_mod_status(WC2_WRAPTEXT, set_in_game);
GetNHApp()->bWrapText = iflags.wc2_wraptext;
/* create the main nethack window */

View File

@@ -2068,8 +2068,10 @@ $(O)o_init.o: o_init.c $(HACK_H)
$(O)objects.o: objects.c $(CONFIG_H) $(INCL)\obj.h $(INCL)\objclass.h \
$(INCL)\prop.h $(INCL)\skills.h $(INCL)\color.h
$(O)objnam.o: objnam.c $(HACK_H)
$(O)options.o: options.c $(CONFIG_H) $(INCL)\objclass.h $(INCL)\flag.h \
$(O)options.o: options.c $(INCL)\optlist.h $(CONFIG_H) $(INCL)\objclass.h $(INCL)\flag.h \
$(HACK_H) $(INCL)\tcap.h
$(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) /EP options.c >$(@B).preproc
$(cc) $(cflagsBuild) $(CROSSCOMPILE) $(CROSSCOMPILE_TARGET) -Fo$@ options.c
$(O)pager.o: pager.c $(HACK_H) $(INCL)\dlb.h
$(O)pickup.o: pickup.c $(HACK_H)
$(O)pline.o: pline.c $(HACK_H)

View File

@@ -339,7 +339,7 @@ int *wid, *hgt;
{
*wid = console.width;
*hgt = console.height;
set_option_mod_status("mouse_support", SET_IN_GAME);
set_option_mod_status("mouse_support", set_in_game);
}
void

View File

@@ -209,7 +209,7 @@ test_portable_config(
/* assure_syscf_file(); */
config_error_init(TRUE, tmppath, FALSE);
/* ... and _must_ parse correctly. */
if (read_config_file(tmppath, SET_IN_SYS)
if (read_config_file(tmppath, set_in_sysconf)
&& sysopt.portable_device_paths)
retval = TRUE;
(void) config_error_done();