diff --git a/src/cmd-eat.c b/src/cmd-eat.c index 9a0b7a49..6227bd4b 100644 --- a/src/cmd-eat.c +++ b/src/cmd-eat.c @@ -22,6 +22,7 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) { int ident, lev; + BIT_FLAGS inventory_flags; object_type *o_ptr; if (music_singing_any()) stop_singing(p_ptr); @@ -300,7 +301,16 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) } } - p_ptr->update |= (PU_COMBINE | PU_REORDER); + /* + * Store what may have to be updated for the inventory (including + * autodestroy if set by something else). Then turn off those flags + * so that updates triggered by calling gain_exp() or set_food() below + * do not rearrange the inventory before the food item is destroyed in + * the pack. + */ + 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))) { @@ -321,7 +331,6 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER); - /* Food can feed the player */ if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE)) { @@ -345,6 +354,7 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) if (o_ptr->tval == TV_STAFF && (item < 0) && (o_ptr->number > 1)) { + p_ptr->update |= inventory_flags; msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs.")); return; } @@ -355,7 +365,7 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) { msg_format(_("この%sにはもう魔力が残っていない。", "The %s has no charges left."), staff); o_ptr->ident |= (IDENT_EMPTY); - p_ptr->update |= (PU_COMBINE | PU_REORDER); + p_ptr->update |= inventory_flags; p_ptr->window |= (PW_INVEN); return; @@ -406,6 +416,7 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) } p_ptr->window |= (PW_INVEN | PW_EQUIP); + p_ptr->update |= inventory_flags; /* Don't eat a staff/wand itself */ return; @@ -472,7 +483,9 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item) (void)set_food(p_ptr->food + o_ptr->pval); } - /* Destroy a food in the pack */ + p_ptr->update |= inventory_flags; + + /* Destroy a food in the pack */ if (item >= 0) { inven_item_increase(item, -1);