OSDN Git Service

[Refactor] #40561 artifact-info.c/h from artifact.c/h
authorHourier <hourier@users.sourceforge.jp>
Tue, 14 Jul 2020 11:06:02 +0000 (20:06 +0900)
committerHourier <hourier@users.sourceforge.jp>
Tue, 14 Jul 2020 11:06:02 +0000 (20:06 +0900)
13 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/artifact/artifact-info.c [new file with mode: 0644]
src/artifact/artifact-info.h [new file with mode: 0644]
src/artifact/fixed-art-generator.c
src/artifact/random-art-generator.c
src/cmd-item/cmd-activate.c
src/market/building-craft-fix.c
src/object-enchant/artifact.c
src/object-enchant/artifact.h
src/object/object-info.c
src/object/object-value-calc.c

index bdf9850..1223d4b 100644 (file)
     <ClCompile Include="..\..\src\action\travel-execution.c" />\r
     <ClCompile Include="..\..\src\action\tunnel-execution.c" />\r
     <ClCompile Include="..\..\src\action\weapon-shield.c" />\r
+    <ClCompile Include="..\..\src\artifact\artifact-info.c" />\r
     <ClCompile Include="..\..\src\artifact\fixed-art-generator.c" />\r
     <ClCompile Include="..\..\src\artifact\random-art-activation.c" />\r
     <ClCompile Include="..\..\src\artifact\random-art-characteristics.c" />\r
     <ClInclude Include="..\..\src\art-definition\art-sword-types.h" />\r
     <ClInclude Include="..\..\src\art-definition\art-weapon-types.h" />\r
     <ClInclude Include="..\..\src\art-definition\random-art-effects.h" />\r
+    <ClInclude Include="..\..\src\artifact\artifact-info.h" />\r
     <ClInclude Include="..\..\src\artifact\fixed-art-generator.h" />\r
     <ClInclude Include="..\..\src\artifact\random-art-activation.h" />\r
     <ClInclude Include="..\..\src\artifact\random-art-generator.h" />\r
index b296947..e271395 100644 (file)
     <ClCompile Include="..\..\src\artifact\fixed-art-generator.c">
       <Filter>artifact</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\artifact\artifact-info.c">
+      <Filter>artifact</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\artifact\fixed-art-generator.h">
       <Filter>artifact</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\artifact\artifact-info.h">
+      <Filter>artifact</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index ab255a1..f282fc6 100644 (file)
@@ -14,6 +14,8 @@ hengband_SOURCES = \
        action/tunnel-execution.c action/tunnel-execution.h \
        action/weapon-shield.c action/weapon-shield.h \
        \
+       artifact/artifact-info.c artifact/artifact-info.h \
+       artifact/fixed-art-generator.c artifact/fixed-art-generator.h \
        artifact/random-art-activation.c artifact/random-art-activation.h \
        artifact/random-art-bias-types.h \
        artifact/random-art-characteristics.c artifact/random-art-characteristics.h \
diff --git a/src/artifact/artifact-info.c b/src/artifact/artifact-info.c
new file mode 100644 (file)
index 0000000..d0b667c
--- /dev/null
@@ -0,0 +1,64 @@
+#include "artifact/artifact-info.h"
+#include "art-definition/random-art-effects.h"
+#include "cmd-item/cmd-smith.h"
+#include "mind/mind-weaponsmith.h"
+#include "object-enchant/artifact.h"
+#include "object-enchant/object-ego.h"
+#include "object-enchant/tr-types.h"
+#include "object-hook/hook-enchant.h"
+#include "object/object-kind.h"
+#include "system/object-type-definition.h"
+#include "util/bit-flags-calculator.h"
+
+/*!
+ * @brief オブジェクトから能力発動IDを取得する。
+ * @details いくつかのケースで定義されている発動効果から、
+ * 鍛冶師による付与>固定アーティファクト>エゴ>ランダムアーティファクト>ベースアイテムの優先順位で走査していく。
+ * @param o_ptr 対象のオブジェクト構造体ポインタ
+ * @return 発動効果のIDを返す
+ */
+int activation_index(player_type *player_ptr, object_type *o_ptr)
+{
+    if (object_is_smith(player_ptr, o_ptr)) {
+        switch (o_ptr->xtra3 - 1) {
+        case ESSENCE_TMP_RES_ACID:
+            return ACT_RESIST_ACID;
+        case ESSENCE_TMP_RES_ELEC:
+            return ACT_RESIST_ELEC;
+        case ESSENCE_TMP_RES_FIRE:
+            return ACT_RESIST_FIRE;
+        case ESSENCE_TMP_RES_COLD:
+            return ACT_RESIST_COLD;
+        case TR_IMPACT:
+            return ACT_QUAKE;
+        }
+    }
+
+    if (object_is_fixed_artifact(o_ptr) && have_flag(a_info[o_ptr->name1].flags, TR_ACTIVATE))
+        return a_info[o_ptr->name1].act_idx;
+
+    if (object_is_ego(o_ptr) && have_flag(e_info[o_ptr->name2].flags, TR_ACTIVATE))
+        return e_info[o_ptr->name2].act_idx;
+
+    if (!object_is_random_artifact(o_ptr) && have_flag(k_info[o_ptr->k_idx].flags, TR_ACTIVATE))
+        return k_info[o_ptr->k_idx].act_idx;
+
+    return o_ptr->xtra2;
+}
+
+/*!
+ * @brief オブジェクトから発動効果構造体のポインタを取得する。
+ * @details activation_index() 関数の結果から参照する。
+ * @param o_ptr 対象のオブジェクト構造体ポインタ
+ * @return 発動効果構造体のポインタを返す
+ */
+const activation_type *find_activation_info(player_type *player_ptr, object_type *o_ptr)
+{
+    const int index = activation_index(player_ptr, o_ptr);
+    const activation_type *p;
+    for (p = activation_info; p->flag != NULL; ++p)
+        if (p->index == index)
+            return p;
+
+    return NULL;
+}
diff --git a/src/artifact/artifact-info.h b/src/artifact/artifact-info.h
new file mode 100644 (file)
index 0000000..0c4d141
--- /dev/null
@@ -0,0 +1,7 @@
+#pragma once
+
+#include "object-enchant/activation-info-table.h"
+#include "system/angband.h"
+
+int activation_index(player_type *player_ptr, object_type *o_ptr);
+const activation_type *find_activation_info(player_type *player_ptr, object_type *o_ptr);
index 0f34bf7..fbe5801 100644 (file)
@@ -1,4 +1,16 @@
-#include "artifact/fixed-art-generator.h"
+/*!
+ * @brief 固定アーティファクトの生成 / Artifact code
+ * @date 2020/07/14
+ * @author
+ * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * This software may be copied and distributed for educational, research, and
+ * not for profit purposes provided that this copyright and statement are
+ * included in all such copies.
+ * 2013 Deskull rearranged comment for Doxygen.
+ * 2020 Hourier rearranged
+ */
+
+#include "artifact/fixed-art-generator.h"
 #include "art-definition/art-armor-types.h"
 #include "art-definition/art-protector-types.h"
 #include "art-definition/art-sword-types.h"
index a2e8035..7e4bf62 100644 (file)
@@ -1,4 +1,10 @@
-#include "artifact/random-art-generator.h"
+/*!
+ * @brief ランダムアーティファクトの生成 / Artifact code
+ * @date 2020/07/14
+ * @author Hourier
+ */
+
+#include "artifact/random-art-generator.h"
 #include "artifact/random-art-activation.h"
 #include "artifact/random-art-bias-types.h"
 #include "artifact/random-art-characteristics.h"
index 5b09e37..ff442ff 100644 (file)
@@ -6,6 +6,7 @@
 
 #include "cmd-item/cmd-activate.h"
 #include "action/action-limited.h"
+#include "artifact/artifact-info.h"
 #include "art-definition/art-bow-types.h"
 #include "art-definition/art-sword-types.h"
 #include "art-definition/art-weapon-types.h"
index 29dd323..52ac39b 100644 (file)
@@ -1,4 +1,5 @@
 #include "market/building-craft-fix.h"
+#include "artifact/artifact-info.h"
 #include "art-definition/art-sword-types.h"
 #include "core/asking-player.h"
 #include "core/player-update-types.h"
@@ -9,7 +10,6 @@
 #include "inventory/inventory-object.h"
 #include "market/building-util.h"
 #include "mind/racial-android.h"
-#include "object-enchant/artifact.h"
 #include "object-enchant/object-boost.h"
 #include "object-enchant/special-object-flags.h"
 #include "object-enchant/tr-types.h"
index af812a2..e18bb9b 100644 (file)
@@ -1,65 +1,4 @@
-/*!
- * @brief アーティファクトの生成と管理 / Artifact code
- * @date 2013/12/11
- * @author
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke\n
- * This software may be copied and distributed for educational, research, and\n
- * not for profit purposes provided that this copyright and statement are\n
- * included in all such copies.\n
- * 2013 Deskull rearranged comment for Doxygen.
- */
-
-#include "object-enchant/artifact.h"
-#include "artifact/random-art-activation.h"
-#include "artifact/random-art-bias-types.h"
-#include "artifact/random-art-characteristics.h"
-#include "artifact/random-art-pval-investor.h"
-#include "art-definition/art-armor-types.h"
-#include "art-definition/art-protector-types.h"
-#include "art-definition/art-sword-types.h"
-#include "art-definition/art-weapon-types.h"
-#include "art-definition/random-art-effects.h"
-#include "cmd-item/cmd-smith.h"
-#include "core/asking-player.h"
-#include "core/window-redrawer.h"
-#include "flavor/object-flavor.h"
-#include "floor/floor-object.h"
-#include "floor/floor.h"
-#include "game-option/cheat-types.h"
-#include "grid/grid.h"
-#include "io/files-util.h"
-#include "mind/mind-weaponsmith.h"
-#include "object-enchant/object-boost.h"
-#include "object-enchant/object-curse.h"
-#include "object-enchant/object-ego.h"
-#include "object-enchant/special-object-flags.h"
-#include "object-enchant/tr-types.h"
-#include "object-enchant/trc-types.h"
-#include "object-enchant/trg-types.h"
-#include "object-hook/hook-armor.h"
-#include "object-hook/hook-checker.h"
-#include "object-hook/hook-enchant.h"
-#include "object-hook/hook-weapon.h"
-#include "object/object-flags.h"
-#include "object/object-generator.h"
-#include "object/object-kind-hook.h"
-#include "object/object-kind.h"
-#include "object/object-value-calc.h"
-#include "perception/identification.h"
-#include "perception/object-perception.h"
-#include "player/avatar.h"
-#include "player/player-class.h"
-#include "player/player-personalities-types.h"
-#include "spell/spells-object.h"
-#include "sv-definition/sv-armor-types.h"
-#include "sv-definition/sv-weapon-types.h"
-#include "system/system-variables.h"
-#include "util/bit-flags-calculator.h"
-#include "util/quarks.h"
-#include "view/display-messages.h"
-#include "wizard/artifact-bias-table.h"
-#include "wizard/wizard-messages.h"
-#include "world/world.h"
+#include "object-enchant/artifact.h"
 
 /*
  * The artifact arrays
@@ -72,67 +11,3 @@ char *a_text;
  * Maximum number of artifacts in a_info.txt
  */
 ARTIFACT_IDX max_a_idx;
-
-/*!
- * @brief オブジェクトから能力発動IDを取得する。
- * @details いくつかのケースで定義されている発動効果から、
- * 鍛冶師による付与>固定アーティファクト>エゴ>ランダムアーティファクト>ベースアイテムの優先順位で走査していく。
- * @param o_ptr 対象のオブジェクト構造体ポインタ
- * @return 発動効果のIDを返す
- */
-int activation_index(player_type *player_ptr, object_type *o_ptr)
-{
-    if (object_is_smith(player_ptr, o_ptr)) {
-        switch (o_ptr->xtra3 - 1) {
-        case ESSENCE_TMP_RES_ACID:
-            return ACT_RESIST_ACID;
-        case ESSENCE_TMP_RES_ELEC:
-            return ACT_RESIST_ELEC;
-        case ESSENCE_TMP_RES_FIRE:
-            return ACT_RESIST_FIRE;
-        case ESSENCE_TMP_RES_COLD:
-            return ACT_RESIST_COLD;
-        case TR_IMPACT:
-            return ACT_QUAKE;
-        }
-    }
-
-    if (object_is_fixed_artifact(o_ptr)) {
-        if (have_flag(a_info[o_ptr->name1].flags, TR_ACTIVATE)) {
-            return a_info[o_ptr->name1].act_idx;
-        }
-    }
-
-    if (object_is_ego(o_ptr)) {
-        if (have_flag(e_info[o_ptr->name2].flags, TR_ACTIVATE)) {
-            return e_info[o_ptr->name2].act_idx;
-        }
-    }
-
-    if (!object_is_random_artifact(o_ptr)) {
-        if (have_flag(k_info[o_ptr->k_idx].flags, TR_ACTIVATE)) {
-            return k_info[o_ptr->k_idx].act_idx;
-        }
-    }
-
-    return o_ptr->xtra2;
-}
-
-/*!
- * @brief オブジェクトから発動効果構造体のポインタを取得する。
- * @details activation_index() 関数の結果から参照する。
- * @param o_ptr 対象のオブジェクト構造体ポインタ
- * @return 発動効果構造体のポインタを返す
- */
-const activation_type *find_activation_info(player_type *player_ptr, object_type *o_ptr)
-{
-    const int index = activation_index(player_ptr, o_ptr);
-    const activation_type *p;
-    for (p = activation_info; p->flag != NULL; ++p) {
-        if (p->index == index) {
-            return p;
-        }
-    }
-
-    return NULL;
-}
index 9abdc3b..6c74fa1 100644 (file)
@@ -41,6 +41,3 @@ extern artifact_type *a_info;
 extern char *a_name;
 extern char *a_text;
 extern ARTIFACT_IDX max_a_idx;
-
-int activation_index(player_type *player_ptr, object_type *o_ptr);
-const activation_type *find_activation_info(player_type *player_ptr, object_type *o_ptr);
index 6ae085e..5623422 100644 (file)
  */
 
 #include "object/object-info.h"
+#include "artifact/artifact-info.h"
 #include "art-definition/art-weapon-types.h"
 #include "art-definition/random-art-effects.h"
 #include "floor/floor.h"
 #include "inventory/inventory-slot-types.h"
 #include "monster-race/monster-race.h"
 #include "object-enchant/activation-info-table.h"
-#include "object-enchant/artifact.h"
 #include "object-enchant/dragon-breaths-table.h"
 #include "object-enchant/object-ego.h"
 #include "object/object-flags.h"
index dc5ee56..7256e8e 100644 (file)
@@ -1,4 +1,5 @@
 #include "object/object-value-calc.h"
+#include "artifact/artifact-info.h"
 #include "object-enchant/artifact.h"
 #include "object-enchant/object-ego.h"
 #include "object-enchant/tr-types.h"