From: PatR Date: Sun, 31 Jan 2021 00:42:36 +0000 (-0800) Subject: squeaky board message grammar bit X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=aacea63f7c86198cec2c306b6888b69469fe10ff;p=nethack squeaky board message grammar bit "You hear a [BCDG] note squeak in the distance" is ok, but "you hear a [AEF] note squeak in the distance" isn't. Squeaky board notes already had correct a/an handling but that particular message explicitly suppressed it. --- diff --git a/doc/fixes37.0 b/doc/fixes37.0 index 1a3f56d2e..0ac163319 100644 --- a/doc/fixes37.0 +++ b/doc/fixes37.0 @@ -1,4 +1,4 @@ -NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.437 $ $NHDT-Date: 1611882611 2021/01/29 01:10:11 $ +NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.438 $ $NHDT-Date: 1612053751 2021/01/31 00:42:31 $ General Fixes and Modified Features ----------------------------------- @@ -377,6 +377,7 @@ spells that require a target spot rather than a direction (like skilled in the message window while the spell was being performed prevent wish request "death wand" from matching Death monster and producing a random wand instead of a wand of death +grammar bit: "you hear a [AEF] note squeak in the distance" (should be "an") Fixes to 3.7.0-x Problems that Were Exposed Via git Repository diff --git a/src/objnam.c b/src/objnam.c index 244814a9a..b349af529 100644 --- a/src/objnam.c +++ b/src/objnam.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 objnam.c $NHDT-Date: 1611882005 2021/01/29 01:00:05 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.312 $ */ +/* NetHack 3.7 objnam.c $NHDT-Date: 1612053751 2021/01/31 00:42:31 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.313 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2011. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1675,8 +1675,8 @@ just_an(char *outbuf, const char *str) *outbuf = '\0'; c0 = lowc(*str); - if (!str[1]) { - /* single letter; might be used for named fruit */ + if (!str[1] || str[1] == ' ') { + /* single letter; might be used for named fruit or a musical note */ Strcpy(outbuf, index("aefhilmnosx", c0) ? "an " : "a "); } else if (!strncmpi(str, "the ", 4) || !strcmpi(str, "molten lava") || !strcmpi(str, "iron bars") || !strcmpi(str, "ice")) { diff --git a/src/trap.c b/src/trap.c index 15955a08e..d3718cad0 100644 --- a/src/trap.c +++ b/src/trap.c @@ -1,4 +1,4 @@ -/* NetHack 3.7 trap.c $NHDT-Date: 1611182256 2021/01/20 22:37:36 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.398 $ */ +/* NetHack 3.7 trap.c $NHDT-Date: 1612053752 2021/01/31 00:42:32 $ $NHDT-Branch: NetHack-3.7 $:$NHDT-Revision: 1.402 $ */ /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */ /*-Copyright (c) Robert Patrick Rankin, 2013. */ /* NetHack may be freely redistributed. See license for details. */ @@ -1132,7 +1132,8 @@ trapeffect_sqky_board( seetrap(trap); pline("A board beneath you %s%s%s.", Deaf ? "vibrates" : "squeaks ", - Deaf ? "" : trapnote(trap, 0), Deaf ? "" : " loudly"); + Deaf ? "" : trapnote(trap, FALSE), + Deaf ? "" : " loudly"); wake_nearby(); } } else { @@ -1144,7 +1145,7 @@ trapeffect_sqky_board( if (in_sight) { if (!Deaf) { pline("A board beneath %s squeaks %s loudly.", - mon_nam(mtmp), trapnote(trap, 0)); + mon_nam(mtmp), trapnote(trap, FALSE)); seetrap(trap); } else { pline("%s stops momentarily and appears to cringe.", @@ -1155,7 +1156,7 @@ trapeffect_sqky_board( int range = couldsee(mtmp->mx, mtmp->my) /* 9 or 5 */ ? (BOLT_LIM + 1) : (BOLT_LIM - 3); - You_hear("a %s squeak %s.", trapnote(trap, 1), + You_hear("%s squeak %s.", trapnote(trap, FALSE), (distu(mtmp->mx, mtmp->my) <= range * range) ? "nearby" : "in the distance"); } @@ -2453,19 +2454,19 @@ dotrap(register struct trap* trap, unsigned int trflags) static char * trapnote(struct trap* trap, boolean noprefix) { - static char tnbuf[12]; - const char *tn, - *tnnames[12] = { "C note", "D flat", "D note", "E flat", - "E note", "F note", "F sharp", "G note", - "G sharp", "A note", "B flat", "B note" }; + static const char *const tnnames[] = { + "C note", "D flat", "D note", "E flat", + "E note", "F note", "F sharp", "G note", + "G sharp", "A note", "B flat", "B note", + }; + static char tnbuf[12]; /* result buffer */ + const char *tn; tnbuf[0] = '\0'; tn = tnnames[trap->tnote]; if (!noprefix) - Sprintf(tnbuf, "%s ", - (*tn == 'A' || *tn == 'E' || *tn == 'F') ? "an" : "a"); - Sprintf(eos(tnbuf), "%s", tn); - return tnbuf; + (void) just_an(tnbuf, tn); + return strcat(tnbuf, tn); } static int