OSDN Git Service

[Refactor] #37353 コメント整理 / Refactor comments.
[hengband/hengband.git] / src / monster2.c
index f5d71f1..7e40dfb 100644 (file)
@@ -11,6 +11,9 @@
  */
 
 #include "angband.h"
+#include "cmd-pet.h"
+#include "monster-hook.h"
+#include "monster-status.h"
 
 #define HORDE_NOGOOD 0x01 /*!< (未実装フラグ)HORDE生成でGOODなモンスターの生成を禁止する? */
 #define HORDE_NOEVIL 0x02 /*!< (未実装フラグ)HORDE生成でEVILなモンスターの生成を禁止する? */
@@ -169,7 +172,7 @@ cptr funny_comments[MAX_SAN_COMMENT] =
  * @param x 目標x座標
  * @return なし
  */
-void set_target(monster_type *m_ptr, int y, int x)
+void set_target(monster_type *m_ptr, POSITION y, POSITION x)
 {
        m_ptr->target_y = y;
        m_ptr->target_x = x;
@@ -221,20 +224,15 @@ monster_race *real_r_ptr(monster_type *m_ptr)
  */
 void delete_monster_idx(MONSTER_IDX i)
 {
-       int x, y;
-
+       POSITION x, y;
        monster_type *m_ptr = &m_list[i];
-
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Get location */
        y = m_ptr->fy;
        x = m_ptr->fx;
 
-
        /* Hack -- Reduce the racial counter */
        real_r_ptr(m_ptr)->cur_num--;
 
@@ -268,8 +266,6 @@ void delete_monster_idx(MONSTER_IDX i)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -280,7 +276,6 @@ void delete_monster_idx(MONSTER_IDX i)
                 * to prevent calling lite_spot()
                 */
 
-               /* Delete the object */
                delete_object_idx(this_o_idx);
        }
 
@@ -332,23 +327,18 @@ void delete_monster(POSITION y, POSITION x)
  */
 static void compact_monsters_aux(IDX i1, IDX i2)
 {
-       int y, x, i;
-
+       POSITION y, x;
+       int i;
        cave_type *c_ptr;
-
        monster_type *m_ptr;
-
-       s16b this_o_idx, next_o_idx = 0;
-
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
 
        /* Do nothing */
        if (i1 == i2) return;
 
-
        /* Old monster */
        m_ptr = &m_list[i1];
 
-       /* Location */
        y = m_ptr->fy;
        x = m_ptr->fx;
 
@@ -362,8 +352,6 @@ static void compact_monsters_aux(IDX i1, IDX i2)
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
                object_type *o_ptr;
-
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -478,12 +466,10 @@ void compact_monsters(int size)
                        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                        {
                                char m_name[80];
-
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
                        }
 
-                       /* Delete the monster */
                        delete_monster_idx(i);
 
                        /* Count the monster */
@@ -597,7 +583,6 @@ MONSTER_IDX m_pop(void)
 {
        MONSTER_IDX i;
 
-
        /* Normal allocation */
        if (m_max < max_m_idx)
        {
@@ -614,7 +599,6 @@ MONSTER_IDX m_pop(void)
                return (i);
        }
 
-
        /* Recycle dead monsters */
        for (i = 1; i < m_max; i++)
        {
@@ -633,7 +617,6 @@ MONSTER_IDX m_pop(void)
                return (i);
        }
 
-
        /* Warn the player (except during dungeon creation) */
        if (character_dungeon) msg_print(_("モンスターが多すぎる!", "Too many monsters!"));
 
@@ -961,8 +944,6 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
                        break;
                }
        }
-
-       /* Result */
        /* Since okay is int, "return (okay);" is not correct. */
        return (bool)(okay ? TRUE : FALSE);
 }
@@ -1454,8 +1435,6 @@ MONRACE_IDX get_mon_num(DEPTH level)
                /* Keep the "best" one */
                if (table[i].level < table[j].level) i = j;
        }
-
-       /* Result */
        return (table[i].index);
 }
 
@@ -1898,7 +1877,6 @@ int lore_do_probe(MONRACE_IDX r_idx)
        /* Update monster recall window */
        if (p_ptr->monster_race_idx == r_idx)
        {
-               /* Window stuff */
                p_ptr->window |= (PW_MONSTER);
        }
 
@@ -1944,7 +1922,6 @@ void lore_treasure(MONSTER_IDX m_idx, ITEM_NUMBER num_item, ITEM_NUMBER num_gold
        /* Update monster recall window */
        if (p_ptr->monster_race_idx == m_ptr->r_idx)
        {
-               /* Window stuff */
                p_ptr->window |= (PW_MONSTER);
        }
 }
@@ -1985,7 +1962,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
                        return; /* Cannot see it for some reason */
 
                if (!(r_ptr->flags2 & RF2_ELDRITCH_HORROR))
-                       return; /* oops */
+                       return;
 
                if (is_pet(m_ptr))
                        return; /* Pet eldritch horrors are safe most of the time */
@@ -2301,7 +2278,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
  * "disturb_near" (monster which is "easily" viewable moves in some
  * way).  Note that "moves" includes "appears" and "disappears".
  */
-void update_mon(MONSTER_IDX m_idx, bool full)
+void update_monster(MONSTER_IDX m_idx, bool full)
 {
        monster_type *m_ptr = &m_list[m_idx];
 
@@ -2620,7 +2597,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (disturb_near && (projectable(m_ptr->fy, m_ptr->fx, p_ptr->y, p_ptr->x) && projectable(p_ptr->y, p_ptr->x, m_ptr->fy, m_ptr->fx)))
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2645,7 +2622,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2664,7 +2641,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2682,7 +2659,7 @@ void update_mon(MONSTER_IDX m_idx, bool full)
                        if (do_disturb)
                        {
                                if (disturb_pets || is_hostile(m_ptr))
-                                       disturb(1, 1);
+                                       disturb(TRUE, TRUE);
                        }
                }
        }
@@ -2705,9 +2682,7 @@ void update_monsters(bool full)
 
                /* Skip dead monsters */
                if (!m_ptr->r_idx) continue;
-
-               /* Update the monster */
-               update_mon(i, full);
+               update_monster(i, full);
        }
 }
 
@@ -2810,7 +2785,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        if (!r_idx)
        {
-               int level;
+               DEPTH level;
 
                chameleon_change_m_idx = m_idx;
                if (old_unique)
@@ -2840,7 +2815,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        m_ptr->r_idx = r_idx;
        m_ptr->ap_r_idx = r_idx;
-       update_mon(m_idx, FALSE);
+       update_monster(m_idx, FALSE);
        lite_spot(m_ptr->fy, m_ptr->fx);
 
        if ((r_info[old_r_idx].flags7 & (RF7_LITE_MASK | RF7_DARK_MASK)) ||
@@ -2988,10 +2963,10 @@ byte get_mspeed(monster_race *r_ptr)
  *
  * This routine refuses to place out-of-depth "FORCE_DEPTH" monsters.
  *
- * XXX XXX XXX Use special "here" and "dead" flags for unique monsters,
+ * Use special "here" and "dead" flags for unique monsters,
  * remove old "cur_num" and "max_num" fields.
  *
- * XXX XXX XXX Actually, do something similar for artifacts, to simplify
+ * Actually, do something similar for artifacts, to simplify
  * the "preserve" mode, and to make the "what artifacts" flag more useful.
  *
  * This is the only function which may place a monster in the dungeon,
@@ -3099,7 +3074,6 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                        c_ptr->info &= ~(CAVE_OBJECT);
                        c_ptr->mimic = 0;
 
-                       /* Notice */
                        note_spot(y, x);
                }
                else return FALSE;
@@ -3287,9 +3261,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                p_ptr->update |= (PU_MON_LITE);
        else if ((r_ptr->flags7 & RF7_HAS_LD_MASK) && !MON_CSLEEP(m_ptr))
                p_ptr->update |= (PU_MON_LITE);
-
-       /* Update the monster */
-       update_mon(c_ptr->m_idx, TRUE);
+       update_monster(c_ptr->m_idx, TRUE);
 
 
        /* Count the monsters on the level */
@@ -3463,8 +3435,6 @@ static bool mon_scatter(MONRACE_IDX r_idx, POSITION *yp, POSITION *xp, POSITION
        return TRUE;
 }
 
-#define GROUP_MAX 32 /*!< place_monster_group() 関数によるモンスターのGROUP生成時の配置最大数 / Maximum size of a group of monsters */
-
 /*!
  * @brief モンスターを目標地点に集団生成する / Attempt to place a "group" of monsters around the given location
  * @param who 召喚主のモンスター情報ID
@@ -3607,7 +3577,6 @@ static bool place_monster_can_escort(MONRACE_IDX r_idx)
        if ((r_ptr->flags7 & RF7_CHAMELEON) && !(z_ptr->flags7 & RF7_CHAMELEON))
                return FALSE;
 
-       /* Okay */
        return (TRUE);
 }
 
@@ -3739,13 +3708,9 @@ bool place_monster(POSITION y, POSITION x, BIT_FLAGS mode)
        /* Attempt to place the monster */
        if (place_monster_aux(0, y, x, r_idx, mode)) return (TRUE);
 
-       /* Oops */
        return (FALSE);
 }
 
-
-#ifdef MONSTER_HORDES
-
 /*!
  * @brief 指定地点に1種類のモンスター種族による群れを生成する
  * @param y 生成地点y座標
@@ -3809,9 +3774,6 @@ bool alloc_horde(POSITION y, POSITION x)
        return TRUE;
 }
 
-#endif /* MONSTER_HORDES */
-
-
 /*!
  * @brief ダンジョンの主生成を試みる / Put the Guardian
  * @param def_val 現在の主の生成状態
@@ -3862,10 +3824,10 @@ bool alloc_guardian(bool def_val)
  * Use "slp" to choose the initial "sleep" status
  * Use "monster_level" for the monster level
  */
-bool alloc_monster(int dis, BIT_FLAGS mode)
+bool alloc_monster(POSITION dis, BIT_FLAGS mode)
 {
-       int                     y = 0, x = 0;
-       int         attempts_left = 10000;
+       int y = 0, x = 0;
+       int attempts_left = 10000;
 
        /* Put the Guardian */
        if (alloc_guardian(FALSE)) return TRUE;
@@ -3902,7 +3864,6 @@ bool alloc_monster(int dis, BIT_FLAGS mode)
        }
 
 
-#ifdef MONSTER_HORDES
        if (randint1(5000) <= dun_level)
        {
                if (alloc_horde(y, x))
@@ -3913,16 +3874,10 @@ bool alloc_monster(int dis, BIT_FLAGS mode)
        }
        else
        {
-#endif /* MONSTER_HORDES */
-
                /* Attempt to place the monster, allow groups */
                if (place_monster(y, x, (mode | PM_ALLOW_GROUP))) return (TRUE);
-
-#ifdef MONSTER_HORDES
        }
-#endif /* MONSTER_HORDES */
 
-       /* Nope */
        return (FALSE);
 }
 
@@ -4469,7 +4424,6 @@ void update_smart_learn(MONSTER_IDX m_idx, int what)
        if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
 
 
-       /* XXX XXX XXX */
 
        /* Analyze the knowledge */
        switch (what)
@@ -4590,7 +4544,7 @@ bool player_place(POSITION y, POSITION x)
  */
 void monster_drop_carried_objects(monster_type *m_ptr)
 {
-       s16b this_o_idx, next_o_idx = 0;
+       OBJECT_IDX this_o_idx, next_o_idx = 0;
        object_type forge;
        object_type *o_ptr;
        object_type *q_ptr;
@@ -4599,7 +4553,6 @@ void monster_drop_carried_objects(monster_type *m_ptr)
        /* Drop objects being carried */
        for (this_o_idx = m_ptr->hold_o_idx; this_o_idx; this_o_idx = next_o_idx)
        {
-               /* Acquire object */
                o_ptr = &o_list[this_o_idx];
 
                /* Acquire next object */
@@ -4614,7 +4567,6 @@ void monster_drop_carried_objects(monster_type *m_ptr)
                /* Forget monster */
                q_ptr->held_m_idx = 0;
 
-               /* Delete the object */
                delete_object_idx(this_o_idx);
 
                /* Drop it */