OSDN Git Service

[Fix] #39815 backwardsEric氏による、未識別の巻物を読んだ時に間違ったアイテムをザックから消してしまう問題の解決 / Fix reading...
authorHourier <hourier@users.sourceforge.jp>
Tue, 21 Jan 2020 13:02:29 +0000 (22:02 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 21 Jan 2020 13:02:29 +0000 (22:02 +0900)
src/cmd/cmd-eat.c
src/cmd/cmd-read.c
src/cmd/cmd-usestaff.c
src/cmd/cmd-zapwand.c

index f92b417..7c10f2a 100644 (file)
@@ -292,7 +292,16 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
 
                }
        }
-       creature_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.
+        */
+       BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
+       creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
 
        if (!(object_is_aware(o_ptr)))
        {
@@ -313,7 +322,6 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
 
-
        /* Food can feed the player */
        if (PRACE_IS_(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE))
        {
@@ -337,6 +345,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
                if (o_ptr->tval == TV_STAFF &&
                        (item < 0) && (o_ptr->number > 1))
                {
+                       creature_ptr->update |= inventory_flags;
                        msg_print(_("まずは杖を拾わなければ。", "You must first pick up the staffs."));
                        return;
                }
@@ -347,7 +356,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
                {
                        msg_format(_("この%sにはもう魔力が残っていない。", "The %s has no charges left."), staff);
                        o_ptr->ident |= (IDENT_EMPTY);
-                       creature_ptr->update |= (PU_COMBINE | PU_REORDER);
+                       creature_ptr->update |= inventory_flags;
                        creature_ptr->window |= (PW_INVEN);
 
                        return;
@@ -396,11 +405,13 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
                }
 
                creature_ptr->window |= (PW_INVEN | PW_EQUIP);
+               creature_ptr->update |= inventory_flags;
 
                /* Don't eat a staff/wand itself */
                return;
        }
-       else if ((PRACE_IS_(creature_ptr, RACE_DEMON) ||
+
+       if ((PRACE_IS_(creature_ptr, RACE_DEMON) ||
                (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) &&
                (o_ptr->tval == TV_CORPSE && o_ptr->sval == SV_CORPSE &&
                        my_strchr("pht", r_info[o_ptr->pval].d_char)))
@@ -452,6 +463,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
                (void)set_food(creature_ptr, creature_ptr->food + o_ptr->pval);
        }
 
+       creature_ptr->update |= inventory_flags;
        vary_item(creature_ptr, item, -1);
 }
 
index 3c8761d..a4ebd0d 100644 (file)
@@ -554,7 +554,14 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
                used_up=FALSE;
        }
 
-       creature_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 destroying the scroll in the pack.
+        */
+       BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
+       creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
 
        if (!(object_is_aware(o_ptr)))
        {
@@ -574,7 +581,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
        }
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-
+       creature_ptr->update |= inventory_flags;
 
        /* Hack -- allow certain scrolls to be "preserved" */
        if (!used_up)
index 78ac618..b7873df 100644 (file)
@@ -352,7 +352,14 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
                chg_virtue(creature_ptr, V_CHANCE, 1);
                chg_virtue(creature_ptr, V_KNOWLEDGE, -1);
        }
-       creature_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 staff.
+        */
+       BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
+       creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
 
        /* Tried the item */
        object_tried(o_ptr);
@@ -365,7 +372,7 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
        }
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-
+       creature_ptr->update |= inventory_flags;
 
        /* Hack -- some uses are "free" */
        if (!use_charge) return;
index 34d7e5f..2d70005 100644 (file)
@@ -404,7 +404,14 @@ void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
        sound(SOUND_ZAP);
 
        ident = wand_effect(creature_ptr, o_ptr->sval, dir, FALSE, FALSE);
-       creature_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.
+        */
+       BIT_FLAGS inventory_flags = (PU_COMBINE | PU_REORDER | (creature_ptr->update & PU_AUTODESTROY));
+       creature_ptr->update &= ~(PU_COMBINE | PU_REORDER | PU_AUTODESTROY);
 
        if (!(object_is_aware(o_ptr)))
        {
@@ -424,6 +431,7 @@ void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
        }
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
+       creature_ptr->window |= inventory_flags;
 
        /* Use a single charge */
        o_ptr->pval--;