OSDN Git Service

[Refactor] Grid::has_monster()の定義
authordis- <dis.rogue@gmail.com>
Sat, 2 Mar 2024 18:47:57 +0000 (03:47 +0900)
committerdis- <dis.rogue@gmail.com>
Sun, 3 Mar 2024 05:03:59 +0000 (14:03 +0900)
Gridに関してis_monster()を使用している箇所をGrid::has_monster()でラップする。

62 files changed:
src/action/movement-execution.cpp
src/action/mutation-execution.cpp
src/action/run-execution.cpp
src/action/travel-execution.cpp
src/blue-magic/blue-magic-caster.cpp
src/cmd-action/cmd-mane.cpp
src/cmd-action/cmd-open-close.cpp
src/cmd-action/cmd-others.cpp
src/cmd-action/cmd-pet.cpp
src/cmd-action/cmd-tunnel.cpp
src/combat/shoot.cpp
src/effect/effect-feature.cpp
src/effect/effect-monster.cpp
src/effect/effect-processor.cpp
src/floor/floor-streams.cpp
src/floor/object-allocator.cpp
src/floor/wild.cpp
src/grid/feature.cpp
src/grid/grid.cpp
src/io/cursor.cpp
src/mind/mind-berserker.cpp
src/mind/mind-force-trainer.cpp
src/mind/mind-ninja.cpp
src/mind/mind-warrior.cpp
src/mind/monk-attack.cpp
src/monster-attack/monster-attack-processor.cpp
src/monster-floor/monster-move.cpp
src/monster-floor/monster-remover.cpp
src/monster-floor/one-monster-placer.cpp
src/monster/monster-info.cpp
src/monster/monster-list.cpp
src/monster/monster-processor.cpp
src/monster/monster-update.cpp
src/mspell/mspell-checker.cpp
src/mspell/mspell-judgement.cpp
src/mutation/mutation-techniques.cpp
src/object-use/throw-execution.cpp
src/object/warning.cpp
src/pet/pet-fall-off.cpp
src/player-attack/player-attack.cpp
src/player/player-status.cpp
src/racial/racial-vampire.cpp
src/realm/realm-hex.cpp
src/realm/realm-hissatsu.cpp
src/room/vault-builder.cpp
src/spell-class/spells-mirror-master.cpp
src/spell-kind/earthquake.cpp
src/spell-kind/spells-floor.cpp
src/spell-kind/spells-lite.cpp
src/spell-kind/spells-teleport.cpp
src/spell-realm/spells-chaos.cpp
src/spell-realm/spells-crusade.cpp
src/spell/spells-status.cpp
src/system/grid-type-definition.cpp
src/system/grid-type-definition.h
src/target/projection-path-calculator.cpp
src/target/target-describer.cpp
src/target/target-preparation.cpp
src/util/sort.cpp
src/view/display-map.cpp
src/window/display-sub-windows.cpp
src/world/world-turn-processor.cpp

index 6b40e73..d255c2c 100644 (file)
@@ -26,7 +26,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "mutation/mutation-flag-types.h"
 #include "object/warning.h"
 #include "player-base/player-class.h"
@@ -166,7 +165,7 @@ void exe_movement(PlayerType *player_ptr, DIRECTION dir, bool do_pickup, bool br
     std::string m_name;
     bool can_move = true;
     bool do_past = false;
-    if (is_monster(grid.m_idx) && (m_ptr->ml || p_can_enter || p_can_kill_walls)) {
+    if (grid.has_monster() && (m_ptr->ml || p_can_enter || p_can_kill_walls)) {
         auto *r_ptr = &m_ptr->get_monrace();
         auto effects = player_ptr->effects();
         auto is_stunned = effects->stun()->is_stunned();
index ec33cb4..6041792 100644 (file)
@@ -23,7 +23,6 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-info.h"
-#include "monster/monster-util.h"
 #include "mutation/mutation-flag-types.h"
 #include "mutation/mutation-techniques.h"
 #include "object-enchant/item-feeling.h"
@@ -248,7 +247,7 @@ bool exe_mutation_power(PlayerType *player_ptr, PlayerMutationType power)
         const auto y = player_ptr->y + ddy[dir];
         const auto x = player_ptr->x + ddx[dir];
         const auto &grid = floor.grid_array[y][x];
-        if (!is_monster(grid.m_idx)) {
+        if (!grid.has_monster()) {
             msg_print(_("邪悪な存在を感じとれません!", "You sense no evil there!"));
             return true;
         }
@@ -288,7 +287,7 @@ bool exe_mutation_power(PlayerType *player_ptr, PlayerMutationType power)
         const auto y = player_ptr->y + ddy[dir];
         const auto x = player_ptr->x + ddx[dir];
         auto &grid = floor.grid_array[y][x];
-        if (!is_monster(grid.m_idx)) {
+        if (!grid.has_monster()) {
             msg_print(_("あなたは何もない場所で手を振った。", "You wave your hands in the air."));
             return true;
         }
index 1cdd49a..dd9885d 100644 (file)
@@ -13,7 +13,6 @@
 #include "grid/grid.h"
 #include "main/sound-definitions-table.h"
 #include "main/sound-of-music.h"
-#include "monster/monster-util.h"
 #include "object/object-mark-types.h"
 #include "player-status/player-energy.h"
 #include "player/player-status-flags.h"
@@ -227,7 +226,7 @@ static bool run_test(PlayerType *player_ptr)
         int new_dir = cycle[chome[prev_dir] + i];
         const Pos2D pos(player_ptr->y + ddy[new_dir], player_ptr->x + ddx[new_dir]);
         const auto &grid = floor.get_grid(pos);
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             const auto &monster = floor.m_list[grid.m_idx];
             if (monster.ml) {
                 return true;
index 28f681c..cf4fe71 100644 (file)
@@ -13,7 +13,6 @@
 #include "game-option/special-options.h"
 #include "grid/feature.h"
 #include "grid/grid.h"
-#include "monster/monster-util.h"
 #include "player-status/player-energy.h"
 #include "player/player-move.h"
 #include "system/floor-type-definition.h"
@@ -62,7 +61,7 @@ static DIRECTION travel_test(PlayerType *player_ptr, DIRECTION prev_dir)
         POSITION row = player_ptr->y + ddy[dir];
         POSITION col = player_ptr->x + ddx[dir];
         g_ptr = &floor_ptr->grid_array[row][col];
-        if (is_monster(g_ptr->m_idx)) {
+        if (g_ptr->has_monster()) {
             auto *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
             if (m_ptr->ml) {
                 return 0;
index aeb1d16..ef5b203 100644 (file)
@@ -18,7 +18,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "spell-kind/spells-launcher.h"
 #include "spell-kind/spells-lite.h"
@@ -100,7 +99,7 @@ static std::optional<std::string> exe_blue_teleport_back(PlayerType *player_ptr)
     const auto &floor = *player_ptr->current_floor_ptr;
     const Pos2D pos(target_row, target_col);
     const auto &grid = floor.get_grid(pos);
-    if (!is_monster(grid.m_idx) || !grid.has_los() || !projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
+    if (!grid.has_monster() || !grid.has_los() || !projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col)) {
         return std::nullopt;
     }
 
index 6d77417..6c9405b 100644 (file)
@@ -34,7 +34,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-processor.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "mspell/monster-power-table.h"
 #include "player-base/player-class.h"
 #include "player-info/mane-data-type.h"
@@ -961,7 +960,7 @@ static bool use_mane(PlayerType *player_ptr, MonsterAbilityType spell)
         const auto &floor = *player_ptr->current_floor_ptr;
         const Pos2D pos(target_row, target_col);
         const auto &grid_target = floor.get_grid(pos);
-        auto should_teleport = !is_monster(grid_target.m_idx);
+        auto should_teleport = !grid_target.has_monster();
         should_teleport &= grid_target.has_los();
         should_teleport &= projectable(player_ptr, player_ptr->y, player_ptr->x, target_row, target_col);
         if (!should_teleport) {
index a15a588..902dbb1 100644 (file)
@@ -11,7 +11,6 @@
 #include "inventory/inventory-object.h"
 #include "inventory/inventory-slot-types.h"
 #include "io/input-key-requester.h"
-#include "monster/monster-util.h"
 #include "object/tval-types.h"
 #include "player-base/player-class.h"
 #include "player-info/samurai-data-type.h"
@@ -131,7 +130,7 @@ void do_cmd_open(PlayerType *player_ptr)
         const auto o_idx = chest_check(player_ptr->current_floor_ptr, pos, false);
         if (grid.get_terrain_mimic().flags.has_not(TerrainCharacteristics::OPEN) && !o_idx) {
             msg_print(_("そこには開けるものが見当たらない。", "You see nothing there to open."));
-        } else if (is_monster(grid.m_idx) && player_ptr->riding != grid.m_idx) {
+        } else if (grid.has_monster() && player_ptr->riding != grid.m_idx) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
             msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
             do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
@@ -180,7 +179,7 @@ void do_cmd_close(PlayerType *player_ptr)
         const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
         if (grid.get_terrain_mimic().flags.has_not(TerrainCharacteristics::CLOSE)) {
             msg_print(_("そこには閉じるものが見当たらない。", "You see nothing there to close."));
-        } else if (is_monster(grid.m_idx)) {
+        } else if (grid.has_monster()) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
             msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
             do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
@@ -232,7 +231,7 @@ void do_cmd_disarm(PlayerType *player_ptr)
         const auto o_idx = chest_check(player_ptr->current_floor_ptr, pos, true);
         if (!is_trap(player_ptr, feat) && !o_idx) {
             msg_print(_("そこには解除するものが見当たらない。", "You see nothing there to disarm."));
-        } else if (is_monster(grid.m_idx) && player_ptr->riding != grid.m_idx) {
+        } else if (grid.has_monster() && player_ptr->riding != grid.m_idx) {
             msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
             do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
         } else if (o_idx) {
@@ -285,7 +284,7 @@ void do_cmd_bash(PlayerType *player_ptr)
         const Grid &grid = player_ptr->current_floor_ptr->get_grid(pos);
         if (grid.get_terrain_mimic().flags.has_not(TerrainCharacteristics::BASH)) {
             msg_print(_("そこには体当たりするものが見当たらない。", "You see nothing there to bash."));
-        } else if (is_monster(grid.m_idx)) {
+        } else if (grid.has_monster()) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
             msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
             do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
@@ -356,7 +355,7 @@ void do_cmd_spike(PlayerType *player_ptr)
         msg_print(_("そこにはくさびを打てるものが見当たらない。", "You see nothing there to spike."));
     } else if (!get_spike(player_ptr, &i_idx)) {
         msg_print(_("くさびを持っていない!", "You have no spikes!"));
-    } else if (is_monster(grid.m_idx)) {
+    } else if (grid.has_monster()) {
         PlayerEnergy(player_ptr).set_player_turn_energy(100);
         msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
         do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
index 06397f9..3b4fb50 100644 (file)
@@ -23,7 +23,6 @@
 #include "io/write-diary.h"
 #include "main/music-definitions-table.h"
 #include "main/sound-of-music.h"
-#include "monster/monster-util.h"
 #include "player-base/player-class.h"
 #include "player-info/samurai-data-type.h"
 #include "player-status/player-energy.h"
@@ -72,7 +71,7 @@ static bool exe_alter(PlayerType *player_ptr)
     const auto &grid = player_ptr->current_floor_ptr->get_grid(pos);
     const auto &terrain = grid.get_terrain_mimic();
     PlayerEnergy(player_ptr).set_player_turn_energy(100);
-    if (is_monster(grid.m_idx)) {
+    if (grid.has_monster()) {
         do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
         return false;
     }
index 0806dc3..6c1142f 100644 (file)
@@ -28,7 +28,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "object-hook/hook-weapon.h"
 #include "pet/pet-util.h"
@@ -219,7 +218,7 @@ bool do_cmd_riding(PlayerType *player_ptr, bool force)
             return false;
         }
 
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             PlayerEnergy(player_ptr).set_player_turn_energy(100);
 
             msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
@@ -238,7 +237,7 @@ bool do_cmd_riding(PlayerType *player_ptr, bool force)
 
         const auto *m_ptr = &player_ptr->current_floor_ptr->m_list[grid.m_idx];
 
-        if (!is_monster(grid.m_idx) || !m_ptr->ml) {
+        if (!grid.has_monster() || !m_ptr->ml) {
             msg_print(_("その場所にはモンスターはいません。", "There is no monster here."));
             return false;
         }
@@ -327,7 +326,7 @@ static void do_name_pet(PlayerType *player_ptr)
     target_pet = old_target_pet;
     auto &floor = *player_ptr->current_floor_ptr;
     const auto &grid = floor.grid_array[target_row][target_col];
-    if (!is_monster(grid.m_idx)) {
+    if (!grid.has_monster()) {
         return;
     }
 
@@ -704,7 +703,7 @@ void do_cmd_pet(PlayerType *player_ptr)
             player_ptr->pet_t_m_idx = 0;
         } else {
             auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[target_row][target_col];
-            if (is_monster(g_ptr->m_idx) && (player_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)) {
+            if (g_ptr->has_monster() && (player_ptr->current_floor_ptr->m_list[g_ptr->m_idx].ml)) {
                 player_ptr->pet_t_m_idx = player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx;
                 player_ptr->pet_follow_distance = PET_DESTROY_DIST;
             } else {
index 9f42b58..c260b7c 100644 (file)
@@ -5,7 +5,6 @@
 #include "floor/geometry.h"
 #include "grid/grid.h"
 #include "io/input-key-requester.h"
-#include "monster/monster-util.h"
 #include "player-base/player-class.h"
 #include "player-info/samurai-data-type.h"
 #include "player-status/player-energy.h"
@@ -57,7 +56,7 @@ void do_cmd_tunnel(PlayerType *player_ptr)
         msg_print(_("ドアは掘れない。", "You cannot tunnel through doors."));
     } else if (terrain_mimic.flags.has_not(TerrainCharacteristics::TUNNEL)) {
         msg_print(_("そこは掘れない。", "You can't tunnel through that."));
-    } else if (is_monster(grid.m_idx)) {
+    } else if (grid.has_monster()) {
         PlayerEnergy(player_ptr).set_player_turn_energy(100);
         msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
         do_cmd_attack(player_ptr, pos.y, pos.x, HISSATSU_NONE);
index 322160c..997396a 100644 (file)
@@ -38,7 +38,6 @@
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "object/object-broken.h"
 #include "object/object-info.h"
 #include "object/object-mark-types.h"
@@ -633,7 +632,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX i_idx, ItemEntity *j_ptr, SP
             if (snipe_type == SP_KILL_WALL) {
                 g_ptr = &floor_ptr->grid_array[ny][nx];
 
-                if (g_ptr->cave_has_flag(TerrainCharacteristics::HURT_ROCK) && !is_monster(g_ptr->m_idx)) {
+                if (g_ptr->cave_has_flag(TerrainCharacteristics::HURT_ROCK) && !g_ptr->has_monster()) {
                     if (any_bits(g_ptr->info, (CAVE_MARK))) {
                         msg_print(_("岩が砕け散った。", "Wall rocks were shattered."));
                     }
@@ -656,7 +655,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX i_idx, ItemEntity *j_ptr, SP
             }
 
             /* Stopped by walls/doors */
-            if (!cave_has_flag_bold(floor_ptr, ny, nx, TerrainCharacteristics::PROJECT) && !is_monster(floor_ptr->grid_array[ny][nx].m_idx)) {
+            if (!cave_has_flag_bold(floor_ptr, ny, nx, TerrainCharacteristics::PROJECT) && !floor_ptr->grid_array[ny][nx].has_monster()) {
                 break;
             }
 
@@ -715,7 +714,7 @@ void exe_fire(PlayerType *player_ptr, INVENTORY_IDX i_idx, ItemEntity *j_ptr, SP
             y = ny;
 
             /* Monster here, Try to hit it */
-            if (is_monster(floor_ptr->grid_array[y][x].m_idx)) {
+            if (floor_ptr->grid_array[y][x].has_monster()) {
                 sound(SOUND_SHOOT_HIT);
                 Grid *c_mon_ptr = &floor_ptr->grid_array[y][x];
 
index 884bea7..04734a0 100644 (file)
@@ -355,7 +355,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
         if (player_can_see_bold(player_ptr, y, x)) {
             obvious = true;
         }
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             update_monster(player_ptr, grid.m_idx, false);
         }
 
@@ -408,7 +408,7 @@ bool affect_feature(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION r, POS
         if (player_can_see_bold(player_ptr, y, x)) {
             obvious = true;
         }
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             update_monster(player_ptr, grid.m_idx, false);
         }
 
index 527cc98..8c75835 100644 (file)
@@ -64,7 +64,7 @@
  */
 static ProcessResult is_affective(PlayerType *player_ptr, EffectMonster *em_ptr)
 {
-    if (!is_monster(em_ptr->g_ptr->m_idx)) {
+    if (!em_ptr->g_ptr->has_monster()) {
         return ProcessResult::PROCESS_FALSE;
     }
     if (is_monster(em_ptr->src_idx) && (em_ptr->g_ptr->m_idx == em_ptr->src_idx)) {
index 8a1ce74..3e8acf6 100644 (file)
@@ -483,7 +483,7 @@ ProjectResult project(PlayerType *player_ptr, const MONSTER_IDX src_idx, POSITIO
         if (!src_idx && (project_m_n == 1) && none_bits(flag, PROJECT_JUMP)) {
             const Pos2D pos_project(project_m_y, project_m_x);
             const auto &grid = floor.get_grid(pos_project);
-            if (is_monster(grid.m_idx)) {
+            if (grid.has_monster()) {
                 auto &monster = floor.m_list[grid.m_idx];
                 if (monster.ml) {
                     if (!player_ptr->effects()->hallucination()->is_hallucinated()) {
index ba21e4c..7c2c1b3 100644 (file)
@@ -28,7 +28,6 @@
 #include "grid/grid.h"
 #include "monster-race/monster-race.h"
 #include "monster/monster-info.h"
-#include "monster/monster-util.h"
 #include "room/lake-types.h"
 #include "spell-kind/spells-floor.h"
 #include "system/artifact-type-definition.h"
@@ -344,7 +343,7 @@ void build_streamer(PlayerType *player_ptr, FEAT_IDX feat, int chance)
             }
 
             auto *r_ptr = &monraces_info[floor.m_list[grid.m_idx].r_idx];
-            if (is_monster(grid.m_idx) && !(streamer.flags.has(TerrainCharacteristics::PLACE) && monster_can_cross_terrain(player_ptr, feat, r_ptr, 0))) {
+            if (grid.has_monster() && !(streamer.flags.has(TerrainCharacteristics::PLACE) && monster_can_cross_terrain(player_ptr, feat, r_ptr, 0))) {
                 /* Delete the monster (if any) */
                 delete_monster(player_ptr, pos.y, pos.x);
             }
index 37d23ee..2839b07 100644 (file)
@@ -11,7 +11,6 @@
 #include "grid/object-placer.h"
 #include "grid/trap.h"
 #include "monster-race/monster-race.h"
-#include "monster/monster-util.h"
 #include "system/dungeon-info.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
@@ -63,7 +62,7 @@ static bool alloc_stairs_aux(PlayerType *player_ptr, POSITION y, POSITION x, int
 {
     auto *floor_ptr = player_ptr->current_floor_ptr;
     auto *g_ptr = &floor_ptr->grid_array[y][x];
-    if (!g_ptr->is_floor() || pattern_tile(floor_ptr, y, x) || !g_ptr->o_idx_list.empty() || is_monster(g_ptr->m_idx) || next_to_walls(floor_ptr, y, x) < walls) {
+    if (!g_ptr->is_floor() || pattern_tile(floor_ptr, y, x) || !g_ptr->o_idx_list.empty() || g_ptr->has_monster() || next_to_walls(floor_ptr, y, x) < walls) {
         return false;
     }
 
@@ -195,7 +194,7 @@ void alloc_object(PlayerType *player_ptr, dap_type set, dungeon_allocation_type
             x = randint0(floor_ptr->width);
             const Pos2D pos(y, x);
             const auto &grid = floor_ptr->get_grid(pos);
-            if (!grid.is_floor() || !grid.o_idx_list.empty() || is_monster(grid.m_idx)) {
+            if (!grid.is_floor() || !grid.o_idx_list.empty() || grid.has_monster()) {
                 continue;
             }
 
index ce05c42..59924e5 100644 (file)
@@ -551,7 +551,7 @@ void wilderness_gen(PlayerType *player_ptr)
                     continue;
                 }
 
-                if (is_monster(grid.m_idx)) {
+                if (grid.has_monster()) {
                     delete_monster_idx(player_ptr, grid.m_idx);
                 }
 
@@ -569,7 +569,7 @@ void wilderness_gen(PlayerType *player_ptr)
                     continue;
                 }
 
-                if (is_monster(grid.m_idx)) {
+                if (grid.has_monster()) {
                     delete_monster_idx(player_ptr, grid.m_idx);
                 }
 
index 17fbd40..114c981 100644 (file)
@@ -7,7 +7,6 @@
 #include "grid/lighting-colors-table.h"
 #include "mind/mind-ninja.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "player/special-defense-types.h"
 #include "room/door-definition.h"
 #include "system/dungeon-info.h"
@@ -235,7 +234,7 @@ void cave_set_feat(PlayerType *player_ptr, POSITION y, POSITION x, FEAT_IDX feat
         g_ptr->info &= ~(CAVE_MARK);
     }
 
-    if (is_monster(g_ptr->m_idx)) {
+    if (g_ptr->has_monster()) {
         update_monster(player_ptr, g_ptr->m_idx, false);
     }
 
@@ -265,7 +264,7 @@ void cave_set_feat(PlayerType *player_ptr, POSITION y, POSITION x, FEAT_IDX feat
         auto *cc_ptr = &floor_ptr->grid_array[yy][xx];
         cc_ptr->info |= CAVE_GLOW;
         if (cc_ptr->is_view()) {
-            if (is_monster(cc_ptr->m_idx)) {
+            if (cc_ptr->has_monster()) {
                 update_monster(player_ptr, cc_ptr->m_idx, false);
             }
 
index 7f31d25..7ee06ef 100644 (file)
@@ -37,7 +37,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "object/item-tester-hooker.h"
 #include "object/object-mark-types.h"
 #include "player-info/class-info.h"
@@ -85,7 +84,7 @@ bool new_player_spot(PlayerType *player_ptr)
         const auto &grid = player_ptr->current_floor_ptr->get_grid({ y, x });
 
         /* Must be a "naked" floor grid */
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             continue;
         }
         if (floor.is_in_dungeon()) {
@@ -185,7 +184,7 @@ static void update_local_illumination_aux(PlayerType *player_ptr, int y, int x)
         return;
     }
 
-    if (is_monster(grid.m_idx)) {
+    if (grid.has_monster()) {
         update_monster(player_ptr, grid.m_idx, false);
     }
 
@@ -850,7 +849,7 @@ bool cave_monster_teleportable_bold(PlayerType *player_ptr, MONSTER_IDX m_idx, P
         return false;
     }
 
-    if (is_monster(grid.m_idx) && (grid.m_idx != m_idx)) {
+    if (grid.has_monster() && (grid.m_idx != m_idx)) {
         return false;
     }
     if (player_ptr->is_located_at(pos)) {
@@ -897,7 +896,7 @@ bool cave_player_teleportable_bold(PlayerType *player_ptr, POSITION y, POSITION
         return false;
     }
 
-    if (is_monster(grid.m_idx) && (grid.m_idx != player_ptr->riding)) {
+    if (grid.has_monster() && (grid.m_idx != player_ptr->riding)) {
         return false;
     }
 
@@ -1061,7 +1060,7 @@ void place_grid(PlayerType *player_ptr, Grid *g_ptr, grid_bold_type gb_type)
         return;
     }
 
-    if (is_monster(g_ptr->m_idx)) {
+    if (g_ptr->has_monster()) {
         delete_monster_idx(player_ptr, g_ptr->m_idx);
     }
 }
index 4e625bf..80ba10c 100644 (file)
@@ -7,7 +7,6 @@
 #include "game-option/special-options.h"
 #include "grid/feature.h"
 #include "io/screen-util.h"
-#include "monster/monster-util.h"
 #include "player/player-status.h"
 #include "system/angband-system.h"
 #include "system/floor-type-definition.h"
@@ -58,7 +57,7 @@ void print_path(PlayerType *player_ptr, POSITION y, POSITION x)
             TERM_COLOR ta = default_color;
             auto tc = '*';
 
-            if (is_monster(g_ptr->m_idx) && floor_ptr->m_list[g_ptr->m_idx].ml) {
+            if (g_ptr->has_monster() && floor_ptr->m_list[g_ptr->m_idx].ml) {
                 map_info(player_ptr, ny, nx, &a, &c, &ta, &tc);
 
                 if (!is_ascii_graphics(a)) {
index 908e777..a44eedd 100644 (file)
@@ -6,7 +6,6 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "mind/mind-numbers.h"
-#include "monster/monster-util.h"
 #include "player-attack/player-attack.h"
 #include "player/player-move.h"
 #include "spell-kind/earthquake.h"
@@ -43,7 +42,7 @@ bool cast_berserk_spell(PlayerType *player_ptr, MindBerserkerType spell)
 
         y = player_ptr->y + ddy[dir];
         x = player_ptr->x + ddx[dir];
-        if (!is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+        if (!player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
             msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
             return false;
         }
@@ -55,7 +54,7 @@ bool cast_berserk_spell(PlayerType *player_ptr, MindBerserkerType spell)
 
         y += ddy[dir];
         x += ddx[dir];
-        if (player_can_enter(player_ptr, player_ptr->current_floor_ptr->grid_array[y][x].feat, 0) && !is_trap(player_ptr, player_ptr->current_floor_ptr->grid_array[y][x].feat) && !is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+        if (player_can_enter(player_ptr, player_ptr->current_floor_ptr->grid_array[y][x].feat, 0) && !is_trap(player_ptr, player_ptr->current_floor_ptr->grid_array[y][x].feat) && !player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
             msg_print(nullptr);
             (void)move_player_effect(player_ptr, y, x, MPE_FORGET_FLOW | MPE_HANDLE_STUFF | MPE_DONT_PICKUP);
         }
index 5edf278..85ccbf4 100644 (file)
@@ -17,7 +17,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "pet/pet-util.h"
 #include "player-base/player-class.h"
 #include "player-info/equipment-info.h"
@@ -212,7 +211,7 @@ bool shock_power(PlayerType *player_ptr)
     PLAYER_LEVEL plev = player_ptr->lev;
     int dam = damroll(8 + ((plev - 5) / 4) + boost / 12, 8);
     fire_beam(player_ptr, AttributeType::MISSILE, dir, dam);
-    if (!is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (!player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         return true;
     }
 
index 8987d10..3ef33ec 100644 (file)
@@ -23,7 +23,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "object-enchant/trc-types.h"
 #include "object/object-kind-hook.h"
 #include "player-attack/player-attack.h"
@@ -180,7 +179,7 @@ bool rush_attack(PlayerType *player_ptr, bool *mdeath)
             continue;
         }
 
-        if (!is_monster(grid_new.m_idx)) {
+        if (!grid_new.has_monster()) {
             if (tm_idx) {
                 msg_print(_("失敗!", "Failed!"));
             } else {
index 497b230..a7e54ac 100644 (file)
@@ -1,7 +1,6 @@
 #include "mind/mind-warrior.h"
 #include "cmd-action/cmd-attack.h"
 #include "floor/geometry.h"
-#include "monster/monster-util.h"
 #include "spell-kind/spells-teleport.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
@@ -22,7 +21,7 @@ bool hit_and_away(PlayerType *player_ptr)
     }
     POSITION y = player_ptr->y + ddy[dir];
     POSITION x = player_ptr->x + ddx[dir];
-    if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
         if (randint0(player_ptr->skill_dis) < 7) {
             msg_print(_("うまく逃げられなかった。", "You failed to run away."));
@@ -54,7 +53,7 @@ bool sword_dancing(PlayerType *player_ptr)
         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
 
         /* Hack -- attack monsters */
-        if (is_monster(g_ptr->m_idx)) {
+        if (g_ptr->has_monster()) {
             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
         } else {
             msg_print(_("攻撃が空をきった。", "You attack the empty air."));
index c9f5530..def04ea 100644 (file)
@@ -18,7 +18,6 @@
 #include "monster-race/monster-race.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "player-attack/player-attack.h"
 #include "player-base/player-class.h"
 #include "player-info/monk-data-type.h"
@@ -273,7 +272,7 @@ bool double_attack(PlayerType *player_ptr)
     }
     POSITION y = player_ptr->y + ddy[dir];
     POSITION x = player_ptr->x + ddx[dir];
-    if (!is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (!player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         msg_print(_("その方向にはモンスターはいません。", "You don't see any monster in this direction"));
         msg_print(nullptr);
         return true;
@@ -288,7 +287,7 @@ bool double_attack(PlayerType *player_ptr)
     }
 
     do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
-    if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         handle_stuff(player_ptr);
         do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
     }
index c7d5685..8a3ee14 100644 (file)
@@ -14,7 +14,6 @@
 #include "monster/monster-processor-util.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "system/dungeon-info.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
@@ -123,7 +122,7 @@ static bool exe_monster_attack_to_monster(PlayerType *player_ptr, MONSTER_IDX m_
  */
 bool process_monster_attack_to_monster(PlayerType *player_ptr, turn_flags *turn_flags_ptr, MONSTER_IDX m_idx, Grid *g_ptr, bool can_cross)
 {
-    if (!turn_flags_ptr->do_move || !is_monster(g_ptr->m_idx)) {
+    if (!turn_flags_ptr->do_move || !g_ptr->has_monster()) {
         return false;
     }
 
index e2909dd..c486fed 100644 (file)
@@ -27,7 +27,6 @@
 #include "monster/monster-processor-util.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "pet/pet-util.h"
 #include "player/player-status-flags.h"
 #include "system/angband-system.h"
@@ -67,7 +66,7 @@ static bool process_wall(PlayerType *player_ptr, turn_flags *turn_flags_ptr, con
         return true;
     }
 
-    if (is_monster(grid.m_idx)) {
+    if (grid.has_monster()) {
         turn_flags_ptr->do_move = true;
         return true;
     }
index f3085f1..33e29f4 100644 (file)
@@ -9,7 +9,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
 #include "system/item-entity.h"
@@ -159,7 +158,7 @@ void delete_monster(PlayerType *player_ptr, POSITION y, POSITION x)
     }
 
     g_ptr = &floor_ptr->grid_array[y][x];
-    if (is_monster(g_ptr->m_idx)) {
+    if (g_ptr->has_monster()) {
         delete_monster_idx(player_ptr, g_ptr->m_idx);
     }
 }
index d4552d3..dffaffa 100644 (file)
@@ -169,7 +169,7 @@ static bool check_quest_placeable(const FloorType &floor, MonsterRaceId r_idx)
     int number_mon = 0;
     for (int i2 = 0; i2 < floor.width; ++i2) {
         for (int j2 = 0; j2 < floor.height; j2++) {
-            auto quest_monster = is_monster(floor.grid_array[j2][i2].m_idx);
+            auto quest_monster = floor.grid_array[j2][i2].has_monster();
             quest_monster &= (floor.m_list[floor.grid_array[j2][i2].m_idx].r_idx == q_ptr->r_idx);
             if (quest_monster) {
                 number_mon++;
@@ -285,7 +285,7 @@ bool place_monster_one(PlayerType *player_ptr, MONSTER_IDX src_idx, POSITION y,
 
     g_ptr->m_idx = m_pop(&floor);
     hack_m_idx_ii = g_ptr->m_idx;
-    if (!is_monster(g_ptr->m_idx)) {
+    if (!g_ptr->has_monster()) {
         return false;
     }
 
index 23d7f28..17b69a2 100644 (file)
@@ -19,7 +19,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-flag-types.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "player/player-status-flags.h"
 #include "system/floor-type-definition.h"
@@ -148,7 +147,7 @@ bool monster_can_enter(PlayerType *player_ptr, POSITION y, POSITION x, MonsterRa
     if (player_ptr->is_located_at(pos)) {
         return false;
     }
-    if (is_monster(grid.m_idx)) {
+    if (grid.has_monster()) {
         return false;
     }
 
index 5964101..052a4da 100644 (file)
@@ -449,7 +449,7 @@ int get_monster_crowd_number(FloorType *floor_ptr, MONSTER_IDX m_idx)
         if (!in_bounds(floor_ptr, ay, ax)) {
             continue;
         }
-        if (is_monster(floor_ptr->grid_array[ay][ax].m_idx)) {
+        if (floor_ptr->grid_array[ay][ax].has_monster()) {
             count++;
         }
     }
index fe4b056..4af97be 100644 (file)
@@ -452,7 +452,7 @@ bool decide_monster_multiplication(PlayerType *player_ptr, MONSTER_IDX m_idx, PO
                 continue;
             }
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 k++;
             }
         }
index 6213f4d..0831bbc 100644 (file)
@@ -21,7 +21,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-processor-util.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "player-base/player-class.h"
 #include "player-info/samurai-data-type.h"
@@ -78,7 +77,7 @@ bool update_riding_monster(PlayerType *player_ptr, turn_flags *turn_flags_ptr, M
     }
 
     player_ptr->current_floor_ptr->grid_array[oy][ox].m_idx = g_ptr->m_idx;
-    if (is_monster(g_ptr->m_idx)) {
+    if (g_ptr->has_monster()) {
         y_ptr->fy = oy;
         y_ptr->fx = ox;
         update_monster(player_ptr, g_ptr->m_idx, true);
index 4564337..de3f728 100644 (file)
@@ -167,7 +167,7 @@ bool clean_shot(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION y2, P
     for (const auto &[y, x] : grid_g) {
         const Pos2D pos(y, x);
         const auto &grid = floor_ptr->get_grid(pos);
-        if (is_monster(grid.m_idx) && (y != y2 || x != x2)) {
+        if (grid.has_monster() && (y != y2 || x != x2)) {
             auto *m_ptr = &floor_ptr->m_list[grid.m_idx];
             if (is_friend == m_ptr->is_pet()) {
                 return false;
index a577a0f..71ba860 100644 (file)
@@ -20,7 +20,6 @@
 #include "monster-race/monster-race.h"
 #include "monster-race/race-flags-resistance.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "player-base/player-class.h"
 #include "player-base/player-race.h"
 #include "player-info/race-info.h"
@@ -66,7 +65,7 @@ bool direct_beam(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION y2,
         const auto &grid = floor.get_grid(pos);
         if (y == y2 && x == x2) {
             hit2 = true;
-        } else if (is_friend && is_monster(grid.m_idx) && !m_ptr->is_hostile_to_melee(floor.m_list[grid.m_idx])) {
+        } else if (is_friend && grid.has_monster() && !m_ptr->is_hostile_to_melee(floor.m_list[grid.m_idx])) {
             return false;
         }
 
index 9b1a3da..2064b80 100644 (file)
@@ -9,7 +9,6 @@
 #include "floor/geometry.h"
 #include "grid/grid.h"
 #include "monster/monster-info.h"
-#include "monster/monster-util.h"
 #include "player/digestion-processor.h"
 #include "player/player-move.h"
 #include "player/player-status.h"
@@ -44,7 +43,7 @@ bool eat_rock(PlayerType *player_ptr)
         msg_print(_("この地形は食べられない。", "You cannot eat this feature."));
     } else if (terrain.flags.has(TerrainCharacteristics::PERMANENT)) {
         msg_format(_("いてっ!この%sはあなたの歯より硬い!", "Ouch!  This %s is harder than your teeth!"), terrain_mimic.name.data());
-    } else if (is_monster(grid.m_idx)) {
+    } else if (grid.has_monster()) {
         const auto &monster = player_ptr->current_floor_ptr->m_list[grid.m_idx];
         msg_print(_("何かが邪魔しています!", "There's something in the way!"));
         if (!monster.ml || !monster.is_pet()) {
index 5dd0109..1b1a0bc 100644 (file)
@@ -38,7 +38,6 @@
 #include "monster/monster-pain-describer.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "object-enchant/tr-types.h"
 #include "object-hook/hook-expendable.h"
 #include "object-hook/hook-weapon.h"
@@ -264,7 +263,7 @@ void ObjectThrowEntity::display_potion_throw()
 
     auto *floor_ptr = this->player_ptr->current_floor_ptr;
     auto *angry_m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[this->y][this->x].m_idx];
-    if (!is_monster(floor_ptr->grid_array[this->y][this->x].m_idx) || !angry_m_ptr->is_friendly() || angry_m_ptr->is_invulnerable()) {
+    if (!floor_ptr->grid_array[this->y][this->x].has_monster() || !angry_m_ptr->is_friendly() || angry_m_ptr->is_invulnerable()) {
         this->do_drop = false;
         return;
     }
index db46865..3f61805 100644 (file)
@@ -17,7 +17,6 @@
 #include "monster-race/race-indice-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "mspell/mspell-damage-calculator.h"
 #include "mutation/mutation-flag-types.h"
 #include "object-enchant/tr-types.h"
@@ -367,7 +366,7 @@ bool process_warning(PlayerType *player_ptr, POSITION xx, POSITION yy)
 
             const auto *g_ptr = &floor.grid_array[my][mx];
 
-            if (!is_monster(g_ptr->m_idx)) {
+            if (!g_ptr->has_monster()) {
                 continue;
             }
 
index 81940cd..e3486ae 100644 (file)
@@ -13,7 +13,6 @@
 #include "monster-attack/monster-attack-player.h"
 #include "monster-race/monster-race.h"
 #include "monster/monster-describer.h"
-#include "monster/monster-util.h"
 #include "pet/pet-util.h"
 #include "player-base/player-class.h"
 #include "player/player-damage.h"
@@ -112,7 +111,7 @@ bool process_fall_off_horse(PlayerType *player_ptr, int dam, bool force)
             Grid *g_ptr;
             g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
 
-            if (is_monster(g_ptr->m_idx)) {
+            if (g_ptr->has_monster()) {
                 continue;
             }
 
index 09ee54d..3a5b448 100644 (file)
@@ -520,7 +520,7 @@ static void cause_earthquake(PlayerType *player_ptr, player_attack_type *pa_ptr,
     }
 
     earthquake(player_ptr, player_ptr->y, player_ptr->x, 10, 0);
-    if (!is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (!player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         *(pa_ptr->mdeath) = true;
     }
 }
@@ -613,7 +613,7 @@ void massacre(PlayerType *player_ptr)
         POSITION x = player_ptr->x + ddx_ddd[dir];
         g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
         m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
-        if (is_monster(g_ptr->m_idx) && (m_ptr->ml || cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::PROJECT))) {
+        if (g_ptr->has_monster() && (m_ptr->ml || cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::PROJECT))) {
             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
         }
     }
index 2044ba9..7e760d0 100644 (file)
@@ -34,7 +34,6 @@
 #include "monster-race/monster-race-hook.h"
 #include "monster-race/monster-race.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "mutation/mutation-calculator.h"
 #include "mutation/mutation-flag-types.h"
@@ -174,7 +173,7 @@ static void delayed_visual_update(PlayerType *player_ptr)
         }
 
         lite_spot(player_ptr, y, x);
-        if (is_monster(g_ptr->m_idx)) {
+        if (g_ptr->has_monster()) {
             update_monster(player_ptr, g_ptr->m_idx, false);
         }
 
@@ -2817,7 +2816,7 @@ bool player_has_no_spellbooks(PlayerType *player_ptr)
  */
 bool player_place(PlayerType *player_ptr, POSITION y, POSITION x)
 {
-    if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+    if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
         return false;
     }
 
index f220da4..b5d5a4a 100644 (file)
@@ -2,7 +2,6 @@
 #include "dungeon/dungeon-flag-types.h"
 #include "floor/geometry.h"
 #include "hpmp/hp-mp-processor.h"
-#include "monster/monster-util.h"
 #include "player/digestion-processor.h"
 #include "player/player-status.h"
 #include "spell-kind/spells-specific-bolt.h"
@@ -30,7 +29,7 @@ bool vampirism(PlayerType *player_ptr)
     POSITION x = player_ptr->x + ddx[dir];
     const auto *g_ptr = &floor.grid_array[y][x];
     stop_mouth(player_ptr);
-    if (!is_monster(g_ptr->m_idx)) {
+    if (!g_ptr->has_monster()) {
         msg_print(_("何もない場所に噛みついた!", "You bite into thin air!"));
         return false;
     }
index 0f6bfad..7fa992a 100644 (file)
@@ -20,7 +20,6 @@
 #include "inventory/inventory-slot-types.h"
 #include "io/input-key-requester.h"
 #include "monster-race/monster-race.h"
-#include "monster/monster-util.h"
 #include "object-enchant/object-curse.h"
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
@@ -842,7 +841,7 @@ std::optional<std::string> do_hex_spell(PlayerType *player_ptr, spell_hex_type s
                     if (dir == 5) {
                         continue;
                     }
-                    if (is_monster(floor_ptr->grid_array[dy][dx].m_idx)) {
+                    if (floor_ptr->grid_array[dy][dx].has_monster()) {
                         flag = true;
                     }
                 }
index a494202..753503a 100644 (file)
@@ -26,7 +26,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-info.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "object-enchant/tr-types.h"
 #include "player-info/equipment-info.h"
 #include "player/player-damage.h"
@@ -123,7 +122,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
 
             y = player_ptr->y + ddy_cdd[cdir];
             x = player_ptr->x + ddx_cdd[cdir];
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
             } else {
                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
@@ -131,7 +130,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
 
             y = player_ptr->y + ddy_cdd[(cdir + 7) % 8];
             x = player_ptr->x + ddx_cdd[(cdir + 7) % 8];
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
             } else {
                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
@@ -139,7 +138,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
 
             y = player_ptr->y + ddy_cdd[(cdir + 1) % 8];
             x = player_ptr->x + ddx_cdd[(cdir + 1) % 8];
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
             } else {
                 msg_print(_("攻撃は空を切った。", "You attack the empty air."));
@@ -184,7 +183,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_FIRE);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -227,7 +226,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_MINEUCHI);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -284,7 +283,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
 
             const auto *floor_ptr = player_ptr->current_floor_ptr;
             const auto &grid = floor_ptr->grid_array[y][x];
-            if (!is_monster(grid.m_idx)) {
+            if (!grid.has_monster()) {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
                 return std::nullopt;
             }
@@ -325,7 +324,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_POISON);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -356,7 +355,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_ZANMA);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -387,7 +386,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             x = player_ptr->x + ddx[dir];
 
             const auto &floor = *player_ptr->current_floor_ptr;
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -396,7 +395,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             if (floor.get_dungeon_definition().flags.has(DungeonFeatureType::NO_MELEE)) {
                 return "";
             }
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 int i;
                 POSITION ty = y, tx = x;
                 POSITION oy = y, ox = x;
@@ -476,7 +475,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_HAGAN);
             }
 
@@ -512,7 +511,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_COLD);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -543,7 +542,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_KYUSHO);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -573,7 +572,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_MAJIN);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -604,7 +603,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_SUTEMI);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -635,7 +634,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_ELEC);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -679,7 +678,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
                 x = player_ptr->x + ddx_ddd[dir];
                 auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
                 auto *m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
-                if (!is_monster(g_ptr->m_idx) || (!m_ptr->ml && !cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::PROJECT))) {
+                if (!g_ptr->has_monster() || (!m_ptr->ml && !cave_has_flag_bold(player_ptr->current_floor_ptr, y, x, TerrainCharacteristics::PROJECT))) {
                     continue;
                 }
 
@@ -715,7 +714,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_QUAKE);
             } else {
                 earthquake(player_ptr, player_ptr->y, player_ptr->x, 10, 0);
@@ -815,7 +814,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
                 x = player_ptr->x + ddx[dir];
                 g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
 
-                if (is_monster(g_ptr->m_idx)) {
+                if (g_ptr->has_monster()) {
                     do_cmd_attack(player_ptr, y, x, HISSATSU_3DAN);
                 } else {
                     msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -827,7 +826,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
                 }
 
                 /* Monster is dead? */
-                if (!is_monster(g_ptr->m_idx)) {
+                if (!g_ptr->has_monster()) {
                     break;
                 }
 
@@ -897,7 +896,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_DRAIN);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
@@ -1013,9 +1012,9 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
-                if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+                if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                     handle_stuff(player_ptr);
                     do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
                 }
@@ -1108,7 +1107,7 @@ std::optional<std::string> do_hissatsu_spell(PlayerType *player_ptr, SPELL_IDX s
             y = player_ptr->y + ddy[dir];
             x = player_ptr->x + ddx[dir];
 
-            if (is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx)) {
+            if (player_ptr->current_floor_ptr->grid_array[y][x].has_monster()) {
                 do_cmd_attack(player_ptr, y, x, HISSATSU_UNDEAD);
             } else {
                 msg_print(_("その方向にはモンスターはいません。", "There is no monster."));
index 2b8fe48..0b4c256 100644 (file)
@@ -8,7 +8,6 @@
 #include "grid/trap.h"
 #include "monster-floor/monster-generator.h"
 #include "monster-floor/place-monster-types.h"
-#include "monster/monster-util.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
 #include "system/player-type-definition.h"
@@ -28,7 +27,7 @@ static bool player_grid(PlayerType *player_ptr, Grid *g_ptr)
 static bool is_cave_empty_grid(PlayerType *player_ptr, Grid *g_ptr)
 {
     bool is_empty_grid = g_ptr->cave_has_flag(TerrainCharacteristics::PLACE);
-    is_empty_grid &= !is_monster(g_ptr->m_idx);
+    is_empty_grid &= !g_ptr->has_monster();
     is_empty_grid &= !player_grid(player_ptr, g_ptr);
     return is_empty_grid;
 }
@@ -140,7 +139,7 @@ static void vault_trap_aux(FloorType *floor_ptr, POSITION y, POSITION x, POSITIO
         }
 
         g_ptr = &floor_ptr->grid_array[y1][x1];
-        if (!g_ptr->is_floor() || !g_ptr->o_idx_list.empty() || is_monster(g_ptr->m_idx)) {
+        if (!g_ptr->is_floor() || !g_ptr->o_idx_list.empty() || g_ptr->has_monster()) {
             continue;
         }
 
index 02e83b2..dd13908 100644 (file)
@@ -24,7 +24,6 @@
 #include "io/cursor.h"
 #include "io/screen-util.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "pet/pet-util.h"
 #include "spell-kind/spells-teleport.h"
 #include "system/angband-system.h"
@@ -63,7 +62,7 @@ void SpellsMirrorMaster::remove_mirror(int y, int x)
             reset_bits(g_ptr->info, CAVE_MARK);
         }
 
-        if (is_monster(g_ptr->m_idx)) {
+        if (g_ptr->has_monster()) {
             update_monster(this->player_ptr, g_ptr->m_idx, false);
         }
 
@@ -197,7 +196,7 @@ void SpellsMirrorMaster::seal_of_mirror(const int dam)
                 continue;
             }
 
-            if (!is_monster(g_ref.m_idx)) {
+            if (!g_ref.has_monster()) {
                 this->remove_mirror(y, x);
             }
         }
@@ -335,7 +334,7 @@ void SpellsMirrorMaster::project_seeker_ray(int target_x, int target_y, int dam)
             }
             const auto &grid = floor.grid_array[project_m_y][project_m_x];
             const auto &monster = floor.m_list[grid.m_idx];
-            if (project_m_n == 1 && is_monster(grid.m_idx) && monster.ml) {
+            if (project_m_n == 1 && grid.has_monster() && monster.ml) {
                 if (!this->player_ptr->effects()->hallucination()->is_hallucinated()) {
                     monster_race_track(this->player_ptr, monster.ap_r_idx);
                 }
@@ -432,7 +431,7 @@ static bool activate_super_ray_effect(PlayerType *player_ptr, int y, int x, int
     const auto *floor_ptr = player_ptr->current_floor_ptr;
     const auto *g_ptr = &floor_ptr->grid_array[project_m_y][project_m_x];
     const auto *m_ptr = &floor_ptr->m_list[g_ptr->m_idx];
-    if (project_m_n == 1 && is_monster(g_ptr->m_idx) && m_ptr->ml) {
+    if (project_m_n == 1 && g_ptr->has_monster() && m_ptr->ml) {
         if (!player_ptr->effects()->hallucination()->is_hallucinated()) {
             monster_race_track(player_ptr, m_ptr->ap_r_idx);
         }
index 6076cc0..e9ec609 100644 (file)
@@ -20,7 +20,6 @@
 #include "monster/monster-info.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "player/player-damage.h"
 #include "player/player-move.h"
@@ -111,7 +110,7 @@ bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MO
                 continue;
             }
 
-            if (is_monster(floor_ptr->grid_array[y][x].m_idx)) {
+            if (floor_ptr->grid_array[y][x].has_monster()) {
                 continue;
             }
 
@@ -179,7 +178,7 @@ bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MO
                 continue;
             }
 
-            if (!is_monster(grid.m_idx)) {
+            if (!grid.has_monster()) {
                 continue;
             }
 
@@ -219,7 +218,7 @@ bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MO
                         continue;
                     }
 
-                    if (is_monster(grid_neighbor.m_idx)) {
+                    if (grid_neighbor.has_monster()) {
                         continue;
                     }
 
@@ -250,7 +249,7 @@ bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MO
                     msg_format(_("%s^は岩石に埋もれてしまった!", "%s^ is embedded in the rock!"), m_name.data());
                 }
 
-                if (is_monster(grid.m_idx)) {
+                if (grid.has_monster()) {
                     const auto &m_ref = floor_ptr->m_list[grid.m_idx];
                     if (record_named_pet && m_ref.is_named_pet()) {
                         const auto m2_name = monster_desc(player_ptr, m_ptr, MD_INDEF_VISIBLE);
index cc6be08..e49f19f 100644 (file)
@@ -33,7 +33,6 @@
 #include "monster/monster-description-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "monster/smart-learn-types.h"
 #include "object-enchant/special-object-flags.h"
 #include "object/object-mark-types.h"
@@ -336,7 +335,7 @@ bool destroy_area(PlayerType *player_ptr, const POSITION y1, const POSITION x1,
                 continue;
             }
 
-            if (is_monster(grid.m_idx)) {
+            if (grid.has_monster()) {
                 auto &monster = floor.m_list[grid.m_idx];
                 auto &monrace = monster.get_monrace();
 
index 72c7272..66ce8a9 100644 (file)
@@ -14,7 +14,6 @@
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "player/special-defense-types.h"
 #include "spell-kind/spells-launcher.h"
 #include "system/angband-system.h"
@@ -63,7 +62,7 @@ static void cave_temp_room_lite(PlayerType *player_ptr, const std::vector<Pos2D>
         auto *g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
         g_ptr->info &= ~(CAVE_TEMP);
         g_ptr->info |= (CAVE_GLOW);
-        if (is_monster(g_ptr->m_idx)) {
+        if (g_ptr->has_monster()) {
             PERCENTAGE chance = 25;
             auto *m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
             auto *r_ptr = &m_ptr->get_monrace();
@@ -133,7 +132,7 @@ static void cave_temp_room_unlite(PlayerType *player_ptr, const std::vector<Pos2
             note_spot(player_ptr, point.y, point.x);
         }
 
-        if (is_monster(grid.m_idx)) {
+        if (grid.has_monster()) {
             update_monster(player_ptr, grid.m_idx, false);
         }
 
index e4546c7..64ae90f 100644 (file)
@@ -26,7 +26,6 @@
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
 #include "monster/monster-update.h"
-#include "monster/monster-util.h"
 #include "mutation/mutation-flag-types.h"
 #include "object-enchant/tr-types.h"
 #include "player-base/player-class.h"
@@ -72,7 +71,7 @@ bool teleport_swap(PlayerType *player_ptr, DIRECTION dir)
 
     Grid *g_ptr;
     g_ptr = &player_ptr->current_floor_ptr->grid_array[ty][tx];
-    if (!is_monster(g_ptr->m_idx) || (g_ptr->m_idx == player_ptr->riding)) {
+    if (!g_ptr->has_monster() || (g_ptr->m_idx == player_ptr->riding)) {
         msg_print(_("それとは場所を交換できません。", "You can't trade places with that!"));
         return false;
     }
@@ -515,7 +514,7 @@ void teleport_player_to(PlayerType *player_ptr, POSITION ny, POSITION nx, telepo
 
         bool is_anywhere = w_ptr->wizard;
         is_anywhere &= (mode & TELEPORT_PASSIVE) == 0;
-        is_anywhere &= is_monster(player_ptr->current_floor_ptr->grid_array[y][x].m_idx) || player_ptr->current_floor_ptr->grid_array[y][x].m_idx == player_ptr->riding;
+        is_anywhere &= player_ptr->current_floor_ptr->grid_array[y][x].has_monster() || player_ptr->current_floor_ptr->grid_array[y][x].m_idx == player_ptr->riding;
         if (is_anywhere) {
             break;
         }
index 060d47e..aa49094 100644 (file)
@@ -11,7 +11,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-status-setter.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "player-info/class-info.h"
 #include "player/player-damage.h"
 #include "spell-kind/spells-floor.h"
@@ -163,7 +162,7 @@ bool vanish_dungeon(PlayerType *player_ptr)
             const auto &terrrain = grid.get_terrain();
             grid.info &= ~(CAVE_ROOM | CAVE_ICKY);
             const auto &monster = floor.m_list[grid.m_idx];
-            if (is_monster(grid.m_idx) && monster.is_asleep()) {
+            if (grid.has_monster() && monster.is_asleep()) {
                 (void)set_monster_csleep(player_ptr, grid.m_idx, 0);
                 if (monster.ml) {
                     const auto m_name = monster_desc(player_ptr, &monster, 0);
index 8cac7cc..9ac9f11 100644 (file)
@@ -14,7 +14,6 @@
 #include "floor/geometry.h"
 #include "game-option/disturbance-options.h"
 #include "grid/feature-flag-types.h"
-#include "monster/monster-util.h"
 #include "spell-realm/spells-crusade.h"
 #include "spell/range-calc.h"
 #include "system/angband-system.h"
@@ -62,7 +61,7 @@ bool cast_wrath_of_the_god(PlayerType *player_ptr, int dam, POSITION rad)
         if (!cave_has_flag_bold(&floor, pos_to.y, pos_to.x, TerrainCharacteristics::PROJECT)) {
             break;
         }
-        if ((dir != 5) && is_monster(floor.get_grid(pos_to).m_idx)) {
+        if ((dir != 5) && floor.get_grid(pos_to).has_monster()) {
             break;
         }
 
index 5051c60..2d5341e 100644 (file)
@@ -25,7 +25,6 @@
 #include "main/sound-of-music.h"
 #include "mind/mind-force-trainer.h"
 #include "monster/monster-describer.h"
-#include "monster/monster-util.h"
 #include "object/object-kind-hook.h"
 #include "player-base/player-class.h"
 #include "player-info/class-info.h"
@@ -547,7 +546,7 @@ bool fishing(PlayerType *player_ptr)
         return false;
     }
 
-    if (is_monster(floor_ptr->grid_array[y][x].m_idx)) {
+    if (floor_ptr->grid_array[y][x].has_monster()) {
         const auto m_name = monster_desc(player_ptr, &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx], 0);
         msg_format(_("%sが邪魔だ!", "%s^ is standing in your way."), m_name.data());
         PlayerEnergy(player_ptr).reset_player_turn();
index ca42e78..78753a2 100644 (file)
@@ -1,4 +1,5 @@
 #include "system/grid-type-definition.h"
+#include "monster/monster-util.h"
 #include "system/angband-system.h"
 #include "system/monster-race-info.h"
 #include "system/terrain-type-definition.h"
@@ -91,6 +92,11 @@ bool Grid::is_rune_explosion() const
     return this->is_object() && TerrainList::get_instance()[this->mimic].flags.has(TerrainCharacteristics::RUNE_EXPLOSION);
 }
 
+bool Grid::has_monster() const
+{
+    return is_monster(this->m_idx);
+}
+
 byte Grid::get_cost(const MonsterRaceInfo *r_ptr) const
 {
     return this->costs[get_grid_flow_type(r_ptr)];
index ed45104..d716cb8 100644 (file)
@@ -83,6 +83,7 @@ public:
     bool is_mirror() const;
     bool is_rune_protection() const;
     bool is_rune_explosion() const;
+    bool has_monster() const;
     byte get_cost(const MonsterRaceInfo *r_ptr) const;
     byte get_distance(const MonsterRaceInfo *r_ptr) const;
     FEAT_IDX get_feat_mimic() const;
index f3125f8..0a0ac94 100644 (file)
@@ -3,7 +3,6 @@
 #include "effect/spells-effect-util.h"
 #include "floor/cave.h"
 #include "grid/feature-flag-types.h"
-#include "monster/monster-util.h"
 #include "spell-class/spells-mirror-master.h"
 #include "system/angband-system.h"
 #include "system/floor-type-definition.h"
@@ -124,7 +123,7 @@ static bool project_stop(PlayerType *player_ptr, projection_path_type *pp_ptr)
         }
     }
 
-    if (any_bits(pp_ptr->flag, PROJECT_STOP) && !pp_ptr->position->empty() && (player_ptr->is_located_at(pos) || is_monster(grid.m_idx))) {
+    if (any_bits(pp_ptr->flag, PROJECT_STOP) && !pp_ptr->position->empty() && (player_ptr->is_located_at(pos) || grid.has_monster())) {
         return true;
     }
 
index 79e2181..61323a4 100644 (file)
@@ -20,7 +20,6 @@
 #include "monster/monster-describer.h"
 #include "monster/monster-description-types.h"
 #include "monster/monster-flag-types.h"
-#include "monster/monster-util.h"
 #include "object/item-tester-hooker.h"
 #include "object/object-mark-types.h"
 #include "player-base/player-race.h"
@@ -271,7 +270,7 @@ static bool within_char_util(const short input)
 
 static short describe_grid(PlayerType *player_ptr, GridExamination *ge_ptr)
 {
-    if (!is_monster(ge_ptr->g_ptr->m_idx) || !player_ptr->current_floor_ptr->m_list[ge_ptr->g_ptr->m_idx].ml) {
+    if (!ge_ptr->g_ptr->has_monster() || !player_ptr->current_floor_ptr->m_list[ge_ptr->g_ptr->m_idx].ml) {
         return CONTINUOUS_DESCRIPTION;
     }
 
index 9990e51..f1bf38c 100644 (file)
@@ -6,7 +6,6 @@
 #include "monster/monster-flag-types.h"
 #include "monster/monster-info.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "object/object-mark-types.h"
 #include "system/angband-system.h"
 #include "system/floor-type-definition.h"
@@ -87,7 +86,7 @@ static bool target_set_accept(PlayerType *player_ptr, const Pos2D &pos)
     }
 
     const auto &grid = floor.get_grid(pos);
-    if (is_monster(grid.m_idx)) {
+    if (grid.has_monster()) {
         auto &monster = floor.m_list[grid.m_idx];
         if (monster.ml) {
             return true;
index f472b03..0b39b02 100644 (file)
@@ -4,7 +4,6 @@
 #include "grid/grid.h"
 #include "monster-race/monster-race.h"
 #include "monster/monster-flag-types.h"
-#include "monster/monster-util.h"
 #include "system/artifact-type-definition.h"
 #include "system/floor-type-definition.h"
 #include "system/grid-type-definition.h"
@@ -138,14 +137,14 @@ bool ang_sort_comp_importance(PlayerType *player_ptr, vptr u, vptr v, int a, int
 
     /* Extract monster race */
     MonsterRaceInfo *ap_r_ptr_a;
-    if (is_monster(grid_a.m_idx) && monster_a.ml) {
+    if (grid_a.has_monster() && monster_a.ml) {
         ap_r_ptr_a = &monster_a.get_appearance_monrace();
     } else {
         ap_r_ptr_a = nullptr;
     }
 
     MonsterRaceInfo *ap_r_ptr_b;
-    if (is_monster(grid_b.m_idx) && monster_b.ml) {
+    if (grid_b.has_monster() && monster_b.ml) {
         ap_r_ptr_b = &monster_b.get_appearance_monrace();
     } else {
         ap_r_ptr_b = nullptr;
index 0ed47c3..da76b16 100644 (file)
@@ -9,7 +9,6 @@
 #include "grid/feature.h"
 #include "grid/grid.h"
 #include "monster-race/monster-race.h"
-#include "monster/monster-util.h"
 #include "object/object-info.h"
 #include "object/object-mark-types.h"
 #include "system/baseitem-info.h"
@@ -302,7 +301,7 @@ void map_info(PlayerType *player_ptr, POSITION y, POSITION x, TERM_COLOR *ap, ch
         break;
     }
 
-    if (is_monster(grid.m_idx) && display_autopick != 0) {
+    if (grid.has_monster() && display_autopick != 0) {
         set_term_color(player_ptr, y, x, ap, cp);
         return;
     }
index 1b7f6c7..b0c301c 100644 (file)
@@ -16,7 +16,6 @@
 #include "monster-race/monster-race.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-description-types.h"
-#include "monster/monster-util.h"
 #include "object/item-tester-hooker.h"
 #include "object/object-info.h"
 #include "player-base/player-class.h"
@@ -528,7 +527,7 @@ void fix_object(PlayerType *player_ptr)
  */
 static const MonsterEntity *monster_on_floor_items(FloorType *floor_ptr, const Grid *g_ptr)
 {
-    if (!is_monster(g_ptr->m_idx)) {
+    if (!g_ptr->has_monster()) {
         return nullptr;
     }
 
index 91644b0..21ad9c8 100644 (file)
@@ -22,7 +22,6 @@
 #include "monster-floor/monster-summon.h"
 #include "monster/monster-describer.h"
 #include "monster/monster-status.h"
-#include "monster/monster-util.h"
 #include "mutation/mutation-processor.h"
 #include "object/lite-processor.h"
 #include "perception/simple-perception.h"
@@ -147,7 +146,7 @@ void WorldTurnProcessor::process_monster_arena()
     for (auto x = 0; x < floor_ptr->width; ++x) {
         for (auto y = 0; y < floor_ptr->height; y++) {
             auto *g_ptr = &floor_ptr->grid_array[y][x];
-            if (is_monster(g_ptr->m_idx) && (g_ptr->m_idx != this->player_ptr->riding)) {
+            if (g_ptr->has_monster() && (g_ptr->m_idx != this->player_ptr->riding)) {
                 number_mon++;
                 win_m_idx = g_ptr->m_idx;
             }