diff --git a/include/hack.h b/include/hack.h index 040cb7a37..a3aa8ae6c 100644 --- a/include/hack.h +++ b/include/hack.h @@ -1,4 +1,4 @@ -/* NetHack 3.7 hack.h $NHDT-Date: 1601595709 2020/10/01 23:41:49 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.141 $ */ +/* NetHack 3.7 hack.h $NHDT-Date: 1652861829 2022/05/18 08:17:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.181 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Pasi Kallinen, 2017. */ /* NetHack may be freely redistributed. See license for details. */ @@ -479,7 +479,9 @@ typedef uint32_t mmflags_nht; /* makemon MM_ flags */ /* get_count flags */ #define GC_NOFLAGS 0 #define GC_SAVEHIST 1 /* save "Count: 123" in message history */ -#define GC_ECHOFIRST 2 /* echo "Count: 1" even when there's only one digit */ +#define GC_CONDHIST 2 /* save "Count: N" in message history unless the + * first digit is passed in and N matches it */ +#define GC_ECHOFIRST 4 /* echo "Count: 1" even when there's only one digit */ /* rloc() flags */ #define RLOC_NONE 0x00 diff --git a/src/cmd.c b/src/cmd.c index 99804960c..642c4e3d8 100644 --- a/src/cmd.c +++ b/src/cmd.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 cmd.c $NHDT-Date: 1652719274 2022/05/16 16:41:14 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.564 $ */ +/* NetHack 3.7 cmd.c $NHDT-Date: 1652861829 2022/05/18 08:17:09 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.565 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -5152,10 +5152,13 @@ get_count( { char qbuf[QBUFSZ]; int key; - long cnt = 0L; + long cnt = 0L, first = inkey ? (long) (inkey - '0') : 0L; boolean backspaced = FALSE, showzero = TRUE, /* should "Count: 123" go into message history? */ historicmsg = (gc_flags & GC_SAVEHIST) != 0, + /* put "Count: N" into mesg hist unless N is the same as the + [first digit] value passed in via 'inkey' */ + conditionalmsg = (gc_flags & GC_CONDHIST) != 0, /* normally "Count: 12" isn't echoed until the second digit */ echoalways = (gc_flags & GC_ECHOFIRST) != 0; /* this should be done in port code so that we have erase_char @@ -5206,7 +5209,7 @@ get_count( } } - if (historicmsg) { + if (historicmsg || (conditionalmsg && *count != first)) { Sprintf(qbuf, "Count: %ld ", *count); (void) key2txt((uchar) key, eos(qbuf)); putmsghistory(qbuf, FALSE); diff --git a/src/invent.c b/src/invent.c index 1101be42d..3fe7e29f5 100644 --- a/src/invent.c +++ b/src/invent.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 invent.c $NHDT-Date: 1652831520 2022/05/17 23:52:00 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.388 $ */ +/* NetHack 3.7 invent.c $NHDT-Date: 1652861830 2022/05/18 08:17:10 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.389 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Derek S. Ray, 2015. */ /* NetHack may be freely redistributed. See license for details. */ @@ -4831,7 +4831,16 @@ adjust_split(void) /* got first digit, get more until next non-digit (except for backspace/delete which will take away most recent digit and keep going; we expect one of ' ', '\n', or '\r') */ - let = get_count(NULL, dig, LARGEST_INT, &splitamount, GC_ECHOFIRST); + let = get_count(NULL, dig, 0L, &splitamount, + /* yn_function() added the first digit to the + prompt when recording message history; have + get_count() display "Count: N" when waiting + for additional digits (ordinarily that won't be + shown until a second digit is entered) and also + add "Count: N" to message history if more than + one digit gets entered or the original N is + deleted and replaced with different digit */ + GC_ECHOFIRST | GC_CONDHIST); /* \033 is in quitchars[] so we need to check for it separately in order to treat it as cancel rather than as accept */ if (!let || let == '\033' || !index(quitchars, let)) {