OSDN Git Service

[Refactor] #40521 Separated test_inventory() from get_item()
authorHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 02:23:19 +0000 (11:23 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 4 Jul 2020 02:23:19 +0000 (11:23 +0900)
src/inventory/floor-item-getter.c
src/inventory/item-getter.c

index 3b662a6..55ab1ec 100644 (file)
@@ -147,7 +147,7 @@ static bool check_floor_item_tag(player_type *owner_ptr, fis_type *fis_ptr, char
  * @param fis_ptr 床上アイテムへの参照ポインタ
  * @return なし
  */
-static void test_inventory(player_type *owner_ptr, fis_type *fis_ptr)
+static void test_inventory_floor(player_type *owner_ptr, fis_type *fis_ptr)
 {
     if (!fis_ptr->inven) {
         fis_ptr->i2 = -1;
@@ -168,7 +168,7 @@ static void test_inventory(player_type *owner_ptr, fis_type *fis_ptr)
  * @param fis_ptr 床上アイテムへの参照ポインタ
  * @return なし
  */
-static void test_equipment(player_type *owner_ptr, fis_type *fis_ptr)
+static void test_equipment_floor(player_type *owner_ptr, fis_type *fis_ptr)
 {
     if (!fis_ptr->equip) {
         fis_ptr->e2 = -1;
@@ -201,7 +201,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
         return TRUE;
 
     msg_print(NULL);
-    test_inventory(owner_ptr, fis_ptr);
+    test_inventory_floor(owner_ptr, fis_ptr);
     fis_ptr->done = FALSE;
     fis_ptr->item = FALSE;
     fis_ptr->i1 = 0;
@@ -214,7 +214,7 @@ bool get_item_floor(player_type *owner_ptr, COMMAND_CODE *cp, concptr pmt, concp
 
     fis_ptr->e1 = INVEN_RARM;
     fis_ptr->e2 = INVEN_TOTAL - 1;
-    test_equipment(owner_ptr, fis_ptr);
+    test_equipment_floor(owner_ptr, fis_ptr);
     if (owner_ptr->ryoute && !(fis_ptr->mode & IGNORE_BOTHHAND_SLOT))
         fis_ptr->max_equip++;
 
index e90d923..5d4a890 100644 (file)
@@ -128,6 +128,27 @@ static bool check_item_tag(player_type *owner_ptr, item_selection_type *item_sel
 }
 
 /*!
+ * @brief インベントリ内のアイテムが妥当かを判定する
+ * @param owner_ptr プレーヤーへの参照ポインタ
+ * @param fis_ptr アイテム選択への参照ポインタ
+ * @return なし
+ */
+static void test_inventory(player_type *owner_ptr, item_selection_type *item_selection_ptr)
+{
+    if (!item_selection_ptr->inven) {
+        item_selection_ptr->i2 = -1;
+        return;
+    }
+    
+    if (!use_menu)
+        return;
+
+    for (int j = 0; j < INVEN_PACK; j++)
+        if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], item_selection_ptr->tval) || (item_selection_ptr->mode & USE_FULL))
+            item_selection_ptr->max_inven++;
+}
+
+/*!
  * @brief オブジェクト選択の汎用関数 / General function for the selection of item
  * Let the user select an item, save its "index"
  * @param owner_ptr プレーヤーへの参照ポインタ
@@ -155,13 +176,7 @@ bool get_item(player_type *owner_ptr, OBJECT_IDX *cp, concptr pmt, concptr str,
     item_selection_ptr->item = FALSE;
     item_selection_ptr->i1 = 0;
     item_selection_ptr->i2 = INVEN_PACK - 1;
-    if (!item_selection_ptr->inven)
-        item_selection_ptr->i2 = -1;
-    else if (use_menu)
-        for (int j = 0; j < INVEN_PACK; j++)
-            if (item_tester_okay(owner_ptr, &owner_ptr->inventory_list[j], item_selection_ptr->tval) || (item_selection_ptr->mode & USE_FULL))
-                item_selection_ptr->max_inven++;
-
+    test_inventory(owner_ptr, item_selection_ptr);
     while ((item_selection_ptr->i1 <= item_selection_ptr->i2) && (!get_item_okay(owner_ptr, item_selection_ptr->i1, item_selection_ptr->tval)))
         item_selection_ptr->i1++;