From 6dadde4acf2d5e34a2a952d70bb0f47df6eb0ea1 Mon Sep 17 00:00:00 2001 From: backwardsEric Date: Wed, 4 Sep 2019 10:07:32 -0700 Subject: [PATCH] Modified so that zapping an unidentified wand from the pack will deduct the charge from the correct item. --- src/cmd-zapwand.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/cmd-zapwand.c b/src/cmd-zapwand.c index 8396a446..a4ef4047 100644 --- a/src/cmd-zapwand.c +++ b/src/cmd-zapwand.c @@ -321,6 +321,7 @@ void do_cmd_aim_wand_aux(INVENTORY_IDX item) DEPTH lev; int ident, chance; DIRECTION dir; + BIT_FLAGS inventory_flags; object_type *o_ptr; bool old_target_pet = target_pet; @@ -402,7 +403,14 @@ void do_cmd_aim_wand_aux(INVENTORY_IDX item) sound(SOUND_ZAP); ident = wand_effect(o_ptr->sval, dir, FALSE, FALSE); - p_ptr->update |= (PU_COMBINE | PU_REORDER); + /* + * Temporarily remove the flags for updating the inventory so + * gain_exp() does not reorder the inventory before the charge + * is deducted from the wand. + */ + inventory_flags = (PU_COMBINE | PU_REORDER | + (p_ptr->update & PU_AUTODESTROY)); + p_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY); if (!(object_is_aware(o_ptr))) { @@ -422,7 +430,7 @@ void do_cmd_aim_wand_aux(INVENTORY_IDX item) } p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); - + p_ptr->update |= inventory_flags; /* Use a single charge */ o_ptr->pval--; -- 2.20.1 (Apple Git-117)