OSDN Git Service

[Refactor] struct player_type を class PlayerType に置換。
[hengbandforosx/hengbandosx.git] / src / floor / geometry.cpp
index 7dd78a5..0596427 100644 (file)
@@ -4,6 +4,7 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "system/floor-type-definition.h"
+#include "system/grid-type-definition.h"
 #include "system/monster-type-definition.h"
 #include "system/player-type-definition.h"
 #include "target/projection-path-calculator.h"
@@ -74,7 +75,7 @@ POSITION distance(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
     if (!dy || !dx)
         return d;
 
-    while (TRUE) {
+    while (true) {
         /* Approximate error */
         err = (target - d * d) / (2 * d);
 
@@ -96,14 +97,14 @@ POSITION distance(POSITION y1, POSITION x1, POSITION y2, POSITION x2)
  * @param x 方角を確認したX座標
  * @return 方向ID
  */
-DIRECTION coords_to_dir(player_type *creature_ptr, POSITION y, POSITION x)
+DIRECTION coords_to_dir(PlayerType *player_ptr, POSITION y, POSITION x)
 {
     DIRECTION d[3][3] = { { 7, 4, 1 }, { 8, 5, 2 }, { 9, 6, 3 } };
     POSITION dy, dx;
 
-    dy = y - creature_ptr->y;
-    dx = x - creature_ptr->x;
-    if (ABS(dx) > 1 || ABS(dy) > 1)
+    dy = y - player_ptr->y;
+    dx = x - player_ptr->x;
+    if (std::abs(dx) > 1 || std::abs(dy) > 1)
         return 0;
 
     return d[dx + 1][dy + 1];
@@ -144,39 +145,39 @@ DIRECTION coords_to_dir(player_type *creature_ptr, POSITION y, POSITION x)
  * "glowing" grid.  This prevents the player from being able to "see" the\n
  * walls of illuminated rooms from a corridor outside the room.\n
  */
-bool player_can_see_bold(player_type *creature_ptr, POSITION y, POSITION x)
+bool player_can_see_bold(PlayerType *player_ptr, POSITION y, POSITION x)
 {
     grid_type *g_ptr;
 
     /* Blind players see nothing */
-    if (creature_ptr->blind)
-        return FALSE;
+    if (player_ptr->blind)
+        return false;
 
-    g_ptr = &creature_ptr->current_floor_ptr->grid_array[y][x];
+    g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
 
     /* Note that "torch-lite" yields "illumination" */
     if (g_ptr->info & (CAVE_LITE | CAVE_MNLT))
-        return TRUE;
+        return true;
 
     /* Require line of sight to the grid */
-    if (!player_has_los_bold(creature_ptr, y, x))
-        return FALSE;
+    if (!player_has_los_bold(player_ptr, y, x))
+        return false;
 
     /* Noctovision of Ninja */
-    if (creature_ptr->see_nocto)
-        return TRUE;
+    if (player_ptr->see_nocto)
+        return true;
 
     /* Require "perma-lite" of the grid */
     if ((g_ptr->info & (CAVE_GLOW | CAVE_MNDK)) != CAVE_GLOW)
-        return FALSE;
+        return false;
 
     /* Feature code (applying "mimic" field) */
     /* Floors are simple */
-    if (feat_supports_los(get_feat_mimic(g_ptr)))
-        return TRUE;
+    if (feat_supports_los(g_ptr->get_feat_mimic()))
+        return true;
 
     /* Check for "local" illumination */
-    return check_local_illumination(creature_ptr, y, x);
+    return check_local_illumination(player_ptr, y, x);
 }
 
 /*
@@ -232,16 +233,16 @@ void mmove2(POSITION *y, POSITION *x, POSITION y1, POSITION x1, POSITION y2, POS
 
 /*!
  * @brief Is the monster seen by the player?
- * @param creature_ptr プレーヤーへの参照ポインタ
+ * @param player_ptr プレイヤーへの参照ポインタ
  * @param m_ptr 個々のモンスターへの参照ポインタ
- * @return å\80\8bã\80\85ã\81®ã\83¢ã\83³ã\82¹ã\82¿ã\83¼ã\81\8cã\83\97ã\83¬ã\83¼ヤーが見えたらTRUE
+ * @return å\80\8bã\80\85ã\81®ã\83¢ã\83³ã\82¹ã\82¿ã\83¼ã\81\8cã\83\97ã\83¬ã\82¤ヤーが見えたらTRUE
  * @todo is_seen() の関数マクロをバラそうとしたがインクルード関係のコンパイルエラーで失敗
  */
-bool is_seen(player_type *creature_ptr, monster_type *m_ptr)
+bool is_seen(PlayerType *player_ptr, monster_type *m_ptr)
 {
     bool is_inside_view = !ignore_unview;
-    is_inside_view |= creature_ptr->phase_out;
+    is_inside_view |= player_ptr->phase_out;
     is_inside_view
-        |= player_can_see_bold(creature_ptr, m_ptr->fy, m_ptr->fx) && projectable(creature_ptr, creature_ptr->y, creature_ptr->x, m_ptr->fy, m_ptr->fx);
+        |= player_can_see_bold(player_ptr, m_ptr->fy, m_ptr->fx) && projectable(player_ptr, player_ptr->y, player_ptr->x, m_ptr->fy, m_ptr->fx);
     return m_ptr->ml && is_inside_view;
 }