OSDN Git Service

[Refactor] #38997 is_autopick_aux() にplayer_type * 引数を追加/ Added player_type * argumen...
authorHourier <hourier@users.sourceforge.jp>
Sat, 11 Jan 2020 08:10:36 +0000 (17:10 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 11 Jan 2020 08:10:36 +0000 (17:10 +0900)
14 files changed:
src/autopick.c
src/autopick.h
src/birth.c
src/bldg.c
src/cmd/cmd-item.c
src/cmd/cmd-smith.c
src/core.c
src/player-move.c
src/spells-object.c
src/spells1.c
src/spells2.c
src/spells3.c
src/store.c
src/view-mainwindow.c

index f31ee21..509b09f 100644 (file)
@@ -1041,7 +1041,7 @@ static concptr autopick_line_from_entry_kill(autopick_type *entry)
  * A function for Auto-picker/destroyer
  * Examine whether the object matches to the entry
  */
-static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_name)
+static bool is_autopick_aux(player_type *player_ptr, object_type *o_ptr, autopick_type *entry, concptr o_name)
 {
        int j;
        concptr ptr = entry->name;
@@ -1289,15 +1289,15 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_
        /*** First realm spellbooks ***/
        if (IS_FLG(FLG_REALM1) && 
            (REALM1_BOOK != o_ptr->tval ||
-            p_ptr->pclass == CLASS_SORCERER ||
-            p_ptr->pclass == CLASS_RED_MAGE))
+            player_ptr->pclass == CLASS_SORCERER ||
+            player_ptr->pclass == CLASS_RED_MAGE))
                return FALSE;
 
        /*** Second realm spellbooks ***/
        if (IS_FLG(FLG_REALM2) &&
            (REALM2_BOOK != o_ptr->tval ||
-            p_ptr->pclass == CLASS_SORCERER ||
-            p_ptr->pclass == CLASS_RED_MAGE))
+            player_ptr->pclass == CLASS_SORCERER ||
+            player_ptr->pclass == CLASS_RED_MAGE))
                return FALSE;
 
        /*** First rank spellbooks ***/
@@ -1449,8 +1449,8 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_
                 * into an inventory slot.
                 * But an item can not be absorbed into itself!
                 */
-               if ((&p_ptr->inventory_list[j] != o_ptr) &&
-                   object_similar(&p_ptr->inventory_list[j], o_ptr))
+               if ((&player_ptr->inventory_list[j] != o_ptr) &&
+                   object_similar(&player_ptr->inventory_list[j], o_ptr))
                        return TRUE;
        }
 
@@ -1463,7 +1463,7 @@ static bool is_autopick_aux(object_type *o_ptr, autopick_type *entry, concptr o_
  * A function for Auto-picker/destroyer
  * Examine whether the object matches to the list of keywords or not.
  */
-int is_autopick(object_type *o_ptr)
+int is_autopick(player_type *player_ptr, object_type *o_ptr)
 {
        int i;
        GAME_TEXT o_name[MAX_NLEN];
@@ -1481,7 +1481,7 @@ int is_autopick(object_type *o_ptr)
        {
                autopick_type *entry = &autopick_list[i];
 
-               if (is_autopick_aux(o_ptr, entry, o_name)) return i;
+               if (is_autopick_aux(player_ptr, o_ptr, entry, o_name)) return i;
        }
 
        /* No matching entry */
@@ -1694,15 +1694,15 @@ void autopick_delayed_alter(player_type *owner_ptr)
  * Auto-destroyer works only on inventory or on floor stack only when
  * requested.
  */
-void autopick_alter_item(INVENTORY_IDX item, bool destroy)
+void autopick_alter_item(player_type *player_ptr, INVENTORY_IDX item, bool destroy)
 {
        object_type *o_ptr;
        int idx;
 
-       o_ptr = REF_ITEM(p_ptr, p_ptr->current_floor_ptr, item);
+       o_ptr = REF_ITEM(player_ptr, player_ptr->current_floor_ptr, item);
 
        /* Get the index in the auto-pick/destroy list */
-       idx = is_autopick(o_ptr);
+       idx = is_autopick(player_ptr, o_ptr);
 
        /* Do auto-inscription */
        auto_inscribe_item(o_ptr, idx);
@@ -1716,7 +1716,7 @@ void autopick_alter_item(INVENTORY_IDX item, bool destroy)
 /*
  * Automatically pickup/destroy items in this grid.
  */
-void autopick_pickup_items(grid_type *g_ptr)
+void autopick_pickup_items(player_type* player_ptr, grid_type *g_ptr)
 {
        OBJECT_IDX this_o_idx, next_o_idx = 0;
        
@@ -1727,7 +1727,7 @@ void autopick_pickup_items(grid_type *g_ptr)
                        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);
+               idx = is_autopick(player_ptr, o_ptr);
 
                /* Item index for floor -1,-2,-3,...  */
                auto_inscribe_item(o_ptr, idx);
@@ -1917,7 +1917,7 @@ bool autopick_autoregister(player_type *player_ptr, object_type *o_ptr)
        FILE *pref_fff;
        autopick_type an_entry, *entry = &an_entry;
 
-       int match_autopick = is_autopick(o_ptr);
+       int match_autopick = is_autopick(player_ptr, o_ptr);
 
        /* Already registered */
        if (match_autopick != -1)
@@ -3596,7 +3596,7 @@ static byte get_string_for_search(object_type **o_handle, concptr *search_strp)
 /*
  * Search next line matches for o_ptr
  */
-static void search_for_object(text_body_type *tb, object_type *o_ptr, bool forward)
+static void search_for_object(player_type *player_ptr, text_body_type *tb, object_type *o_ptr, bool forward)
 {
        autopick_type an_entry, *entry = &an_entry;
        GAME_TEXT o_name[MAX_NLEN];
@@ -3629,7 +3629,7 @@ static void search_for_object(text_body_type *tb, object_type *o_ptr, bool forwa
                if (!autopick_new_entry(entry, tb->lines_list[i], FALSE)) continue;
 
                /* Does this line match to the object? */
-               match = is_autopick_aux(o_ptr, entry, o_name);
+               match = is_autopick_aux(player_ptr, o_ptr, entry, o_name);
                autopick_free_entry(entry);
                if (!match)     continue;
 
@@ -5581,7 +5581,7 @@ static bool do_editor_command(player_type *player_ptr, text_body_type *tb, int c
        case EC_SEARCH_FORW:
                if (tb->search_o_ptr)
                {
-                       search_for_object(tb, tb->search_o_ptr, TRUE);
+                       search_for_object(player_ptr, tb, tb->search_o_ptr, TRUE);
                }
                else if (tb->search_str && tb->search_str[0])
                {
@@ -5596,7 +5596,7 @@ static bool do_editor_command(player_type *player_ptr, text_body_type *tb, int c
        case EC_SEARCH_BACK:
                if (tb->search_o_ptr)
                {
-                       search_for_object(tb, tb->search_o_ptr, FALSE);
+                       search_for_object(player_ptr, tb, tb->search_o_ptr, FALSE);
                }
                else if (tb->search_str && tb->search_str[0])
                {
index 8db0557..d0bbc81 100644 (file)
@@ -30,9 +30,9 @@ extern autopick_type *autopick_list;
 extern void autopick_load_pref(player_type *player_ptr, bool disp_mes);
 extern errr process_autopick_file_command(char *buf);
 extern concptr autopick_line_from_entry(autopick_type *entry);
-extern int is_autopick(object_type *o_ptr);
-extern void autopick_alter_item(INVENTORY_IDX item, bool destroy);
+extern int is_autopick(player_type *player_ptr, object_type *o_ptr);
+extern void autopick_alter_item(player_type *player_ptr, INVENTORY_IDX item, bool destroy);
 extern void autopick_delayed_alter(player_type *player_ptr);
-extern void autopick_pickup_items(grid_type *g_ptr);
+extern void autopick_pickup_items(player_type *player_ptr, grid_type *g_ptr);
 extern bool autopick_autoregister(player_type *player_ptr, object_type *o_ptr);
 extern void do_cmd_edit_autopick(player_type *player_ptr);
index c1b6240..95861b6 100644 (file)
@@ -2225,7 +2225,7 @@ static void add_outfit(player_type *creature_ptr, object_type *o_ptr)
        slot = inven_carry(creature_ptr, o_ptr);
 
        /* Auto-inscription */
-       autopick_alter_item(slot, FALSE);
+       autopick_alter_item(creature_ptr, slot, FALSE);
 
        /* Now try wielding everything */ 
        wield_all(creature_ptr); 
index 640b7e8..a3d86d8 100644 (file)
@@ -1965,7 +1965,7 @@ static bool kankin(player_type *player_ptr)
                                msg_format(_("%s(%c)を貰った。", "You get %s (%c). "), o_name, index_to_label(item_new));
 
                                /* Auto-inscription */
-                               autopick_alter_item(item_new, FALSE);
+                               autopick_alter_item(player_ptr, item_new, FALSE);
                                handle_stuff(player_ptr);
 
                                change = TRUE;
@@ -3261,9 +3261,10 @@ static bool enchant_item(player_type *player_ptr, PRICE cost, HIT_PROB to_hit, H
  * The cost for rods depends on the level of the rod. The prices\n
  * for recharging wands and staves are dependent on the cost of\n
  * the base-item.\n
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
-static void building_recharge(void)
+static void building_recharge(player_type *player_ptr)
 {
        OBJECT_IDX  item;
        DEPTH       lev;
@@ -3313,7 +3314,7 @@ static void building_recharge(void)
                        msg_format(_("%s です。", "You have: %s."), tmp_str);
 
                        /* Auto-inscription */
-                       autopick_alter_item(item, FALSE);
+                       autopick_alter_item(player_ptr, item, FALSE);
 
                        /* Update the gold display */
                        building_prt_gold();
@@ -3470,9 +3471,10 @@ static void building_recharge(void)
  * The cost for rods depends on the level of the rod. The prices\n
  * for recharging wands and staves are dependent on the cost of\n
  * the base-item.\n
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
-static void building_recharge_all(void)
+static void building_recharge_all(player_type *player_ptr)
 {
        INVENTORY_IDX i;
        DEPTH lev;
@@ -3481,7 +3483,6 @@ static void building_recharge_all(void)
        PRICE price = 0;
        PRICE total_cost = 0;
 
-
        /* Display some info */
        msg_flag = FALSE;
        clear_bldg(4, 18);
@@ -3565,7 +3566,7 @@ static void building_recharge_all(void)
                        identify_item(p_ptr, o_ptr);
 
                        /* Auto-inscription */
-                       autopick_alter_item(i, FALSE);
+                       autopick_alter_item(player_ptr, i, FALSE);
                }
 
                /* Recharge */
@@ -3942,10 +3943,10 @@ static void bldg_process_command(player_type *player_ptr, building_type *bldg, i
                enchant_item(player_ptr, bcost, 0, 0, 1);
                break;
        case BACT_RECHARGE:
-               building_recharge();
+               building_recharge(player_ptr);
                break;
        case BACT_RECHARGE_ALL:
-               building_recharge_all();
+               building_recharge_all(player_ptr);
                break;
        case BACT_IDENTS: /* needs work */
                if (!get_check(_("持ち物を全て鑑定してよろしいですか?", "Do you pay for identify all your possession? "))) break;
index dda88fc..882a8ee 100644 (file)
@@ -134,6 +134,7 @@ bool select_ring_slot = FALSE;
 
 /*!
  * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし 
  */
 void do_cmd_wield(player_type *creature_ptr)
@@ -324,7 +325,7 @@ void do_cmd_wield(player_type *creature_ptr)
                identify_item(creature_ptr, o_ptr);
 
                /* Auto-inscription */
-               autopick_alter_item(item, FALSE);
+               autopick_alter_item(creature_ptr, item, FALSE);
        }
 
        take_turn(creature_ptr, 100);
@@ -606,6 +607,7 @@ void do_cmd_drop(player_type *creature_ptr)
 
 /*!
  * @brief アイテムを破壊するコマンドのメインルーチン / Destroy an item
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 void do_cmd_destroy(player_type *creature_ptr)
@@ -682,7 +684,7 @@ void do_cmd_destroy(player_type *creature_ptr)
                                if (autopick_autoregister(creature_ptr, o_ptr))
                                {
                                        /* Auto-destroy it */
-                                       autopick_alter_item(item, TRUE);
+                                       autopick_alter_item(creature_ptr, item, TRUE);
                                }
 
                                /* The object is already destroyed. */
index 6eb2c77..946e164 100644 (file)
@@ -511,6 +511,7 @@ static void display_essence(player_type *creature_ptr)
 
 /*!
  * @brief エッセンスの抽出処理
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @return なし
  */
 static void drain_essence(player_type *creature_ptr)
@@ -731,7 +732,7 @@ static void drain_essence(player_type *creature_ptr)
        }
 
        /* Apply autodestroy/inscription to the drained item */
-       autopick_alter_item(item, TRUE);
+       autopick_alter_item(creature_ptr, item, TRUE);
        creature_ptr->update |= (PU_COMBINE | PU_REORDER);
        creature_ptr->window |= (PW_INVEN);
 }
index 1563f5a..b016de4 100644 (file)
@@ -130,10 +130,11 @@ int init_flags;
 /*!
  * @brief 擬似鑑定を実際に行い判定を反映する
  * @param slot 擬似鑑定を行うプレイヤーの所持リストID
+ * @param creature_ptr プレーヤーへの参照ポインタ
  * @param heavy 重度の擬似鑑定を行うならばTRUE
  * @return なし
  */
-static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
+static void sense_inventory_aux(player_type *creature_ptr, INVENTORY_IDX slot, bool heavy)
 {
        byte feel;
        object_type *o_ptr = &p_ptr->inventory_list[slot];
@@ -240,7 +241,7 @@ static void sense_inventory_aux(INVENTORY_IDX slot, bool heavy)
        o_ptr->feeling = feel;
 
        /* Auto-inscription/destroy */
-       autopick_alter_item(slot, destroy_feeling);
+       autopick_alter_item(creature_ptr, slot, destroy_feeling);
        p_ptr->update |= (PU_COMBINE | PU_REORDER);
 
        p_ptr->window |= (PW_INVEN | PW_EQUIP);
@@ -477,7 +478,7 @@ static void sense_inventory1(player_type *creature_ptr)
                        heavy = TRUE;
                }
 
-               sense_inventory_aux(i, heavy);
+               sense_inventory_aux(creature_ptr, i, heavy);
        }
 }
 
@@ -599,7 +600,7 @@ static void sense_inventory2(player_type *creature_ptr)
                /* Occasional failure on creature_ptr->inventory_list items */
                if ((i < INVEN_RARM) && (0 != randint0(5))) continue;
 
-               sense_inventory_aux(i, TRUE);
+               sense_inventory_aux(creature_ptr, i, TRUE);
        }
 }
 
index 28aaeed..99d6628 100644 (file)
@@ -306,7 +306,7 @@ void py_pickup_aux(player_type *owner_ptr, OBJECT_IDX o_idx)
                bool old_known = identify_item(owner_ptr, o_ptr);
 
                /* Auto-inscription/destroy */
-               autopick_alter_item(slot, (bool)(destroy_identify && !old_known));
+               autopick_alter_item(owner_ptr, slot, (bool)(destroy_identify && !old_known));
 
                /* If it is destroyed, don't pick it up */
                if (o_ptr->marked & OM_AUTODESTROY) return;
@@ -375,7 +375,7 @@ void carry(player_type *creature_ptr, bool pickup)
        handle_stuff(creature_ptr);
 
        /* Automatically pickup/destroy/inscribe items */
-       autopick_pickup_items(g_ptr);
+       autopick_pickup_items(creature_ptr, g_ptr);
 
        if (easy_floor)
        {
index 8eb69ce..24da9c5 100644 (file)
@@ -169,7 +169,7 @@ bool create_ammo(player_type *creature_ptr)
                msg_format(_("%sを作った。", "You make some ammo."), o_name);
 
                /* Auto-inscription */
-               if (slot >= 0) autopick_alter_item(slot, FALSE);
+               if (slot >= 0) autopick_alter_item(creature_ptr, slot, FALSE);
 
                /* Destroy the wall */
                cave_alter_feat(creature_ptr, y, x, FF_HURT_ROCK);
@@ -210,7 +210,7 @@ bool create_ammo(player_type *creature_ptr)
                slot = inven_carry(creature_ptr, q_ptr);
 
                /* Auto-inscription */
-               if (slot >= 0) autopick_alter_item(slot, FALSE);
+               if (slot >= 0) autopick_alter_item(creature_ptr, slot, FALSE);
                return TRUE;
        }
 
@@ -248,7 +248,7 @@ bool create_ammo(player_type *creature_ptr)
                slot = inven_carry(creature_ptr, q_ptr);
 
                /* Auto-inscription */
-               if (slot >= 0) autopick_alter_item(slot, FALSE);
+               if (slot >= 0) autopick_alter_item(creature_ptr, slot, FALSE);
        }
 
        return TRUE;
index cb28d88..94002c0 100644 (file)
@@ -952,7 +952,7 @@ static bool project_o(player_type *caster_ptr, MONSTER_IDX who, POSITION r, POSI
                                identify_item(caster_ptr, o_ptr);
 
                                /* Auto-inscription */
-                               autopick_alter_item((-this_o_idx), FALSE);
+                               autopick_alter_item(caster_ptr, (-this_o_idx), FALSE);
                                break;
                        }
 
index 1497141..6448ec4 100644 (file)
@@ -4224,7 +4224,7 @@ bool psychometry(player_type *caster_ptr)
        }
 
        /* Auto-inscription/destroy */
-       autopick_alter_item(item, (bool)(okay && destroy_feeling));
+       autopick_alter_item(caster_ptr, item, (bool)(okay && destroy_feeling));
 
        return TRUE;
 }
index 3a19159..ca5c3fb 100644 (file)
@@ -1369,7 +1369,7 @@ void identify_pack(player_type *target_ptr)
                identify_item(target_ptr, o_ptr);
 
                /* Auto-inscription */
-               autopick_alter_item(i, FALSE);
+               autopick_alter_item(target_ptr, i, FALSE);
        }
 }
 
@@ -1732,7 +1732,7 @@ bool ident_spell(player_type *caster_ptr, bool only_equip)
                msg_format(_("床上: %s。", "On the ground: %s."), o_name);
        }
 
-       autopick_alter_item(item, (bool)(destroy_identify && !old_known));
+       autopick_alter_item(caster_ptr, item, (bool)(destroy_identify && !old_known));
        return TRUE;
 }
 
@@ -1844,7 +1844,7 @@ bool identify_fully(player_type *caster_ptr, bool only_equip)
        }
 
        (void)screen_object(o_ptr, 0L);
-       autopick_alter_item(item, (bool)(destroy_identify && !old_known));
+       autopick_alter_item(caster_ptr, item, (bool)(destroy_identify && !old_known));
        return TRUE;
 }
 
index a9ee078..57aed29 100644 (file)
@@ -4758,7 +4758,7 @@ static void store_purchase(player_type *player_ptr)
                                msg_format(_("%s(%c)を手に入れた。", "You have %s (%c)."), o_name, index_to_label(item_new));
 
                                /* Auto-inscription */
-                               autopick_alter_item(item_new, FALSE);
+                               autopick_alter_item(player_ptr, item_new, FALSE);
 
                                /* Now, reduce the original stack's pval. */
                                if ((o_ptr->tval == TV_ROD) || (o_ptr->tval == TV_WAND))
@@ -5093,7 +5093,7 @@ static void store_sell(player_type *owner_ptr)
 
                        /* If items remain, auto-inscribe before optimizing */
                        if (o_ptr->number > 0)
-                               autopick_alter_item(item, FALSE);
+                               autopick_alter_item(owner_ptr, item, FALSE);
 
                        inven_item_optimize(owner_ptr, item);
                        handle_stuff(owner_ptr);
index f551e41..cc9f560 100644 (file)
@@ -3130,7 +3130,7 @@ void map_info(POSITION y, POSITION x, TERM_COLOR *ap, SYMBOL_CODE *cp, TERM_COLO
                        {
                                byte act;
 
-                               match_autopick = is_autopick(o_ptr);
+                               match_autopick = is_autopick(p_ptr, o_ptr);
                                if (match_autopick == -1)
                                        continue;