diff --git a/doc/fixes3-7-0.txt b/doc/fixes3-7-0.txt index 23782811f..f8a776ba8 100644 --- a/doc/fixes3-7-0.txt +++ b/doc/fixes3-7-0.txt @@ -1422,6 +1422,10 @@ if hero is on scroll of scare monster or Elbereth, werecreature switching from "n ESC c" wasn't treated as "n M-c" because reading the 'n' changed program_state.input_state from commandInp to otherInp, preventing special ESC handling; not an issue when number_pad was Off +a 3.6 fix to avoid a potential "object lost" panic when drinking potions had + unintended side-effect of making used up potions on shop's bill become + separate bill entries all with count 1 despite having come from same + unpaid stack; affected Ix inventory listing and itemized shop billing Fixes to 3.7.0-x General Problems Exposed Via git Repository diff --git a/src/potion.c b/src/potion.c index d97f274a9..5274e904d 100644 --- a/src/potion.c +++ b/src/potion.c @@ -570,19 +570,29 @@ dodrink(void) if (!otmp) return ECMD_CANCEL; - /* quan > 1 used to be left to useup(), but we need to force - the current potion to be unworn, and don't want to do - that for the entire stack when starting with more than 1. - [Drinking a wielded potion of polymorph can trigger a shape - change which causes hero's weapon to be dropped. In 3.4.x, - that led to an "object lost" panic since subsequent useup() - was no longer dealing with an inventory item. Unwearing - the current potion is intended to keep it in inventory.] */ - if (otmp->quan > 1L) { - otmp = splitobj(otmp, 1L); - otmp->owornmask = 0L; /* rest of original stuck unaffected */ - } else if (otmp->owornmask) { - remove_worn_item(otmp, FALSE); + /* + * 3.6: quan > 1 used to be left to useup(), but we need to + * force the current potion to be unworn, and don't want to do + * that for the entire stack when starting with more than 1. + * [Drinking a wielded potion of polymorph can trigger a shape + * change which causes hero's weapon to be dropped. In 3.4.x, + * that led to an "object lost" panic since subsequent useup() + * was no longer dealing with an inventory item. Unwearing + * the current potion is intended to keep it in inventory.] + * + * 3.7: switch back to relying on useup() unless the object is + * actually worn. Otherwise drinking a stack of unpaid potions + * one by one in a shop makes each one a separate used-up item + * for 'Ix' invent display and for itemized shop billing instead + * of having a single stack with quantity greater than 1. + */ + if (otmp->owornmask) { + if (otmp->quan > 1L) { + otmp = splitobj(otmp, 1L); + otmp->owornmask = 0L; /* rest of original stack is unaffected */ + } else { + remove_worn_item(otmp, FALSE); + } } otmp->in_use = TRUE; /* you've opened the stopper */