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 dcd06f6..17801da 100644 (file)
@@ -1,26 +1,28 @@
 #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"
 
 
 /*!
 * @brief 杖の効果を発動する
+* @param creature_ptr プレーヤーへの参照ポインタ
 * @param sval オブジェクトのsval
 * @param use_charge 使用回数を消費したかどうかを返す参照ポインタ
 * @param powerful 強力発動上の処理ならばTRUE
@@ -44,7 +46,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
                        {
                                if (set_blind(creature_ptr, creature_ptr->blind + 3 + randint1(5))) ident = TRUE;
                        }
-                       if (unlite_area(10, (powerful ? 6 : 3))) ident = TRUE;
+                       if (unlite_area(creature_ptr, 10, (powerful ? 6 : 3))) ident = TRUE;
                        break;
                }
 
@@ -56,7 +58,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_HASTE_MONSTERS:
                {
-                       if (speed_monsters()) ident = TRUE;
+                       if (speed_monsters(creature_ptr)) ident = TRUE;
                        break;
                }
 
@@ -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;
@@ -103,12 +105,12 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
                }
 
                case SV_STAFF_STARLITE:
-                       ident = starlight(magic);
+                       ident = starlight(creature_ptr, magic);
                        break;
 
                case SV_STAFF_LITE:
                {
-                       if (lite_area(damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
+                       if (lite_area(creature_ptr, damroll(2, 8), (powerful ? 4 : 2))) ident = TRUE;
                        break;
                }
 
@@ -121,14 +123,14 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_DETECT_GOLD:
                {
-                       if (detect_treasure(detect_rad)) ident = TRUE;
+                       if (detect_treasure(creature_ptr, detect_rad)) ident = TRUE;
                        if (detect_objects_gold(creature_ptr, detect_rad)) ident = TRUE;
                        break;
                }
 
                case SV_STAFF_DETECT_ITEM:
                {
-                       if (detect_objects_normal(detect_rad)) ident = TRUE;
+                       if (detect_objects_normal(creature_ptr, detect_rad)) ident = TRUE;
                        break;
                }
 
@@ -140,20 +142,20 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_DETECT_DOOR:
                {
-                       if (detect_doors(detect_rad)) ident = TRUE;
-                       if (detect_stairs(detect_rad)) ident = TRUE;
+                       if (detect_doors(creature_ptr, detect_rad)) ident = TRUE;
+                       if (detect_stairs(creature_ptr, detect_rad)) ident = TRUE;
                        break;
                }
 
                case SV_STAFF_DETECT_INVIS:
                {
-                       if (detect_monsters_invis(detect_rad)) ident = TRUE;
+                       if (detect_monsters_invis(creature_ptr, detect_rad)) ident = TRUE;
                        break;
                }
 
                case SV_STAFF_DETECT_EVIL:
                {
-                       if (detect_monsters_evil(detect_rad)) ident = TRUE;
+                       if (detect_monsters_evil(creature_ptr, detect_rad)) ident = TRUE;
                        break;
                }
 
@@ -186,13 +188,13 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_SLEEP_MONSTERS:
                {
-                       if (sleep_monsters(lev)) ident = TRUE;
+                       if (sleep_monsters(creature_ptr, lev)) ident = TRUE;
                        break;
                }
 
                case SV_STAFF_SLOW_MONSTERS:
                {
-                       if (slow_monsters(lev)) ident = TRUE;
+                       if (slow_monsters(creature_ptr, lev)) ident = TRUE;
                        break;
                }
 
@@ -210,13 +212,13 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
 
                case SV_STAFF_DISPEL_EVIL:
                {
-                       ident = dispel_evil(powerful ? 120 : 80);
+                       ident = dispel_evil(creature_ptr, powerful ? 120 : 80);
                        break;
                }
 
                case SV_STAFF_POWER:
                {
-                       ident = dispel_monsters(powerful ? 225 : 150) ;
+                       ident = dispel_monsters(creature_ptr, powerful ? 225 : 150) ;
                        break;
                }
 
@@ -244,13 +246,13 @@ 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;
                }
 
                case SV_STAFF_ANIMATE_DEAD:
                {
-                       ident = animate_dead(0, creature_ptr->y, creature_ptr->x);
+                       ident = animate_dead(creature_ptr, 0, creature_ptr->y, creature_ptr->x);
                        break;
                }
 
@@ -272,6 +274,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use
        return ident;
 }
 
+
 /*!
  * @brief 杖を使うコマンドのサブルーチン /
  * Use a staff.                        -RAK-
@@ -286,8 +289,7 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
        int         ident, chance, lev;
        object_type *o_ptr;
 
-
-       /* Hack -- let staffs of identify get aborted */
+               /* Hack -- let staffs of identify get aborted */
        bool use_charge = TRUE;
 
        o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
@@ -299,8 +301,7 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
                return;
        }
 
-
-       take_turn(creature_ptr, 100);
+               take_turn(creature_ptr, 100);
 
        lev = k_info[o_ptr->k_idx].level;
        if (lev > 50) lev = 50 + (lev - 50) / 2;
@@ -343,7 +344,6 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
                return;
        }
 
-
        sound(SOUND_ZAP);
 
        ident = staff_effect(creature_ptr, o_ptr->sval, &use_charge, FALSE, FALSE, object_is_aware(o_ptr));
@@ -354,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);
@@ -362,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;
@@ -393,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."));
        }
@@ -401,16 +408,17 @@ 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);
        }
 }
 
+
 /*!
 * @brief 杖を使うコマンドのメインルーチン /
 * @return なし