OSDN Git Service

[Refactor] #2647 is_pet() をmonster_type のオブジェクトメソッドとして再定義した
authorHourier <66951241+Hourier@users.noreply.github.com>
Sat, 17 Sep 2022 02:13:39 +0000 (11:13 +0900)
committerHourier <66951241+Hourier@users.noreply.github.com>
Sun, 18 Sep 2022 10:58:11 +0000 (19:58 +0900)
56 files changed:
src/action/activation-execution.cpp
src/action/mutation-execution.cpp
src/cmd-action/cmd-pet.cpp
src/effect/effect-item.cpp
src/effect/effect-monster-charm.cpp
src/effect/effect-monster-oldies.cpp
src/effect/effect-monster.cpp
src/floor/floor-changer.cpp
src/floor/floor-events.cpp
src/floor/floor-leaver.cpp
src/floor/wild.cpp
src/io-dump/character-dump.cpp
src/knowledge/knowledge-monsters.cpp
src/melee/melee-postprocess.cpp
src/melee/melee-spell-util.cpp
src/mind/mind-cavalry.cpp
src/monster-attack/monster-attack-player.cpp
src/monster-floor/monster-death-util.cpp
src/monster-floor/monster-death.cpp
src/monster-floor/monster-direction.cpp
src/monster-floor/monster-move.cpp
src/monster-floor/monster-object.cpp
src/monster-floor/monster-runaway.cpp
src/monster-floor/monster-summon.cpp
src/monster-floor/monster-sweep-grid.cpp
src/monster-floor/one-monster-placer.cpp
src/monster-floor/quantum-effect.cpp
src/monster-floor/special-death-switcher.cpp
src/monster/monster-compaction.cpp
src/monster/monster-damage.cpp
src/monster/monster-describer.cpp
src/monster/monster-info.cpp
src/monster/monster-info.h
src/monster/monster-processor.cpp
src/monster/monster-status.cpp
src/mspell/mspell-checker.cpp
src/mspell/mspell-judgement.cpp
src/mspell/mspell-summon.cpp
src/mutation/mutation-techniques.cpp
src/pet/pet-util.cpp
src/player-info/alignment.cpp
src/player/eldritch-horror.cpp
src/spell-kind/earthquake.cpp
src/spell-kind/spells-floor.cpp
src/spell-kind/spells-genocide.cpp
src/spell-kind/spells-pet.cpp
src/spell-kind/spells-polymorph.cpp
src/spell-kind/spells-sight.cpp
src/spell-kind/spells-world.cpp
src/spell/spells-summon.cpp
src/system/monster-type-definition.cpp
src/system/monster-type-definition.h
src/target/target-preparation.cpp
src/view/display-monster-status.cpp
src/window/display-sub-windows.cpp
src/wizard/wizard-special-process.cpp

index 7dc3c5f..788e633 100644 (file)
@@ -210,7 +210,8 @@ static bool activate_whistle(PlayerType *player_ptr, ae_type *ae_ptr)
 
     std::vector<MONSTER_IDX> who;
     for (MONSTER_IDX pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--) {
-        if (is_pet(&player_ptr->current_floor_ptr->m_list[pet_ctr]) && (player_ptr->riding != pet_ctr)) {
+        const auto &m_ref = player_ptr->current_floor_ptr->m_list[pet_ctr];
+        if (m_ref.is_pet() && (player_ptr->riding != pet_ctr)) {
             who.push_back(pet_ctr);
         }
     }
index 84a1404..a35c3ae 100644 (file)
@@ -259,7 +259,7 @@ bool exe_mutation_power(PlayerType *player_ptr, PlayerMutationType power)
         monster_race *r_ptr;
         r_ptr = &r_info[m_ptr->r_idx];
         if (r_ptr->kind_flags.has(MonsterKindType::EVIL) && none_bits(r_ptr->flags1, RF1_QUESTOR) && r_ptr->kind_flags.has_not(MonsterKindType::UNIQUE) && !player_ptr->current_floor_ptr->inside_arena && !inside_quest(player_ptr->current_floor_ptr->quest_number) && (r_ptr->level < randint1(player_ptr->lev + 50)) && m_ptr->mflag2.has_not(MonsterConstantFlagType::NOGENO)) {
-            if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+            if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
                 GAME_TEXT m_name[MAX_NLEN];
                 monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
                 exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
index ab1d13c..4bed00b 100644 (file)
@@ -92,7 +92,8 @@ void do_cmd_pet_dismiss(PlayerType *player_ptr)
 
     /* Process the monsters (backwards) */
     for (MONSTER_IDX pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--) {
-        if (is_pet(&player_ptr->current_floor_ptr->m_list[pet_ctr])) {
+        const auto &m_ref = player_ptr->current_floor_ptr->m_list[pet_ctr];
+        if (m_ref.is_pet()) {
             who.push_back(pet_ctr);
         }
     }
@@ -250,7 +251,7 @@ bool do_cmd_riding(PlayerType *player_ptr, bool force)
             msg_print(_("その場所にはモンスターはいません。", "There is no monster here."));
             return false;
         }
-        if (!is_pet(m_ptr) && !force) {
+        if (!m_ptr->is_pet() && !force) {
             msg_print(_("そのモンスターはペットではありません。", "That monster is not a pet."));
             return false;
         }
@@ -336,7 +337,7 @@ static void do_name_pet(PlayerType *player_ptr)
     if (player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx) {
         m_ptr = &player_ptr->current_floor_ptr->m_list[player_ptr->current_floor_ptr->grid_array[target_row][target_col].m_idx];
 
-        if (!is_pet(m_ptr)) {
+        if (!m_ptr->is_pet()) {
             msg_print(_("そのモンスターはペットではない。", "This monster is not a pet."));
             return;
         }
@@ -677,8 +678,8 @@ void do_cmd_pet(PlayerType *player_ptr)
     {
         /* Check pets (backwards) */
         for (pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--) {
-            /* Player has pet */
-            if (is_pet(&player_ptr->current_floor_ptr->m_list[pet_ctr])) {
+            const auto &m_ref = player_ptr->current_floor_ptr->m_list[pet_ctr];
+            if (m_ref.is_pet()) {
                 break;
             }
         }
@@ -750,8 +751,7 @@ void do_cmd_pet(PlayerType *player_ptr)
             player_ptr->pet_extra_flags &= ~(PF_PICKUP_ITEMS);
             for (pet_ctr = player_ptr->current_floor_ptr->m_max - 1; pet_ctr >= 1; pet_ctr--) {
                 m_ptr = &player_ptr->current_floor_ptr->m_list[pet_ctr];
-
-                if (is_pet(m_ptr)) {
+                if (m_ptr->is_pet()) {
                     monster_drop_carried_objects(player_ptr, m_ptr);
                 }
             }
index 1b8d0d7..534c081 100644 (file)
@@ -228,7 +228,7 @@ bool affect_item(PlayerType *player_ptr, MONSTER_IDX who, POSITION r, POSITION y
             }
 
             BIT_FLAGS mode = 0L;
-            if (!who || is_pet(&player_ptr->current_floor_ptr->m_list[who])) {
+            if (!who || player_ptr->current_floor_ptr->m_list[who].is_pet()) {
                 mode |= PM_FORCE_PET;
             }
 
index 41755a6..8accb6a 100644 (file)
@@ -333,7 +333,7 @@ static bool effect_monster_crusade_domination(PlayerType *player_ptr, effect_mon
         em_ptr->dam = 1;
     }
 
-    if (is_pet(em_ptr->m_ptr)) {
+    if (em_ptr->m_ptr->is_pet()) {
         em_ptr->note = _("の動きが速くなった。", " starts moving faster.");
         (void)set_monster_fast(player_ptr, em_ptr->g_ptr->m_idx, monster_fast_remaining(em_ptr->m_ptr) + 100);
         return true;
@@ -393,7 +393,7 @@ ProcessResult effect_monster_crusade(PlayerType *player_ptr, effect_monster_type
  */
 static int calcutate_capturable_hp(PlayerType *player_ptr, monster_type *m_ptr, int hp)
 {
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         return hp * 4L;
     }
 
@@ -443,7 +443,7 @@ ProcessResult effect_monster_capture(PlayerType *player_ptr, effect_monster_type
 
     auto quest_monster = inside_quest(floor_ptr->quest_number);
     quest_monster &= (quest_list[floor_ptr->quest_number].type == QuestKindType::KILL_ALL);
-    quest_monster &= !is_pet(em_ptr->m_ptr);
+    quest_monster &= !em_ptr->m_ptr->is_pet();
 
     auto cannot_capture = quest_monster;
     cannot_capture |= em_ptr->r_ptr->kind_flags.has(MonsterKindType::UNIQUE);
index f37a201..7774354 100644 (file)
@@ -48,7 +48,7 @@ ProcessResult effect_monster_old_clone(PlayerType *player_ptr, effect_monster_ty
     }
 
     bool has_resistance = (player_ptr->current_floor_ptr->inside_arena);
-    has_resistance |= is_pet(em_ptr->m_ptr);
+    has_resistance |= em_ptr->m_ptr->is_pet();
     has_resistance |= em_ptr->r_ptr->kind_flags.has(MonsterKindType::UNIQUE);
     has_resistance |= any_bits(em_ptr->r_ptr->flags1, RF1_QUESTOR);
     has_resistance |= em_ptr->r_ptr->population_flags.has(MonsterPopulationType::NAZGUL);
index 990ffa6..6c8824c 100644 (file)
@@ -178,7 +178,7 @@ static ProcessResult exe_affect_monster_by_effect(PlayerType *player_ptr, effect
  */
 static void effect_damage_killed_pet(PlayerType *player_ptr, effect_monster_type *em_ptr)
 {
-    bool sad = is_pet(em_ptr->m_ptr) && !(em_ptr->m_ptr->ml);
+    bool sad = em_ptr->m_ptr->is_pet() && !(em_ptr->m_ptr->ml);
     if (em_ptr->known && em_ptr->note) {
         monster_desc(player_ptr, em_ptr->m_name, em_ptr->m_ptr, MD_TRUE_NAME);
         if (em_ptr->see_s_msg) {
@@ -267,7 +267,7 @@ static bool heal_leaper(PlayerType *player_ptr, effect_monster_type *em_ptr)
         msg_print(_("不潔な病人は病気が治った!", "The Mangy looking leper is healed!"));
     }
 
-    if (record_named_pet && is_pet(em_ptr->m_ptr) && em_ptr->m_ptr->nickname) {
+    if (record_named_pet && em_ptr->m_ptr->is_pet() && em_ptr->m_ptr->nickname) {
         char m2_name[MAX_NLEN];
         monster_desc(player_ptr, m2_name, em_ptr->m_ptr, MD_INDEF_VISIBLE);
         exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_HEAL_LEPER, m2_name);
@@ -619,20 +619,22 @@ static void update_phase_out_stat(PlayerType *player_ptr, effect_monster_type *e
  */
 static void postprocess_by_effected_pet(PlayerType *player_ptr, effect_monster_type *em_ptr)
 {
-    if ((em_ptr->dam <= 0) || is_pet(em_ptr->m_ptr) || em_ptr->m_ptr->is_friendly()) {
+    auto *m_ptr = em_ptr->m_ptr;
+    if ((em_ptr->dam <= 0) || m_ptr->is_pet() || m_ptr->is_friendly()) {
         return;
     }
 
     if (em_ptr->who == 0) {
         if (!(em_ptr->flag & PROJECT_NO_HANGEKI)) {
-            set_target(em_ptr->m_ptr, monster_target_y, monster_target_x);
+            set_target(m_ptr, monster_target_y, monster_target_x);
         }
 
         return;
     }
 
-    if ((em_ptr->who > 0) && is_pet(em_ptr->m_caster_ptr) && !player_bold(player_ptr, em_ptr->m_ptr->target_y, em_ptr->m_ptr->target_x)) {
-        set_target(em_ptr->m_ptr, em_ptr->m_caster_ptr->fy, em_ptr->m_caster_ptr->fx);
+    const auto &m_caster_ref = *em_ptr->m_caster_ptr;
+    if ((em_ptr->who > 0) && m_caster_ref.is_pet() && !player_bold(player_ptr, m_ptr->target_y, m_ptr->target_x)) {
+        set_target(m_ptr, m_caster_ref.fy, m_caster_ref.fx);
     }
 }
 
index 2f173e6..20cbb85 100644 (file)
@@ -259,7 +259,7 @@ static void reset_unique_by_floor_change(PlayerType *player_ptr)
             continue;
         }
 
-        if (!is_pet(m_ptr)) {
+        if (!m_ptr->is_pet()) {
             m_ptr->hp = m_ptr->maxhp = m_ptr->max_maxhp;
             (void)set_monster_fast(player_ptr, i, 0);
             (void)set_monster_slow(player_ptr, i, 0);
index f8696ad..5ffce7e 100644 (file)
@@ -129,7 +129,7 @@ static byte get_dungeon_feeling(PlayerType *player_ptr)
         auto *m_ptr = &floor_ptr->m_list[i];
         monster_race *r_ptr;
         int delta = 0;
-        if (!monster_is_valid(m_ptr) || is_pet(m_ptr)) {
+        if (!monster_is_valid(m_ptr) || m_ptr->is_pet()) {
             continue;
         }
 
index af85de8..6607a07 100644 (file)
@@ -90,7 +90,7 @@ static void sweep_preserving_pet(PlayerType *player_ptr)
 
     for (MONSTER_IDX i = player_ptr->current_floor_ptr->m_max - 1, party_monster_num = 1; (i >= 1) && (party_monster_num < MAX_PARTY_MON); i--) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!monster_is_valid(m_ptr) || !is_pet(m_ptr) || (i == player_ptr->riding) || check_pet_preservation_conditions(player_ptr, m_ptr)) {
+        if (!monster_is_valid(m_ptr) || !m_ptr->is_pet() || (i == player_ptr->riding) || check_pet_preservation_conditions(player_ptr, m_ptr)) {
             continue;
         }
 
@@ -109,7 +109,7 @@ static void record_pet_diary(PlayerType *player_ptr)
     for (MONSTER_IDX i = player_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
         GAME_TEXT m_name[MAX_NLEN];
-        if (!monster_is_valid(m_ptr) || !is_pet(m_ptr) || !m_ptr->nickname || (player_ptr->riding == i)) {
+        if (!monster_is_valid(m_ptr) || !m_ptr->is_pet() || !m_ptr->nickname || (player_ptr->riding == i)) {
             continue;
         }
 
index c099586..85a0496 100644 (file)
@@ -922,7 +922,7 @@ bool change_wild_mode(PlayerType *player_ptr, bool encount)
             continue;
         }
 
-        if (is_pet(m_ptr) && i != player_ptr->riding) {
+        if (m_ptr->is_pet() && i != player_ptr->riding) {
             has_pet = true;
         }
 
index 61cfd8b..a79a340 100644 (file)
@@ -64,7 +64,7 @@ static void dump_aux_pet(PlayerType *player_ptr, FILE *fff)
         if (!monster_is_valid(m_ptr)) {
             continue;
         }
-        if (!is_pet(m_ptr)) {
+        if (!m_ptr->is_pet()) {
             continue;
         }
         pet_settings = true;
index 9878ba3..c6be499 100644 (file)
@@ -122,7 +122,7 @@ void do_cmd_knowledge_pets(PlayerType *player_ptr)
     int t_friends = 0;
     for (int i = player_ptr->current_floor_ptr->m_max - 1; i >= 1; i--) {
         m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!monster_is_valid(m_ptr) || !is_pet(m_ptr)) {
+        if (!monster_is_valid(m_ptr) || !m_ptr->is_pet()) {
             continue;
         }
 
index 39ba44e..5eacf6a 100644 (file)
@@ -296,9 +296,10 @@ void mon_take_hit_mon(PlayerType *player_ptr, MONSTER_IDX m_idx, int dam, bool *
     *dead = false;
     cancel_fear_by_pain(player_ptr, mam_pp_ptr);
     make_monster_fear(player_ptr, mam_pp_ptr);
-    if ((dam > 0) && !is_pet(m_ptr) && !m_ptr->is_friendly() && (mam_pp_ptr->who != m_idx)) {
-        if (is_pet(&floor_ptr->m_list[mam_pp_ptr->who]) && !player_bold(player_ptr, m_ptr->target_y, m_ptr->target_x)) {
-            set_target(m_ptr, floor_ptr->m_list[mam_pp_ptr->who].fy, floor_ptr->m_list[mam_pp_ptr->who].fx);
+    if ((dam > 0) && !m_ptr->is_pet() && !m_ptr->is_friendly() && (mam_pp_ptr->who != m_idx)) {
+        const auto &m_ref = floor_ptr->m_list[who];
+        if (m_ref.is_pet() && !player_bold(player_ptr, m_ptr->target_y, m_ptr->target_x)) {
+            set_target(m_ptr, m_ref.fy, m_ref.fx);
         }
     }
 
index 6b05dd4..4f56276 100644 (file)
@@ -25,7 +25,7 @@ melee_spell_type *initialize_melee_spell_type(PlayerType *player_ptr, melee_spel
     ms_ptr->r_ptr = &r_info[ms_ptr->m_ptr->r_idx];
     ms_ptr->see_m = is_seen(player_ptr, ms_ptr->m_ptr);
     ms_ptr->maneable = player_has_los_bold(player_ptr, ms_ptr->m_ptr->fy, ms_ptr->m_ptr->fx);
-    ms_ptr->pet = is_pet(ms_ptr->m_ptr);
+    ms_ptr->pet = ms_ptr->m_ptr->is_pet();
     ms_ptr->in_no_magic_dungeon = d_info[player_ptr->dungeon_idx].flags.has(DungeonFeatureType::NO_MAGIC) && floor_ptr->dun_level && (!inside_quest(floor_ptr->quest_number) || quest_type::is_fixed(floor_ptr->quest_number));
     return ms_ptr;
 }
index eab1da3..6899130 100644 (file)
@@ -47,7 +47,7 @@ bool rodeo(PlayerType *player_ptr)
     monster_desc(player_ptr, m_name, m_ptr, 0);
     msg_format(_("%sに乗った。", "You ride on %s."), m_name);
 
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         return true;
     }
 
index a4e6e4b..92c0879 100644 (file)
@@ -219,7 +219,7 @@ bool MonsterAttackPlayer::check_monster_continuous_attack()
     }
 
     auto *r_ptr = &r_info[this->m_ptr->r_idx];
-    if (is_pet(this->m_ptr) && r_ptr->kind_flags.has(MonsterKindType::UNIQUE) && (this->method == RaceBlowMethodType::EXPLODE)) {
+    if (this->m_ptr->is_pet() && r_ptr->kind_flags.has(MonsterKindType::UNIQUE) && (this->method == RaceBlowMethodType::EXPLODE)) {
         this->method = RaceBlowMethodType::HIT;
         this->d_dice /= 10;
     }
index dcfe83b..3c6cd2c 100644 (file)
@@ -48,6 +48,6 @@ monster_death_type *initialize_monster_death_type(PlayerType *player_ptr, monste
     md_ptr->do_item = (md_ptr->r_ptr->drop_flags.has_not(MonsterDropType::ONLY_GOLD) || md_ptr->r_ptr->drop_flags.has_any_of({ MonsterDropType::DROP_GOOD, MonsterDropType::DROP_GREAT }));
     md_ptr->cloned = md_ptr->m_ptr->mflag2.has(MonsterConstantFlagType::CLONED);
     md_ptr->force_coin = get_coin_type(md_ptr->m_ptr->r_idx);
-    md_ptr->drop_chosen_item = drop_item && !md_ptr->cloned && !floor_ptr->inside_arena && !player_ptr->phase_out && !is_pet(md_ptr->m_ptr);
+    md_ptr->drop_chosen_item = drop_item && !md_ptr->cloned && !floor_ptr->inside_arena && !player_ptr->phase_out && !md_ptr->m_ptr->is_pet();
     return md_ptr;
 }
index 64e0e54..e606a44 100644 (file)
@@ -54,7 +54,7 @@ static void write_pet_death(PlayerType *player_ptr, monster_death_type *md_ptr)
 {
     md_ptr->md_y = md_ptr->m_ptr->fy;
     md_ptr->md_x = md_ptr->m_ptr->fx;
-    if (record_named_pet && is_pet(md_ptr->m_ptr) && md_ptr->m_ptr->nickname) {
+    if (record_named_pet && md_ptr->m_ptr->is_pet() && md_ptr->m_ptr->nickname) {
         GAME_TEXT m_name[MAX_NLEN];
         monster_desc(player_ptr, m_name, md_ptr->m_ptr, MD_INDEF_VISIBLE);
         exe_write_diary(player_ptr, DIARY_NAMED_PET, 3, m_name);
@@ -81,7 +81,7 @@ static void on_dead_explosion(PlayerType *player_ptr, monster_death_type *md_ptr
 static void on_defeat_arena_monster(PlayerType *player_ptr, monster_death_type *md_ptr)
 {
     auto *floor_ptr = player_ptr->current_floor_ptr;
-    if (!floor_ptr->inside_arena || is_pet(md_ptr->m_ptr)) {
+    if (!floor_ptr->inside_arena || md_ptr->m_ptr->is_pet()) {
         return;
     }
 
@@ -119,7 +119,7 @@ static void drop_corpse(PlayerType *player_ptr, monster_death_type *md_ptr)
     auto *floor_ptr = player_ptr->current_floor_ptr;
     bool is_drop_corpse = one_in_(md_ptr->r_ptr->kind_flags.has(MonsterKindType::UNIQUE) ? 1 : 4);
     is_drop_corpse &= md_ptr->r_ptr->drop_flags.has_any_of({ MonsterDropType::DROP_CORPSE, MonsterDropType::DROP_SKELETON });
-    is_drop_corpse &= !(floor_ptr->inside_arena || player_ptr->phase_out || md_ptr->cloned || ((md_ptr->m_ptr->r_idx == w_ptr->today_mon) && is_pet(md_ptr->m_ptr)));
+    is_drop_corpse &= !(floor_ptr->inside_arena || player_ptr->phase_out || md_ptr->cloned || ((md_ptr->m_ptr->r_idx == w_ptr->today_mon) && md_ptr->m_ptr->is_pet()));
     if (!is_drop_corpse) {
         return;
     }
@@ -282,7 +282,7 @@ static int decide_drop_numbers(PlayerType *player_ptr, monster_death_type *md_pt
         drop_numbers = 0;
     }
 
-    if (is_pet(md_ptr->m_ptr) || player_ptr->phase_out || player_ptr->current_floor_ptr->inside_arena) {
+    if (md_ptr->m_ptr->is_pet() || player_ptr->phase_out || player_ptr->current_floor_ptr->inside_arena) {
         drop_numbers = 0;
     }
 
index 13013aa..80d5a61 100644 (file)
@@ -33,7 +33,7 @@
 static bool decide_pet_approch_direction(PlayerType *player_ptr, monster_type *m_ptr, monster_type *t_ptr)
 {
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    if (!is_pet(m_ptr)) {
+    if (!m_ptr->is_pet()) {
         return false;
     }
 
@@ -117,7 +117,7 @@ bool get_enemy_dir(PlayerType *player_ptr, MONSTER_IDX m_idx, int *mm)
     if (player_ptr->riding_t_m_idx && player_bold(player_ptr, m_ptr->fy, m_ptr->fx)) {
         y = floor_ptr->m_list[player_ptr->riding_t_m_idx].fy;
         x = floor_ptr->m_list[player_ptr->riding_t_m_idx].fx;
-    } else if (is_pet(m_ptr) && player_ptr->pet_t_m_idx) {
+    } else if (m_ptr->is_pet() && player_ptr->pet_t_m_idx) {
         y = floor_ptr->m_list[player_ptr->pet_t_m_idx].fy;
         x = floor_ptr->m_list[player_ptr->pet_t_m_idx].fx;
     } else {
@@ -197,7 +197,7 @@ static bool random_walk(PlayerType *player_ptr, DIRECTION *mm, monster_type *m_p
 static bool decide_pet_movement_direction(MonsterSweepGrid *msd)
 {
     auto *m_ptr = &msd->player_ptr->current_floor_ptr->m_list[msd->m_idx];
-    if (!is_pet(m_ptr)) {
+    if (!m_ptr->is_pet()) {
         return false;
     }
 
index ebbf285..194b0f2 100644 (file)
@@ -113,7 +113,7 @@ static bool bash_normal_door(PlayerType *player_ptr, turn_flags *turn_flags_ptr,
     feature_type *f_ptr;
     f_ptr = &f_info[g_ptr->feat];
     turn_flags_ptr->do_move = false;
-    if ((r_ptr->behavior_flags.has_not(MonsterBehaviorType::OPEN_DOOR)) || f_ptr->flags.has_not(FloorFeatureType::OPEN) || (is_pet(m_ptr) && ((player_ptr->pet_extra_flags & PF_OPEN_DOORS) == 0))) {
+    if ((r_ptr->behavior_flags.has_not(MonsterBehaviorType::OPEN_DOOR)) || f_ptr->flags.has_not(FloorFeatureType::OPEN) || (m_ptr->is_pet() && ((player_ptr->pet_extra_flags & PF_OPEN_DOORS) == 0))) {
         return true;
     }
 
@@ -143,7 +143,7 @@ static bool bash_normal_door(PlayerType *player_ptr, turn_flags *turn_flags_ptr,
 static void bash_glass_door(PlayerType *player_ptr, turn_flags *turn_flags_ptr, monster_type *m_ptr, feature_type *f_ptr, bool may_bash)
 {
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    if (!may_bash || (r_ptr->behavior_flags.has_not(MonsterBehaviorType::BASH_DOOR)) || f_ptr->flags.has_not(FloorFeatureType::BASH) || (is_pet(m_ptr) && ((player_ptr->pet_extra_flags & PF_OPEN_DOORS) == 0))) {
+    if (!may_bash || (r_ptr->behavior_flags.has_not(MonsterBehaviorType::BASH_DOOR)) || f_ptr->flags.has_not(FloorFeatureType::BASH) || (m_ptr->is_pet() && ((player_ptr->pet_extra_flags & PF_OPEN_DOORS) == 0))) {
         return;
     }
 
@@ -232,7 +232,7 @@ static bool process_protection_rune(PlayerType *player_ptr, turn_flags *turn_fla
     }
 
     turn_flags_ptr->do_move = false;
-    if (is_pet(m_ptr) || (randint1(BREAK_RUNE_PROTECTION) >= r_ptr->level)) {
+    if (m_ptr->is_pet() || (randint1(BREAK_RUNE_PROTECTION) >= r_ptr->level)) {
         return true;
     }
 
@@ -267,7 +267,7 @@ static bool process_explosive_rune(PlayerType *player_ptr, turn_flags *turn_flag
     }
 
     turn_flags_ptr->do_move = false;
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         return true;
     }
 
@@ -451,7 +451,7 @@ bool process_monster_movement(PlayerType *player_ptr, turn_flags *turn_flags_ptr
         bool is_pickup_items = (player_ptr->pet_extra_flags & PF_PICKUP_ITEMS) != 0;
         is_pickup_items &= r_ptr->behavior_flags.has(MonsterBehaviorType::TAKE_ITEM);
 
-        is_takable_or_killable &= !is_pet(m_ptr) || is_pickup_items;
+        is_takable_or_killable &= !m_ptr->is_pet() || is_pickup_items;
         if (!is_takable_or_killable) {
             if (turn_flags_ptr->do_turn) {
                 break;
@@ -486,7 +486,7 @@ static std::string_view get_speak_filename(monster_type *m_ptr)
     }
 
     constexpr auto monspeak_txt(_("monspeak_j.txt", "monspeak.txt"));
-    if (is_pet(m_ptr) && can_speak(ap_r_ref, MonsterSpeakType::SPEAK_BATTLE)) {
+    if (m_ptr->is_pet() && can_speak(ap_r_ref, MonsterSpeakType::SPEAK_BATTLE)) {
         return monspeak_txt;
     }
 
index 983b842..72c2c46 100644 (file)
@@ -156,7 +156,7 @@ static void monster_pickup_object(PlayerType *player_ptr, turn_flags *turn_flags
         return;
     }
 
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         return;
     }
 
index 81f9adc..9fae501 100644 (file)
@@ -91,7 +91,7 @@ bool runaway_monster(PlayerType *player_ptr, turn_flags *turn_flags_ptr, MONSTER
 {
     auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    bool can_runaway = is_pet(m_ptr) || m_ptr->is_friendly();
+    bool can_runaway = m_ptr->is_pet() || m_ptr->is_friendly();
     can_runaway &= (r_ptr->kind_flags.has(MonsterKindType::UNIQUE)) || (r_ptr->population_flags.has(MonsterPopulationType::NAZGUL));
     can_runaway &= !player_ptr->phase_out;
     if (!can_runaway) {
index 6b7785d..ccb6802 100644 (file)
@@ -165,7 +165,7 @@ bool summon_specific(PlayerType *player_ptr, MONSTER_IDX who, POSITION y1, POSIT
         notice = true;
     } else {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[who];
-        if (is_pet(m_ptr)) {
+        if (m_ptr->is_pet()) {
             notice = true;
         } else if (is_seen(player_ptr, m_ptr)) {
             notice = true;
index bb3f22d..97363e7 100644 (file)
@@ -94,7 +94,7 @@ bool MonsterSweepGrid::mon_will_run()
 {
     auto *m_ptr = &this->player_ptr->current_floor_ptr->m_list[this->m_idx];
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         return (this->player_ptr->pet_follow_distance < 0) && (m_ptr->cdis <= (0 - this->player_ptr->pet_follow_distance));
     }
 
@@ -213,7 +213,7 @@ void MonsterSweepGrid::search_pet_runnable_grid(POSITION *y, POSITION *x, bool n
 {
     auto *floor_ptr = this->player_ptr->current_floor_ptr;
     auto *m_ptr = &floor_ptr->m_list[this->m_idx];
-    if (is_pet(m_ptr) && this->will_run) {
+    if (m_ptr->is_pet() && this->will_run) {
         *y = -(*y);
         *x = -(*x);
         return;
index 1340a08..b2da739 100644 (file)
@@ -338,7 +338,7 @@ bool place_monster_one(PlayerType *player_ptr, MONSTER_IDX who, POSITION y, POSI
     m_ptr->nickname = 0;
     m_ptr->exp = 0;
 
-    if (who > 0 && is_pet(&floor_ptr->m_list[who])) {
+    if (who > 0 && floor_ptr->m_list[who].is_pet()) {
         set_bits(mode, PM_FORCE_PET);
         m_ptr->parent_m_idx = who;
     } else {
index b7010a3..2b0c413 100644 (file)
@@ -36,7 +36,7 @@ static void vanish_nonunique(PlayerType *player_ptr, MONSTER_IDX m_idx, bool see
 
     monster_death(player_ptr, m_idx, false, AttributeType::NONE);
     delete_monster_idx(player_ptr, m_idx);
-    if (is_pet(m_ptr) && !(m_ptr->ml)) {
+    if (m_ptr->is_pet() && !(m_ptr->ml)) {
         msg_print(_("少しの間悲しい気分になった。", "You feel sad for a moment."));
     }
 }
index a88327a..6fb66d9 100644 (file)
@@ -51,7 +51,7 @@
  */
 static BIT_FLAGS dead_mode(monster_death_type *md_ptr)
 {
-    bool pet = is_pet(md_ptr->m_ptr);
+    bool pet = md_ptr->m_ptr->is_pet();
     bool clone = md_ptr->m_ptr->mflag2.has(MonsterConstantFlagType::CLONED);
     BIT_FLAGS mode = pet ? PM_FORCE_PET : PM_NONE;
     if (clone) {
@@ -80,7 +80,7 @@ static void summon_self(PlayerType *player_ptr, monster_death_type *md_ptr, summ
     POSITION wy = md_ptr->md_y;
     POSITION wx = md_ptr->md_x;
     int attempts = 100;
-    bool pet = is_pet(md_ptr->m_ptr);
+    bool pet = md_ptr->m_ptr->is_pet();
     do {
         scatter(player_ptr, &wy, &wx, md_ptr->md_y, md_ptr->md_x, radius, PROJECT_NONE);
     } while (!(in_bounds(floor_ptr, wy, wx) && is_cave_empty_bold2(player_ptr, wy, wx)) && --attempts);
@@ -106,7 +106,7 @@ static void on_dead_pink_horror(PlayerType *player_ptr, monster_death_type *md_p
     for (int i = 0; i < blue_horrors; i++) {
         POSITION wy = md_ptr->md_y;
         POSITION wx = md_ptr->md_x;
-        bool pet = is_pet(md_ptr->m_ptr);
+        bool pet = md_ptr->m_ptr->is_pet();
         BIT_FLAGS mode = dead_mode(md_ptr);
         if (summon_specific(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, 100, SUMMON_BLUE_HORROR, mode) && player_can_see_bold(player_ptr, wy, wx)) {
             notice = true;
@@ -254,7 +254,7 @@ static void on_dead_aqua_illusion(PlayerType *player_ptr, monster_death_type *md
     for (int i = 0; i < popped_bubbles; i++) {
         POSITION wy = md_ptr->md_y;
         POSITION wx = md_ptr->md_x;
-        bool pet = is_pet(md_ptr->m_ptr);
+        bool pet = md_ptr->m_ptr->is_pet();
         BIT_FLAGS mode = dead_mode(md_ptr);
         auto smaller_bubble = md_ptr->m_ptr->r_idx - 1;
         if (summon_named_creature(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, smaller_bubble, mode) && player_can_see_bold(player_ptr, wy, wx)) {
@@ -289,7 +289,7 @@ static void on_dead_dragon_centipede(PlayerType *player_ptr, monster_death_type
     for (int i = 0; i < reproduced_centipede; i++) {
         POSITION wy = md_ptr->md_y;
         POSITION wx = md_ptr->md_x;
-        bool pet = is_pet(md_ptr->m_ptr);
+        bool pet = md_ptr->m_ptr->is_pet();
         BIT_FLAGS mode = dead_mode(md_ptr);
 
         auto smaller_centipede = md_ptr->m_ptr->r_idx - 1;
@@ -447,7 +447,7 @@ static void on_dead_chest_mimic(PlayerType *player_ptr, monster_death_type *md_p
     for (auto i = 0; i < num_summons; i++) {
         auto wy = md_ptr->md_y;
         auto wx = md_ptr->md_x;
-        auto pet = is_pet(md_ptr->m_ptr);
+        auto pet = md_ptr->m_ptr->is_pet();
         BIT_FLAGS mode = dead_mode(md_ptr);
         if (summon_named_creature(player_ptr, (pet ? -1 : md_ptr->m_idx), wy, wx, mimic_inside, (BIT_FLAGS)mode) && player_can_see_bold(player_ptr, wy, wx)) {
             notice = true;
index afe68cd..1d481e3 100644 (file)
@@ -65,7 +65,7 @@ static void compact_monsters_aux(PlayerType *player_ptr, MONSTER_IDX i1, MONSTER
         health_track(player_ptr, i2);
     }
 
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         for (int i = 1; i < floor_ptr->m_max; i++) {
             monster_type *m2_ptr = &floor_ptr->m_list[i];
 
@@ -140,7 +140,7 @@ void compact_monsters(PlayerType *player_ptr, int size)
                 continue;
             }
 
-            if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+            if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
                 GAME_TEXT m_name[MAX_NLEN];
                 monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
                 exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
index ad221a2..6449abe 100644 (file)
@@ -425,7 +425,7 @@ void MonsterDamageProcessor::show_bounty_message(GAME_TEXT *m_name)
 void MonsterDamageProcessor::get_exp_from_mon(monster_type *m_ptr, int exp_dam)
 {
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    if (!monster_is_valid(m_ptr) || is_pet(m_ptr) || this->player_ptr->phase_out) {
+    if (!monster_is_valid(m_ptr) || m_ptr->is_pet() || this->player_ptr->phase_out) {
         return;
     }
 
@@ -510,7 +510,7 @@ void MonsterDamageProcessor::summon_special_unique()
     auto dummy_y = m_ptr->fy;
     auto dummy_x = m_ptr->fx;
     auto mode = (BIT_FLAGS)0;
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         mode |= PM_FORCE_PET;
     }
 
index 877e347..83529de 100644 (file)
@@ -163,7 +163,7 @@ void monster_desc(PlayerType *player_ptr, char *desc, monster_type *m_ptr, BIT_F
 
     /* Handle all other visible monster requests */
     /* Tanuki? */
-    if (is_pet(m_ptr) && !is_original_ap(m_ptr)) {
+    if (m_ptr->is_pet() && !is_original_ap(m_ptr)) {
 #ifdef JP
         char *t;
         char buf[128];
@@ -214,7 +214,7 @@ void monster_desc(PlayerType *player_ptr, char *desc, monster_type *m_ptr, BIT_F
 #endif
             (void)strcat(desc, name);
         } else {
-            if (is_pet(m_ptr)) {
+            if (m_ptr->is_pet()) {
                 (void)strcpy(desc, _("あなたの", "your "));
             } else {
                 (void)strcpy(desc, _("", "the "));
index b2c7715..517a075 100644 (file)
@@ -186,18 +186,19 @@ static bool check_hostile_align(byte sub_align1, byte sub_align2)
  */
 bool are_enemies(PlayerType *player_ptr, monster_type *m_ptr, monster_type *n_ptr)
 {
-    auto *r_ptr = &r_info[m_ptr->r_idx];
-    monster_race *s_ptr = &r_info[n_ptr->r_idx];
-
     if (player_ptr->phase_out) {
-        if (is_pet(m_ptr) || is_pet(n_ptr)) {
+        if (m_ptr->is_pet() || n_ptr->is_pet()) {
             return false;
         }
         return true;
     }
 
-    if (r_ptr->wilderness_flags.has_any_of({ MonsterWildernessType::WILD_TOWN, MonsterWildernessType::WILD_ALL }) && s_ptr->wilderness_flags.has_any_of({ MonsterWildernessType::WILD_TOWN, MonsterWildernessType::WILD_ALL })) {
-        if (!is_pet(m_ptr) && !is_pet(n_ptr)) {
+    const auto &r1_ref = r_info[m_ptr->r_idx];
+    const auto &r2_ref = r_info[n_ptr->r_idx];
+    const auto is_m1_wild = r1_ref.wilderness_flags.has_any_of({ MonsterWildernessType::WILD_TOWN, MonsterWildernessType::WILD_ALL });
+    const auto is_m2_wild = r2_ref.wilderness_flags.has_any_of({ MonsterWildernessType::WILD_TOWN, MonsterWildernessType::WILD_ALL });
+    if (is_m1_wild && is_m2_wild) {
+        if (!m_ptr->is_pet() && !n_ptr->is_pet()) {
             return false;
         }
     }
@@ -271,14 +272,9 @@ bool is_original_ap(const monster_type *m_ptr)
     return m_ptr->ap_r_idx == m_ptr->r_idx;
 }
 
-bool is_pet(const monster_type *m_ptr)
-{
-    return m_ptr->mflag2.has(MonsterConstantFlagType::PET);
-}
-
 bool is_hostile(const monster_type *m_ptr)
 {
-    return !m_ptr->is_friendly() && !is_pet(m_ptr);
+    return !m_ptr->is_friendly() && !m_ptr->is_pet();
 }
 
 /*!
index 084b93c..e494cc2 100644 (file)
@@ -17,7 +17,6 @@ bool are_enemies(PlayerType *player_ptr, monster_type *m_ptr1, monster_type *m_p
 bool monster_has_hostile_align(PlayerType *player_ptr, monster_type *m_ptr, int pa_good, int pa_evil, monster_race *r_ptr);
 bool is_original_ap_and_seen(PlayerType *player_ptr, monster_type *m_ptr);
 
-bool is_pet(const monster_type *m_ptr);
 bool is_hostile(const monster_type *m_ptr);
 bool is_original_ap(const monster_type *m_ptr);
 bool is_mimicry(monster_type *m_ptr);
index 97098c2..2f3a4d9 100644 (file)
@@ -276,7 +276,7 @@ bool vanish_summoned_children(PlayerType *player_ptr, MONSTER_IDX m_idx, bool se
         msg_format(_("%sは消え去った!", "%^s disappears!"), m_name);
     }
 
-    if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+    if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
         GAME_TEXT m_name[MAX_NLEN];
         monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
         exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_LOSE_PARENT, m_name);
@@ -333,7 +333,7 @@ void process_angar(PlayerType *player_ptr, MONSTER_IDX m_idx, bool see_m)
         gets_angry = true;
     }
 
-    if (is_pet(m_ptr) && (((r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || (r_ptr->population_flags.has(MonsterPopulationType::NAZGUL))) && monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr)) || r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL))) {
+    if (m_ptr->is_pet() && (((r_ptr->kind_flags.has(MonsterKindType::UNIQUE) || (r_ptr->population_flags.has(MonsterPopulationType::NAZGUL))) && monster_has_hostile_align(player_ptr, nullptr, 10, -10, r_ptr)) || r_ptr->resistance_flags.has(MonsterResistanceType::RESIST_ALL))) {
         gets_angry = true;
     }
 
@@ -342,7 +342,7 @@ void process_angar(PlayerType *player_ptr, MONSTER_IDX m_idx, bool see_m)
     }
 
     GAME_TEXT m_name[MAX_NLEN];
-    monster_desc(player_ptr, m_name, m_ptr, is_pet(m_ptr) ? MD_ASSUME_VISIBLE : 0);
+    monster_desc(player_ptr, m_name, m_ptr, m_ptr->is_pet() ? MD_ASSUME_VISIBLE : 0);
 
     /* When riding a hostile alignment pet */
     if (player_ptr->riding == m_idx) {
@@ -358,7 +358,7 @@ void process_angar(PlayerType *player_ptr, MONSTER_IDX m_idx, bool see_m)
         msg_format(_("あなたは振り落とされた。", "You have fallen."));
     }
 
-    if (is_pet(m_ptr) || see_m) {
+    if (m_ptr->is_pet() || see_m) {
         msg_format(_("%^sは突然敵にまわった!", "%^s suddenly becomes hostile!"), m_name);
     }
 
@@ -398,7 +398,7 @@ void process_special(PlayerType *player_ptr, MONSTER_IDX m_idx)
 
     int count = 0;
     DEPTH rlev = ((r_ptr->level >= 1) ? r_ptr->level : 1);
-    BIT_FLAGS p_mode = is_pet(m_ptr) ? PM_FORCE_PET : PM_NONE;
+    BIT_FLAGS p_mode = m_ptr->is_pet() ? PM_FORCE_PET : PM_NONE;
 
     for (int k = 0; k < A_MAX; k++) {
         if (summon_specific(player_ptr, m_idx, m_ptr->fy, m_ptr->fx, rlev, SUMMON_MOLD, (PM_ALLOW_GROUP | p_mode))) {
@@ -447,7 +447,7 @@ bool decide_monster_multiplication(PlayerType *player_ptr, MONSTER_IDX m_idx, PO
     }
 
     if ((k < 4) && (!k || !randint0(k * MON_MULT_ADJ))) {
-        if (multiply_monster(player_ptr, m_idx, false, (is_pet(m_ptr) ? PM_FORCE_PET : 0))) {
+        if (multiply_monster(player_ptr, m_idx, false, (m_ptr->is_pet() ? PM_FORCE_PET : 0))) {
             if (player_ptr->current_floor_ptr->m_list[hack_m_idx_ii].ml && is_original_ap_and_seen(player_ptr, m_ptr)) {
                 r_ptr->r_flags2 |= RF2_MULTIPLY;
             }
@@ -633,7 +633,7 @@ bool decide_process_continue(PlayerType *player_ptr, monster_type *m_ptr)
         m_ptr->mflag2.reset(MonsterConstantFlagType::NOFLOW);
     }
 
-    if (m_ptr->cdis <= (is_pet(m_ptr) ? (r_ptr->aaf > MAX_SIGHT ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
+    if (m_ptr->cdis <= (m_ptr->is_pet() ? (r_ptr->aaf > MAX_SIGHT ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
         return true;
     }
 
index 4966a5b..3f10e03 100644 (file)
@@ -171,7 +171,7 @@ static void process_monsters_mtimed_aux(PlayerType *player_ptr, MONSTER_IDX m_id
         auto is_wakeup = false;
         if (m_ptr->cdis < AAF_LIMIT) {
             /* Handle "sensing radius" */
-            if (m_ptr->cdis <= (is_pet(m_ptr) ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
+            if (m_ptr->cdis <= (m_ptr->is_pet() ? ((r_ptr->aaf > MAX_SIGHT) ? MAX_SIGHT : r_ptr->aaf) : r_ptr->aaf)) {
                 is_wakeup = true;
             }
 
@@ -475,7 +475,7 @@ void monster_gain_exp(PlayerType *player_ptr, MONSTER_IDX m_idx, MonsterRaceId s
     m_ptr->mspeed = get_mspeed(floor_ptr, r_ptr);
 
     /* Sub-alignment of a monster */
-    if (!is_pet(m_ptr) && r_ptr->kind_flags.has_none_of(alignment_mask)) {
+    if (!m_ptr->is_pet() && r_ptr->kind_flags.has_none_of(alignment_mask)) {
         m_ptr->sub_align = old_sub_align;
     } else {
         m_ptr->sub_align = SUB_ALIGN_NEUTRAL;
@@ -489,7 +489,7 @@ void monster_gain_exp(PlayerType *player_ptr, MONSTER_IDX m_idx, MonsterRaceId s
     }
 
     m_ptr->exp = 0;
-    if (is_pet(m_ptr) || m_ptr->ml) {
+    if (m_ptr->is_pet() || m_ptr->ml) {
         auto is_hallucinated = player_ptr->effects()->hallucination()->is_hallucinated();
         if (!ignore_unview || player_can_see_bold(player_ptr, m_ptr->fy, m_ptr->fx)) {
             if (is_hallucinated) {
index e42dd39..7e39571 100644 (file)
@@ -169,7 +169,7 @@ bool clean_shot(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION y2, P
     for (const auto &[y, x] : grid_g) {
         if ((floor_ptr->grid_array[y][x].m_idx > 0) && (y != y2 || x != x2)) {
             auto *m_ptr = &floor_ptr->m_list[floor_ptr->grid_array[y][x].m_idx];
-            if (is_friend == is_pet(m_ptr)) {
+            if (is_friend == m_ptr->is_pet()) {
                 return false;
             }
         }
index d800bf7..4d40121 100644 (file)
@@ -59,7 +59,7 @@ bool direct_beam(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION y2,
     }
 
     bool hit2 = false;
-    bool is_friend = is_pet(m_ptr);
+    bool is_friend = m_ptr->is_pet();
     for (const auto &[y, x] : grid_g) {
         if (y == y2 && x == x2) {
             hit2 = true;
index 476667b..13bb68e 100644 (file)
@@ -59,7 +59,7 @@ static BIT_FLAGS monster_u_mode(floor_type *floor_ptr, MONSTER_IDX m_idx)
 {
     BIT_FLAGS u_mode = 0L;
     auto *m_ptr = &floor_ptr->m_list[m_idx];
-    bool pet = is_pet(m_ptr);
+    bool pet = m_ptr->is_pet();
     if (!pet) {
         u_mode |= PM_ALLOW_UNIQUE;
     }
index bbe045c..f0fa32c 100644 (file)
@@ -50,7 +50,7 @@ bool eat_rock(PlayerType *player_ptr)
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[g_ptr->m_idx];
         msg_print(_("何かが邪魔しています!", "There's something in the way!"));
 
-        if (!m_ptr->ml || !is_pet(m_ptr)) {
+        if (!m_ptr->ml || !m_ptr->is_pet()) {
             do_cmd_attack(player_ptr, y, x, HISSATSU_NONE);
         }
     } else if (f_ptr->flags.has(FloorFeatureType::TREE)) {
index 74dd507..c3c9d83 100644 (file)
@@ -77,7 +77,7 @@ PERCENTAGE calculate_upkeep(PlayerType *player_ptr)
         }
         auto *r_ptr = &r_info[m_ptr->r_idx];
 
-        if (!is_pet(m_ptr)) {
+        if (!m_ptr->is_pet()) {
             continue;
         }
 
index 7e37686..3c3aeb8 100644 (file)
@@ -51,7 +51,7 @@ void PlayerAlignment::update_alignment()
         }
         auto *r_ptr = &r_info[m_ptr->r_idx];
 
-        if (!is_pet(m_ptr)) {
+        if (!m_ptr->is_pet()) {
             continue;
         }
 
index 7dd7a4d..9f72d6b 100644 (file)
@@ -116,7 +116,7 @@ void sanity_blast(PlayerType *player_ptr, monster_type *m_ptr, bool necro)
             return;
         }
 
-        if (is_pet(m_ptr)) {
+        if (m_ptr->is_pet()) {
             return;
         }
 
index 0d1cc9d..d42ff06 100644 (file)
@@ -277,7 +277,8 @@ bool earthquake(PlayerType *player_ptr, POSITION cy, POSITION cx, POSITION r, MO
                 }
 
                 if (gg_ptr->m_idx) {
-                    if (record_named_pet && is_pet(&floor_ptr->m_list[gg_ptr->m_idx]) && floor_ptr->m_list[gg_ptr->m_idx].nickname) {
+                    const auto &m_ref = floor_ptr->m_list[gg_ptr->m_idx];
+                    if (record_named_pet && m_ref.is_pet() && m_ref.nickname) {
                         char m2_name[MAX_NLEN];
 
                         monster_desc(player_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
index 606799f..bf7e039 100644 (file)
@@ -324,7 +324,7 @@ bool destroy_area(PlayerType *player_ptr, POSITION y1, POSITION x1, POSITION r,
                         continue;
                     }
                 } else {
-                    if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+                    if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
                         GAME_TEXT m_name[MAX_NLEN];
 
                         monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
index 0af766e..b57eb9e 100644 (file)
@@ -44,7 +44,7 @@ bool genocide_aux(PlayerType *player_ptr, MONSTER_IDX m_idx, int power, bool pla
 {
     auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
     auto *r_ptr = &r_info[m_ptr->r_idx];
-    if (is_pet(m_ptr) && !player_cast) {
+    if (m_ptr->is_pet() && !player_cast) {
         return false;
     }
 
@@ -62,7 +62,7 @@ bool genocide_aux(PlayerType *player_ptr, MONSTER_IDX m_idx, int power, bool pla
     } else if (player_cast && m_ptr->mflag2.has(MonsterConstantFlagType::NOGENO)) {
         resist = true;
     } else {
-        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+        if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
             GAME_TEXT m_name[MAX_NLEN];
             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_GENOCIDE, m_name);
@@ -86,7 +86,7 @@ bool genocide_aux(PlayerType *player_ptr, MONSTER_IDX m_idx, int power, bool pla
             }
         }
 
-        if (m_ptr->is_friendly() && !is_pet(m_ptr)) {
+        if (m_ptr->is_friendly() && !m_ptr->is_pet()) {
             if (see_m) {
                 msg_format(_("%sは怒った!", "%^s gets angry!"), m_name);
             }
index 2df72e8..a1ba7ea 100644 (file)
@@ -26,7 +26,7 @@ void discharge_minion(PlayerType *player_ptr)
     bool okay = true;
     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!MonsterRace(m_ptr->r_idx).is_valid() || !is_pet(m_ptr)) {
+        if (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
             continue;
         }
         if (m_ptr->nickname) {
@@ -42,7 +42,7 @@ void discharge_minion(PlayerType *player_ptr)
 
     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!MonsterRace(m_ptr->r_idx).is_valid() || !is_pet(m_ptr)) {
+        if (!MonsterRace(m_ptr->r_idx).is_valid() || !m_ptr->is_pet()) {
             continue;
         }
 
index 83604b5..86c53ba 100644 (file)
@@ -97,7 +97,7 @@ bool polymorph_monster(PlayerType *player_ptr, POSITION y, POSITION x)
     if (m_ptr->is_friendly()) {
         mode |= PM_FORCE_FRIENDLY;
     }
-    if (is_pet(m_ptr)) {
+    if (m_ptr->is_pet()) {
         mode |= PM_FORCE_PET;
     }
     if (m_ptr->mflag2.has(MonsterConstantFlagType::NOPET)) {
index 5a0419e..4d3f611 100644 (file)
@@ -233,13 +233,13 @@ void aggravate_monsters(PlayerType *player_ptr, MONSTER_IDX who)
                 sleep = true;
             }
 
-            if (!is_pet(m_ptr)) {
+            if (!m_ptr->is_pet()) {
                 m_ptr->mflag2.set(MonsterConstantFlagType::NOPET);
             }
         }
 
         if (player_has_los_bold(player_ptr, m_ptr->fy, m_ptr->fx)) {
-            if (!is_pet(m_ptr)) {
+            if (!m_ptr->is_pet()) {
                 (void)set_monster_fast(player_ptr, i, monster_fast_remaining(m_ptr) + 100);
                 speed = true;
             }
index fd61387..2cf286d 100644 (file)
@@ -219,7 +219,7 @@ void teleport_level(PlayerType *player_ptr, MONSTER_IDX m_idx)
 
     auto *m_ptr = &player_ptr->current_floor_ptr->m_list[m_idx];
     QuestCompletionChecker(player_ptr, m_ptr).complete();
-    if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+    if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
         char m2_name[MAX_NLEN];
 
         monster_desc(player_ptr, m2_name, m_ptr, MD_INDEF_VISIBLE);
index ad22653..3c34ab6 100644 (file)
@@ -273,7 +273,7 @@ int summon_cyber(PlayerType *player_ptr, MONSTER_IDX who, POSITION y, POSITION x
     auto *floor_ptr = player_ptr->current_floor_ptr;
     if (who > 0) {
         auto *m_ptr = &floor_ptr->m_list[who];
-        if (is_pet(m_ptr)) {
+        if (m_ptr->is_pet()) {
             mode |= PM_FORCE_PET;
         }
     }
index bb8537c..ee51e20 100644 (file)
@@ -4,3 +4,8 @@ bool monster_type::is_friendly() const
 {
     return this->mflag2.has(MonsterConstantFlagType::FRIENDLY);
 }
+
+bool monster_type::is_pet() const
+{
+    return this->mflag2.has(MonsterConstantFlagType::PET);
+}
index a0c9a0e..7f27c05 100644 (file)
@@ -53,4 +53,5 @@ struct monster_type {
     MONSTER_IDX parent_m_idx{}; /*!< 召喚主のモンスターID */
 
     bool is_friendly() const;
+    bool is_pet() const;
 };
index eb84b9a..afde241 100644 (file)
@@ -144,17 +144,17 @@ void target_set_prepare(PlayerType *player_ptr, std::vector<POSITION> &ys, std::
 
     for (POSITION y = min_hgt; y <= max_hgt; y++) {
         for (POSITION x = min_wid; x <= max_wid; x++) {
-            grid_type *g_ptr;
             if (!target_set_accept(player_ptr, y, x)) {
                 continue;
             }
 
-            g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
-            if ((mode & (TARGET_KILL)) && !target_able(player_ptr, g_ptr->m_idx)) {
+            const auto &g_ref = player_ptr->current_floor_ptr->grid_array[y][x];
+            if ((mode & (TARGET_KILL)) && !target_able(player_ptr, g_ref.m_idx)) {
                 continue;
             }
 
-            if ((mode & (TARGET_KILL)) && !target_pet && is_pet(&player_ptr->current_floor_ptr->m_list[g_ptr->m_idx])) {
+            const auto &m_ref = player_ptr->current_floor_ptr->m_list[g_ref.m_idx];
+            if ((mode & (TARGET_KILL)) && !target_pet && m_ref.is_pet()) {
                 continue;
             }
 
@@ -191,7 +191,7 @@ void target_sensing_monsters_prepare(PlayerType *player_ptr, std::vector<MONSTER
 
     for (MONSTER_IDX i = 1; i < player_ptr->current_floor_ptr->m_max; i++) {
         auto *m_ptr = &player_ptr->current_floor_ptr->m_list[i];
-        if (!monster_is_valid(m_ptr) || !m_ptr->ml || is_pet(m_ptr)) {
+        if (!monster_is_valid(m_ptr) || !m_ptr->ml || m_ptr->is_pet()) {
             continue;
         }
 
index 640f513..8f15d80 100644 (file)
@@ -31,7 +31,7 @@ concptr look_mon_desc(monster_type *m_ptr, BIT_FLAGS mode)
     concptr attitude;
     if (!(mode & 0x01)) {
         attitude = "";
-    } else if (is_pet(m_ptr)) {
+    } else if (m_ptr->is_pet()) {
         attitude = _(", ペット", ", pet");
     } else if (m_ptr->is_friendly()) {
         attitude = _(", 友好的", ", friendly");
index ac0113a..4f237a5 100644 (file)
@@ -149,7 +149,7 @@ void print_monster_list(floor_type *floor_ptr, const std::vector<MONSTER_IDX> &m
     size_t i;
     for (i = 0; i < monster_list.size(); i++) {
         auto m_ptr = &floor_ptr->m_list[monster_list[i]];
-        if (is_pet(m_ptr)) {
+        if (m_ptr->is_pet()) {
             continue;
         } // pet
         if (!MonsterRace(m_ptr->r_idx).is_valid()) {
index cad63cf..d453813 100644 (file)
@@ -802,7 +802,7 @@ void wiz_zap_surrounding_monsters(PlayerType *player_ptr)
             continue;
         }
 
-        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+        if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
             GAME_TEXT m_name[MAX_NLEN];
 
             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
@@ -825,7 +825,7 @@ void wiz_zap_floor_monsters(PlayerType *player_ptr)
             continue;
         }
 
-        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname) {
+        if (record_named_pet && m_ptr->is_pet() && m_ptr->nickname) {
             GAME_TEXT m_name[MAX_NLEN];
             monster_desc(player_ptr, m_name, m_ptr, MD_INDEF_VISIBLE);
             exe_write_diary(player_ptr, DIARY_NAMED_PET, RECORD_NAMED_PET_WIZ_ZAP, m_name);