From 7e96026b44645617d9ca4e7a4e014dc3a5834eb9 Mon Sep 17 00:00:00 2001 From: Michael Meyer Date: Fri, 16 Sep 2022 22:50:39 -0400 Subject: [PATCH] Fix: impossible from splitting named stack on bill Trying to split an unpaid stack of named items in a shop, with perm_invent enabled, would cause an impossible 'unpaid_cost: object wasn't on any bill' because copy_oextra -> oname triggered an inventory update while the newly created split stack was marked unpaid but before the billing information had been split to match. Defer the copy_oextra call until the billing info has already been split. --- src/mkobj.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mkobj.c b/src/mkobj.c index 7de478aee..d23c2c0df 100644 --- a/src/mkobj.c +++ b/src/mkobj.c @@ -423,11 +423,11 @@ splitobj(struct obj *obj, long num) be tracking the original */ if (otmp->where == OBJ_LUAFREE) otmp->where = OBJ_FREE; + if (obj->unpaid) + splitbill(obj, otmp); copy_oextra(otmp, obj); if (has_omid(otmp)) free_omid(otmp); /* only one association with m_id*/ - if (obj->unpaid) - splitbill(obj, otmp); if (obj->timed) obj_split_timers(obj, otmp); if (obj_sheds_light(obj))