OSDN Git Service

[Refactor] #40577 Moved aaa() from stair.c/h to space-finder.c
authorHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 10:21:37 +0000 (19:21 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 20 Aug 2020 10:22:29 +0000 (19:22 +0900)
13 files changed:
Hengband/Hengband/Hengband.vcxproj
Hengband/Hengband/Hengband.vcxproj.filters
src/Makefile.am
src/core/player-processor.c
src/floor/floor.c
src/floor/floor.h
src/grid/stair.c [new file with mode: 0644]
src/grid/stair.h [new file with mode: 0644]
src/room/rooms-normal.c
src/room/space-finder.c
src/spell-kind/earthquake.c
src/spell-kind/spells-grid.c
src/target/target-preparation.c

index 9184dfa..78579ec 100644 (file)
     <ClCompile Include="..\..\src\grid\feature-generator.c" />\r
     <ClCompile Include="..\..\src\grid\object-placer.c" />\r
     <ClCompile Include="..\..\src\grid\lighting-colors-table.c" />\r
+    <ClCompile Include="..\..\src\grid\stair.c" />\r
     <ClCompile Include="..\..\src\info-reader\artifact-reader.c" />\r
     <ClCompile Include="..\..\src\info-reader\dungeon-info-tokens-table.c" />\r
     <ClCompile Include="..\..\src\info-reader\dungeon-reader.c" />\r
     <ClInclude Include="..\..\src\grid\feature-generator.h" />\r
     <ClInclude Include="..\..\src\grid\object-placer.h" />\r
     <ClInclude Include="..\..\src\grid\lighting-colors-table.h" />\r
+    <ClInclude Include="..\..\src\grid\stair.h" />\r
     <ClInclude Include="..\..\src\info-reader\artifact-reader.h" />\r
     <ClInclude Include="..\..\src\info-reader\dungeon-info-tokens-table.h" />\r
     <ClInclude Include="..\..\src\info-reader\dungeon-reader.h" />\r
index 9d8ac4c..d0594e2 100644 (file)
     <ClCompile Include="..\..\src\grid\object-placer.c">
       <Filter>grid</Filter>
     </ClCompile>
+    <ClCompile Include="..\..\src\grid\stair.c">
+      <Filter>grid</Filter>
+    </ClCompile>
   </ItemGroup>
   <ItemGroup>
     <ClInclude Include="..\..\src\combat\shoot.h">
     <ClInclude Include="..\..\src\grid\object-placer.h">
       <Filter>grid</Filter>
     </ClInclude>
+    <ClInclude Include="..\..\src\grid\stair.h">
+      <Filter>grid</Filter>
+    </ClInclude>
   </ItemGroup>
   <ItemGroup>
     <None Include="..\..\src\wall.bmp" />
index 926a3aa..6812160 100644 (file)
@@ -262,6 +262,7 @@ hengband_SOURCES = \
        grid/grid.c grid/grid.h \
        grid/lighting-colors-table.c grid/lighting-colors-table.h \
        grid/object-placer.c grid/object-placer.h \
+       grid/stair.c grid/stair.h \
        grid/trap.c grid/trap.h \
        \
        info-reader/artifact-reader.c info-reader/artifact-reader.h \
index fb8bcf2..0efedeb 100644 (file)
@@ -93,7 +93,6 @@ void process_player(player_type *creature_ptr)
 {
     if (creature_ptr->hack_mutation) {
         msg_print(_("何か変わった気がする!", "You feel different!"));
-
         (void)gain_mutation(creature_ptr, 0);
         creature_ptr->hack_mutation = FALSE;
     }
index f008309..ea1bb0c 100644 (file)
@@ -121,72 +121,6 @@ void forget_flow(floor_type *floor_ptr)
 }
 
 /*!
- * @brief 所定の位置に上り階段か下り階段を配置する / Place an up/down staircase at given location
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y 配置を試みたいマスのY座標
- * @param x 配置を試みたいマスのX座標
- * @return なし
- */
-void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x)
-{
-    bool up_stairs = TRUE;
-    bool down_stairs = TRUE;
-    grid_type *g_ptr;
-    floor_type *floor_ptr = player_ptr->current_floor_ptr;
-    g_ptr = &floor_ptr->grid_array[y][x];
-    if (!is_floor_grid(g_ptr) || g_ptr->o_idx)
-        return;
-
-    if (!floor_ptr->dun_level)
-        up_stairs = FALSE;
-    if (ironman_downward)
-        up_stairs = FALSE;
-    if (floor_ptr->dun_level >= d_info[player_ptr->dungeon_idx].maxdepth)
-        down_stairs = FALSE;
-    if (quest_number(player_ptr, floor_ptr->dun_level) && (floor_ptr->dun_level > 1))
-        down_stairs = FALSE;
-
-    if (down_stairs && up_stairs) {
-        if (randint0(100) < 50)
-            up_stairs = FALSE;
-        else
-            down_stairs = FALSE;
-    }
-
-    if (up_stairs)
-        set_cave_feat(floor_ptr, y, x, feat_up_stair);
-    else if (down_stairs)
-        set_cave_feat(floor_ptr, y, x, feat_down_stair);
-}
-
-/*!
- * @brief 指定された座標が地震や階段生成の対象となるマスかを返す。 / Determine if a given location may be "destroyed"
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param y y座標
- * @param x x座標
- * @return 各種の変更が可能ならTRUEを返す。
- * @details
- * 条件は永久地形でなく、なおかつ該当のマスにアーティファクトが存在しないか、である。英語の旧コメントに反して*破壊*の抑止判定には現在使われていない。
- */
-bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x)
-{
-    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
-    if (cave_have_flag_grid(g_ptr, FF_PERMANENT))
-        return FALSE;
-
-    OBJECT_IDX next_o_idx = 0;
-    for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) {
-        object_type *o_ptr;
-        o_ptr = &floor_ptr->o_list[this_o_idx];
-        next_o_idx = o_ptr->next_o_idx;
-        if (object_is_artifact(o_ptr))
-            return FALSE;
-    }
-
-    return TRUE;
-}
-
-/*!
  * @brief グローバルオブジェクト配列を初期化する /
  * Delete all the items when player leaves the level
  * @note we do NOT visually reflect these (irrelevant) changes
@@ -233,24 +167,6 @@ void wipe_o_list(floor_type *floor_ptr)
 }
 
 /*!
- * @brief 指定のマスが床系地形であるかを返す / Function that sees if a square is a floor.  (Includes range checking.)
- * @param x チェックするマスのX座標
- * @param y チェックするマスのY座標
- * @return 床系地形ならばTRUE
- */
-bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y)
-{
-    if (!in_bounds(floor_ptr, y, x)) {
-        return FALSE;
-    }
-
-    if (is_floor_bold(floor_ptr, y, x))
-        return TRUE;
-
-    return FALSE;
-}
-
-/*!
  * @brief 指定のマスを床地形に変える / Set a square to be floor.  (Includes range checking.)
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param x 地形を変えたいマスのX座標
@@ -290,9 +206,8 @@ static void compact_objects_aux(floor_type *floor_ptr, OBJECT_IDX i1, OBJECT_IDX
         if (!o_ptr->k_idx)
             continue;
 
-        if (o_ptr->next_o_idx == i1) {
+        if (o_ptr->next_o_idx == i1)
             o_ptr->next_o_idx = i2;
-        }
     }
 
     o_ptr = &floor_ptr->o_list[i1];
@@ -300,18 +215,15 @@ static void compact_objects_aux(floor_type *floor_ptr, OBJECT_IDX i1, OBJECT_IDX
     if (object_is_held_monster(o_ptr)) {
         monster_type *m_ptr;
         m_ptr = &floor_ptr->m_list[o_ptr->held_m_idx];
-        if (m_ptr->hold_o_idx == i1) {
+        if (m_ptr->hold_o_idx == i1)
             m_ptr->hold_o_idx = i2;
-        }
     } else {
         POSITION y = o_ptr->iy;
         POSITION x = o_ptr->ix;
         grid_type *g_ptr;
         g_ptr = &floor_ptr->grid_array[y][x];
-
-        if (g_ptr->o_idx == i1) {
+        if (g_ptr->o_idx == i1)
             g_ptr->o_idx = i2;
-        }
     }
 
     floor_ptr->o_list[i2] = floor_ptr->o_list[i1];
@@ -340,8 +252,8 @@ void compact_objects(player_type *player_ptr, int size)
     object_type *o_ptr;
     if (size) {
         msg_print(_("アイテム情報を圧縮しています...", "Compacting objects..."));
-        player_ptr->redraw |= (PR_MAP);
-        player_ptr->window |= (PW_OVERHEAD | PW_DUNGEON);
+        player_ptr->redraw |= PR_MAP;
+        player_ptr->window |= PW_OVERHEAD | PW_DUNGEON;
     }
 
     floor_type *floor_ptr = player_ptr->current_floor_ptr;
@@ -351,9 +263,7 @@ void compact_objects(player_type *player_ptr, int size)
         for (OBJECT_IDX i = 1; i < floor_ptr->o_max; i++) {
             o_ptr = &floor_ptr->o_list[i];
 
-            if (!object_is_valid(o_ptr))
-                continue;
-            if (k_info[o_ptr->k_idx].level > cur_lev)
+            if (!object_is_valid(o_ptr) || (k_info[o_ptr->k_idx].level > cur_lev))
                 continue;
 
             POSITION y, x;
index ba617fd..6fc6e8e 100644 (file)
@@ -6,10 +6,7 @@ extern floor_type floor_info;
 
 void update_smell(floor_type *floor_ptr, player_type *subject_ptr);
 void forget_flow(floor_type *floor_ptr);
-void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x);
-bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
 void wipe_o_list(floor_type *floor_ptr);
-bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y);
 void set_floor(player_type *player_ptr, POSITION x, POSITION y);
 void compact_objects(player_type *owner_ptr, int size);
 void scatter(player_type *player_ptr, POSITION *yp, POSITION *xp, POSITION y, POSITION x, POSITION d, BIT_FLAGS mode);
diff --git a/src/grid/stair.c b/src/grid/stair.c
new file mode 100644 (file)
index 0000000..165d99e
--- /dev/null
@@ -0,0 +1,78 @@
+#include "grid/stair.h"
+#include "dungeon/dungeon.h"
+#include "dungeon/quest.h"
+#include "game-option/birth-options.h"
+#include "floor/cave.h"
+#include "grid/grid.h"
+#include "object-hook/hook-enchant.h"
+#include "system/floor-type-definition.h"
+#include "system/object-type-definition.h"
+
+/*!
+ * @brief \8f\8a\92è\82Ì\88Ê\92u\82É\8fã\82è\8aK\92i\82©\89º\82è\8aK\92i\82ð\94z\92u\82·\82é / Place an up/down staircase at given location
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y \94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌY\8dÀ\95W
+ * @param x \94z\92u\82ð\8e\8e\82Ý\82½\82¢\83}\83X\82ÌX\8dÀ\95W
+ * @return \82È\82µ
+ */
+void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x)
+{
+    bool up_stairs = TRUE;
+    bool down_stairs = TRUE;
+    grid_type *g_ptr;
+    floor_type *floor_ptr = player_ptr->current_floor_ptr;
+    g_ptr = &floor_ptr->grid_array[y][x];
+    if (!is_floor_grid(g_ptr) || g_ptr->o_idx)
+        return;
+
+    if (!floor_ptr->dun_level)
+        up_stairs = FALSE;
+
+    if (ironman_downward)
+        up_stairs = FALSE;
+
+    if (floor_ptr->dun_level >= d_info[player_ptr->dungeon_idx].maxdepth)
+        down_stairs = FALSE;
+
+    if (quest_number(player_ptr, floor_ptr->dun_level) && (floor_ptr->dun_level > 1))
+        down_stairs = FALSE;
+
+    if (down_stairs && up_stairs) {
+        if (randint0(100) < 50)
+            up_stairs = FALSE;
+        else
+            down_stairs = FALSE;
+    }
+
+    if (up_stairs)
+        set_cave_feat(floor_ptr, y, x, feat_up_stair);
+    else if (down_stairs)
+        set_cave_feat(floor_ptr, y, x, feat_down_stair);
+}
+
+/*!
+ * @brief \8ew\92è\82³\82ê\82½\8dÀ\95W\82ª\92n\90k\82â\8aK\92i\90\90¬\82Ì\91Î\8fÛ\82Æ\82È\82é\83}\83X\82©\82ð\95Ô\82·\81B / Determine if a given location may be "destroyed"
+ * @param player_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param y y\8dÀ\95W
+ * @param x x\8dÀ\95W
+ * @return \8ae\8eí\82Ì\95Ï\8dX\82ª\89Â\94\\82È\82çTRUE\82ð\95Ô\82·\81B
+ * @details
+ * \8fð\8c\8f\82Í\89i\8bv\92n\8c`\82Å\82È\82­\81A\82È\82¨\82©\82Â\8aY\93\96\82Ì\83}\83X\82É\83A\81[\83e\83B\83t\83@\83N\83g\82ª\91\8dÝ\82µ\82È\82¢\82©\81A\82Å\82 \82é\81B\89p\8cê\82Ì\8b\8c\83R\83\81\83\93\83g\82É\94½\82µ\82Ä\81\96\94j\89ó\81\96\82Ì\97}\8e~\94»\92è\82É\82Í\8c»\8dÝ\8eg\82í\82ê\82Ä\82¢\82È\82¢\81B
+ */
+bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    grid_type *g_ptr = &floor_ptr->grid_array[y][x];
+    if (cave_have_flag_grid(g_ptr, FF_PERMANENT))
+        return FALSE;
+
+    OBJECT_IDX next_o_idx = 0;
+    for (OBJECT_IDX this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx) {
+        object_type *o_ptr;
+        o_ptr = &floor_ptr->o_list[this_o_idx];
+        next_o_idx = o_ptr->next_o_idx;
+        if (object_is_artifact(o_ptr))
+            return FALSE;
+    }
+
+    return TRUE;
+}
diff --git a/src/grid/stair.h b/src/grid/stair.h
new file mode 100644 (file)
index 0000000..02023b2
--- /dev/null
@@ -0,0 +1,6 @@
+#pragma once
+
+#include "system/angband.h"
+
+void place_random_stairs(player_type *player_ptr, POSITION y, POSITION x);
+bool cave_valid_bold(floor_type *floor_ptr, POSITION y, POSITION x);
index cd43f12..a27db5a 100644 (file)
@@ -1,9 +1,9 @@
 #include "room/rooms-normal.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
-#include "floor/floor.h"
 #include "grid/door.h"
 #include "grid/grid.h"
+#include "grid/stair.h"
 #include "grid/object-placer.h"
 #include "grid/trap.h"
 #include "room/door-definition.h"
index b2069ce..79729c7 100644 (file)
@@ -1,11 +1,31 @@
 #include "room/space-finder.h"
 #include "dungeon/dungeon-flag-types.h"
 #include "dungeon/dungeon.h"
+#include "floor/cave.h"
 #include "floor/floor.h"
+#include "grid/grid.h"
 #include "system/dungeon-data-definition.h"
 #include "system/floor-type-definition.h"
 
 /*!
+ * @brief 指定のマスが床系地形であるかを返す / Function that sees if a square is a floor.  (Includes range checking.)
+ * @param x チェックするマスのX座標
+ * @param y チェックするマスのY座標
+ * @return 床系地形ならばTRUE
+ */
+static bool get_is_floor(floor_type *floor_ptr, POSITION x, POSITION y)
+{
+    if (!in_bounds(floor_ptr, y, x)) {
+        return FALSE;
+    }
+
+    if (is_floor_bold(floor_ptr, y, x))
+        return TRUE;
+
+    return FALSE;
+}
+
+/*!
  * @brief
  * 指定範囲に通路が通っていることを確認した上で床で埋める
  * This function tunnels around a room if it will cut off part of a grid system.
index bc0457c..1250e45 100644 (file)
@@ -7,10 +7,10 @@
 #include "dungeon/quest.h"
 #include "floor/cave.h"
 #include "floor/floor-object.h"
-#include "floor/floor.h"
 #include "game-option/play-record-options.h"
 #include "game-option/text-display-options.h"
 #include "grid/grid.h"
+#include "grid/stair.h"
 #include "io/write-diary.h"
 #include "mind/mind-ninja.h"
 #include "monster-floor/monster-lite.h"
index 719583d..8eeec5f 100644 (file)
@@ -5,9 +5,9 @@
 #include "floor/floor-object.h"
 #include "floor/floor-save-util.h"
 #include "floor/floor-save.h"
-#include "floor/floor.h"
 #include "game-option/birth-options.h"
 #include "grid/grid.h"
+#include "grid/stair.h"
 #include "system/floor-type-definition.h"
 #include "util/bit-flags-calculator.h"
 #include "view/display-messages.h"
index 83df2b1..c8066ef 100644 (file)
@@ -1,6 +1,5 @@
 #include "target/target-preparation.h"
 #include "floor/cave.h"
-#include "floor/floor.h"
 #include "game-option/input-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
@@ -9,6 +8,7 @@
 #include "object/object-mark-types.h"
 #include "system/floor-type-definition.h"
 #include "system/object-type-definition.h"
+#include "target/projection-path-calculator.h"
 #include "target/target-types.h"
 #include "util/bit-flags-calculator.h"
 #include "util/sort.h"