OSDN Git Service

[Refactor] #3286 Removed player-redraw-types.h
[hengbandforosx/hengbandosx.git] / src / target / target-checker.cpp
index 5aa86a5..a23a50e 100644 (file)
  */
 
 #include "target/target-checker.h"
-#include "core/player-redraw-types.h"
-#include "core/player-update-types.h"
-#include "core/window-redrawer.h"
 #include "core/disturbance.h"
+#include "core/window-redrawer.h"
 #include "game-option/disturbance-options.h"
 #include "game-option/map-screen-options.h"
 #include "io/cursor.h"
 #include "io/screen-util.h"
 #include "system/floor-type-definition.h"
-#include "system/monster-type-definition.h"
+#include "system/monster-entity.h"
 #include "system/player-type-definition.h"
+#include "system/redrawing-flags-updater.h"
 #include "target/target-preparation.h"
 #include "target/target-types.h"
 #include "window/main-window-util.h"
@@ -32,7 +31,7 @@ POSITION target_row;
 
 /*!
  * @brief マップ描画のフォーカスを当てるべき座標を更新する
- * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param player_ptr プレイヤーへの参照ポインタ
  * @details
  * Given an row (y) and col (x), this routine detects when a move
  * off the screen has occurred and figures new borders. -RAK-
@@ -40,96 +39,118 @@ POSITION target_row;
  * The map is reprinted if necessary, and "TRUE" is returned.
  * @return 実際に再描画が必要だった場合TRUEを返す
  */
-void verify_panel(player_type *creature_ptr)
+void verify_panel(PlayerType *player_ptr)
 {
-    POSITION y = creature_ptr->y;
-    POSITION x = creature_ptr->x;
+    POSITION y = player_ptr->y;
+    POSITION x = player_ptr->x;
     TERM_LEN wid, hgt;
     get_screen_size(&wid, &hgt);
-    int max_prow_min = creature_ptr->current_floor_ptr->height - hgt;
-    int max_pcol_min = creature_ptr->current_floor_ptr->width - wid;
-    if (max_prow_min < 0)
+    int max_prow_min = player_ptr->current_floor_ptr->height - hgt;
+    int max_pcol_min = player_ptr->current_floor_ptr->width - wid;
+    if (max_prow_min < 0) {
         max_prow_min = 0;
-    if (max_pcol_min < 0)
+    }
+    if (max_pcol_min < 0) {
         max_pcol_min = 0;
+    }
 
     int prow_min;
     int pcol_min;
-    if (center_player && (center_running || !creature_ptr->running)) {
+    if (center_player && (center_running || !player_ptr->running)) {
         prow_min = y - hgt / 2;
-        if (prow_min < 0)
+        if (prow_min < 0) {
             prow_min = 0;
-        else if (prow_min > max_prow_min)
+        } else if (prow_min > max_prow_min) {
             prow_min = max_prow_min;
+        }
 
         pcol_min = x - wid / 2;
-        if (pcol_min < 0)
+        if (pcol_min < 0) {
             pcol_min = 0;
-        else if (pcol_min > max_pcol_min)
+        } else if (pcol_min > max_pcol_min) {
             pcol_min = max_pcol_min;
+        }
     } else {
         prow_min = panel_row_min;
         pcol_min = panel_col_min;
-        if (y > panel_row_max - 2)
-            while (y > prow_min + hgt - 1 - 2)
+        if (y > panel_row_max - 2) {
+            while (y > prow_min + hgt - 1 - 2) {
                 prow_min += (hgt / 2);
+            }
+        }
 
-        if (y < panel_row_min + 2)
-            while (y < prow_min + 2)
+        if (y < panel_row_min + 2) {
+            while (y < prow_min + 2) {
                 prow_min -= (hgt / 2);
+            }
+        }
 
-        if (prow_min > max_prow_min)
+        if (prow_min > max_prow_min) {
             prow_min = max_prow_min;
+        }
 
-        if (prow_min < 0)
+        if (prow_min < 0) {
             prow_min = 0;
+        }
 
-        if (x > panel_col_max - 4)
-            while (x > pcol_min + wid - 1 - 4)
+        if (x > panel_col_max - 4) {
+            while (x > pcol_min + wid - 1 - 4) {
                 pcol_min += (wid / 2);
+            }
+        }
 
-        if (x < panel_col_min + 4)
-            while (x < pcol_min + 4)
+        if (x < panel_col_min + 4) {
+            while (x < pcol_min + 4) {
                 pcol_min -= (wid / 2);
+            }
+        }
 
-        if (pcol_min > max_pcol_min)
+        if (pcol_min > max_pcol_min) {
             pcol_min = max_pcol_min;
+        }
 
-        if (pcol_min < 0)
+        if (pcol_min < 0) {
             pcol_min = 0;
+        }
     }
 
-    if ((prow_min == panel_row_min) && (pcol_min == panel_col_min))
+    if ((prow_min == panel_row_min) && (pcol_min == panel_col_min)) {
         return;
+    }
 
     panel_row_min = prow_min;
     panel_col_min = pcol_min;
-    if (disturb_panel && !center_player)
-        disturb(creature_ptr, FALSE, FALSE);
+    if (disturb_panel && !center_player) {
+        disturb(player_ptr, false, false);
+    }
 
     panel_bounds_center();
-    creature_ptr->update |= PU_MONSTERS;
-    creature_ptr->redraw |= PR_MAP;
-    creature_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
+    auto &rfu = RedrawingFlagsUpdater::get_instance();
+    rfu.set_flag(StatusRedrawingFlag::MONSTER_STATUSES);
+    rfu.set_flag(MainWindowRedrawingFlag::MAP);
+    player_ptr->window_flags |= PW_OVERHEAD | PW_DUNGEON;
 }
 
 /*
  * Update (if necessary) and verify (if possible) the target.
  * We return TRUE if the target is "okay" and FALSE otherwise.
  */
-bool target_okay(player_type *creature_ptr)
+bool target_okay(PlayerType *player_ptr)
 {
-    if (target_who < 0)
-        return TRUE;
+    if (target_who < 0) {
+        return true;
+    }
 
-    if (target_who <= 0)
-        return FALSE;
+    if (target_who <= 0) {
+        return false;
+    }
 
-    if (!target_able(creature_ptr, target_who))
-        return FALSE;
+    if (!target_able(player_ptr, target_who)) {
+        return false;
+    }
 
-    monster_type *m_ptr = &creature_ptr->current_floor_ptr->m_list[target_who];
+    auto *m_ptr = &player_ptr->current_floor_ptr->m_list[target_who];
     target_row = m_ptr->fy;
     target_col = m_ptr->fx;
-    return TRUE;
+    return true;
 }