OSDN Git Service

[Refactor] #38862 Moved player-*.c/h to player/ except for player-inventory.c/h
[hengband/hengband.git] / src / cmd / cmd-usestaff.c
index ad6ad03..17801da 100644 (file)
@@ -1,21 +1,23 @@
 #include "angband.h"
 #include "util.h"
+#include "main/sound-definitions-table.h"
 
-#include "player-race.h"
+#include "player/player-race.h"
 #include "spells-summon.h"
 #include "avatar.h"
-#include "player-status.h"
-#include "player-effects.h"
-#include "player-class.h"
+#include "player/player-status.h"
+#include "player/player-effects.h"
+#include "player/player-class.h"
 #include "player-inventory.h"
-#include "spells.h"
+#include "spell/spells2.h"
+#include "spell/spells3.h"
 #include "spells-status.h"
 #include "spells-floor.h"
-#include "object-hook.h"
+#include "object/object-hook.h"
 #include "cmd-basic.h"
-#include "floor.h"
-#include "objectkind.h"
-#include "view-mainwindow.h"
+#include "floor/floor.h"
+#include "object/object-kind.h"
+#include "view/display-main-window.h"
 
 
 /*!
@@ -65,7 +67,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
                        const int times = randint1(powerful ? 8 : 4);
                        for (k = 0; k < times; k++)
                        {
-                               if (summon_specific(0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
+                               if (summon_specific(creature_ptr, 0, creature_ptr->y, creature_ptr->x, creature_ptr->current_floor_ptr->dun_level, 0, (PM_ALLOW_GROUP | PM_ALLOW_UNIQUE | PM_NO_PET)))
                                {
                                        ident = TRUE;
                                }
@@ -83,10 +85,10 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
                case SV_STAFF_IDENTIFY:
                {
                        if (powerful) {
-                               if (!identify_fully(FALSE)) *use_charge = FALSE;
+                               if (!identify_fully(creature_ptr, FALSE, 0)) *use_charge = FALSE;
                        }
                        else {
-                               if (!ident_spell(creature_ptr, FALSE)) *use_charge = FALSE;
+                               if (!ident_spell(creature_ptr, FALSE, 0)) *use_charge = FALSE;
                        }
                        ident = TRUE;
                        break;
@@ -244,7 +246,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_DESTRUCTION:
                {
-                       ident = destroy_area(creature_ptr->current_floor_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
+                       ident = destroy_area(creature_ptr, creature_ptr->y, creature_ptr->x, (powerful ? 18 : 13) + randint0(5), FALSE);
                        break;
                }
 
@@ -352,7 +354,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);
@@ -360,12 +369,12 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
        /* An identification was made */
        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;
 
        /* Hack -- some uses are "free" */
        if (!use_charge) return;
@@ -391,7 +400,7 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
                /* Unstack the used item */
                o_ptr->number--;
                creature_ptr->total_weight -= q_ptr->weight;
-               item = inven_carry(q_ptr);
+               item = inven_carry(creature_ptr, q_ptr);
 
                msg_print(_("杖をまとめなおした。", "You unstack your staff."));
        }
@@ -399,13 +408,13 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
        /* Describe charges in the pack */
        if (item >= 0)
        {
-               inven_item_charges(item);
+               inven_item_charges(creature_ptr, item);
        }
 
        /* Describe charges on the floor */
        else
        {
-               floor_item_charges(0 - item);
+               floor_item_charges(creature_ptr->current_floor_ptr, 0 - item);
        }
 }