fix #H6713 - unpaid_cost: object not on any bill
Stealing a shop object from outside the shop with a grappling hook
would result in that item being left marked 'unpaid' after the shop's
bill was treated as being bought and not yet paid for. This led to
"unpaid_cost: object wasn't on any bill" every time inventory was
examined. The problem was caused by handling the shop robbery after
removing the object from the floor but before adding it to inventory,
so it couldn't be found to have its unpaid bit cleared.
When investigating this I came across a more severe bug: if the hero
had never entered the shop, the shopkeeper's bill wasn't initialized
properly and add_one_tobill() could crash while attempting to execute
bp->bo_id = obj->o_id;
because 'bp' was Null.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
/* NetHack 3.6 shk.c $NHDT-Date: 1464138042 2016/05/25 01:00:42 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.132 $ */
|
||||
/* NetHack 3.6 shk.c $NHDT-Date: 1515144230 2018/01/05 09:23:50 $ $NHDT-Branch: NetHack-3.6.0 $:$NHDT-Revision: 1.136 $ */
|
||||
/* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
|
||||
/* NetHack may be freely redistributed. See license for details. */
|
||||
|
||||
@@ -2354,6 +2354,12 @@ struct monst *shkp;
|
||||
return;
|
||||
}
|
||||
|
||||
/* normally bill_p gets set up whenever you enter the shop, but obj
|
||||
might be going onto the bill because hero just snagged it with
|
||||
a grappling hook from outside without ever having been inside */
|
||||
if (!eshkp->bill_p)
|
||||
eshkp->bill_p = &(eshkp->bill[0]);
|
||||
|
||||
bct = eshkp->billct;
|
||||
bp = &(eshkp->bill_p[bct]);
|
||||
bp->bo_id = obj->o_id;
|
||||
|
||||
Reference in New Issue
Block a user