OSDN Git Service

[Refactor] #39963 Separated effect-monster-util.c/h from effect-monster.c
authorHourier <hourier@users.sourceforge.jp>
Wed, 29 Apr 2020 09:09:28 +0000 (18:09 +0900)
committerHourier <hourier@users.sourceforge.jp>
Wed, 29 Apr 2020 09:09:28 +0000 (18:09 +0900)
Hengband_vcs2017/Hengband/Hengband.vcxproj
Hengband_vcs2017/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/effect/effect-monster-util.c [new file with mode: 0644]
src/effect/effect-monster-util.h [new file with mode: 0644]
src/effect/effect-monster.c

index 408f2cd..85da93e 100644 (file)
     <ClCompile Include="..\..\src\cmd\dump-util.c" />\r
     <ClCompile Include="..\..\src\effect\effect-feature.c" />\r
     <ClCompile Include="..\..\src\effect\effect-item.c" />\r
+    <ClCompile Include="..\..\src\effect\effect-monster-util.c" />\r
     <ClCompile Include="..\..\src\effect\effect-monster.c" />\r
     <ClCompile Include="..\..\src\effect\effect-player.c" />\r
     <ClCompile Include="..\..\src\effect\spells-effect-util.c" />\r
     <ClInclude Include="..\..\src\cmd\dump-util.h" />\r
     <ClInclude Include="..\..\src\effect\effect-feature.h" />\r
     <ClInclude Include="..\..\src\effect\effect-item.h" />\r
+    <ClInclude Include="..\..\src\effect\effect-monster-util.h" />\r
     <ClInclude Include="..\..\src\effect\effect-monster.h" />\r
     <ClInclude Include="..\..\src\effect\effect-player.h" />\r
     <ClInclude Include="..\..\src\effect\spells-effect-util.h" />\r
index a75a3e7..846a9cf 100644 (file)
     <ClCompile Include="..\..\src\effect\effect-monster.c">
       <Filter>effect</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\effect\effect-monster-util.c">
+      <Filter>effect</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\gamevalue.h" />
     <ClInclude Include="..\..\src\effect\effect-monster.h">
       <Filter>effect</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\effect\effect-monster-util.h">
+      <Filter>effect</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index bf4870a..c9c543b 100644 (file)
@@ -170,6 +170,7 @@ hengband_SOURCES = \
        effect/spells-effect-util.c effect/spells-effect-util.h \
        effect/effect-player.c effect/effect-player.h \
        effect/effect-monster.c effect/effect-monster.h \
+       effect/effect-monster-util.c effect/effect-monster-util.h \
        \
        spell/technic-info-table.c spell/technic-info-table.h \
        spell/spells-execution.c spell/spells-execution.h \
diff --git a/src/effect/effect-monster-util.c b/src/effect/effect-monster-util.c
new file mode 100644 (file)
index 0000000..7656835
--- /dev/null
@@ -0,0 +1,54 @@
+#include "angband.h"
+#include "effect/effect-monster-util.h"
+
+static void substitute_effect_monster(effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
+{
+       effect_monster_ptr->who = who;
+       effect_monster_ptr->r = r;
+       effect_monster_ptr->y = y;
+       effect_monster_ptr->x = x;
+       effect_monster_ptr->dam = dam;
+       effect_monster_ptr->effect_type = effect_type;
+       effect_monster_ptr->flag = flag;
+       effect_monster_ptr->see_s_msg = see_s_msg;
+}
+
+
+/*!
+ * @brief effect_monster構造体を初期化する
+ * @param caster_ptr プレーヤーへの参照ポインタ
+ * @param effect_monster_ptr モンスター効果構造体への参照ポインタ
+ * @param 魔法を発動したモンスター (0ならばプレーヤー)
+ * @param 目標y座標
+ * @param 目標x座標
+ * @return なし
+ */
+void initialize_effect_monster(player_type *caster_ptr, effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
+{
+       substitute_effect_monster(effect_monster_ptr, who, r, y, x, dam, effect_type, flag, see_s_msg);
+
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
+       effect_monster_ptr->g_ptr = &floor_ptr->grid_array[effect_monster_ptr->y][effect_monster_ptr->x];
+       effect_monster_ptr->m_ptr = &floor_ptr->m_list[effect_monster_ptr->g_ptr->m_idx];
+       effect_monster_ptr->m_caster_ptr = (effect_monster_ptr->who > 0) ? &floor_ptr->m_list[effect_monster_ptr->who] : NULL;
+       effect_monster_ptr->r_ptr = &r_info[effect_monster_ptr->m_ptr->r_idx];
+       effect_monster_ptr->seen = effect_monster_ptr->m_ptr->ml;
+       effect_monster_ptr->seen_msg = is_seen(effect_monster_ptr->m_ptr);
+       effect_monster_ptr->slept = (bool)MON_CSLEEP(effect_monster_ptr->m_ptr);
+       effect_monster_ptr->obvious = FALSE;
+       effect_monster_ptr->known = ((effect_monster_ptr->m_ptr->cdis <= MAX_SIGHT) || caster_ptr->phase_out);
+       effect_monster_ptr->skipped = FALSE;
+       effect_monster_ptr->get_angry = FALSE;
+       effect_monster_ptr->do_poly = FALSE;
+       effect_monster_ptr->do_dist = 0;
+       effect_monster_ptr->do_conf = 0;
+       effect_monster_ptr->do_stun = 0;
+       effect_monster_ptr->do_sleep = 0;
+       effect_monster_ptr->do_fear = 0;
+       effect_monster_ptr->do_time = 0;
+       effect_monster_ptr->heal_leper = FALSE;
+       effect_monster_ptr->photo = 0;
+       effect_monster_ptr->note = NULL;
+       effect_monster_ptr->note_dies = extract_note_dies(real_r_idx(effect_monster_ptr->m_ptr));
+       effect_monster_ptr->caster_lev = (effect_monster_ptr->who > 0) ? r_info[effect_monster_ptr->m_caster_ptr->r_idx].level : (caster_ptr->lev * 2);
+}
diff --git a/src/effect/effect-monster-util.h b/src/effect/effect-monster-util.h
new file mode 100644 (file)
index 0000000..592daaf
--- /dev/null
@@ -0,0 +1,42 @@
+#pragma once
+
+typedef struct
+{
+       grid_type *g_ptr;
+       monster_type *m_ptr;
+       monster_type *m_caster_ptr;
+       monster_race *r_ptr;
+       char killer[80];
+       bool seen;
+       bool seen_msg;
+       bool slept;
+       bool obvious;
+       bool known;
+       bool skipped;
+       bool get_angry;
+       bool do_poly;
+       int do_dist;
+       int do_conf;
+       int do_stun;
+       int do_sleep;
+       int do_fear;
+       int do_time;
+       bool heal_leper;
+       GAME_TEXT m_name[MAX_NLEN];
+       char m_poss[10];
+       PARAMETER_VALUE photo;
+       concptr note;
+       concptr note_dies;
+       DEPTH caster_lev;
+
+       MONSTER_IDX who;
+       POSITION r;
+       POSITION y;
+       POSITION x;
+       HIT_POINT dam;
+       EFFECT_ID effect_type;
+       BIT_FLAGS flag;
+       bool see_s_msg;
+} effect_monster;
+
+void initialize_effect_monster(player_type *caster_ptr, effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg);
index de3b77a..b966599 100644 (file)
@@ -1,5 +1,5 @@
 /*!
- * todo 単体で2400行を超えている。要分割
+ * todo 単体で2400行近い。要分割
  * @brief 魔法によるモンスターへの効果まとめ
  * @date 2020/04/29
  * @author Hourier
 #include "cmd/cmd-pet.h" // 暫定、後で消すかも.
 #include "combat/melee.h"
 #include "core.h" // 暫定、後で消す.
-
-typedef struct
-{
-       grid_type *g_ptr;
-       monster_type *m_ptr;
-       monster_type *m_caster_ptr;
-       monster_race *r_ptr;
-       char killer[80];
-       bool seen;
-       bool seen_msg;
-       bool slept;
-       bool obvious;
-       bool known;
-       bool skipped;
-       bool get_angry;
-       bool do_poly;
-       int do_dist;
-       int do_conf;
-       int do_stun;
-       int do_sleep;
-       int do_fear;
-       int do_time;
-       bool heal_leper;
-       GAME_TEXT m_name[MAX_NLEN];
-       char m_poss[10];
-       PARAMETER_VALUE photo;
-       concptr note;
-       concptr note_dies;
-       DEPTH caster_lev;
-
-       MONSTER_IDX who;
-       POSITION r;
-       POSITION y;
-       POSITION x;
-       HIT_POINT dam;
-       EFFECT_ID effect_type;
-       BIT_FLAGS flag;
-       bool see_s_msg;
-} effect_monster;
-
-
-static void substitute_effect_monster(effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
-{
-       effect_monster_ptr->who = who;
-       effect_monster_ptr->r = r;
-       effect_monster_ptr->y = y;
-       effect_monster_ptr->x = x;
-       effect_monster_ptr->dam = dam;
-       effect_monster_ptr->effect_type = effect_type;
-       effect_monster_ptr->flag = flag;
-       effect_monster_ptr->see_s_msg = see_s_msg;
-}
-
-
-/*!
- * @brief effect_monster構造体を初期化する
- * @param caster_ptr プレーヤーへの参照ポインタ
- * @param effect_monster_ptr モンスター効果構造体への参照ポインタ
- * @param 魔法を発動したモンスター (0ならばプレーヤー)
- * @param 目標y座標
- * @param 目標x座標
- * @return なし
- */
-void initialize_effect_monster(player_type *caster_ptr, effect_monster *effect_monster_ptr, MONSTER_IDX who, POSITION r, POSITION y, POSITION x, HIT_POINT dam, EFFECT_ID effect_type, BIT_FLAGS flag, bool see_s_msg)
-{
-       substitute_effect_monster(effect_monster_ptr, who, r, y, x, dam, effect_type, flag, see_s_msg);
-
-       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
-       effect_monster_ptr->g_ptr = &floor_ptr->grid_array[effect_monster_ptr->y][effect_monster_ptr->x];
-       effect_monster_ptr->m_ptr = &floor_ptr->m_list[effect_monster_ptr->g_ptr->m_idx];
-       effect_monster_ptr->m_caster_ptr = (effect_monster_ptr->who > 0) ? &floor_ptr->m_list[effect_monster_ptr->who] : NULL;
-       effect_monster_ptr->r_ptr = &r_info[effect_monster_ptr->m_ptr->r_idx];
-       effect_monster_ptr->seen = effect_monster_ptr->m_ptr->ml;
-       effect_monster_ptr->seen_msg = is_seen(effect_monster_ptr->m_ptr);
-       effect_monster_ptr->slept = (bool)MON_CSLEEP(effect_monster_ptr->m_ptr);
-       effect_monster_ptr->obvious = FALSE;
-       effect_monster_ptr->known = ((effect_monster_ptr->m_ptr->cdis <= MAX_SIGHT) || caster_ptr->phase_out);
-       effect_monster_ptr->skipped = FALSE;
-       effect_monster_ptr->get_angry = FALSE;
-       effect_monster_ptr->do_poly = FALSE;
-       effect_monster_ptr->do_dist = 0;
-       effect_monster_ptr->do_conf = 0;
-       effect_monster_ptr->do_stun = 0;
-       effect_monster_ptr->do_sleep = 0;
-       effect_monster_ptr->do_fear = 0;
-       effect_monster_ptr->do_time = 0;
-       effect_monster_ptr->heal_leper = FALSE;
-       effect_monster_ptr->photo = 0;
-       effect_monster_ptr->note = NULL;
-       effect_monster_ptr->note_dies = extract_note_dies(real_r_idx(effect_monster_ptr->m_ptr));
-       effect_monster_ptr->caster_lev = (effect_monster_ptr->who > 0) ? r_info[effect_monster_ptr->m_caster_ptr->r_idx].level : (caster_ptr->lev * 2);
-}
-
+#include "effect/effect-monster-util.h"
 
 /*!
  * @brief 汎用的なビーム/ボルト/ボール系によるモンスターへの効果処理 / Handle a beam/bolt/ball causing damage to a monster.