-/* 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. */
*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")) {
-/* 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. */
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 {
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.",
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");
}
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