diff --git a/include/hack.h b/include/hack.h index 2b276606b..7d2c9a115 100644 --- a/include/hack.h +++ b/include/hack.h @@ -837,7 +837,8 @@ enum verbosity_values { vb3hit = 0x01000000, vb3miss = 0x02000000, vb3makewish = 0x04000000, - /* 4 available bits*/ + vb3prinv = 0x08000000, + /* 3 available bits*/ vb4do_attack = 0x00000001, vb4known_hitum = 0x00000002, diff --git a/include/optlist.h b/include/optlist.h index b0a88c3b8..b19b3007b 100644 --- a/include/optlist.h +++ b/include/optlist.h @@ -527,8 +527,10 @@ opt_##a, "use_truecolour", &iflags.use_truecolor) NHOPTC(vary_msgcount, 20, opt_in, set_gameview, No, Yes, No, No, NoAlias, "show more old messages at a time") +#if defined(NO_VERBOSE_GRANULARITY) NHOPTB(verbose, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias, &flags.verbose) +#endif #ifdef MSDOS NHOPTC(video, 20, opt_in, set_in_config, No, Yes, No, No, NoAlias, "method of video updating") @@ -599,7 +601,10 @@ opt_##a, NHOPTP(IBM_, 0, opt_in, set_hidden, No, No, Yes, No, NoAlias, "prefix for old micro IBM_ options") #endif /* MICRO */ - +#if !defined(NO_VERBOSE_GRANULARITY) + NHOPTP(verbose, 0, opt_in, set_in_game, Yes, Yes, Yes, Yes, NoAlias, + "suppress verbose messages") +#endif #undef NoAlias #undef NHOPTB #undef NHOPTC diff --git a/src/invent.c b/src/invent.c index 29bcc6a66..d8b600bc7 100644 --- a/src/invent.c +++ b/src/invent.c @@ -2498,10 +2498,19 @@ obj_to_let(struct obj *obj) void prinv(const char *prefix, struct obj *obj, long quan) { + boolean total_of = (quan && (quan < obj->quan)); + char totalbuf[QBUFSZ]; + if (!prefix) prefix = ""; - pline("%s%s%s", prefix, *prefix ? " " : "", - xprname(obj, (char *) 0, obj_to_let(obj), TRUE, 0L, quan)); + + totalbuf[0] = '\0'; + if (total_of) + Snprintf(totalbuf, sizeof totalbuf, + " (%ld in total).", obj->quan); + pline("%s%s%s%s", prefix, *prefix ? " " : "", + xprname(obj, (char *) 0, obj_to_let(obj), !total_of, 0L, quan), + Verbose(3, prinv) ? totalbuf : ""); } DISABLE_WARNING_FORMAT_NONLITERAL diff --git a/src/options.c b/src/options.c index ed14c3dbf..3f34e20df 100644 --- a/src/options.c +++ b/src/options.c @@ -324,6 +324,9 @@ static int handler_whatis_filter(void); static int handler_autopickup_exception(void); static int handler_menu_colors(void); static int handler_msgtype(void); +#ifndef NO_VERBOSE_GRANULARITY +static int handler_verbose(int optidx); +#endif static boolean is_wc_option(const char *); static boolean wc_supported(const char *); @@ -348,7 +351,7 @@ boolean parseoptions(register char *opts, boolean tinitial, boolean tfrom_file) { char *op; - boolean negated, got_match = FALSE; + boolean negated, got_match = FALSE, pfx_match = FALSE; #if 0 boolean has_val = FALSE; #endif @@ -408,7 +411,7 @@ parseoptions(register char *opts, boolean tinitial, boolean tfrom_file) if (allopt[i].pfx) { if (str_start_is(opts, allopt[i].name, TRUE)) { matchidx = i; - got_match = TRUE; + got_match = pfx_match = TRUE; } } #if 0 /* this prevents "boolopt:True" &c */ @@ -514,6 +517,17 @@ parseoptions(register char *opts, boolean tinitial, boolean tfrom_file) if (optresult == optn_silenterr) return FALSE; + if (pfx_match && optresult == optn_err) { + char pfxbuf[BUFSZ], *pfxp; + + if (opts) { + Snprintf(pfxbuf, sizeof pfxbuf, "%s", opts); + if ((pfxp = index(pfxbuf, ':')) != 0) + *pfxp = '\0'; + config_error_add("bad option suffix variation '%s'", pfxbuf); + } + return FALSE; + } if (got_match && optresult == optn_err) return FALSE; if (optresult == optn_ok) @@ -4256,6 +4270,62 @@ pfxfn_IBM_(int optidx UNUSED, int req, boolean negated UNUSED, } #endif +#ifndef NO_VERBOSE_GRANULARITY +int pfxfn_verbose(int optidx UNUSED, int req, boolean negated, + char *opts, char *op) +{ + long ltmp = 0; + int reslt; + char *p; + boolean param_optional = FALSE; + + if (req == do_init) { + return optn_ok; + } + if (req == do_set) { + if (opts) { + if (!strncmp(opts, "verbose", 7)) { + p = index("01234", *(opts + 7)); + if (p && *p == '\0') /* plain verbose, not verboseN */ + param_optional = TRUE; + if ((op = string_for_opt(opts, param_optional)) != empty_optstr) { + ltmp = atol(op); + int idx; + + if (p && (*p != '\0')) { + idx = *p - '0'; + if (idx >= 0 && idx < vb_elements) + verbosity_suppressions[idx] = ltmp; + return optn_ok; + } + } else { + if (param_optional) { + /* indicates plain verbose, not verboseN */ + flags.verbose = (negated ? 0 : 1); + return optn_ok; + } + } + } + } + return optn_err; + } + if (req == get_val) { + if (!opts) + return optn_err; + Sprintf(opts, "%s,%ld,%ld,%ld,%ld,%ld", flags.verbose ? "On" : "Off", + verbosity_suppressions[0], verbosity_suppressions[1], + verbosity_suppressions[2], verbosity_suppressions[3], + verbosity_suppressions[4]); + return optn_ok; + } + if (req == do_handler) { + reslt = handler_verbose(optidx); + return optn_ok; + } + return optn_ok; +} +#endif + /* * General boolean option handler * (Use optidx to reference the specific option) @@ -5407,6 +5477,74 @@ handler_msgtype(void) return optn_ok; } +#ifndef NO_VERBOSE_GRANULARITY + +DISABLE_WARNING_FORMAT_NONLITERAL + +static int +handler_verbose(int optidx) +{ + winid tmpwin; + anything any; + char buf[BUFSZ]; + int pick_cnt; + int i; + menu_item *picks = (menu_item *) 0; + static const char *const vbstrings[] = { + " verbose toggle (currently %s)", + " verbose_suppressor[%d] =%08X", + }; + char vbbuf[QBUFSZ]; + + tmpwin = create_nhwindow(NHW_MENU); + start_menu(tmpwin, MENU_BEHAVE_STANDARD); + any = cg.zeroany; + Snprintf(vbbuf, sizeof vbbuf, vbstrings[0], flags.verbose ? "On" : "Off"); + any.a_int = 1; + add_menu(tmpwin, &nul_glyphinfo, &any, 'a', 0, ATR_NONE, + vbbuf, MENU_ITEMFLAGS_NONE); + for (i = 0; i < vb_elements; i++) { + Snprintf(vbbuf, sizeof vbbuf, vbstrings[1], i, + verbosity_suppressions[i]); + any.a_int = i + 2; + add_menu(tmpwin, &nul_glyphinfo, &any, 'b' + i, 0, + ATR_NONE, vbbuf, MENU_ITEMFLAGS_NONE); + } + end_menu(tmpwin, "Select verbosity choices:"); + + pick_cnt = select_menu(tmpwin, PICK_ANY, &picks); + destroy_nhwindow(tmpwin); + if (pick_cnt > 0) { + int j; + /* PICK_ANY, with one preselected entry (ATR_NONE) which + should be excluded if any other choices were picked */ + for (i = 0; i < pick_cnt; ++i) { + char abuf[BUFSZ]; + j = picks[i].item.a_int - 2; + if (j < 0) { + flags.verbose = !flags.verbose; + } else { + Sprintf(buf, + "Set verbose_suppressor[%d] (%ld) to what new decimal value ?", + j, verbosity_suppressions[j]); + abuf[0] = '\0'; + getlin(buf, abuf); + if (abuf[0] == '\033') + continue; + Sprintf(buf, "%s%d:", allopt[optidx].name, j); + (void) strncat(eos(buf), abuf, (sizeof buf - 1 - strlen(buf))); + /* pass the buck */ + (void) parseoptions(buf, TRUE, TRUE); + } + } + free((genericptr_t) picks), picks = (menu_item *) 0; + } + return optn_ok; +} + +RESTORE_WARNING_FORMAT_NONLITERAL + +#endif /* **********************************