OSDN Git Service

[Refactor] #37353 summon_specific() が可能な限りグローバル変数 summon_kin_type にアクセスしないように修正。...
authorDeskull <deskull@users.sourceforge.jp>
Fri, 4 Jan 2019 10:43:24 +0000 (19:43 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Fri, 4 Jan 2019 10:43:24 +0000 (19:43 +0900)
src/monster2.c
src/mspells4.c
src/spells-summon.c

index 3646903..6707d22 100644 (file)
@@ -3718,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, '\0');
+               (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;
 }
 
@@ -3827,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);
                }
        }
@@ -3935,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 */
index acfe7fe..0e29eea 100644 (file)
@@ -2667,11 +2667,10 @@ MONSTER_NUMBER summon_Kin(POSITION y, POSITION x, int rlev, MONSTER_IDX m_idx)
        int k, count = 0;
        monster_type    *m_ptr = &m_list[m_idx];
        monster_race    *r_ptr = &r_info[m_ptr->r_idx];
-       summon_kin_type = r_ptr->d_char; /* Big hack */
 
        for (k = 0; k < 4; k++)
        {
-               count += summon_specific(m_idx, y, x, rlev, SUMMON_KIN, PM_ALLOW_GROUP, '\0');
+               count += summon_specific(m_idx, y, x, rlev, SUMMON_KIN, PM_ALLOW_GROUP, r_ptr->d_char);
        }
        return count;
 }
index d3d305a..4b1ea0a 100644 (file)
@@ -176,6 +176,7 @@ bool cast_summon_greater_demon(void)
 bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)\r
 {\r
        bool pet = (bool)(mode & PM_FORCE_PET);\r
+       SYMBOL_CODE symbol = '\0';\r
        if (!pet) mode |= PM_NO_PET;\r
 \r
        switch (p_ptr->mimic_form)\r
@@ -188,7 +189,7 @@ bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
                case RACE_BARBARIAN:\r
                case RACE_BEASTMAN:\r
                case RACE_DUNADAN:\r
-                       summon_kin_type = 'p';\r
+                       symbol = 'p';\r
                        break;\r
                case RACE_HALF_ELF:\r
                case RACE_ELF:\r
@@ -201,82 +202,82 @@ bool summon_kin_player(DEPTH level, POSITION y, POSITION x, BIT_FLAGS mode)
                case RACE_MIND_FLAYER:\r
                case RACE_KUTAR:\r
                case RACE_S_FAIRY:\r
-                       summon_kin_type = 'h';\r
+                       symbol = 'h';\r
                        break;\r
                case RACE_HALF_ORC:\r
-                       summon_kin_type = 'o';\r
+                       symbol = 'o';\r
                        break;\r
                case RACE_HALF_TROLL:\r
-                       summon_kin_type = 'T';\r
+                       symbol = 'T';\r
                        break;\r
                case RACE_HALF_OGRE:\r
-                       summon_kin_type = 'O';\r
+                       symbol = 'O';\r
                        break;\r
                case RACE_HALF_GIANT:\r
                case RACE_HALF_TITAN:\r
                case RACE_CYCLOPS:\r
-                       summon_kin_type = 'P';\r
+                       symbol = 'P';\r
                        break;\r
                case RACE_YEEK:\r
-                       summon_kin_type = 'y';\r
+                       symbol = 'y';\r
                        break;\r
                case RACE_KLACKON:\r
-                       summon_kin_type = 'K';\r
+                       symbol = 'K';\r
                        break;\r
                case RACE_KOBOLD:\r
-                       summon_kin_type = 'k';\r
+                       symbol = 'k';\r
                        break;\r
                case RACE_IMP:\r
-                       if (one_in_(13)) summon_kin_type = 'U';\r
-                       else summon_kin_type = 'u';\r
+                       if (one_in_(13)) symbol = 'U';\r
+                       else symbol = 'u';\r
                        break;\r
                case RACE_DRACONIAN:\r
-                       summon_kin_type = 'd';\r
+                       symbol = 'd';\r
                        break;\r
                case RACE_GOLEM:\r
                case RACE_ANDROID:\r
-                       summon_kin_type = 'g';\r
+                       symbol = 'g';\r
                        break;\r
                case RACE_SKELETON:\r
-                       if (one_in_(13)) summon_kin_type = 'L';\r
-                       else summon_kin_type = 's';\r
+                       if (one_in_(13)) symbol = 'L';\r
+                       else symbol = 's';\r
                        break;\r
                case RACE_ZOMBIE:\r
-                       summon_kin_type = 'z';\r
+                       symbol = 'z';\r
                        break;\r
                case RACE_VAMPIRE:\r
-                       summon_kin_type = 'V';\r
+                       symbol = 'V';\r
                        break;\r
                case RACE_SPECTRE:\r
-                       summon_kin_type = 'G';\r
+                       symbol = 'G';\r
                        break;\r
                case RACE_SPRITE:\r
-                       summon_kin_type = 'I';\r
+                       symbol = 'I';\r
                        break;\r
                case RACE_ENT:\r
-                       summon_kin_type = '#';\r
+                       symbol = '#';\r
                        break;\r
                case RACE_ANGEL:\r
-                       summon_kin_type = 'A';\r
+                       symbol = 'A';\r
                        break;\r
                case RACE_DEMON:\r
-                       summon_kin_type = 'U';\r
+                       symbol = 'U';\r
                        break;\r
                default:\r
-                       summon_kin_type = 'p';\r
+                       symbol = 'p';\r
                        break;\r
                }\r
                break;\r
        case MIMIC_DEMON:\r
-               if (one_in_(13)) summon_kin_type = 'U';\r
-               else summon_kin_type = 'u';\r
+               if (one_in_(13)) symbol = 'U';\r
+               else symbol = 'u';\r
                break;\r
        case MIMIC_DEMON_LORD:\r
-               summon_kin_type = 'U';\r
+               symbol = 'U';\r
                break;\r
        case MIMIC_VAMPIRE:\r
-               summon_kin_type = 'V';\r
+               symbol = 'V';\r
                break;\r
        }\r
-       return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode, '\0');\r
+       return summon_specific((pet ? -1 : 0), y, x, level, SUMMON_KIN, mode, symbol);\r
 }\r