nethack --windowtype=badchoice

If you used the commandline to ask for an interface that doesn't exist
or isn't available, you'd get complaints about it not being recognized
twice.  First before any other options, then again after regular
option processing has taken place.  Clear the command line setting if
the first attempt gets rejected so that it won't be retried later and
be rejected again.  Probably the game should just quit if setting the
interface fails.
This commit is contained in:
PatR
2023-01-01 17:35:06 -08:00
parent 8755b3bb53
commit dc6ad9266b

View File

@@ -6525,10 +6525,17 @@ initoptions_init(void)
set it again in initoptions_finish() so that NETHACKOPTIONS and
.nethrackrc can't override it (command line takes precedence) */
if (gc.cmdline_windowsys) {
nmcpy(gc.chosen_windowtype, gc.cmdline_windowsys, WINTYPELEN);
config_error_init(FALSE, "command line", FALSE);
choose_windows(gc.cmdline_windowsys);
config_error_done();
/* do not free gc.cmdline_windowsys yet */
/* do not free gc.cmdline_windowsys yet unless it was rejected;
keeping it in that situation would complain about it twice */
if (!windowprocs.name
|| strcmpi(windowprocs.name, gc.cmdline_windowsys) != 0) {
free((genericptr_t) gc.cmdline_windowsys),
gc.cmdline_windowsys = NULL;
}
}
#ifdef ENHANCED_SYMBOLS