OSDN Git Service

Adjust so eating an unidentified piece of food from the pack removes that piece of...
authorEric Branlund <ebranlund@fastmail.com>
Wed, 4 Sep 2019 15:16:33 +0000 (08:16 -0700)
committerEric Branlund <ebranlund@fastmail.com>
Wed, 4 Sep 2019 15:16:33 +0000 (08:16 -0700)
src/cmd-eat.c

index 9a0b7a4..4cd71a1 100644 (file)
@@ -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() 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)))
        {
@@ -320,7 +330,7 @@ void do_cmd_eat_food_aux(INVENTORY_IDX item)
        }
 
        p_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-
+       p_ptr->update |= inventory_flags;
 
        /* Food can feed the player */
        if (prace_is_(RACE_VAMPIRE) || (p_ptr->mimic_form == MIMIC_VAMPIRE))