From dce5f60f0cfa8dc91c8da2dd9a76fc14084c7304 Mon Sep 17 00:00:00 2001 From: dis- Date: Sun, 3 Mar 2024 03:47:57 +0900 Subject: [PATCH 1/1] =?utf8?q?[Refactor]=20Grid::has=5Fmonster()=E3=81=AE?= =?utf8?q?=E5=AE=9A=E7=BE=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Gridに関してis_monster()を使用している箇所をGrid::has_monster()でラップする。 --- src/action/movement-execution.cpp | 3 +- src/action/mutation-execution.cpp | 5 +-- src/action/run-execution.cpp | 3 +- src/action/travel-execution.cpp | 3 +- src/blue-magic/blue-magic-caster.cpp | 3 +- src/cmd-action/cmd-mane.cpp | 3 +- src/cmd-action/cmd-open-close.cpp | 11 +++--- src/cmd-action/cmd-others.cpp | 3 +- src/cmd-action/cmd-pet.cpp | 9 ++--- src/cmd-action/cmd-tunnel.cpp | 3 +- src/combat/shoot.cpp | 7 ++-- src/effect/effect-feature.cpp | 4 +- src/effect/effect-monster.cpp | 2 +- src/effect/effect-processor.cpp | 2 +- src/floor/floor-streams.cpp | 3 +- src/floor/object-allocator.cpp | 5 +-- src/floor/wild.cpp | 4 +- src/grid/feature.cpp | 5 +-- src/grid/grid.cpp | 11 +++--- src/io/cursor.cpp | 3 +- src/mind/mind-berserker.cpp | 5 +-- src/mind/mind-force-trainer.cpp | 3 +- src/mind/mind-ninja.cpp | 3 +- src/mind/mind-warrior.cpp | 5 +-- src/mind/monk-attack.cpp | 5 +-- src/monster-attack/monster-attack-processor.cpp | 3 +- src/monster-floor/monster-move.cpp | 3 +- src/monster-floor/monster-remover.cpp | 3 +- src/monster-floor/one-monster-placer.cpp | 4 +- src/monster/monster-info.cpp | 3 +- src/monster/monster-list.cpp | 2 +- src/monster/monster-processor.cpp | 2 +- src/monster/monster-update.cpp | 3 +- src/mspell/mspell-checker.cpp | 2 +- src/mspell/mspell-judgement.cpp | 3 +- src/mutation/mutation-techniques.cpp | 3 +- src/object-use/throw-execution.cpp | 3 +- src/object/warning.cpp | 3 +- src/pet/pet-fall-off.cpp | 3 +- src/player-attack/player-attack.cpp | 4 +- src/player/player-status.cpp | 5 +-- src/racial/racial-vampire.cpp | 3 +- src/realm/realm-hex.cpp | 3 +- src/realm/realm-hissatsu.cpp | 49 ++++++++++++------------- src/room/vault-builder.cpp | 5 +-- src/spell-class/spells-mirror-master.cpp | 9 ++--- src/spell-kind/earthquake.cpp | 9 ++--- src/spell-kind/spells-floor.cpp | 3 +- src/spell-kind/spells-lite.cpp | 5 +-- src/spell-kind/spells-teleport.cpp | 5 +-- src/spell-realm/spells-chaos.cpp | 3 +- src/spell-realm/spells-crusade.cpp | 3 +- src/spell/spells-status.cpp | 3 +- src/system/grid-type-definition.cpp | 6 +++ src/system/grid-type-definition.h | 1 + src/target/projection-path-calculator.cpp | 3 +- src/target/target-describer.cpp | 3 +- src/target/target-preparation.cpp | 3 +- src/util/sort.cpp | 5 +-- src/view/display-map.cpp | 3 +- src/window/display-sub-windows.cpp | 3 +- src/world/world-turn-processor.cpp | 3 +- 62 files changed, 124 insertions(+), 168 deletions(-) diff --git a/src/action/movement-execution.cpp b/src/action/movement-execution.cpp index 6b40e73be..d255c2c10 100644 --- a/src/action/movement-execution.cpp +++ b/src/action/movement-execution.cpp @@ -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(); diff --git a/src/action/mutation-execution.cpp b/src/action/mutation-execution.cpp index ec33cb4ec..604179295 100644 --- a/src/action/mutation-execution.cpp +++ b/src/action/mutation-execution.cpp @@ -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; } diff --git a/src/action/run-execution.cpp b/src/action/run-execution.cpp index 1cdd49a5d..dd9885d52 100644 --- a/src/action/run-execution.cpp +++ b/src/action/run-execution.cpp @@ -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; diff --git a/src/action/travel-execution.cpp b/src/action/travel-execution.cpp index 28f681c05..cf4fe710e 100644 --- a/src/action/travel-execution.cpp +++ b/src/action/travel-execution.cpp @@ -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; diff --git a/src/blue-magic/blue-magic-caster.cpp b/src/blue-magic/blue-magic-caster.cpp index aeb1d16a0..ef5b203cd 100644 --- a/src/blue-magic/blue-magic-caster.cpp +++ b/src/blue-magic/blue-magic-caster.cpp @@ -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 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; } diff --git a/src/cmd-action/cmd-mane.cpp b/src/cmd-action/cmd-mane.cpp index 6d7741795..6c9405b44 100644 --- a/src/cmd-action/cmd-mane.cpp +++ b/src/cmd-action/cmd-mane.cpp @@ -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) { diff --git a/src/cmd-action/cmd-open-close.cpp b/src/cmd-action/cmd-open-close.cpp index a15a588c0..902dbb117 100644 --- a/src/cmd-action/cmd-open-close.cpp +++ b/src/cmd-action/cmd-open-close.cpp @@ -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); diff --git a/src/cmd-action/cmd-others.cpp b/src/cmd-action/cmd-others.cpp index 06397f920..3b4fb5013 100644 --- a/src/cmd-action/cmd-others.cpp +++ b/src/cmd-action/cmd-others.cpp @@ -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; } diff --git a/src/cmd-action/cmd-pet.cpp b/src/cmd-action/cmd-pet.cpp index 0806dc328..6c1142f2b 100644 --- a/src/cmd-action/cmd-pet.cpp +++ b/src/cmd-action/cmd-pet.cpp @@ -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 { diff --git a/src/cmd-action/cmd-tunnel.cpp b/src/cmd-action/cmd-tunnel.cpp index 9f42b58bd..c260b7c75 100644 --- a/src/cmd-action/cmd-tunnel.cpp +++ b/src/cmd-action/cmd-tunnel.cpp @@ -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); diff --git a/src/combat/shoot.cpp b/src/combat/shoot.cpp index 322160c99..997396acf 100644 --- a/src/combat/shoot.cpp +++ b/src/combat/shoot.cpp @@ -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]; diff --git a/src/effect/effect-feature.cpp b/src/effect/effect-feature.cpp index 884bea763..04734a0a3 100644 --- a/src/effect/effect-feature.cpp +++ b/src/effect/effect-feature.cpp @@ -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); } diff --git a/src/effect/effect-monster.cpp b/src/effect/effect-monster.cpp index 527cc983e..8c75835be 100644 --- a/src/effect/effect-monster.cpp +++ b/src/effect/effect-monster.cpp @@ -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)) { diff --git a/src/effect/effect-processor.cpp b/src/effect/effect-processor.cpp index 8a1ce7420..3e8acf621 100644 --- a/src/effect/effect-processor.cpp +++ b/src/effect/effect-processor.cpp @@ -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()) { diff --git a/src/floor/floor-streams.cpp b/src/floor/floor-streams.cpp index ba21e4c3b..7c2c1b3cc 100644 --- a/src/floor/floor-streams.cpp +++ b/src/floor/floor-streams.cpp @@ -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); } diff --git a/src/floor/object-allocator.cpp b/src/floor/object-allocator.cpp index 37d23eec1..2839b07bd 100644 --- a/src/floor/object-allocator.cpp +++ b/src/floor/object-allocator.cpp @@ -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; } diff --git a/src/floor/wild.cpp b/src/floor/wild.cpp index ce05c42a3..59924e54e 100644 --- a/src/floor/wild.cpp +++ b/src/floor/wild.cpp @@ -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); } diff --git a/src/grid/feature.cpp b/src/grid/feature.cpp index 17fbd40ab..114c98117 100644 --- a/src/grid/feature.cpp +++ b/src/grid/feature.cpp @@ -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); } diff --git a/src/grid/grid.cpp b/src/grid/grid.cpp index 7f31d25cb..7ee06ef21 100644 --- a/src/grid/grid.cpp +++ b/src/grid/grid.cpp @@ -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); } } diff --git a/src/io/cursor.cpp b/src/io/cursor.cpp index 4e625bfcb..80ba10c8d 100644 --- a/src/io/cursor.cpp +++ b/src/io/cursor.cpp @@ -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)) { diff --git a/src/mind/mind-berserker.cpp b/src/mind/mind-berserker.cpp index 908e77735..a44eedd6d 100644 --- a/src/mind/mind-berserker.cpp +++ b/src/mind/mind-berserker.cpp @@ -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); } diff --git a/src/mind/mind-force-trainer.cpp b/src/mind/mind-force-trainer.cpp index 5edf27801..85ccbf4ec 100644 --- a/src/mind/mind-force-trainer.cpp +++ b/src/mind/mind-force-trainer.cpp @@ -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; } diff --git a/src/mind/mind-ninja.cpp b/src/mind/mind-ninja.cpp index 8987d10e0..3ef33ecf5 100644 --- a/src/mind/mind-ninja.cpp +++ b/src/mind/mind-ninja.cpp @@ -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 { diff --git a/src/mind/mind-warrior.cpp b/src/mind/mind-warrior.cpp index 497b230dc..a7e54ac14 100644 --- a/src/mind/mind-warrior.cpp +++ b/src/mind/mind-warrior.cpp @@ -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.")); diff --git a/src/mind/monk-attack.cpp b/src/mind/monk-attack.cpp index c9f553006..def04ea6f 100644 --- a/src/mind/monk-attack.cpp +++ b/src/mind/monk-attack.cpp @@ -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); } diff --git a/src/monster-attack/monster-attack-processor.cpp b/src/monster-attack/monster-attack-processor.cpp index c7d5685bd..8a3ee1470 100644 --- a/src/monster-attack/monster-attack-processor.cpp +++ b/src/monster-attack/monster-attack-processor.cpp @@ -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; } diff --git a/src/monster-floor/monster-move.cpp b/src/monster-floor/monster-move.cpp index e2909ddae..c486fedcb 100644 --- a/src/monster-floor/monster-move.cpp +++ b/src/monster-floor/monster-move.cpp @@ -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; } diff --git a/src/monster-floor/monster-remover.cpp b/src/monster-floor/monster-remover.cpp index f3085f13e..33e29f472 100644 --- a/src/monster-floor/monster-remover.cpp +++ b/src/monster-floor/monster-remover.cpp @@ -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); } } diff --git a/src/monster-floor/one-monster-placer.cpp b/src/monster-floor/one-monster-placer.cpp index d4552d34c..dffaffacf 100644 --- a/src/monster-floor/one-monster-placer.cpp +++ b/src/monster-floor/one-monster-placer.cpp @@ -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; } diff --git a/src/monster/monster-info.cpp b/src/monster/monster-info.cpp index 23d7f2869..17b69a292 100644 --- a/src/monster/monster-info.cpp +++ b/src/monster/monster-info.cpp @@ -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; } diff --git a/src/monster/monster-list.cpp b/src/monster/monster-list.cpp index 596410131..052a4da6d 100644 --- a/src/monster/monster-list.cpp +++ b/src/monster/monster-list.cpp @@ -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++; } } diff --git a/src/monster/monster-processor.cpp b/src/monster/monster-processor.cpp index fe4b05619..4af97be64 100644 --- a/src/monster/monster-processor.cpp +++ b/src/monster/monster-processor.cpp @@ -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++; } } diff --git a/src/monster/monster-update.cpp b/src/monster/monster-update.cpp index 6213f4d0a..0831bbc1d 100644 --- a/src/monster/monster-update.cpp +++ b/src/monster/monster-update.cpp @@ -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); diff --git a/src/mspell/mspell-checker.cpp b/src/mspell/mspell-checker.cpp index 4564337bf..de3f72841 100644 --- a/src/mspell/mspell-checker.cpp +++ b/src/mspell/mspell-checker.cpp @@ -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; diff --git a/src/mspell/mspell-judgement.cpp b/src/mspell/mspell-judgement.cpp index a577a0fb6..71ba860aa 100644 --- a/src/mspell/mspell-judgement.cpp +++ b/src/mspell/mspell-judgement.cpp @@ -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; } diff --git a/src/mutation/mutation-techniques.cpp b/src/mutation/mutation-techniques.cpp index 9b1a3da43..2064b806a 100644 --- a/src/mutation/mutation-techniques.cpp +++ b/src/mutation/mutation-techniques.cpp @@ -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()) { diff --git a/src/object-use/throw-execution.cpp b/src/object-use/throw-execution.cpp index 5dd010985..1b1a0bc12 100644 --- a/src/object-use/throw-execution.cpp +++ b/src/object-use/throw-execution.cpp @@ -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; } diff --git a/src/object/warning.cpp b/src/object/warning.cpp index db4686514..3f6180598 100644 --- a/src/object/warning.cpp +++ b/src/object/warning.cpp @@ -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; } diff --git a/src/pet/pet-fall-off.cpp b/src/pet/pet-fall-off.cpp index 81940cddf..e3486aea1 100644 --- a/src/pet/pet-fall-off.cpp +++ b/src/pet/pet-fall-off.cpp @@ -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; } diff --git a/src/player-attack/player-attack.cpp b/src/player-attack/player-attack.cpp index 09ee54d6f..3a5b448a7 100644 --- a/src/player-attack/player-attack.cpp +++ b/src/player-attack/player-attack.cpp @@ -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); } } diff --git a/src/player/player-status.cpp b/src/player/player-status.cpp index 2044ba9b5..7e760d0a7 100644 --- a/src/player/player-status.cpp +++ b/src/player/player-status.cpp @@ -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; } diff --git a/src/racial/racial-vampire.cpp b/src/racial/racial-vampire.cpp index f220da440..b5d5a4a59 100644 --- a/src/racial/racial-vampire.cpp +++ b/src/racial/racial-vampire.cpp @@ -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; } diff --git a/src/realm/realm-hex.cpp b/src/realm/realm-hex.cpp index 0f6bfadae..7fa992a10 100644 --- a/src/realm/realm-hex.cpp +++ b/src/realm/realm-hex.cpp @@ -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 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; } } diff --git a/src/realm/realm-hissatsu.cpp b/src/realm/realm-hissatsu.cpp index a4942024e..753503a37 100644 --- a/src/realm/realm-hissatsu.cpp +++ b/src/realm/realm-hissatsu.cpp @@ -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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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.")); diff --git a/src/room/vault-builder.cpp b/src/room/vault-builder.cpp index 2b8fe4825..0b4c2567b 100644 --- a/src/room/vault-builder.cpp +++ b/src/room/vault-builder.cpp @@ -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; } diff --git a/src/spell-class/spells-mirror-master.cpp b/src/spell-class/spells-mirror-master.cpp index 02e83b283..dd13908dd 100644 --- a/src/spell-class/spells-mirror-master.cpp +++ b/src/spell-class/spells-mirror-master.cpp @@ -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); } diff --git a/src/spell-kind/earthquake.cpp b/src/spell-kind/earthquake.cpp index 6076cc0d0..e9ec609a5 100644 --- a/src/spell-kind/earthquake.cpp +++ b/src/spell-kind/earthquake.cpp @@ -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); diff --git a/src/spell-kind/spells-floor.cpp b/src/spell-kind/spells-floor.cpp index cc6be08ba..e49f19f82 100644 --- a/src/spell-kind/spells-floor.cpp +++ b/src/spell-kind/spells-floor.cpp @@ -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(); diff --git a/src/spell-kind/spells-lite.cpp b/src/spell-kind/spells-lite.cpp index 72c727258..66ce8a968 100644 --- a/src/spell-kind/spells-lite.cpp +++ b/src/spell-kind/spells-lite.cpp @@ -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 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::vectorcurrent_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; } diff --git a/src/spell-realm/spells-chaos.cpp b/src/spell-realm/spells-chaos.cpp index 060d47e27..aa490948b 100644 --- a/src/spell-realm/spells-chaos.cpp +++ b/src/spell-realm/spells-chaos.cpp @@ -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); diff --git a/src/spell-realm/spells-crusade.cpp b/src/spell-realm/spells-crusade.cpp index 8cac7cc33..9ac9f117b 100644 --- a/src/spell-realm/spells-crusade.cpp +++ b/src/spell-realm/spells-crusade.cpp @@ -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; } diff --git a/src/spell/spells-status.cpp b/src/spell/spells-status.cpp index 5051c60a8..2d5341efa 100644 --- a/src/spell/spells-status.cpp +++ b/src/spell/spells-status.cpp @@ -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(); diff --git a/src/system/grid-type-definition.cpp b/src/system/grid-type-definition.cpp index ca42e78c4..78753a2a1 100644 --- a/src/system/grid-type-definition.cpp +++ b/src/system/grid-type-definition.cpp @@ -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)]; diff --git a/src/system/grid-type-definition.h b/src/system/grid-type-definition.h index ed4510438..d716cb870 100644 --- a/src/system/grid-type-definition.h +++ b/src/system/grid-type-definition.h @@ -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; diff --git a/src/target/projection-path-calculator.cpp b/src/target/projection-path-calculator.cpp index f3125f847..0a0ac940b 100644 --- a/src/target/projection-path-calculator.cpp +++ b/src/target/projection-path-calculator.cpp @@ -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; } diff --git a/src/target/target-describer.cpp b/src/target/target-describer.cpp index 79e21813a..61323a493 100644 --- a/src/target/target-describer.cpp +++ b/src/target/target-describer.cpp @@ -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; } diff --git a/src/target/target-preparation.cpp b/src/target/target-preparation.cpp index 9990e51eb..f1bf38cfe 100644 --- a/src/target/target-preparation.cpp +++ b/src/target/target-preparation.cpp @@ -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; diff --git a/src/util/sort.cpp b/src/util/sort.cpp index f472b0332..0b39b02b9 100644 --- a/src/util/sort.cpp +++ b/src/util/sort.cpp @@ -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; diff --git a/src/view/display-map.cpp b/src/view/display-map.cpp index 0ed47c331..da76b16bd 100644 --- a/src/view/display-map.cpp +++ b/src/view/display-map.cpp @@ -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; } diff --git a/src/window/display-sub-windows.cpp b/src/window/display-sub-windows.cpp index 1b7f6c780..b0c301c02 100644 --- a/src/window/display-sub-windows.cpp +++ b/src/window/display-sub-windows.cpp @@ -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; } diff --git a/src/world/world-turn-processor.cpp b/src/world/world-turn-processor.cpp index 91644b0db..21ad9c86f 100644 --- a/src/world/world-turn-processor.cpp +++ b/src/world/world-turn-processor.cpp @@ -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; } -- 2.11.0