From: nhmall Date: Mon, 20 Jun 2022 01:02:50 +0000 (-0400) Subject: more Verbose X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=377be376fe7b430e7bc3a3755ea37097673a70f5;p=nethack more Verbose Make verbose a prefix compound option. verbose and !verbose should still work just as the boolean option did. verbose0, verbose1, verbose2, verbose3, verbose4 must be given a decimal value in the config file to set the bits in verbosity_suppressions[0] through verbosity_suppressions[4]. That can be used to suppress any messages represented by the verbosity_values defined in include/hack.h. This also adds a more verbose variation of prinv() where the total count is included in the message (that particular more verbose message can be suppressed with OPTIONS=verbose3:134217728). Verbose(n,x) name Hex Value Decimal Option ------------------------------------------------------------------- interrupt_multi 0x00000001 1 verbose0 use_stethoscope 0x00000002 2 verbose0 Mb_hit 0x00000004 4 verbose0 adjattrib 0x00000008 8 verbose0 ballfall 0x00000010 16 verbose0 use_crystal_ball1 0x00000020 32 verbose0 use_crystal_ball2 0x00000040 64 verbose0 digactualhole1 0x00000080 128 verbose0 digactualhole2 0x00000100 256 verbose0 mdig_tunnel1 0x00000200 512 verbose0 mdig_tunnel2 0x00000400 1024 verbose0 boulder_hits_pool1 0x00000800 2048 verbose0 boulder_hits_pool2 0x00001000 4096 verbose0 drop1 0x00002000 8192 verbose0 drop2 0x00004000 16384 verbose0 drop3 0x00008000 32768 verbose0 go_to_level1 0x00010000 65536 verbose0 go_to_level2 0x00020000 131072 verbose0 go_to_level3 0x00040000 262144 verbose0 rot_corpse 0x00080000 524288 verbose0 getpos1 0x00100000 1048576 verbose0 getpos2 0x00200000 2097152 verbose0 off_msg 0x00400000 4194304 verbose0 on_msg 0x00800000 8388608 verbose0 Blindf_on 0x01000000 16777216 verbose0 dog_eat 0x02000000 33554432 verbose0 dog_invent 0x04000000 67108864 verbose0 dokick 0x08000000 134217728 verbose0 toss_up 0x10000000 268435456 verbose0 consume_tin1 0x20000000 536870912 verbose0 consume_tin2 0x40000000 1073741824 verbose0 doengrave1 0x00000001 1 verbose1 doengrave2 0x00000002 2 verbose1 doengrave3 0x00000004 4 verbose1 explode 0x00000008 8 verbose1 moverock 0x00000010 16 verbose1 still_chewing 0x00000020 32 verbose1 trapmove1 0x00000040 64 verbose1 trapmove2 0x00000080 128 verbose1 trapmove3 0x00000100 256 verbose1 trapmove4 0x00000200 512 verbose1 trapmove5 0x00000400 1024 verbose1 getobj1 0x00000800 2048 verbose1 getobj2 0x00001000 4096 verbose1 doprgold 0x00002000 8192 verbose1 doorlock1 0x00004000 16384 verbose1 doorlock2 0x00008000 32768 verbose1 monpoly1 0x00010000 65536 verbose1 monpoly2 0x00020000 131072 verbose1 mswingsm 0x00040000 262144 verbose1 missmu 0x00080000 524288 verbose1 mswings 0x00100000 1048576 verbose1 wildmiss 0x00200000 2097152 verbose1 gulpmu 0x00400000 4194304 verbose1 explmu 0x00800000 8388608 verbose1 meatmetal1 0x01000000 16777216 verbose1 meatmetal2 0x02000000 33554432 verbose1 meatmetal3 0x04000000 67108864 verbose1 meatmetal4 0x08000000 134217728 verbose1 relobj 0x10000000 268435456 verbose1 ready_weapon 0x20000000 536870912 verbose1 wield_tool 0x40000000 1073741824 verbose1 meatobj1 0x00000001 1 verbose2 meatobj2 0x00000002 2 verbose2 meatobj3 0x00000004 4 verbose2 meatobj4 0x00000008 8 verbose2 meatcorpse1 0x00000010 16 verbose2 meatcorpse2 0x00000020 32 verbose2 mpickgold 0x00000040 64 verbose2 mpickstuff 0x00000080 128 verbose2 setmangry 0x00000100 256 verbose2 mb_trapped 0x00000200 512 verbose2 m_move1 0x00000400 1024 verbose2 m_move2 0x00000800 2048 verbose2 m_move3 0x00001000 4096 verbose2 m_move4 0x00002000 8192 verbose2 m_move5 0x00004000 16384 verbose2 thitu1 0x00008000 32768 verbose2 thitu2 0x00010000 65536 verbose2 m_throw 0x00020000 131072 verbose2 handler_menustyle 0x00040000 262144 verbose2 handler_autounlock 0x00080000 524288 verbose2 handler_msg_window 0x00100000 1048576 verbose2 handler_whatis_coord1 0x00200000 2097152 verbose2 handler_whatis_coord2 0x00400000 4194304 verbose2 dolook 0x00800000 8388608 verbose2 describe_decor1 0x01000000 16777216 verbose2 describe_decor2 0x02000000 33554432 verbose2 loot_mon 0x04000000 67108864 verbose2 dotip 0x08000000 134217728 verbose2 polymon 0x10000000 268435456 verbose2 teleds 0x20000000 536870912 verbose2 level_tele 0x40000000 1073741824 verbose2 ghost_from_bottle 0x00000001 1 verbose3 dodip1 0x00000002 2 verbose3 dodip2 0x00000004 4 verbose3 dodip3 0x00000008 8 verbose3 intemple 0x00000010 16 verbose3 doread1 0x00000020 32 verbose3 doread2 0x00000040 64 verbose3 doread3 0x00000080 128 verbose3 doread4 0x00000100 256 verbose3 doread5 0x00000200 512 verbose3 doread6 0x00000400 1024 verbose3 doread7 0x00000800 2048 verbose3 drop_boulder_on_player0x00001000 4096 verbose3 do_genocide 0x00002000 8192 verbose3 call_kops1 0x00004000 16384 verbose3 call_kops2 0x00008000 32768 verbose3 call_kops3 0x00010000 65536 verbose3 erode_obj1 0x00020000 131072 verbose3 erode_obj2 0x00040000 262144 verbose3 erode_obj3 0x00080000 524288 verbose3 trapeffect_rocktrap 0x00100000 1048576 verbose3 climb_pit 0x00200000 2097152 verbose3 drown 0x00400000 4194304 verbose3 mon_adjust_speed 0x00800000 8388608 verbose3 hit 0x01000000 16777216 verbose3 miss 0x02000000 33554432 verbose3 makewish 0x04000000 67108864 verbose3 prinv 0x08000000 134217728 verbose3 do_attack 0x00000001 1 verbose4 known_hitum 0x00000002 2 verbose4 hmon_hitmon1 0x00000004 4 verbose4 hmon_hitmon2 0x00000008 8 verbose4 mhitm_ad_tlpt 0x00000010 16 verbose4 mhitm_ad_wrap1 0x00000020 32 verbose4 mhitm_ad_wrap2 0x00000040 64 verbose4 mhitm_ad_dgst 0x00000080 128 verbose4 damageum 0x00000100 256 verbose4 missum 0x00000200 512 verbose4 hmonas1 0x00000400 1024 verbose4 hmonas2 0x00000800 2048 verbose4 hmonas3 0x00001000 4096 verbose4 hmonas4 0x00002000 8192 verbose4 passive 0x00004000 16384 verbose4 flash_hits_mon 0x00008000 32768 verbose4 --- 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 /* **********************************