]> granicus.if.org Git - nethack/commit
February 2020 options.c overhaul
authornhmall <nhmall@nethack.org>
Wed, 26 Feb 2020 05:19:08 +0000 (00:19 -0500)
committernhmall <nhmall@nethack.org>
Wed, 26 Feb 2020 05:24:37 +0000 (00:24 -0500)
commit68fdc3bbcb0e3c106dc5052fdd3ef3b5b66ca8c6
tree5825b2a5e54aec7b2130803a759a542c68bdc67d
parenta7c143c8f9452030f9fce5886706f800d01166b6
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
21 files changed:
doc/window.doc
include/botl.h
include/decl.h
include/extern.h
include/global.h
include/hack.h
include/optlist.h [new file with mode: 0644]
src/display.c
src/files.c
src/options.c
sys/unix/Makefile.src
sys/wince/mswproc.c
sys/winnt/Makefile.msc
sys/winnt/nttty.c
sys/winnt/windmain.c
win/X11/winX.c
win/curses/cursinit.c
win/curses/cursmain.c
win/gem/wingem.c
win/tty/wintty.c
win/win32/mswproc.c