OSDN Git Service

[Refactor] #38997 floor-save.c のplayer_type *引数が必要な全関数にこれを追加 (コールチェーンが非常に長いので途中経過は省略...
[hengband/hengband.git] / src / autopick.c
index 2cd22b6..993207a 100644 (file)
@@ -24,6 +24,7 @@
 #include "player-move.h"
 #include "player-class.h"
 #include "player-race.h"
+#include "player-inventory.h"
 #include "objectkind.h"
 #include "object-ego.h"
 #include "object-flavor.h"
@@ -156,7 +157,7 @@ static GAME_TEXT KEY_COLLECTING[] = "collecting";
 static GAME_TEXT KEY_ARTIFACT[] = "artifact";
 static GAME_TEXT KEY_EGO[] = "ego";
 static GAME_TEXT KEY_GOOD[] = "good";
-static GAME_TEXT KEY_nameLESS[] = "nameless";
+static GAME_TEXT KEY_NAMELESS[] = "nameless";
 static GAME_TEXT KEY_AVERAGE[] = "average";
 static GAME_TEXT KEY_WORTHLESS[] = "worthless";
 static GAME_TEXT KEY_RARE[] = "rare";
@@ -604,7 +605,7 @@ static void autopick_entry_from_object(autopick_type *entry, object_type *o_ptr)
        }
 
        /* Wanted monster's corpse */
-       if (object_is_shoukinkubi(o_ptr))
+       if (object_is_bounty(o_ptr))
        {
                REM_FLG(FLG_WORTHLESS);
                ADD_FLG(FLG_WANTED);
@@ -1264,7 +1265,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_
                return FALSE;
 
        /*** Wanted monster's corpse/skeletons ***/
-       if (IS_FLG(FLG_WANTED) && !object_is_shoukinkubi(o_ptr))
+       if (IS_FLG(FLG_WANTED) && !object_is_bounty(o_ptr))
                return FALSE;
 
        /*** Unique monster's corpse/skeletons/statues ***/
@@ -1445,7 +1446,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_
        {
                /*
                 * 'Collecting' means the item must be absorbed 
-                * into an p_ptr->inventory_list slot.
+                * into an inventory slot.
                 * But an item can not be absorbed into itself!
                 */
                if ((&p_ptr->inventory_list[j] != o_ptr) &&
@@ -1526,7 +1527,7 @@ static bool is_opt_confirm_destroy(object_type *o_ptr)
 
        if (leave_wanted)
        {
-               if (object_is_shoukinkubi(o_ptr)) return FALSE;
+               if (object_is_bounty(o_ptr)) return FALSE;
        }
 
        if (leave_corpse)
@@ -1606,7 +1607,7 @@ static void auto_destroy_item(object_type *o_ptr, int autopick_idx)
 
        /* Now decided to destroy */
 
-       disturb(FALSE, FALSE);
+       disturb(p_ptr, FALSE, FALSE);
 
        /* Artifact? */
        if (!can_player_destroy_object(o_ptr))
@@ -1639,11 +1640,7 @@ static void autopick_delayed_alter_aux(INVENTORY_IDX item)
 {
        object_type *o_ptr;
 
-       /* Get the item (in the pack) */
-       if (item >= 0) o_ptr = &p_ptr->inventory_list[item];
-
-       /* Get the item (on the floor) */
-       else o_ptr = &current_floor_ptr->o_list[0 - item];
+       o_ptr = REF_ITEM(p_ptr, p_ptr->current_floor_ptr, item);
 
        if (o_ptr->k_idx && (o_ptr->marked & OM_AUTODESTROY))
        {
@@ -1685,10 +1682,10 @@ void autopick_delayed_alter(void)
                autopick_delayed_alter_aux(item);
 
        /* Scan the pile of objects */
-       item = current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx;
+       item = p_ptr->current_floor_ptr->grid_array[p_ptr->y][p_ptr->x].o_idx;
        while (item)
        {
-               OBJECT_IDX next = current_floor_ptr->o_list[item].next_o_idx;
+               OBJECT_IDX next = p_ptr->current_floor_ptr->o_list[item].next_o_idx;
                autopick_delayed_alter_aux(-item);
                item = next;
        }
@@ -1698,7 +1695,7 @@ void autopick_delayed_alter(void)
 /*
  * Auto-inscription and/or destroy
  *
- * Auto-destroyer works only on p_ptr->inventory_list or on floor stack only when
+ * Auto-destroyer works only on inventory or on floor stack only when
  * requested.
  */
 void autopick_alter_item(INVENTORY_IDX item, bool destroy)
@@ -1706,11 +1703,7 @@ void autopick_alter_item(INVENTORY_IDX item, bool destroy)
        object_type *o_ptr;
        int idx;
 
-       /* Get the item (in the pack) */
-       if (item >= 0) o_ptr = &p_ptr->inventory_list[item];
-
-       /* Get the item (on the floor) */
-       else o_ptr = &current_floor_ptr->o_list[0 - item];
+       o_ptr = REF_ITEM(p_ptr, p_ptr->current_floor_ptr, item);
 
        /* Get the index in the auto-pick/destroy list */
        idx = is_autopick(o_ptr);
@@ -1735,7 +1728,7 @@ void autopick_pickup_items(grid_type *g_ptr)
        for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                int idx;
-                       object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
+                       object_type *o_ptr = &p_ptr->current_floor_ptr->o_list[this_o_idx];
                                next_o_idx = o_ptr->next_o_idx;
 
                idx = is_autopick(o_ptr);
@@ -1746,7 +1739,7 @@ void autopick_pickup_items(grid_type *g_ptr)
                if (idx >= 0 &&
                        (autopick_list[idx].action & (DO_AUTOPICK | DO_QUERY_AUTOPICK)))
                {
-                       disturb(FALSE, FALSE);
+                       disturb(p_ptr, FALSE, FALSE);
 
                        if (!inven_carry_okay(o_ptr))
                        {
@@ -3265,7 +3258,7 @@ static bool entry_from_choosed_object(autopick_type *entry)
 
        q = _("どのアイテムを登録しますか? ", "Enter which item? ");
        s = _("アイテムを持っていない。", "You have nothing to enter.");
-       o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, 0);
+       o_ptr = choose_object(p_ptr, NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, 0);
        if (!o_ptr) return FALSE;
 
        autopick_entry_from_object(entry, o_ptr);
@@ -3284,7 +3277,7 @@ static byte get_object_for_search(object_type **o_handle, concptr *search_strp)
 
        q = _("どのアイテムを検索しますか? ", "Enter which item? ");
        s = _("アイテムを持っていない。", "You have nothing to enter.");
-       o_ptr = choose_object(NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, 0);
+       o_ptr = choose_object(p_ptr, NULL, q, s, USE_INVEN | USE_FLOOR | USE_EQUIP, 0);
        if (!o_ptr) return 0;
 
        *o_handle = o_ptr;
@@ -5978,8 +5971,9 @@ static int analyze_move_key(text_body_type *tb, int skey)
 
 /*
  * In-game editor of Object Auto-picker/Destoryer
+ * @param player_ptr プレーヤーへの参照ポインタ
  */
-void do_cmd_edit_autopick(void)
+void do_cmd_edit_autopick(player_type *player_ptr)
 {
        static int cx_save = 0;
        static int cy_save = 0;
@@ -6021,7 +6015,7 @@ void do_cmd_edit_autopick(void)
        /* Autosave */
        if (current_world_ptr->game_turn > old_autosave_turn + 100L)
        {
-               do_cmd_save_game(TRUE);
+               do_cmd_save_game(player_ptr, TRUE);
                old_autosave_turn = current_world_ptr->game_turn;
        }