fix odd messages caused by buffer re-use

Reported and diagnosed by entrez:
"The <mon> yanks <two-handed weapon> from your corpses!"

It became unwielded and that triggered a perm_invent update and
such updates reformat entire inventory, so if that contains a dozen
or more items it will use all the obuf[] static buffers as least
once.  In this case, the bullwhip code had plural of "hand" in one
of those buffers and by the time it delivered the message which
used that, the value had been clobbered.

As the diagnosis mentioned, it can be tricky to reproduce since
either &obuf[0] or &obuf[PREFIX] might be used and if the value
being clobbered didn't overlap, the effect wasn't noticeable.

Instead of fixing the bullwhip message, this changes inventory
display so that it should no longer churn through all the buffers.

It also adds a fixes entry for #K3401, which was already fixed for
3.7 but I hadn't been able to reproduce it for 3.6.x (which I now
blame on the PREFIX trickiness).
This commit is contained in:
PatR
2021-09-15 20:56:06 -07:00
parent fde51720f4
commit e43ec0cef1
4 changed files with 103 additions and 24 deletions

View File

@@ -607,6 +607,16 @@ yet another fix for display problems during restore: if game is saved while
instead it would access steed pointer before that has been set up
resistances gained from worn or wielded items also protect hero's inventory
non-metallic gloves protect worn rings from shock
message "Oops! food rations out of your grasp!" occurred due to perm_invent
in mid-operation overwriting all of xname's/doname's obufs; fixed by
having hold_another_object() defer perm_invent update til done with
all its args (so fixed as a side-effect of "spurious add and remove
perm_invent updates" above, prior to being reported as #K3401)
similar "The ogre lord yanks Cleaver from your corpses!" due to caching the
result from makeplural(body_part(HAND)) then having a perm_invent
update clobber that; fixed by having inventory display release the
obuf used for each item so that the same one will be reused for the
next item, to avoid churning through the whole pool of obufs
Fixes to 3.7.0-x Problems that Were Exposed Via git Repository