OSDN Git Service

[Refactor] #40634 Moved activate_artifact() from activation-switcher.c/h to activatio...
authorHourier <hourier@users.sourceforge.jp>
Wed, 19 Aug 2020 05:48:59 +0000 (14:48 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 19 Aug 2020 05:48:59 +0000 (14:48 +0900)
src/action/activation-execution.c
src/object-activation/activation-switcher.c
src/object-activation/activation-switcher.h
src/object-enchant/activation-info-table.h

index 89f8d0a..6ed4a27 100644 (file)
@@ -1,5 +1,6 @@
 #include "action/activation-execution.h"
 #include "action/action-limited.h"
+#include "art-definition/random-art-effects.h"
 #include "artifact/artifact-info.h"
 #include "core/window-redrawer.h"
 #include "effect/spells-effect-util.h"
@@ -24,6 +25,7 @@
 #include "spell-realm/spells-hex.h"
 #include "spell/spell-types.h"
 #include "sv-definition/sv-lite-types.h"
+#include "sv-definition/sv-ring-types.h"
 #include "system/artifact-type-definition.h"
 #include "system/floor-type-definition.h"
 #include "system/monster-type-definition.h"
@@ -137,6 +139,50 @@ static bool check_activation_conditions(player_type *user_ptr, ae_type *ae_ptr)
     return TRUE;
 }
 
+/*!
+ * @brief \83A\83C\83e\83\80\82Ì\94­\93®\8cø\89Ê\82ð\8f\88\97\9d\82·\82é\81B
+ * @param user_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param o_ptr \91Î\8fÛ\82Ì\83I\83u\83W\83F\83N\83g\8d\\91¢\91Ì\83|\83C\83\93\83^
+ * @return \94­\93®\8eÀ\8ds\82Ì\90¥\94ñ\82ð\95Ô\82·\81B
+ */
+static bool activate_artifact(player_type *user_ptr, object_type *o_ptr)
+{
+    concptr name = k_name + k_info[o_ptr->k_idx].name;
+    const activation_type *const act_ptr = find_activation_info(user_ptr, o_ptr);
+    if (!act_ptr) {
+        msg_print("Activation information is not found.");
+        return FALSE;
+    }
+
+    if (!switch_activation(user_ptr, o_ptr, act_ptr, name))
+        return FALSE;
+
+    if (act_ptr->timeout.constant >= 0) {
+        o_ptr->timeout = (s16b)act_ptr->timeout.constant;
+        if (act_ptr->timeout.dice > 0)
+            o_ptr->timeout += randint1(act_ptr->timeout.dice);
+
+        return TRUE;
+    }
+
+    switch (act_ptr->index) {
+    case ACT_BR_FIRE:
+        o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
+        return TRUE;
+    case ACT_BR_COLD:
+        o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250;
+        return TRUE;
+    case ACT_TERROR:
+        o_ptr->timeout = 3 * (user_ptr->lev + 10);
+        return TRUE;
+    case ACT_MURAMASA:
+        return TRUE;
+    default:
+        msg_format("Special timeout is not implemented: %d.", act_ptr->index);
+        return FALSE;
+    }
+}
+
 static bool activate_whistle(player_type *user_ptr, ae_type *ae_ptr)
 {
     if (ae_ptr->o_ptr->tval != TV_WHISTLE)
index 24cf226..2116fb7 100644 (file)
@@ -505,47 +505,3 @@ bool switch_activation(player_type *user_ptr, object_type *o_ptr, const activati
         return FALSE;
     }
 }
-
-/*!
- * @brief アイテムの発動効果を処理する。
- * @param user_ptr プレーヤーへの参照ポインタ
- * @param o_ptr 対象のオブジェクト構造体ポインタ
- * @return 発動実行の是非を返す。
- */
-bool activate_artifact(player_type *user_ptr, object_type *o_ptr)
-{
-    concptr name = k_name + k_info[o_ptr->k_idx].name;
-    const activation_type *const act_ptr = find_activation_info(user_ptr, o_ptr);
-    if (!act_ptr) {
-        msg_print("Activation information is not found.");
-        return FALSE;
-    }
-
-    if (!switch_activation(user_ptr, o_ptr, act_ptr, name))
-        return FALSE;
-
-    if (act_ptr->timeout.constant >= 0) {
-        o_ptr->timeout = (s16b)act_ptr->timeout.constant;
-        if (act_ptr->timeout.dice > 0)
-            o_ptr->timeout += randint1(act_ptr->timeout.dice);
-
-        return TRUE;
-    }
-
-    switch (act_ptr->index) {
-    case ACT_BR_FIRE:
-        o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_FLAMES)) ? 200 : 250;
-        return TRUE;
-    case ACT_BR_COLD:
-        o_ptr->timeout = ((o_ptr->tval == TV_RING) && (o_ptr->sval == SV_RING_ICE)) ? 200 : 250;
-        return TRUE;
-    case ACT_TERROR:
-        o_ptr->timeout = 3 * (user_ptr->lev + 10);
-        return TRUE;
-    case ACT_MURAMASA:
-        return TRUE;
-    default:
-        msg_format("Special timeout is not implemented: %d.", act_ptr->index);
-        return FALSE;
-    }
-}
index 7ae84ef..b86a854 100644 (file)
@@ -1,6 +1,6 @@
 #pragma once
 
 #include "system/angband.h"
-#include "system/object-type-definition.h"
 
-bool activate_artifact(player_type *user_ptr, object_type *o_ptr);
+typedef struct activation_type activation_type;
+bool switch_activation(player_type *user_ptr, object_type *o_ptr, const activation_type *const act_ptr, concptr name);
index 534e657..b4ce797 100644 (file)
@@ -2,7 +2,7 @@
 
 #include "system/angband.h"
 
-typedef struct {
+typedef struct activation_type {
     concptr flag;
     byte index;
     byte level;