more obufs - two-handed weapon in "hands"

Pointed out by entrez:  prevent doname() from consuming two obuf[]
buffers when it constructs the plural of "hand" while formatting a
wielded two-handed weapon.

Since only one such item should be able to occur in any list of
objects, it is not likely to be the cause of any message oddities
that might happen when a cached value is in a formatting buffer gets
re-used too soon.  However, not releasing a second buffer right away
prevents an attempt to release the first one from succeeding because
it won't be the last one allocated anymore, so some buffer churn was
happening.
This commit is contained in:
PatR
2023-08-16 18:16:11 -07:00
parent f625d2efcf
commit 78607a37a5

View File

@@ -1394,9 +1394,12 @@ doname_base(
Strcat(bp, " (wielded)");
} else {
const char *hand_s = body_part(HAND);
char *obufp, handsbuf[40];
if (bimanual(obj))
hand_s = makeplural(hand_s);
if (bimanual(obj)) {
hand_s = strcpy(handsbuf, obufp = makeplural(hand_s));
releaseobuf(obufp);
}
/* note: Sting's glow message, if added, will insert text
in front of "(weapon in hand)"'s closing paren */
Sprintf(eos(bp), " (%s%s in %s%s)",