OSDN Git Service

[Refactor] #919 Moved grid_cost() and grid_dist() from grid.cpp/h to grid-type-defini...
[hengbandforosx/hengbandosx.git] / src / grid / grid.cpp
index f2db343..c75960f 100644 (file)
@@ -14,8 +14,6 @@
  * 2013 Deskull Doxygen向けのコメント整理\n
  */
 
-#include <queue>
-
 #include "grid/grid.h"
 #include "core/window-redrawer.h"
 #include "dungeon/dungeon-flag-types.h"
@@ -60,6 +58,7 @@
 #include "view/display-messages.h"
 #include "window/main-window-util.h"
 #include "world/world.h"
+#include <queue>
 
 #define MONSTER_FLOW_DEPTH                                                                                                                                     \
     32 /*!< 敵のプレイヤーに対する移動道のりの最大値(この値以上は処理を打ち切る) / OPTION: Maximum flow depth when using "MONSTER_FLOW" */
@@ -259,44 +258,6 @@ bool new_player_spot(player_type *creature_ptr)
 }
 
 /*!
- * @brief マスにフロア端用の永久壁を配置する / Set boundary mimic and add "solid" perma-wall
- * @param g_ptr 永久壁を配置したいマス構造体の参照ポインタ
- */
-void place_bound_perm_wall(player_type *player_ptr, grid_type *g_ptr)
-{
-    if (bound_walls_perm) {
-        /* Clear boundary mimic */
-        g_ptr->mimic = 0;
-    } else {
-        feature_type *f_ptr = &f_info[g_ptr->feat];
-
-        /* Hack -- Decline boundary walls with known treasure  */
-        if ((has_flag(f_ptr->flags, FF_HAS_GOLD) || has_flag(f_ptr->flags, FF_HAS_ITEM)) && !has_flag(f_ptr->flags, FF_SECRET))
-            g_ptr->feat = feat_state(player_ptr->current_floor_ptr, g_ptr->feat, FF_ENSECRET);
-
-        /* Set boundary mimic */
-        g_ptr->mimic = g_ptr->feat;
-    }
-
-    /* Add "solid" perma-wall */
-    place_grid(player_ptr, g_ptr, GB_SOLID_PERM);
-}
-
-/*!
- * @brief マスに看破済みの罠があるかの判定を行う。 / Return TRUE if the given grid is a known trap
- * @param player_ptr プレーヤーへの参照ポインタ
- * @param g_ptr マス構造体の参照ポインタ
- * @return 看破済みの罠があるならTRUEを返す。
- */
-bool is_known_trap(player_type *player_ptr, grid_type *g_ptr)
-{
-    if (!g_ptr->mimic && !cave_has_flag_grid(g_ptr, FF_SECRET) && is_trap(player_ptr, g_ptr->feat))
-        return true;
-    else
-        return false;
-}
-
-/*!
  * @brief マスに隠されたドアがあるかの判定を行う。 / Return TRUE if the given grid is a hidden closed door
  * @param player_ptr プレーヤーへの参照ポインタ
  * @param g_ptr マス構造体の参照ポインタ
@@ -505,7 +466,7 @@ void note_spot(player_type *player_ptr, POSITION y, POSITION x)
     }
 
     /* Hack -- memorize grids */
-    if (!(g_ptr->info & (CAVE_MARK))) {
+    if (!g_ptr->is_mark()) {
         /* Feature code (applying "mimic" field) */
         feature_type *f_ptr = &f_info[get_feat_mimic(g_ptr)];
 
@@ -897,23 +858,6 @@ void update_flow(player_type *subject_ptr)
     }
 }
 
-static flow_type get_grid_flow_type(monster_race *r_ptr)
-{
-    if (any_bits(r_ptr->flags7, RF7_CAN_FLY))
-        return FLOW_CAN_FLY;
-    return FLOW_NORMAL;
-}
-
-byte grid_cost(grid_type *g_ptr, monster_race *r_ptr)
-{
-    return g_ptr->costs[get_grid_flow_type(r_ptr)];
-}
-
-byte grid_dist(grid_type *g_ptr, monster_race *r_ptr)
-{
-    return g_ptr->dists[get_grid_flow_type(r_ptr)];
-}
-
 /*
  * Take a feature, determine what that feature becomes
  * through applying the given action.
@@ -1013,39 +957,6 @@ void remove_mirror(player_type *caster_ptr, POSITION y, POSITION x)
     lite_spot(caster_ptr, y, x);
 }
 
-/*
- *  Return TRUE if there is a mirror on the grid.
- */
-bool is_mirror_grid(grid_type *g_ptr)
-{
-    if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_MIRROR))
-        return true;
-    else
-        return false;
-}
-
-/*
- *  Return TRUE if there is a rune of protection on the grid.
- */
-bool is_rune_protection_grid(grid_type *g_ptr)
-{
-    if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_RUNE_PROTECTION))
-        return true;
-    else
-        return false;
-}
-
-/*
- *  Return TRUE if there is a rune of explosion on the grid.
- */
-bool is_rune_explosion_grid(grid_type *g_ptr)
-{
-    if ((g_ptr->info & CAVE_OBJECT) && has_flag(f_info[g_ptr->mimic].flags, FF_RUNE_EXPLOSION))
-        return true;
-    else
-        return false;
-}
-
 /*!
  * @brief 指定されたマスがモンスターのテレポート可能先かどうかを判定する。
  * @param player_ptr プレーヤーへの参照ポインタ
@@ -1071,9 +982,9 @@ bool cave_monster_teleportable_bold(player_type *player_ptr, MONSTER_IDX m_idx,
         return false;
 
     /* Hack -- no teleport onto rune of protection */
-    if (is_rune_protection_grid(g_ptr))
+    if (g_ptr->is_rune_protection())
         return false;
-    if (is_rune_explosion_grid(g_ptr))
+    if (g_ptr->is_rune_explosion())
         return false;
 
     if (!(mode & TELEPORT_PASSIVE)) {
@@ -1323,7 +1234,7 @@ int count_dt(player_type *creature_ptr, POSITION *y, POSITION *x, bool (*test)(p
         POSITION yy = creature_ptr->y + ddy_ddd[d];
         POSITION xx = creature_ptr->x + ddx_ddd[d];
         g_ptr = &creature_ptr->current_floor_ptr->grid_array[yy][xx];
-        if (!(g_ptr->info & (CAVE_MARK)))
+        if (!g_ptr->is_mark())
             continue;
 
         feat = get_feat_mimic(g_ptr);
@@ -1345,3 +1256,58 @@ bool feat_uses_special(FEAT_IDX f_idx)
 {
     return has_flag(f_info[(f_idx)].flags, FF_SPECIAL);
 }
+
+/*
+ * This function allows us to efficiently add a grid to the "lite" array,
+ * note that we are never called for illegal grids, or for grids which
+ * have already been placed into the "lite" array, and we are never
+ * called when the "lite" array is full.
+ */
+void cave_lite_hack(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    auto *g_ptr = &floor_ptr->grid_array[y][x];
+    if (g_ptr->is_lite()) {
+        return;
+    }
+
+    g_ptr->info |= CAVE_LITE;
+    floor_ptr->lite_y[floor_ptr->lite_n] = y;
+    floor_ptr->lite_x[floor_ptr->lite_n++] = x;
+}
+
+/*
+ * For delayed visual update
+ */
+void cave_redraw_later(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    auto *g_ptr = &floor_ptr->grid_array[y][x];
+    if (g_ptr->is_redraw()) {
+        return;
+    }
+
+    g_ptr->info |= CAVE_REDRAW;
+    floor_ptr->redraw_y[floor_ptr->redraw_n] = y;
+    floor_ptr->redraw_x[floor_ptr->redraw_n++] = x;
+}
+
+/*
+ * For delayed visual update
+ */
+void cave_note_and_redraw_later(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    floor_ptr->grid_array[y][x].info |= CAVE_NOTE;
+    cave_redraw_later(floor_ptr, y, x);
+}
+
+void cave_view_hack(floor_type *floor_ptr, POSITION y, POSITION x)
+{
+    auto *g_ptr = &floor_ptr->grid_array[y][x];
+    if (g_ptr->is_view()) {
+        return;
+    }
+
+    g_ptr->info |= CAVE_VIEW;
+    floor_ptr->view_y[floor_ptr->view_n] = y;
+    floor_ptr->view_x[floor_ptr->view_n] = x;
+    floor_ptr->view_n++;
+}