OSDN Git Service

[Refactor] #1444 Added const to all methods in grid_type
authorHourier <grapefox.whitelucifer.0408@gmail.com>
Fri, 3 Sep 2021 12:46:08 +0000 (21:46 +0900)
committerHourier <grapefox.whitelucifer.0408@gmail.com>
Sun, 5 Sep 2021 02:49:56 +0000 (11:49 +0900)
src/system/grid-type-definition.cpp
src/system/grid-type-definition.h

index cf3f558..04819d7 100644 (file)
  * @param X 指定X座標
  * @return FLOOR属性を持っているならばTRUE
  */
-bool grid_type::is_floor()
+bool grid_type::is_floor() const
 {
     return any_bits(this->info, CAVE_FLOOR);
 }
 
-bool grid_type::is_room()
+bool grid_type::is_room() const
 {
     return any_bits(this->info, CAVE_ROOM);
 }
 
-bool grid_type::is_extra()
+bool grid_type::is_extra() const
 {
     return any_bits(this->info, CAVE_EXTRA);
 }
 
-bool grid_type::is_inner()
+bool grid_type::is_inner() const
 {
     return any_bits(this->info, CAVE_INNER);
 }
 
-bool grid_type::is_outer()
+bool grid_type::is_outer() const
 {
     return any_bits(this->info, CAVE_OUTER);
 }
 
-bool grid_type::is_solid()
+bool grid_type::is_solid() const
 {
     return any_bits(this->info, CAVE_SOLID);
 }
 
-bool grid_type::is_icky()
+bool grid_type::is_icky() const
 {
     return any_bits(this->info, CAVE_ICKY);
 }
 
-bool grid_type::is_lite()
+bool grid_type::is_lite() const
 {
     return any_bits(this->info, CAVE_LITE);
 }
 
-bool grid_type::is_redraw()
+bool grid_type::is_redraw() const
 {
     return any_bits(this->info, CAVE_REDRAW);
 }
 
-bool grid_type::is_view()
+bool grid_type::is_view() const
 {
     return any_bits(this->info, CAVE_VIEW);
 }
 
-bool grid_type::is_object()
+bool grid_type::is_object() const
 {
     return any_bits(this->info, CAVE_OBJECT);
 }
 
-bool grid_type::is_mark()
+bool grid_type::is_mark() const
 {
     return any_bits(this->info, CAVE_MARK);
 }
 
-bool grid_type::is_mirror()
+bool grid_type::is_mirror() const
 {
     return this->is_object() && f_info[this->mimic].flags.has(FF::MIRROR);
 }
@@ -78,7 +78,7 @@ bool grid_type::is_mirror()
 /*
  *  @brief 守りのルーンで守られているかを返す
  */
-bool grid_type::is_rune_protection()
+bool grid_type::is_rune_protection() const
 {
     return this->is_object() && f_info[this->mimic].flags.has(FF::RUNE_PROTECTION);
 }
@@ -86,22 +86,22 @@ bool grid_type::is_rune_protection()
 /*
  *  @brief 爆発のルーンが仕掛けられているかを返す
  */
-bool grid_type::is_rune_explosion()
+bool grid_type::is_rune_explosion() const
 {
     return this->is_object() && f_info[this->mimic].flags.has(FF::RUNE_EXPLOSION);
 }
 
-byte grid_type::get_cost(monster_race *r_ptr)
+byte grid_type::get_cost(monster_race *r_ptr) const
 {
     return this->costs[get_grid_flow_type(r_ptr)];
 }
 
-byte grid_type::get_distance(monster_race *r_ptr)
+byte grid_type::get_distance(monster_race *r_ptr) const
 {
     return this->dists[get_grid_flow_type(r_ptr)];
 }
 
-flow_type grid_type::get_grid_flow_type(monster_race *r_ptr)
+flow_type grid_type::get_grid_flow_type(monster_race *r_ptr) const
 {
     return any_bits(r_ptr->flags7, RF7_CAN_FLY) ? FLOW_CAN_FLY : FLOW_NORMAL;
 }
@@ -111,12 +111,12 @@ flow_type grid_type::get_grid_flow_type(monster_race *r_ptr)
  * @param g_ptr グリッドへの参照ポインタ
  * @return 地形情報
  */
-FEAT_IDX grid_type::get_feat_mimic()
+FEAT_IDX grid_type::get_feat_mimic() const
 {
     return f_info[this->mimic ? this->mimic : this->feat].mimic;
 }
 
-bool grid_type::cave_has_flag(FF feature_flags)
+bool grid_type::cave_has_flag(FF feature_flags) const
 {
     return f_info[this->feat].flags.has(feature_flags);
 }
@@ -126,7 +126,7 @@ bool grid_type::cave_has_flag(FF feature_flags)
  * @param ch 指定するシンボル文字
  * @return シンボルが指定した記号か否か
  */
-bool grid_type::is_symbol(const int ch)
+bool grid_type::is_symbol(const int ch) const
 {
     return f_info[this->feat].x_char[0] == ch;
 }
index 8b24735..f5fe199 100644 (file)
@@ -67,27 +67,27 @@ public:
     byte dists[FLOW_MAX]{}; /* Hack -- distance from player */
     byte when{}; /* Hack -- when cost was computed */
 
-    bool is_floor();
-    bool is_room();
-    bool is_extra();
-    bool is_inner();
-    bool is_outer();
-    bool is_solid();
-    bool is_icky();
-    bool is_lite();
-    bool is_redraw();
-    bool is_view();
-    bool is_object();
-    bool is_mark();
-    bool is_mirror();
-    bool is_rune_protection();
-    bool is_rune_explosion();
-    byte get_cost(monster_race *r_ptr);
-    byte get_distance(monster_race *r_ptr);
-    FEAT_IDX get_feat_mimic();
-    bool cave_has_flag(FF feature_flags);
-    bool is_symbol(const int ch);
+    bool is_floor() const;
+    bool is_room() const;
+    bool is_extra() const;
+    bool is_inner() const;
+    bool is_outer() const;
+    bool is_solid() const;
+    bool is_icky() const;
+    bool is_lite() const;
+    bool is_redraw() const;
+    bool is_view() const;
+    bool is_object() const;
+    bool is_mark() const;
+    bool is_mirror() const;
+    bool is_rune_protection() const;
+    bool is_rune_explosion() const;
+    byte get_cost(monster_race *r_ptr) const;
+    byte get_distance(monster_race *r_ptr) const;
+    FEAT_IDX get_feat_mimic() const;
+    bool cave_has_flag(FF feature_flags) const;
+    bool is_symbol(const int ch) const;
 
 private:
-    flow_type get_grid_flow_type(monster_race *r_ptr);
+    flow_type get_grid_flow_type(monster_race *r_ptr) const;
 };