container_impact_dmg

A post-3.4.3 change made the contents of thrown (or dropped while
levitating) containers subject to breakage, but it had sequence issues.
When something was thrown from outside a shop (or from its doorway or
entry spot) and arrived inside, the shopkeeper was taking possession too
soon, charging the hero for any broken contents, and then going ballistic
(summoning kops and attacking) because the hero was outside the shop while
owing money.  We need to break contents before shk claims ownership, which
turned out to be trickier than it sounds since it has to occur after any
item-hits-floor message if such feedback is given.

    Also, clear the container's contents-known flag when contents break.
Conceivably it should stay set when there is only one item, since hearing
something break could only be that item, but this resets container->cknown
unconditionally if anything inside breaks.
This commit is contained in:
nethack.rankin
2012-05-05 23:26:26 +00:00
parent 07f6cd66d4
commit 669c2ab560
4 changed files with 41 additions and 16 deletions

View File

@@ -511,8 +511,9 @@ register struct obj *obj;
return(1);
}
/* Called in several places - may produce output */
/* eg ship_object() and dropy() -> sellobj() both produce output */
/* dropx - take dropped item out of inventory;
called in several places - may produce output
(eg ship_object() and dropy() -> sellobj() both produce output) */
void
dropx(obj)
register struct obj *obj;
@@ -532,9 +533,19 @@ register struct obj *obj;
dropy(obj);
}
/* dropy - put dropped object at its destination; called from lots of places */
void
dropy(obj)
register struct obj *obj;
struct obj *obj;
{
dropz(obj, FALSE);
}
/* dropz - really put dropped object at its destination... */
void
dropz(obj, with_impact)
struct obj *obj;
boolean with_impact;
{
if (obj == uwep) setuwep((struct obj *)0);
if (obj == uquiver) setuqwep((struct obj *)0);
@@ -580,6 +591,8 @@ register struct obj *obj;
}
} else {
place_object(obj, u.ux, u.uy);
if (with_impact)
container_impact_dmg(obj, u.ux, u.uy);
if (obj == uball)
drop_ball(u.ux,u.uy);
else if (level.flags.has_shop)