OSDN Git Service

[Refactor] #40399 Moved get_random_ego() from object2.c to object-ego.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 2 Jun 2020 13:01:48 +0000 (22:01 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 2 Jun 2020 13:23:23 +0000 (22:23 +0900)
src/object/object-ego.c
src/object/object-ego.h
src/object/object2.c

index f8a67fd..c977c16 100644 (file)
@@ -1,4 +1,9 @@
-#include "system/angband.h"
+/*!
+ * @brief エゴアイテムに関する処理
+ * @date 2019/05/02
+ * @author deskull
+ * @details Ego-Item indexes (see "lib/edit/e_info.txt")
+ */
 #include "object/object-ego.h"
 
 /*
@@ -12,3 +17,38 @@ char *e_text;
  * Maximum number of ego-items in e_info.txt
  */
 EGO_IDX max_e_idx;
+
+/*!
+ * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
+ * Choose random ego type
+ * @param slot 取得したいエゴの装備部位
+ * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
+ * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
+ */
+byte get_random_ego(byte slot, bool good)
+{
+    long total = 0L;
+    for (int i = 1; i < max_e_idx; i++) {
+        ego_item_type *e_ptr;
+        e_ptr = &e_info[i];
+        if (e_ptr->slot == slot && ((good && e_ptr->rating) || (!good && !e_ptr->rating))) {
+            if (e_ptr->rarity)
+                total += (255 / e_ptr->rarity);
+        }
+    }
+
+    int value = randint1(total);
+    int j;
+    for (j = 1; j < max_e_idx; j++) {
+        ego_item_type *e_ptr;
+        e_ptr = &e_info[j];
+        if (e_ptr->slot == slot && ((good && e_ptr->rating) || (!good && !e_ptr->rating))) {
+            if (e_ptr->rarity)
+                value -= (255 / e_ptr->rarity);
+            if (value <= 0L)
+                break;
+        }
+    }
+
+    return (byte)j;
+}
index 5ea3172..1fcafdd 100644 (file)
@@ -1,13 +1,6 @@
 #pragma once
 
-
-/*** Ego-Item indexes (see "lib/edit/e_info.txt") ***/
-
-
-/* Nothing */
-/* xxx */
-/* xxx */
-/* xxx */
+#include "system/angband.h"
 
 /* Body Armor */
 #define EGO_A_MORGUL            4
@@ -269,3 +262,4 @@ extern ego_item_type *e_info;
 extern char *e_name;
 extern char *e_text;
 
+byte get_random_ego(byte slot, bool good);
index 9e59b8a..d71c9bc 100644 (file)
@@ -679,47 +679,6 @@ void object_absorb(object_type *o_ptr, object_type *j_ptr)
 
 
 /*!
- * @brief アイテムのエゴをレア度の重みに合わせてランダムに選択する
- * Choose random ego type
- * @param slot 取得したいエゴの装備部位
- * @param good TRUEならば通常のエゴ、FALSEならば呪いのエゴが選択対象となる。
- * @return 選択されたエゴ情報のID、万一選択できなかった場合はmax_e_idxが返る。
- */
-static byte get_random_ego(byte slot, bool good)
-{
-       long total = 0L;
-       for (int i = 1; i < max_e_idx; i++)
-       {
-               ego_item_type *e_ptr;
-               e_ptr = &e_info[i];
-               if (e_ptr->slot == slot
-                       && ((good && e_ptr->rating) || (!good && !e_ptr->rating)))
-               {
-                       if (e_ptr->rarity)
-                               total += (255 / e_ptr->rarity);
-               }
-       }
-
-       int value = randint1(total);
-       int j;
-       for (j = 1; j < max_e_idx; j++)
-       {
-               ego_item_type *e_ptr;
-               e_ptr = &e_info[j];
-               if (e_ptr->slot == slot
-                       && ((good && e_ptr->rating) || (!good && !e_ptr->rating)))
-               {
-                       if (e_ptr->rarity)
-                               value -= (255 / e_ptr->rarity);
-                       if (value <= 0L) break;
-               }
-       }
-
-       return (byte)j;
-}
-
-
-/*!
  * @brief 武器系オブジェクトに生成ランクごとの強化を与えるサブルーチン
  * Apply magic to an item known to be a "weapon"
  * @param owner_ptr プレーヤーへの参照ポインタ