OSDN Git Service

[Refactor] #37353 ref_item()をget_item()の置換向けに修正。
authorDeskull <deskull@users.sourceforge.jp>
Tue, 27 Nov 2018 00:11:33 +0000 (09:11 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Tue, 27 Nov 2018 13:54:24 +0000 (22:54 +0900)
Refine ref_item() for replace of get_item().

src/cmd-item.c
src/player-item.c
src/player-item.h

index ebb472e..13843b0 100644 (file)
@@ -1290,7 +1290,6 @@ static void do_cmd_refill_torch(void)
 
        if (!get_item(&item, q, s, (USE_INVEN | USE_FLOOR))) return;
 
-       o_ptr = ref_item(p_ptr, item);
        /* Get the item (in the pack) */
        if (item >= 0)
        {
index 3376902..19ca9ad 100644 (file)
@@ -1,8 +1,15 @@
 #include "angband.h"
 #include "player-item.h"
 
-object_type *ref_item(player_type *player_ptr, INVENTORY_IDX idx)
+/*!
+ * @brief get_item()からのリファクタリング
+ * @return アイテムのポインタ、キャンセルや不能ならNULLを返す。
+ */
+object_type *ref_item(player_type *player_ptr, cptr pmt, cptr str, BIT_FLAGS mode)
 {
+       OBJECT_IDX idx;
        (player_ptr); // しばらくは未使用
+
+       if(!get_item(&idx, pmt, str, mode)) return NULL;
        return idx >= 0 ? &inventory[idx] : &o_list[0 - idx];
 }
\ No newline at end of file
index 2b6470f..c76647c 100644 (file)
@@ -1,2 +1,3 @@
 
-extern object_type *ref_item(player_type *player_ptr, INVENTORY_IDX idx);
+extern object_type *ref_item(player_type *player_ptr, cptr pmt, cptr str, BIT_FLAGS mode);
+