OSDN Git Service

[Refactor] #37353 monster_is_valid() 関数を定義し単純な !r_idx の条件から置換。 / Define monster_is_va...
authordeskull <deskull@users.sourceforge.jp>
Sun, 17 Mar 2019 05:48:58 +0000 (14:48 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 17 Mar 2019 05:48:58 +0000 (14:48 +0900)
21 files changed:
src/cmd-activate.c
src/cmd-pet.c
src/cmd4.c
src/dungeon.c
src/files.c
src/floor-generate.c
src/floor-save.c
src/grid.c
src/melee1.c
src/monster-process.c
src/monster-status.c
src/monster-status.h
src/monster2.c
src/mspells2.c
src/spells-summon.c
src/spells2.c
src/spells3.c
src/types.h
src/wild.c
src/wizard2.c
src/xtra2.c

index b60ea00..b5da697 100644 (file)
@@ -19,6 +19,7 @@
 #include "spells-floor.h"
 #include "realm-hex.h"
 #include "player-status.h"
+#include "monster-status.h"
 
 /*!
  * @brief アイテムの発動効果テーブル /
@@ -1608,7 +1609,7 @@ bool activate_artifact(object_type *o_ptr)
                        m_ptr = &current_floor_ptr->m_list[i];
 
                        /* Ignore "dead" monsters */
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        r_ptr = &r_info[m_ptr->r_idx];
 
index bdd41e4..d369c15 100644 (file)
@@ -3,6 +3,7 @@
 #include "sort.h"
 #include "player-status.h"
 #include "object-hook.h"
+#include "monster-status.h"
 
 /*!
 * @brief プレイヤーの騎乗/下馬処理判定
@@ -115,7 +116,7 @@ int calculate_upkeep(void)
                monster_race *r_ptr;
 
                m_ptr = &current_floor_ptr->m_list[m_idx];
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
                r_ptr = &r_info[m_ptr->r_idx];
 
                if (is_pet(m_ptr))
index 7d4956d..b159da2 100644 (file)
@@ -50,6 +50,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "object-hook.h"
+#include "monster-status.h"
 
 
 /*
@@ -5831,7 +5832,7 @@ static void do_cmd_knowledge_pets(void)
                m_ptr = &current_floor_ptr->m_list[i];
 
                /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Calculate "upkeep" for pets */
                if (is_pet(m_ptr))
index 71154a6..8dc901a 100644 (file)
@@ -42,6 +42,7 @@
 #include "realm-hex.h"
 #include "object-hook.h"
 #include "wild.h"
+#include "monster-status.h"
 
 
 static bool load = TRUE; /*!<ロード処理中の分岐フラグ*/
@@ -871,7 +872,7 @@ static void regen_monsters(void)
 
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Allow regeneration (if needed) */
                if (m_ptr->hp < m_ptr->maxhp)
@@ -2420,7 +2421,7 @@ static void process_world_aux_mutation(void)
                        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                        /* Paranoia -- Skip dead monsters */
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        if (r_ptr->level >= p_ptr->lev)
                        {
@@ -3083,7 +3084,7 @@ static byte get_dungeon_feeling(void)
                int delta = 0;
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Ignore pet */
                if (is_pet(m_ptr)) continue;
@@ -4628,7 +4629,7 @@ static void process_player(void)
                {
                        monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
                        update_monster(m_idx, FALSE);
@@ -4994,7 +4995,7 @@ static void process_player(void)
                                        m_ptr = &current_floor_ptr->m_list[m_idx];
 
                                        /* Skip dead monsters */
-                                       if (!m_ptr->r_idx) continue;
+                                       if (!monster_is_valid(m_ptr)) continue;
 
                                        /* Skip unseen monsters */
                                        if (!m_ptr->ml) continue;
@@ -5028,7 +5029,7 @@ static void process_player(void)
                                        m_ptr = &current_floor_ptr->m_list[m_idx];
 
                                        /* Skip dead monsters */
-                                       if (!m_ptr->r_idx) continue;
+                                       if (!monster_is_valid(m_ptr)) continue;
 
                                        /* Nice monsters get mean */
                                        if (m_ptr->mflag & MFLAG_NICE)
index dbc63d9..c56857d 100644 (file)
@@ -25,6 +25,7 @@
 #include "shoot.h"
 #include "player-move.h"
 #include "patron.h"
+#include "monster-status.h"
 
 
 /*
@@ -4189,7 +4190,7 @@ static void dump_aux_pet(FILE *fff)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
                if (!is_pet(m_ptr)) continue;
                pet_settings = TRUE;
                if (!m_ptr->nickname && (p_ptr->riding != i)) continue;
index 6462f6c..9d153c6 100644 (file)
 #include "quest.h"
 #include "player-status.h"
 #include "wild.h"
+#include "monster-status.h"
 
 int dun_tun_rnd; 
 int dun_tun_chg;
@@ -1175,7 +1176,7 @@ static void generate_gambling_arena(void)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                m_ptr->mflag2 |= (MFLAG2_MARK | MFLAG2_SHOW);
                update_monster(i, FALSE);
index bc8df0f..c2a466a 100644 (file)
@@ -18,6 +18,7 @@
 #include "quest.h"
 #include "wild.h"
 #include "spells-floor.h"
+#include "monster-status.h"
 
 
 static FLOOR_IDX new_floor_id;  /*!<次のフロアのID / floor_id of the destination */
@@ -396,7 +397,7 @@ static void preserve_pet(void)
                {
                        monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
                        if (!is_pet(m_ptr)) continue;
                        if (i == p_ptr->riding) continue;
 
@@ -446,7 +447,7 @@ static void preserve_pet(void)
                        monster_type *m_ptr = &current_floor_ptr->m_list[i];
                        GAME_TEXT m_name[MAX_NLEN];
 
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
                        if (!is_pet(m_ptr)) continue;
                        if (!m_ptr->nickname) continue;
                        if (p_ptr->riding == i) continue;
@@ -497,7 +498,7 @@ void precalc_cur_num_of_pet(void)
                m_ptr = &party_mon[i];
 
                /* Skip empty monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Hack -- Increase the racial counter */
                real_r_ptr(m_ptr)->cur_num++;
@@ -636,8 +637,7 @@ static void update_unique_artifact(s16b cur_floor_id)
                monster_race *r_ptr;
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Extract real monster race */
                r_ptr = real_r_ptr(m_ptr);
@@ -893,8 +893,7 @@ void leave_floor(void)
                monster_race *r_ptr;
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Only maintain quest monsters */
                if (quest_r_idx != m_ptr->r_idx) continue;
@@ -1203,8 +1202,7 @@ void change_floor(void)
                                monster_race *r_ptr;
                                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-                               /* Skip dead monsters */
-                               if (!m_ptr->r_idx) continue;
+                               if (!monster_is_valid(m_ptr)) continue;
 
                                if (!is_pet(m_ptr))
                                {
index cdbd690..c262c58 100644 (file)
@@ -28,6 +28,7 @@
 #include "monster.h"
 #include "quest.h"
 #include "feature.h"
+#include "monster-status.h"
 
 static byte display_autopick; /*!< 自動拾い状態の設定フラグ */
 static int match_autopick;
@@ -3736,7 +3737,7 @@ void update_mon_lite(void)
                        r_ptr = &r_info[m_ptr->r_idx];
 
                        /* Skip dead monsters */
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        /* Is it too far away? */
                        if (m_ptr->cdis > dis_lim) continue;
index 07825b9..824a3e0 100644 (file)
@@ -1970,8 +1970,7 @@ bool make_attack_normal(MONSTER_IDX m_idx)
                int d_dice = r_ptr->blow[ap_cnt].d_dice;
                int d_side = r_ptr->blow[ap_cnt].d_side;
 
-
-               if (!m_ptr->r_idx) break;
+               if (!monster_is_valid(m_ptr)) break;
 
                /* Hack -- no more attacks */
                if (!method) break;
index 0248a68..584b224 100644 (file)
@@ -26,6 +26,7 @@
 #include "feature.h"
 #include "grid.h"
 #include "player-move.h"
+#include "monster-status.h"
 
 
 /*!
@@ -79,8 +80,7 @@ static bool get_enemy_dir(MONSTER_IDX m_idx, int *mm)
                        /* The monster itself isn't a target */
                        if (t_ptr == m_ptr) continue;
 
-                       /* Paranoia -- Skip dead monsters */
-                       if (!t_ptr->r_idx) continue;
+                       if (!monster_is_valid(t_ptr)) continue;
 
                        if (is_pet(m_ptr))
                        {
@@ -1494,7 +1494,7 @@ static bool monst_attack_monst(MONSTER_IDX m_idx, MONSTER_IDX t_idx)
                int d_dice = r_ptr->blow[ap_cnt].d_dice;
                int d_side = r_ptr->blow[ap_cnt].d_side;
 
-               if (!m_ptr->r_idx) break;
+               if (!monster_is_valid(m_ptr)) break;
 
                /* Stop attacking if the target dies! */
                if (t_ptr->fx != x_saver || t_ptr->fy != y_saver)
@@ -2746,7 +2746,7 @@ void process_monster(MONSTER_IDX m_idx)
                                {
                                        cave_alter_feat(ny, nx, FF_BASH);
 
-                                       if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+                                       if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                                        {
                                                /* Update some things */
                                                p_ptr->update |= (PU_FLOW);
@@ -2833,7 +2833,7 @@ void process_monster(MONSTER_IDX m_idx)
                                note_spot(ny, nx);
                                lite_spot(ny, nx);
 
-                               if (!m_ptr->r_idx) return;
+                               if (!monster_is_valid(m_ptr)) return;
                                /* Allow movement */
                                do_move = TRUE;
                        }
@@ -2958,7 +2958,7 @@ void process_monster(MONSTER_IDX m_idx)
 
                        cave_alter_feat(ny, nx, FF_HURT_DISI);
 
-                       if (!m_ptr->r_idx) /* Killed by shards of glass, etc. */
+                       if (!monster_is_valid(m_ptr)) /* Killed by shards of glass, etc. */
                        {
                                /* Update some things */
                                p_ptr->update |= (PU_FLOW);
@@ -3376,7 +3376,7 @@ void process_monsters(void)
                if (p_ptr->leaving) break;
 
                /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                if (p_ptr->wild_mode) continue;
 
index 2a2f9f3..d123d2b 100644 (file)
@@ -76,7 +76,7 @@ static void get_exp_from_mon(HIT_POINT dam, monster_type *m_ptr)
        s32b div_h;
        u32b div_l;
 
-       if (!m_ptr->r_idx) return;
+       if (!monster_is_valid(m_ptr)) return;
        if (is_pet(m_ptr) || p_ptr->inside_battle) return;
 
        /*
@@ -202,7 +202,7 @@ void mproc_init(void)
                m_ptr = &current_floor_ptr->m_list[i];
 
                /* Ignore "dead" monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                for (cmi = 0; cmi < MAX_MTIMED; cmi++)
                {
@@ -800,7 +800,7 @@ bool process_the_world(int num, MONSTER_IDX who, bool vs_player)
 
        while (num--)
        {
-               if (!m_ptr->r_idx) break;
+               if (!monster_is_valid(m_ptr)) break;
                process_monster(current_world_ptr->timewalk_m_idx);
                reset_target(m_ptr);
                handle_stuff();
@@ -841,8 +841,7 @@ void monster_gain_exp(MONSTER_IDX m_idx, IDX s_idx)
 
        m_ptr = &current_floor_ptr->m_list[m_idx];
 
-       /* Paranoia -- Skip dead monsters */
-       if (!m_ptr->r_idx) return;
+       if (!monster_is_valid(m_ptr)) return;
 
        r_ptr = &r_info[m_ptr->r_idx];
        s_ptr = &r_info[s_idx];
@@ -989,7 +988,7 @@ bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
        get_exp_from_mon(expdam, &exp_mon);
 
        /* Genocided by chaos patron */
-       if (!m_ptr->r_idx) m_idx = 0;
+       if (!monster_is_valid(m_ptr)) m_idx = 0;
 
        /* Redraw (later) if needed */
        if (p_ptr->health_who == m_idx) p_ptr->redraw |= (PR_HEALTH);
@@ -1381,3 +1380,7 @@ bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note)
        return (FALSE);
 }
 
+bool monster_is_valid(monster_type *m_ptr)
+{
+       return (!m_ptr->r_idx);
+}
\ No newline at end of file
index f6a88ce..a812521 100644 (file)
@@ -2,4 +2,5 @@
 extern HIT_POINT mon_damage_mod(monster_type *m_ptr, HIT_POINT dam, bool is_psy_spear);
 extern bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note);
 extern int get_mproc_idx(MONSTER_IDX m_idx, int mproc_type);
+extern bool monster_is_valid(monster_type *m_ptr);
 
index 30f39a4..3c7aa5e 100644 (file)
@@ -443,7 +443,7 @@ void compact_monsters(int size)
                        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                        /* Paranoia -- skip "dead" monsters */
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
 
                        /* Hack -- High level monsters start out "immune" */
                        if (r_ptr->level > cur_lev) continue;
@@ -532,9 +532,7 @@ void wipe_m_list(void)
        for (i = m_max - 1; i >= 1; i--)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Monster is gone */
                current_floor_ptr->grid_array[m_ptr->fy][m_ptr->fx].m_idx = 0;
@@ -2626,9 +2624,7 @@ void update_monsters(bool full)
        for (i = 1; i < m_max; i++)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
                update_monster(i, full);
        }
 }
index aeb2b49..3b8f6e9 100644 (file)
@@ -16,6 +16,7 @@
 #include "quest.h"
 #include "realm-hex.h"
 #include "player-move.h"
+#include "monster-status.h"
 
 /*!
  * @brief モンスターが敵対モンスターにビームを当てること可能かを判定する /
@@ -362,8 +363,7 @@ bool monst_spell_monst(MONSTER_IDX m_idx)
                        target_idx = dummy;
                        t_ptr = &current_floor_ptr->m_list[target_idx];
 
-                       /* Skip dead monsters */
-                       if (!t_ptr->r_idx) continue;
+                       if (!monster_is_valid(t_ptr)) continue;
 
                        /* Monster must be 'an enemy' */
                        if ((m_idx == target_idx) || !are_enemies(m_ptr, t_ptr)) continue;
index 6506f52..4acf80a 100644 (file)
@@ -1,5 +1,6 @@
 #include "angband.h"
 #include "spells-summon.h"
+#include "monster-status.h"
 
 /*!
 * @brief トランプ魔法独自の召喚処理を行う / Handle summoning and failure of trump spells
@@ -409,7 +410,7 @@ void mitokohmon(void)
                for (i = m_max - 1; i > 0; i--)
                {
                        m_ptr = &current_floor_ptr->m_list[i];
-                       if (!m_ptr->r_idx) continue;
+                       if (!monster_is_valid(m_ptr)) continue;
                        if (!((m_ptr->r_idx == MON_SUKE) || (m_ptr->r_idx == MON_KAKU))) continue;
                        if (!los(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) continue;
                        if (!projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x)) continue;
index fdb1c71..4eb42be 100644 (file)
@@ -28,6 +28,7 @@
 #include "spells-floor.h"
 #include "realm-hex.h"
 #include "object-hook.h"
+#include "monster-status.h"
 
 /*!
  * @brief プレイヤー周辺の地形を感知する
@@ -373,9 +374,7 @@ bool detect_monsters_normal(POSITION range)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -422,8 +421,7 @@ bool detect_monsters_invis(POSITION range)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-               /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -476,7 +474,7 @@ bool detect_monsters_evil(POSITION range)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -532,7 +530,7 @@ bool detect_monsters_nonliving(POSITION range)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -583,7 +581,7 @@ bool detect_monsters_mind(POSITION range)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -636,7 +634,7 @@ bool detect_monsters_string(POSITION range, concptr Match)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -691,7 +689,7 @@ bool detect_monsters_xxx(POSITION range, u32b match_flag)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -793,7 +791,7 @@ bool project_all_los(EFFECT_ID typ, HIT_POINT dam)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                y = m_ptr->fy;
                x = m_ptr->fx;
@@ -983,7 +981,7 @@ void aggravate_monsters(MONSTER_IDX who)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip aggravating monster (or player) */
                if (i == who) continue;
@@ -1134,7 +1132,7 @@ bool symbol_genocide(int power, bool player_cast)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip "wrong" monsters */
                if (r_ptr->d_char != typ) continue;
@@ -1175,7 +1173,7 @@ bool mass_genocide(int power, bool player_cast)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip distant monsters */
                if (m_ptr->cdis > MAX_SIGHT) continue;
@@ -1218,7 +1216,7 @@ bool mass_genocide_undead(int power, bool player_cast)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                if (!(r_ptr->flags3 & RF3_UNDEAD)) continue;
 
@@ -1264,7 +1262,7 @@ bool probing(void)
                monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Require line of sight */
                if (!player_has_los_bold(m_ptr->fy, m_ptr->fx)) continue;
index daabd33..fe05a6e 100644 (file)
@@ -23,6 +23,7 @@
 #include "artifact.h"
 #include "avatar.h"
 #include "spells-floor.h"
+#include "monster-status.h"
 
 
 /*! テレポート先探索の試行数 / Maximum number of tries for teleporting */
@@ -51,7 +52,7 @@ bool teleport_away(MONSTER_IDX m_idx, POSITION dis, BIT_FLAGS mode)
        monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        /* Paranoia */
-       if (!m_ptr->r_idx) return (FALSE);
+       if (!monster_is_valid(m_ptr)) return (FALSE);
 
        oy = m_ptr->fy;
        ox = m_ptr->fx;
index 9936963..332c542 100644 (file)
@@ -587,7 +587,7 @@ typedef struct monster_type monster_type;
 
 struct monster_type
 {
-       MONRACE_IDX r_idx;              /* Monster race index */
+       MONRACE_IDX r_idx;              /* Monster race index 0 = dead. */
        MONRACE_IDX ap_r_idx;   /* Monster race appearance index */
        byte sub_align;         /* Sub-alignment for a neutral monster */
 
index 6eb70a9..8b1a5e4 100644 (file)
@@ -17,6 +17,7 @@
 #include "realm-hex.h"
 #include "player-status.h"
 #include "grid.h"
+#include "monster-status.h"
 
  /*
   * Wilderness
@@ -1141,7 +1142,7 @@ bool change_wild_mode(void)
        {
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
                if (is_pet(m_ptr) && i != p_ptr->riding) have_pet = TRUE;
                if (MON_CSLEEP(m_ptr)) continue;
                if (m_ptr->cdis > MAX_SIGHT) continue;
index 592589f..1313f4c 100644 (file)
@@ -27,6 +27,7 @@
 #include "spells-floor.h"
 
 #include "object-hook.h"
+#include "monster-status.h"
 
 #ifdef ALLOW_WIZARD
 
@@ -1475,7 +1476,7 @@ static void do_cmd_wiz_zap(void)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip the mount */
                if (i == p_ptr->riding) continue;
@@ -1512,7 +1513,7 @@ static void do_cmd_wiz_zap_all(void)
                monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
                /* Paranoia -- Skip dead monsters */
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
 
                /* Skip the mount */
                if (i == p_ptr->riding) continue;
index 728ae5f..04cf374 100644 (file)
@@ -24,6 +24,7 @@
 #include "mutation.h"
 #include "floor-events.h"
 #include "player-move.h"
+#include "monster-status.h"
 
 #define REWARD_CHANCE 10
 
@@ -494,7 +495,7 @@ bool target_able(MONSTER_IDX m_idx)
        monster_type *m_ptr = &current_floor_ptr->m_list[m_idx];
 
        /* Monster must be alive */
-       if (!m_ptr->r_idx) return (FALSE);
+       if (!monster_is_valid(m_ptr)) return (FALSE);
 
        /* Hack -- no targeting hallucinations */
        if (p_ptr->image) return (FALSE);