OSDN Git Service

[Refactor] #40399 Changed macro function REF_ITEM() to normal function
authorHourier <hourier@users.sourceforge.jp>
Thu, 28 May 2020 11:22:05 +0000 (20:22 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 28 May 2020 11:22:05 +0000 (20:22 +0900)
src/autopick/autopick.c
src/cmd/cmd-activate.c
src/cmd/cmd-eat.c
src/cmd/cmd-quaff.c
src/cmd/cmd-read.c
src/cmd/cmd-usestaff.c
src/cmd/cmd-zaprod.c
src/cmd/cmd-zapwand.c
src/inventory/player-inventory.c
src/object/object1.c
src/object/object1.h

index f903714..373141e 100644 (file)
@@ -28,7 +28,7 @@
 static void autopick_delayed_alter_aux(player_type *player_ptr, INVENTORY_IDX item)
 {
        object_type *o_ptr;
-       o_ptr = REF_ITEM(player_ptr, player_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(player_ptr, item);
 
        if (o_ptr->k_idx == 0 || !(o_ptr->marked & OM_AUTODESTROY)) return;
 
@@ -82,7 +82,7 @@ void autopick_delayed_alter(player_type *owner_ptr)
 void autopick_alter_item(player_type *player_ptr, INVENTORY_IDX item, bool destroy)
 {
        object_type *o_ptr;
-       o_ptr = REF_ITEM(player_ptr, player_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(player_ptr, item);
        int idx = find_autopick_list(player_ptr, o_ptr);
        auto_inscribe_item(player_ptr, o_ptr, idx);
        if (destroy && item <= INVEN_PACK)
index c409d65..a45d0d6 100644 (file)
@@ -357,7 +357,7 @@ void exe_activate(player_type *user_ptr, INVENTORY_IDX item)
        object_type *o_ptr;
        bool success;
 
-       o_ptr = REF_ITEM(user_ptr, user_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(user_ptr, item);
        take_turn(user_ptr, 100);
        lev = k_info[o_ptr->k_idx].level;
 
index f1ab34a..04b7d6b 100644 (file)
@@ -41,7 +41,7 @@ void exe_eat_food(player_type *creature_ptr, INVENTORY_IDX item)
 
        if (music_singing_any(creature_ptr)) stop_singing(creature_ptr);
        if (hex_spelling_any(creature_ptr)) stop_hex_spell_all(creature_ptr);
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
 
        sound(SOUND_EAT);
 
index 4afc0f7..34597ef 100644 (file)
@@ -66,7 +66,7 @@ void exe_quaff_potion(player_type *creature_ptr, INVENTORY_IDX item)
                if (!hex_spelling(creature_ptr, HEX_INHAIL)) stop_hex_spell_all(creature_ptr);
        }
 
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
        q_ptr = &forge;
        object_copy(q_ptr, o_ptr);
 
index 2cdc500..7b05477 100644 (file)
@@ -58,7 +58,7 @@ void exe_read(player_type *creature_ptr, INVENTORY_IDX item, bool known)
        int k, used_up, ident, lev;
        object_type *o_ptr;
 
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
 
        take_turn(creature_ptr, 100);
        if (cmd_limit_time_walk(creature_ptr)) return;
index a244190..a56cec1 100644 (file)
@@ -294,7 +294,7 @@ void exe_use_staff(player_type *creature_ptr, INVENTORY_IDX item)
                /* Hack -- let staffs of identify get aborted */
        bool use_charge = TRUE;
 
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
 
        /* Mega-Hack -- refuse to use a pile from the ground */
        if ((item < 0) && (o_ptr->number > 1))
index a53c998..b967615 100644 (file)
@@ -290,7 +290,7 @@ void exe_zap_rod(player_type *creature_ptr, INVENTORY_IDX item)
 
        object_kind *k_ptr;
 
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
 
        /* Mega-Hack -- refuse to zap a pile from the ground */
        if ((item < 0) && (o_ptr->number > 1))
index 2db1fa6..ca16b37 100644 (file)
@@ -341,7 +341,7 @@ void exe_aim_wand(player_type *creature_ptr, INVENTORY_IDX item)
        object_type *o_ptr;
        bool old_target_pet = target_pet;
 
-       o_ptr = REF_ITEM(creature_ptr, creature_ptr->current_floor_ptr, item);
+       o_ptr = ref_item(creature_ptr, item);
 
        /* Mega-Hack -- refuse to aim a pile from the ground */
        if ((item < 0) && (o_ptr->number > 1))
index a4ac669..5d46d43 100644 (file)
@@ -1560,7 +1560,7 @@ object_type *choose_object(player_type *owner_ptr, OBJECT_IDX *idx, concptr q, c
        if (!get_item(owner_ptr, &item, q, s, option, tval)) return NULL;
        if (idx) *idx = item;
        if (item == INVEN_FORCE) return NULL;
-       return REF_ITEM(owner_ptr, owner_ptr->current_floor_ptr, item);
+       return ref_item(owner_ptr, item);
 }
 
 
index 4db8db6..8279228 100644 (file)
@@ -1437,3 +1437,9 @@ bool check_book_realm(player_type *owner_ptr, const tval_type book_tval, const O
 
        return (REALM1_BOOK == book_tval || REALM2_BOOK == book_tval);
 }
+
+object_type *ref_item(player_type *owner_ptr, INVENTORY_IDX item)
+{
+    floor_type *floor_ptr = owner_ptr->current_floor_ptr;
+       return item >= 0 ? &owner_ptr->inventory_list[item] : &(floor_ptr->o_list[0 - item]);
+}
index f3ccc92..c54fa0e 100644 (file)
@@ -48,9 +48,7 @@ extern char index_to_label(int i);
 extern s16b wield_slot(player_type *owner_ptr, object_type *o_ptr);
 
 extern bool check_book_realm(player_type *owner_ptr, const tval_type book_tval, const OBJECT_SUBTYPE_VALUE book_sval);
-
-#define REF_ITEM(P_PTR, FLOOR_PTR, ID) ((ID >= 0 ? &(P_PTR)->inventory_list[ID] : &(FLOOR_PTR)->o_list[0 - item]))
-
+extern object_type *ref_item(player_type *owner_ptr, INVENTORY_IDX item);
 extern int bow_tval_ammo(object_type *o_ptr);
 
 /*!