OSDN Git Service

[Refactor] #39970 Separated recharge-processor.c/h from core.c
authorHourier <hourier@users.sourceforge.jp>
Sat, 9 May 2020 11:51:07 +0000 (20:51 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sat, 9 May 2020 11:51:07 +0000 (20:51 +0900)
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/core.c
src/inventory/recharge-processor.c [new file with mode: 0644]
src/inventory/recharge-processor.h [new file with mode: 0644]

index a5eadf9..cdfa755 100644 (file)
     <ClCompile Include="..\..\src\effect\spells-effect-util.c" />\r
     <ClCompile Include="..\..\src\floor\pattern-walk.c" />\r
     <ClCompile Include="..\..\src\inventory\inventory-curse.c" />\r
+    <ClCompile Include="..\..\src\inventory\recharge-processor.c" />\r
     <ClCompile Include="..\..\src\inventory\simple-appraiser.c" />\r
     <ClCompile Include="..\..\src\io\dump-remover.c" />\r
     <ClCompile Include="..\..\src\io\mutations-dump.c" />\r
     <ClInclude Include="..\..\src\effect\spells-effect-util.h" />\r
     <ClInclude Include="..\..\src\floor\pattern-walk.h" />\r
     <ClInclude Include="..\..\src\inventory\inventory-curse.h" />\r
+    <ClInclude Include="..\..\src\inventory\recharge-processor.h" />\r
     <ClInclude Include="..\..\src\inventory\simple-appraiser.h" />\r
     <ClInclude Include="..\..\src\io\dump-remover.h" />\r
     <ClInclude Include="..\..\src\io\mutations-dump.h" />\r
index 1e40db2..583347c 100644 (file)
     <ClCompile Include="..\..\src\inventory\inventory-curse.c">
       <Filter>inventory</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\inventory\recharge-processor.c">
+      <Filter>inventory</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\inventory\inventory-curse.h">
       <Filter>inventory</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\inventory\recharge-processor.h">
+      <Filter>inventory</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 8d3751f..425343c 100644 (file)
@@ -142,6 +142,7 @@ hengband_SOURCES = \
        \
        inventory/simple-appraiser.c inventory/simple-appraiser.h \
        inventory/inventory-curse.c inventory/inventory-curse.h \
+       inventory/recharge-processor.c inventory/recharge-processor.h \
        \
        patron.h patron.c \
        \
index 234f269..655b74d 100644 (file)
@@ -81,8 +81,6 @@
 #include "player-effects.h"
 #include "cmd-spell.h"
 #include "realm/realm-hex.h"
-#include "object/object-kind.h"
-#include "object-hook.h"
 #include "wild.h"
 #include "monster-process.h"
 #include "monster-status.h"
 #include "object/lite-processor.h"
 #include "core/magic-effects-timeout-reducer.h"
 #include "inventory/inventory-curse.h"
+#include "inventory/recharge-processor.h"
 
  /*!
   * コピーライト情報 /
@@ -155,41 +154,6 @@ static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
 int init_flags;
 
 /*!
- * @brief
- * !!を刻んだ魔道具の時間経過による再充填を知らせる処理 /
- * If player has inscribed the object with "!!", let him know when it's recharged. -LM-
- * @param o_ptr 対象オブジェクトの構造体参照ポインタ
- * @return なし
- */
-static void recharged_notice(player_type *owner_ptr, object_type *o_ptr)
-{
-       if (!o_ptr->inscription) return;
-
-       concptr s = my_strchr(quark_str(o_ptr->inscription), '!');
-       while (s)
-       {
-               if (s[1] == '!')
-               {
-                       GAME_TEXT o_name[MAX_NLEN];
-                       object_desc(owner_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
-#ifdef JP
-                       msg_format("%sは再充填された。", o_name);
-#else
-                       if (o_ptr->number > 1)
-                               msg_format("Your %s are recharged.", o_name);
-                       else
-                               msg_format("Your %s is recharged.", o_name);
-#endif
-                       disturb(owner_ptr, FALSE, FALSE);
-                       return;
-               }
-
-               s = my_strchr(s + 1, '!');
-       }
-}
-
-
-/*!
  * @brief プレイヤーの歌に関する継続処理
  * @return なし
  */
@@ -303,89 +267,6 @@ static void process_world_aux_digestion(player_type *creature_ptr)
 
 
 /*!
- * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
- * / Handle recharging objects once every 10 game turns
- * @return なし
- */
-static void process_world_aux_recharge(player_type *creature_ptr)
-{
-       int i;
-       bool changed;
-
-       for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++)
-       {
-               object_type *o_ptr = &creature_ptr->inventory_list[i];
-               if (!o_ptr->k_idx) continue;
-
-               if (o_ptr->timeout > 0)
-               {
-                       o_ptr->timeout--;
-                       if (!o_ptr->timeout)
-                       {
-                               recharged_notice(creature_ptr, o_ptr);
-                               changed = TRUE;
-                       }
-               }
-       }
-
-       if (changed)
-       {
-               creature_ptr->window |= (PW_EQUIP);
-               wild_regen = 20;
-       }
-
-       /*
-        * Recharge rods.  Rods now use timeout to control charging status,
-        * and each charging rod in a stack decreases the stack's timeout by
-        * one per turn. -LM-
-        */
-       for (changed = FALSE, i = 0; i < INVEN_PACK; i++)
-       {
-               object_type *o_ptr = &creature_ptr->inventory_list[i];
-               object_kind *k_ptr = &k_info[o_ptr->k_idx];
-               if (!o_ptr->k_idx) continue;
-
-               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
-               {
-                       TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
-                       if (temp > o_ptr->number) temp = (TIME_EFFECT)o_ptr->number;
-
-                       o_ptr->timeout -= temp;
-                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
-
-                       if (!(o_ptr->timeout))
-                       {
-                               recharged_notice(creature_ptr, o_ptr);
-                               changed = TRUE;
-                       }
-                       else if (o_ptr->timeout % k_ptr->pval)
-                       {
-                               changed = TRUE;
-                       }
-               }
-       }
-
-       if (changed)
-       {
-               creature_ptr->window |= (PW_INVEN);
-               wild_regen = 20;
-       }
-
-       for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++)
-       {
-               object_type *o_ptr = &creature_ptr->current_floor_ptr->o_list[i];
-               if (!OBJECT_IS_VALID(o_ptr)) continue;
-
-               if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout))
-               {
-                       o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
-                       if (o_ptr->timeout < 0) o_ptr->timeout = 0;
-               }
-       }
-}
-
-
-/*!
  * @brief 10ゲームターンが進行するごとに帰還や現実変容などの残り時間カウントダウンと発動を処理する。
  * / Handle involuntary movement once every 10 game turns
  * @return なし
@@ -741,7 +622,7 @@ static void process_world(player_type *player_ptr)
        reduce_lite_life(player_ptr);
        process_world_aux_mutation(player_ptr);
        process_world_aux_curse(player_ptr);
-       process_world_aux_recharge(player_ptr);
+       recharge_magic_items(player_ptr);
        sense_inventory1(player_ptr);
        sense_inventory2(player_ptr);
        process_world_aux_movement(player_ptr);
diff --git a/src/inventory/recharge-processor.c b/src/inventory/recharge-processor.c
new file mode 100644 (file)
index 0000000..65cc08b
--- /dev/null
@@ -0,0 +1,115 @@
+#include "angband.h"
+#include "object-flavor.h"
+#include "player-move.h"
+#include "core/hp-mp-regenerator.h"
+#include "object/object-kind.h"
+#include "object-hook.h"
+
+/*!
+ * @brief
+ * !!を刻んだ魔道具の時間経過による再充填を知らせる処理 /
+ * If player has inscribed the object with "!!", let him know when it's recharged. -LM-
+ * @param o_ptr 対象オブジェクトの構造体参照ポインタ
+ * @return なし
+ */
+static void recharged_notice(player_type* owner_ptr, object_type* o_ptr)
+{
+    if (!o_ptr->inscription)
+        return;
+
+    concptr s = my_strchr(quark_str(o_ptr->inscription), '!');
+    while (s) {
+        if (s[1] == '!') {
+            GAME_TEXT o_name[MAX_NLEN];
+            object_desc(owner_ptr, o_name, o_ptr, (OD_OMIT_PREFIX | OD_NAME_ONLY));
+#ifdef JP
+            msg_format("%sは再充填された。", o_name);
+#else
+            if (o_ptr->number > 1)
+                msg_format("Your %s are recharged.", o_name);
+            else
+                msg_format("Your %s is recharged.", o_name);
+#endif
+            disturb(owner_ptr, FALSE, FALSE);
+            return;
+        }
+
+        s = my_strchr(s + 1, '!');
+    }
+}
+
+/*!
+ * @brief 10ゲームターンが進行するごとに魔道具の自然充填を行う処理
+ * / Handle recharging objects once every 10 game turns
+ * @return なし
+ */
+void recharge_magic_items(player_type* creature_ptr)
+{
+    int i;
+    bool changed;
+
+    for (changed = FALSE, i = INVEN_RARM; i < INVEN_TOTAL; i++) {
+        object_type* o_ptr = &creature_ptr->inventory_list[i];
+        if (!o_ptr->k_idx)
+            continue;
+
+        if (o_ptr->timeout > 0) {
+            o_ptr->timeout--;
+            if (!o_ptr->timeout) {
+                recharged_notice(creature_ptr, o_ptr);
+                changed = TRUE;
+            }
+        }
+    }
+
+    if (changed) {
+        creature_ptr->window |= (PW_EQUIP);
+        wild_regen = 20;
+    }
+
+    /*
+        * Recharge rods.  Rods now use timeout to control charging status,
+        * and each charging rod in a stack decreases the stack's timeout by
+        * one per turn. -LM-
+        */
+    for (changed = FALSE, i = 0; i < INVEN_PACK; i++) {
+        object_type* o_ptr = &creature_ptr->inventory_list[i];
+        object_kind* k_ptr = &k_info[o_ptr->k_idx];
+        if (!o_ptr->k_idx)
+            continue;
+
+        if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) {
+            TIME_EFFECT temp = (o_ptr->timeout + (k_ptr->pval - 1)) / k_ptr->pval;
+            if (temp > o_ptr->number)
+                temp = (TIME_EFFECT)o_ptr->number;
+
+            o_ptr->timeout -= temp;
+            if (o_ptr->timeout < 0)
+                o_ptr->timeout = 0;
+
+            if (!(o_ptr->timeout)) {
+                recharged_notice(creature_ptr, o_ptr);
+                changed = TRUE;
+            } else if (o_ptr->timeout % k_ptr->pval) {
+                changed = TRUE;
+            }
+        }
+    }
+
+    if (changed) {
+        creature_ptr->window |= (PW_INVEN);
+        wild_regen = 20;
+    }
+
+    for (i = 1; i < creature_ptr->current_floor_ptr->o_max; i++) {
+        object_type* o_ptr = &creature_ptr->current_floor_ptr->o_list[i];
+        if (!OBJECT_IS_VALID(o_ptr))
+            continue;
+
+        if ((o_ptr->tval == TV_ROD) && (o_ptr->timeout)) {
+            o_ptr->timeout -= (TIME_EFFECT)o_ptr->number;
+            if (o_ptr->timeout < 0)
+                o_ptr->timeout = 0;
+        }
+    }
+}
diff --git a/src/inventory/recharge-processor.h b/src/inventory/recharge-processor.h
new file mode 100644 (file)
index 0000000..d842597
--- /dev/null
@@ -0,0 +1,3 @@
+#pragma once
+
+void recharge_magic_items(player_type* creature_ptr);