OSDN Git Service

[WIP] [Refactor] #39963 Separated spells2.h from spells1.h
[hengband/hengband.git] / src / cmd / cmd-zapwand.c
index d4caf7c..67b64c2 100644 (file)
@@ -1,19 +1,21 @@
 #include "angband.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 
 #include "avatar.h"
-#include "spells.h"
+#include "spell/spells-type.h"
 #include "spells-status.h"
 #include "player-status.h"
 #include "player-effects.h"
 #include "player-class.h"
 #include "player-inventory.h"
-#include "objectkind.h"
+#include "object/object-kind.h"
 #include "object-hook.h"
 #include "cmd-basic.h"
 #include "floor.h"
 #include "targeting.h"
-#include "view-mainwindow.h"
+#include "view/display-main-window.h"
+#include "spell/spells2.h"
 
 /*!
 * @brief 魔法棒の効果を発動する
@@ -350,7 +352,7 @@ void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
        if (object_is_aware(o_ptr) && (o_ptr->sval == SV_WAND_HEAL_MONSTER
                || o_ptr->sval == SV_WAND_HASTE_MONSTER))
                target_pet = TRUE;
-       if (!get_aim_dir(&dir))
+       if (!get_aim_dir(creature_ptr, &dir))
        {
                target_pet = old_target_pet;
                return;
@@ -404,7 +406,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)))
        {
@@ -419,27 +428,23 @@ void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
        /* Apply identification */
        if (ident && !object_is_aware(o_ptr))
        {
-               object_aware(o_ptr);
+               object_aware(creature_ptr, o_ptr);
                gain_exp(creature_ptr, (lev + (creature_ptr->lev >> 1)) / creature_ptr->lev);
        }
 
        creature_ptr->window |= (PW_INVEN | PW_EQUIP | PW_PLAYER);
-
+       creature_ptr->update |= inventory_flags;
 
        /* Use a single charge */
        o_ptr->pval--;
 
-       /* Describe the charges in the pack */
        if (item >= 0)
        {
-               inven_item_charges(item);
+               inven_item_charges(creature_ptr, item);
+               return;
        }
 
-       /* Describe the charges on the floor */
-       else
-       {
-               floor_item_charges(0 - item);
-       }
+       floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
 }
 
 /*!