OSDN Git Service

[Refactor] #37353 マジックナンバー修正(A_MAX) / Fix magic number (A_MAX).
[hengband/hengband.git] / src / monster2.c
index 1dbb5a2..3b49643 100644 (file)
@@ -468,7 +468,7 @@ void compact_monsters(int size)
 
                        if (record_named_pet && is_pet(m_ptr) && m_ptr->nickname)
                        {
-                               char m_name[80];
+                               GAME_TEXT m_name[MAX_NLEN];
                                monster_desc(m_name, m_ptr, MD_INDEF_VISIBLE);
                                do_cmd_write_nikki(NIKKI_NAMED_PET, RECORD_NAMED_PET_COMPACT, m_name);
                        }
@@ -793,7 +793,6 @@ static bool summon_specific_aux(MONRACE_IDX r_idx)
                        break;
                }
 
-
                case SUMMON_KIN:
                {
                        okay = ((r_ptr->d_char == summon_kin_type) && (r_idx != MON_HAGURE));
@@ -1170,7 +1169,7 @@ errr get_mon_num_prep(monsterrace_hook_type monster_hook,
        /* Scan the allocation table */
        for (i = 0; i < alloc_race_size; i++)
        {
-               monster_race    *r_ptr;
+               monster_race *r_ptr;
                
                /* Get the entry */
                alloc_entry *entry = &alloc_race_table[i];
@@ -1462,7 +1461,7 @@ void monster_desc(char *desc, monster_type *m_ptr, BIT_FLAGS mode)
 
        cptr            name;
        char            buf[128];
-       char            silly_name[1024];
+       GAME_TEXT silly_name[1024];
        bool            seen, pron;
        bool            named = FALSE;
 
@@ -1904,7 +1903,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
 
        if (!necro && m_ptr)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_race *r_ptr = &r_info[m_ptr->ap_r_idx];
 
                power = r_ptr->level / 2;
@@ -1983,7 +1982,7 @@ void sanity_blast(monster_type *m_ptr, bool necro)
        else if(!necro)
        {
                monster_race *r_ptr;
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                cptr desc;
 
                get_mon_num_prep(get_nightmare, NULL);
@@ -2473,7 +2472,6 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                /* Handle "cold blooded" monsters */
                                if ((r_ptr->flags2 & (RF2_COLD_BLOOD | RF2_AURA_FIRE)) == RF2_COLD_BLOOD)
                                {
-                                       /* Take note */
                                        do_cold_blood = TRUE;
                                }
 
@@ -2491,7 +2489,6 @@ void update_monster(MONSTER_IDX m_idx, bool full)
                                /* Handle "invisible" monsters */
                                if (r_ptr->flags2 & (RF2_INVISIBLE))
                                {
-                                       /* Take note */
                                        do_invisible = TRUE;
 
                                        /* See invisible */
@@ -2734,7 +2731,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
        int oldmaxhp;
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr;
-       char old_m_name[80];
+       char old_m_name[MAX_NLEN];
        bool old_unique = FALSE;
        int old_r_idx = m_ptr->r_idx;
 
@@ -2800,7 +2797,7 @@ void choose_new_monster(MONSTER_IDX m_idx, bool born, MONRACE_IDX r_idx)
 
        if (m_idx == p_ptr->riding)
        {
-               char m_name[80];
+               GAME_TEXT m_name[MAX_NLEN];
                monster_desc(m_name, m_ptr, 0);
                msg_format(_("突然%sが変身した。", "Suddenly, %s transforms!"), old_m_name);
                if (!(r_ptr->flags7 & RF7_RIDING))
@@ -3253,7 +3250,7 @@ static bool place_monster_one(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_I
                {
                        cptr color;
                        object_type *o_ptr;
-                       char o_name[MAX_NLEN];
+                       GAME_TEXT o_name[MAX_NLEN];
 
                        if (r_ptr->level > p_ptr->lev + 30)
                                color = _("黒く", "black");
@@ -3584,7 +3581,7 @@ bool place_monster_aux(MONSTER_IDX who, POSITION y, POSITION x, MONRACE_IDX r_id
        place_monster_m_idx = hack_m_idx_ii;
 
        /* Reinforcement */
-       for(i = 0; i < 6; i++)
+       for(i = 0; i < A_MAX; i++)
        {
                if(!r_ptr->reinforce_id[i]) break;
                n = damroll(r_ptr->reinforce_dd[i], r_ptr->reinforce_ds[i]);
@@ -3721,18 +3718,18 @@ bool alloc_horde(POSITION y, POSITION x)
        m_idx = cave[y][x].m_idx;
 
        if (m_list[m_idx].mflag2 & MFLAG2_CHAMELEON) r_ptr = &r_info[m_list[m_idx].r_idx];
-       summon_kin_type = r_ptr->d_char;
 
        for (attempts = randint1(10) + 5; attempts; attempts--)
        {
                scatter(&cy, &cx, y, x, 5, 0);
 
-               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP);
+               (void)summon_specific(m_idx, cy, cx, dun_level + 5, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
 
                y = cy;
                x = cx;
        }
 
+       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), r_ptr->d_char);
        return TRUE;
 }
 
@@ -3830,7 +3827,6 @@ bool alloc_monster(POSITION dis, BIT_FLAGS mode)
        {
                if (alloc_horde(y, x))
                {
-                       if (cheat_hear) msg_format(_("モンスターの大群(%c)", "Monster horde (%c)."), summon_kin_type);
                        return (TRUE);
                }
        }
@@ -3923,7 +3919,7 @@ static bool summon_specific_okay(MONRACE_IDX r_idx)
  *
  * Note that this function may not succeed, though this is very rare.
  */
-bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode)
+bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int type, BIT_FLAGS mode, SYMBOL_CODE symbol)
 {
        POSITION x, y;
        MONRACE_IDX r_idx;
@@ -3938,6 +3934,8 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
        /* Save the "summon" type */
        summon_specific_type = type;
 
+       summon_kin_type = symbol;
+
        summon_unique_okay = (mode & PM_ALLOW_UNIQUE) ? TRUE : FALSE;
 
        /* Prepare allocation table */
@@ -3978,7 +3976,7 @@ bool summon_specific(MONSTER_IDX who, POSITION y1, POSITION x1, DEPTH lev, int t
  * @param mode 生成オプション 
  * @return 召喚できたらtrueを返す
  */
-bool summon_named_creature (MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
+bool summon_named_creature(MONSTER_IDX who, POSITION oy, POSITION ox, MONRACE_IDX r_idx, BIT_FLAGS mode)
 {
        POSITION x, y;
 
@@ -4043,15 +4041,15 @@ bool multiply_monster(MONSTER_IDX m_idx, bool clone, BIT_FLAGS mode)
  */
 void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 {
-       long oldhp, newhp, tmp;
-       int percentage;
+       HIT_POINT oldhp, newhp;
+       HIT_POINT tmp;
+       PERCENTAGE percentage;
 
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-       char m_name[80];
+       GAME_TEXT m_name[MAX_NLEN];
 
-       /* Get the monster name */
        monster_desc(m_name, m_ptr, 0);
 
        if(dam == 0) // Notice non-damage
@@ -4061,10 +4059,10 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
        }
 
        /* Note -- subtle fix -CFT */
-       newhp = (long)(m_ptr->hp);
-       oldhp = newhp + (long)(dam);
+       newhp = m_ptr->hp;
+       oldhp = newhp + dam;
        tmp = (newhp * 100L) / oldhp;
-       percentage = (int)(tmp);
+       percentage = tmp;
 
        if(my_strchr(",ejmvwQ", r_ptr->d_char)) // Mushrooms, Eyes, Jellies, Molds, Vortices, Worms, Quylthulgs
        {
@@ -4372,10 +4370,8 @@ void message_pain(MONSTER_IDX m_idx, HIT_POINT dam)
 void update_smart_learn(MONSTER_IDX m_idx, int what)
 {
        monster_type *m_ptr = &m_list[m_idx];
-
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
 
-
        /* Not allowed to learn */
        if (!smart_learn) return;
 
@@ -4385,8 +4381,6 @@ void update_smart_learn(MONSTER_IDX m_idx, int what)
        /* Not intelligent, only learn sometimes */
        if (!(r_ptr->flags2 & (RF2_SMART)) && (randint0(100) < 50)) return;
 
-
-
        /* Analyze the knowledge */
        switch (what)
        {