OSDN Git Service

[Refactor] #40479 Separated mspell-lite.c/h from mspell-attack.c
authorHourier <hourier@users.sourceforge.jp>
Thu, 23 Jul 2020 12:01:38 +0000 (21:01 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 23 Jul 2020 12:01:38 +0000 (21:01 +0900)
16 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/action/tunnel-execution.c
src/cmd-building/cmd-store.c
src/floor/cave.c
src/floor/cave.h
src/floor/floor.h
src/floor/wild.c
src/io/cursor.c
src/mspell/mspell-attack.c
src/mspell/mspell-lite.c [new file with mode: 0644]
src/mspell/mspell-lite.h [new file with mode: 0644]
src/pet/pet-fall-off.c
src/spell-kind/spells-detection.c
src/spell/spells-object.c

index 54c0566..afacfc0 100644 (file)
     <ClCompile Include="..\..\src\mspell\improper-mspell-remover.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-attack-util.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-attack.c" />\r
+    <ClCompile Include="..\..\src\mspell\mspell-lite.c" />\r
     <ClCompile Include="..\..\src\mspell\mspell-selector.c" />\r
     <ClCompile Include="..\..\src\mspell\smart-mspell-util.c" />\r
     <ClCompile Include="..\..\src\mspell\specified-summon.c" />\r
     <ClInclude Include="..\..\src\mspell\improper-mspell-remover.h" />\r
     <ClInclude Include="..\..\src\mspell\mspell-attack-util.h" />\r
     <ClInclude Include="..\..\src\mspell\mspell-attack.h" />\r
+    <ClInclude Include="..\..\src\mspell\mspell-lite.h" />\r
     <ClInclude Include="..\..\src\mspell\mspell-selector.h" />\r
     <ClInclude Include="..\..\src\mspell\smart-mspell-util.h" />\r
     <ClInclude Include="..\..\src\mspell\specified-summon.h" />\r
index f9abbfc..3adab8d 100644 (file)
     <ClCompile Include="..\..\src\mspell\mspell-attack-util.c">
       <Filter>mspell</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\mspell\mspell-lite.c">
+      <Filter>mspell</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\mspell\mspell-attack-util.h">
       <Filter>mspell</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\mspell\mspell-lite.h">
+      <Filter>mspell</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index e76ae8c..bc53e18 100644 (file)
@@ -470,6 +470,7 @@ hengband_SOURCES = \
        mspell/mspell-curse.c mspell/mspell-curse.h \
        mspell/mspell-dispel.c mspell/mspell-dispel.h \
        mspell/mspell-judgement.c mspell/mspell-judgement.h \
+       mspell/mspell-lite.c mspell/mspell-lite.h \
        mspell/mspell-summon.c mspell/mspell-summon.h \
        mspell/mspell-util.c mspell/mspell-util.h \
        mspell/mspell-type.h \
index 4261a4b..dc68bc8 100644 (file)
@@ -1,6 +1,6 @@
 #include "action/tunnel-execution.h"
 #include "core/player-update-types.h"
-#include "floor/floor.h"
+#include "floor/cave.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "main/sound-definitions-table.h"
index 8dd1b66..18a0ac9 100644 (file)
@@ -5,9 +5,9 @@
 #include "core/stuff-handler.h"
 #include "core/window-redrawer.h"
 #include "flavor/flavor-describer.h"
+#include "floor/cave.h"
 #include "floor/floor-events.h"
 #include "floor/floor-town.h"
-#include "floor/floor.h"
 #include "floor/wild.h"
 #include "game-option/birth-options.h"
 #include "game-option/input-options.h"
@@ -26,7 +26,6 @@
 #include "store/store.h"
 #include "system/floor-type-definition.h"
 #include "term/screen-processor.h"
-#include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 #include "view/display-store.h"
 #include "world/world.h"
index d17c0a4..0594dc6 100644 (file)
@@ -102,3 +102,5 @@ bool cave_los_bold(floor_type *floor_ptr, POSITION y, POSITION x) { return feat_
 bool feat_supports_los(FEAT_IDX f_idx) { return have_flag(f_info[f_idx].flags, FF_LOS); }
 
 bool cave_los_grid(grid_type *grid_ptr) { return feat_supports_los(grid_ptr->feat); }
+
+bool cave_have_flag_grid(grid_type *grid_ptr, int feature_flags) { return have_flag(f_info[grid_ptr->feat].flags, feature_flags); }
index acda836..7411f0b 100644 (file)
@@ -16,3 +16,4 @@ bool cave_stop_disintegration(floor_type *floor_ptr, POSITION y, POSITION x);
 bool cave_los_bold(floor_type *floor_ptr, POSITION y, POSITION x);
 bool feat_supports_los(FEAT_IDX f_idx);
 bool cave_los_grid(grid_type *grid_ptr);
+bool cave_have_flag_grid(grid_type *grid_ptr, int feature_flags);
index b50881e..d33af79 100644 (file)
@@ -11,10 +11,6 @@ extern floor_type floor_info;
        ((G) == &(C)->current_floor_ptr->grid_array[(C)->y][(C)->x])
 
 
-#define cave_have_flag_grid(C,INDEX) \
-       (have_flag(f_info[(C)->feat].flags, (INDEX)))
-
-
 /*
  * Determine if a "legal" grid is a "clean" floor grid
  * Determine if terrain-change spells are allowed in a grid.
index 7d43ebc..6953696 100644 (file)
@@ -15,8 +15,8 @@
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
 #include "dungeon/quest.h"
+#include "floor/cave.h"
 #include "floor/floor-town.h"
-#include "floor/floor.h"
 #include "game-option/birth-options.h"
 #include "game-option/map-screen-options.h"
 #include "grid/feature.h"
index 6fc406c..5d81a1d 100644 (file)
@@ -4,6 +4,7 @@
 #include "core/stuff-handler.h"
 #include "effect/effect-characteristics.h"
 #include "effect/spells-effect-util.h"
+#include "floor/cave.h"
 #include "floor/floor.h"
 #include "game-option/map-screen-options.h"
 #include "game-option/special-options.h"
@@ -13,7 +14,6 @@
 #include "io/targeting.h"
 #include "system/floor-type-definition.h"
 #include "term/term-color-types.h"
-#include "util/bit-flags-calculator.h"
 #include "view/display-map.h"
 #include "window/main-window-util.h"
 #include "world/world.h"
index 9633c55..4083170 100644 (file)
@@ -28,6 +28,7 @@
 #include "mspell/mspell-attack-util.h"
 #include "mspell/mspell-checker.h"
 #include "mspell/mspell-judgement.h"
+#include "mspell/mspell-lite.h"
 #include "mspell/mspell-mask-definitions.h"
 #include "mspell/mspell-selector.h"
 #include "mspell/mspell-util.h"
 #include "monster/monster-description-types.h"
 #endif
 
-/*!
- * @brief モンスターがプレイヤーにダメージを与えるための最適な座標を算出する /
- * @param target_ptr プレーヤーへの参照ポインタ
- * @param m_ptr 技能を使用するモンスター構造体の参照ポインタ
- * @param yp 最適な目標地点のY座標を返す参照ポインタ
- * @param xp 最適な目標地点のX座標を返す参照ポインタ
- * @param f_flag 射線に入れるのを避ける地形の所持フラグ
- * @param path_check 射線を判定するための関数ポインタ
- * @return 有効な座標があった場合TRUEを返す
- */
-static bool adjacent_grid_check(player_type *target_ptr, monster_type *m_ptr, POSITION *yp, POSITION *xp, int f_flag,
-    bool (*path_check)(player_type *, POSITION, POSITION, POSITION, POSITION))
-{
-    static int tonari_y[4][8] = { { -1, -1, -1, 0, 0, 1, 1, 1 }, { -1, -1, -1, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, -1, -1, -1 }, { 1, 1, 1, 0, 0, -1, -1, -1 } };
-    static int tonari_x[4][8] = { { -1, 0, 1, -1, 1, -1, 0, 1 }, { 1, 0, -1, 1, -1, 1, 0, -1 }, { -1, 0, 1, -1, 1, -1, 0, 1 }, { 1, 0, -1, 1, -1, 1, 0, -1 } };
-
-    int next;
-    if (m_ptr->fy < target_ptr->y && m_ptr->fx < target_ptr->x)
-        next = 0;
-    else if (m_ptr->fy < target_ptr->y)
-        next = 1;
-    else if (m_ptr->fx < target_ptr->x)
-        next = 2;
-    else
-        next = 3;
-
-    floor_type *floor_ptr = target_ptr->current_floor_ptr;
-    for (int i = 0; i < 8; i++) {
-        int next_x = *xp + tonari_x[next][i];
-        int next_y = *yp + tonari_y[next][i];
-        grid_type *g_ptr;
-        g_ptr = &floor_ptr->grid_array[next_y][next_x];
-        if (!cave_have_flag_grid(g_ptr, f_flag))
-            continue;
-
-        if (path_check(target_ptr, m_ptr->fy, m_ptr->fx, next_y, next_x)) {
-            *yp = next_y;
-            *xp = next_x;
-            return TRUE;
-        }
-    }
-
-    return FALSE;
-}
-
-static void decide_lite_range(player_type *target_ptr, msa_type *msa_ptr)
-{
-    if ((msa_ptr->f4 & RF4_BR_LITE) == 0)
-        return;
-
-    msa_ptr->y_br_lite = msa_ptr->y;
-    msa_ptr->x_br_lite = msa_ptr->x;
-    if (los(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y_br_lite, msa_ptr->x_br_lite)) {
-        feature_type *f_ptr = &f_info[target_ptr->current_floor_ptr->grid_array[msa_ptr->y_br_lite][msa_ptr->x_br_lite].feat];
-        if (!have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT) && one_in_(2))
-            msa_ptr->f4 &= ~(RF4_BR_LITE);
-    } else if (!adjacent_grid_check(target_ptr, msa_ptr->m_ptr, &msa_ptr->y_br_lite, &msa_ptr->x_br_lite, FF_LOS, los))
-        msa_ptr->f4 &= ~(RF4_BR_LITE);
-
-    if ((msa_ptr->f4 & RF4_BR_LITE) != 0)
-        return;
-
-    msa_ptr->y_br_lite = 0;
-    msa_ptr->x_br_lite = 0;
-}
-
 static void feature_projection(floor_type *floor_ptr, msa_type *msa_ptr)
 {
     feature_type *f_ptr = &f_info[floor_ptr->grid_array[msa_ptr->y][msa_ptr->x].feat];
diff --git a/src/mspell/mspell-lite.c b/src/mspell/mspell-lite.c
new file mode 100644 (file)
index 0000000..f2d77a8
--- /dev/null
@@ -0,0 +1,80 @@
+/*!
+ * @brief モンスターの魔法によってフロアを明るくする処理及びその判定
+ * @date 2020/07/23
+ * @author Hourier
+ */
+
+#include "mspell/mspell-lite.h"
+#include "floor/cave.h"
+#include "floor/floor.h"
+#include "grid/feature.h"
+#include "grid/grid.h"
+#include "monster-race/race-flags4.h"
+#include "mspell/mspell-attack-util.h"
+#include "system/floor-type-definition.h"
+#include "system/monster-type-definition.h"
+#include "util/bit-flags-calculator.h"
+
+/*!
+ * @brief モンスターがプレイヤーにダメージを与えるための最適な座標を算出する /
+ * @param target_ptr プレーヤーへの参照ポインタ
+ * @param m_ptr 技能を使用するモンスター構造体の参照ポインタ
+ * @param yp 最適な目標地点のY座標を返す参照ポインタ
+ * @param xp 最適な目標地点のX座標を返す参照ポインタ
+ * @param f_flag 射線に入れるのを避ける地形の所持フラグ
+ * @param path_check 射線を判定するための関数ポインタ
+ * @return 有効な座標があった場合TRUEを返す
+ */
+bool adjacent_grid_check(player_type *target_ptr, monster_type *m_ptr, POSITION *yp, POSITION *xp, int f_flag, path_check_pf path_check)
+{
+    static int tonari_y[4][8] = { { -1, -1, -1, 0, 0, 1, 1, 1 }, { -1, -1, -1, 0, 0, 1, 1, 1 }, { 1, 1, 1, 0, 0, -1, -1, -1 }, { 1, 1, 1, 0, 0, -1, -1, -1 } };
+    static int tonari_x[4][8] = { { -1, 0, 1, -1, 1, -1, 0, 1 }, { 1, 0, -1, 1, -1, 1, 0, -1 }, { -1, 0, 1, -1, 1, -1, 0, 1 }, { 1, 0, -1, 1, -1, 1, 0, -1 } };
+
+    int next;
+    if (m_ptr->fy < target_ptr->y && m_ptr->fx < target_ptr->x)
+        next = 0;
+    else if (m_ptr->fy < target_ptr->y)
+        next = 1;
+    else if (m_ptr->fx < target_ptr->x)
+        next = 2;
+    else
+        next = 3;
+
+    for (int i = 0; i < 8; i++) {
+        int next_x = *xp + tonari_x[next][i];
+        int next_y = *yp + tonari_y[next][i];
+        grid_type *g_ptr;
+        g_ptr = &target_ptr->current_floor_ptr->grid_array[next_y][next_x];
+        if (!cave_have_flag_grid(g_ptr, f_flag))
+            continue;
+
+        if (path_check(target_ptr, m_ptr->fy, m_ptr->fx, next_y, next_x)) {
+            *yp = next_y;
+            *xp = next_x;
+            return TRUE;
+        }
+    }
+
+    return FALSE;
+}
+
+void decide_lite_range(player_type *target_ptr, msa_type *msa_ptr)
+{
+    if ((msa_ptr->f4 & RF4_BR_LITE) == 0)
+        return;
+
+    msa_ptr->y_br_lite = msa_ptr->y;
+    msa_ptr->x_br_lite = msa_ptr->x;
+    if (los(target_ptr, msa_ptr->m_ptr->fy, msa_ptr->m_ptr->fx, msa_ptr->y_br_lite, msa_ptr->x_br_lite)) {
+        feature_type *f_ptr = &f_info[target_ptr->current_floor_ptr->grid_array[msa_ptr->y_br_lite][msa_ptr->x_br_lite].feat];
+        if (!have_flag(f_ptr->flags, FF_LOS) && have_flag(f_ptr->flags, FF_PROJECT) && one_in_(2))
+            msa_ptr->f4 &= ~(RF4_BR_LITE);
+    } else if (!adjacent_grid_check(target_ptr, msa_ptr->m_ptr, &msa_ptr->y_br_lite, &msa_ptr->x_br_lite, FF_LOS, los))
+        msa_ptr->f4 &= ~(RF4_BR_LITE);
+
+    if ((msa_ptr->f4 & RF4_BR_LITE) != 0)
+        return;
+
+    msa_ptr->y_br_lite = 0;
+    msa_ptr->x_br_lite = 0;
+}
diff --git a/src/mspell/mspell-lite.h b/src/mspell/mspell-lite.h
new file mode 100644 (file)
index 0000000..16feb9e
--- /dev/null
@@ -0,0 +1,9 @@
+#pragma once
+
+#include "system/angband.h"
+
+typedef struct monster_type monster_type;
+typedef struct msa_type msa_type;
+typedef bool (*path_check_pf)(player_type *, POSITION, POSITION, POSITION, POSITION);
+bool adjacent_grid_check(player_type *target_ptr, monster_type *m_ptr, POSITION *yp, POSITION *xp, int f_flag, path_check_pf path_check);
+void decide_lite_range(player_type *target_ptr, msa_type *msa_ptr);
index d424679..11d966a 100644 (file)
@@ -9,7 +9,7 @@
 #include "core/player-update-types.h"
 #include "core/stuff-handler.h"
 #include "core/window-redrawer.h"
-#include "floor/floor.h"
+#include "floor/cave.h"
 #include "grid/feature.h"
 #include "io/targeting.h"
 #include "monster-race/monster-race.h"
@@ -19,7 +19,6 @@
 #include "player/player-move.h"
 #include "player/player-skill.h"
 #include "system/floor-type-definition.h"
-#include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
 
 /*!
index fbe5b49..9a21ac5 100644 (file)
@@ -2,8 +2,8 @@
 #include "core/window-redrawer.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
+#include "floor/cave.h"
 #include "floor/floor-save.h"
-#include "floor/floor.h"
 #include "grid/grid.h"
 #include "grid/trap.h"
 #include "monster-race/monster-race.h"
@@ -22,7 +22,6 @@
 #include "realm/realm-song.h"
 #include "system/floor-type-definition.h"
 #include "system/object-type-definition.h"
-#include "util/bit-flags-calculator.h"
 #include "util/string-processor.h"
 #include "view/display-messages.h"
 
index 8cbd466..12a5b51 100644 (file)
@@ -14,8 +14,8 @@
 #include "core/window-redrawer.h"
 #include "flavor/flavor-describer.h"
 #include "flavor/object-flavor-types.h"
+#include "floor/cave.h"
 #include "floor/floor-object.h"
-#include "floor/floor.h"
 #include "game-option/disturbance-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"