From b5acfc5c3f36d3b979112f2c7d104a5116ad2133 Mon Sep 17 00:00:00 2001 From: Pasi Kallinen Date: Thu, 4 Aug 2022 09:48:58 +0300 Subject: [PATCH] New options: swap symset to roguesymset on rogue level --- src/options.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/src/options.c b/src/options.c index 29c60ef7c..af149a928 100644 --- a/src/options.c +++ b/src/options.c @@ -302,6 +302,7 @@ static void free_one_menu_coloring(int); static int count_menucolors(void); static boolean parse_role_opts(int, boolean, const char *, char *, char **); +static int get_option_index(const char *); static unsigned int longest_option_name(int, int); static void doset_add_menu(winid, const char *, int, int); static int handle_add_list_remove(const char *, int); @@ -7719,6 +7720,18 @@ longest_option_name(int startpass, int endpass) return longest_name_len; } +static int +get_option_index(const char *optname) +{ + int i; + + for (i = 0; allopt[i].name != 0; i++) + if (!strcmp(optname, allopt[i].name)) + return i; + + return -1; +} + /* #options - the user friendly version */ int doset_simple(void) @@ -7776,10 +7789,18 @@ rerun: const char *value = "unknown"; int reslt = optn_err; char buf2[BUFSZ]; + int k = i; + + if (allopt[i].optfn == optfn_symset && Is_rogue_level(&u.uz)) { + k = get_option_index("roguesymset"); + if (k == -1) + k = i; + name = allopt[k].name; + } buf2[0] = '\0'; - if (allopt[i].optfn) - reslt = (*allopt[i].optfn)(allopt[i].idx, get_val, + if (allopt[k].optfn) + reslt = (*allopt[k].optfn)(allopt[k].idx, get_val, FALSE, buf2, empty_optstr); if (reslt == optn_ok && buf2[0]) value = (const char *) buf2;