From dc6ad9266b0bcd9f48183cb7db57e11cdd1766b5 Mon Sep 17 00:00:00 2001 From: PatR Date: Sun, 1 Jan 2023 17:35:06 -0800 Subject: [PATCH] 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. --- src/options.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/options.c b/src/options.c index 11d294066..312395258 100644 --- a/src/options.c +++ b/src/options.c @@ -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