OSDN Git Service

通常のセーブ/ロード時以外でc_ptr->mimicに0以外の値を代入する際に, 最
[hengband/hengband.git] / src / rooms.c
index c0e33db..87c8aeb 100644 (file)
@@ -67,10 +67,10 @@ static void place_secret_door(int y, int x)
                place_closed_door(y, x);
 
                /* Hide by inner wall because this is used in rooms only */
-               c_ptr->mimic = feat_wall_inner;
+               c_ptr->mimic = f_info[feat_wall_inner].mimic;
 
                /* Floor type terrain cannot hide a door */
-               if (!(c_ptr->mimic & 0x20))
+               if (feat_floor(c_ptr->mimic))
                {
                        c_ptr->feat = c_ptr->mimic;
                        c_ptr->mimic = 0;
@@ -745,7 +745,7 @@ static void build_type3(int by0, int bx0)
                        }
 
                        /* Place a treasure in the vault */
-                       place_object(yval, xval, FALSE, FALSE);
+                       place_object(yval, xval, 0L);
 
                        /* Let's guard the treasure well */
                        vault_monsters(yval, xval, randint0(2) + 3);
@@ -961,7 +961,7 @@ static void build_type4(int by0, int bx0)
                        /* Object (80%) */
                        if (randint0(100) < 80)
                        {
-                               place_object(yval, xval, FALSE, FALSE);
+                               place_object(yval, xval, 0L);
                        }
 
                        /* Stairs (20%) */
@@ -1044,8 +1044,8 @@ static void build_type4(int by0, int bx0)
                                vault_monsters(yval, xval + 2, randint1(2));
 
                                /* Objects */
-                               if (one_in_(3)) place_object(yval, xval - 2, FALSE, FALSE);
-                               if (one_in_(3)) place_object(yval, xval + 2, FALSE, FALSE);
+                               if (one_in_(3)) place_object(yval, xval - 2, 0L);
+                               if (one_in_(3)) place_object(yval, xval + 2, 0L);
                        }
 
                        break;
@@ -1158,7 +1158,7 @@ static void build_type4(int by0, int bx0)
        (monster_dungeon(I) && \
         !(r_info[I].flags1 & RF1_UNIQUE) && \
         !(r_info[I].flags7 & RF7_UNIQUE2) && \
-        !(r_info[I].flags3 & RF3_RES_ALL) && \
+        !(r_info[I].flagsr & RFR_RES_ALL) && \
         !(r_info[I].flags7 & RF7_AQUATIC))
 
 
@@ -1192,7 +1192,7 @@ static bool vault_aux_jelly(int r_idx)
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
-       if (r_ptr->flags2 & (RF2_KILL_BODY)) return (FALSE);
+       if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
 
        /* Also decline evil jellies (like death molds and shoggoths) */
        if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
@@ -1330,7 +1330,7 @@ static bool vault_aux_symbol_e(int r_idx)
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
-       if (r_ptr->flags2 & (RF2_KILL_BODY)) return (FALSE);
+       if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
 
        if (r_ptr->flags3 & (RF3_GOOD)) return (FALSE);
 
@@ -1352,7 +1352,7 @@ static bool vault_aux_symbol_g(int r_idx)
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
-       if (r_ptr->flags2 & (RF2_KILL_BODY)) return (FALSE);
+       if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
 
        if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
 
@@ -1463,7 +1463,7 @@ static bool vault_aux_demon(int r_idx)
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
-       if (r_ptr->flags2 & (RF2_KILL_BODY)) return (FALSE);
+       if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
 
        /* Require demon */
        if (!(r_ptr->flags3 & RF3_DEMON)) return (FALSE);
@@ -1483,7 +1483,7 @@ static bool vault_aux_cthulhu(int r_idx)
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
-       if (r_ptr->flags2 & (RF2_KILL_BODY)) return (FALSE);
+       if ((r_ptr->flags2 & RF2_KILL_BODY) && !(r_ptr->flags1 & RF1_NEVER_BLOW)) return (FALSE);
 
        /* Require eldritch horror */
        if (!(r_ptr->flags2 & (RF2_ELDRITCH_HORROR))) return (FALSE);
@@ -1927,7 +1927,7 @@ static void build_type5(int by0, int bx0, bool pit)
        int i;
        nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
 
-       int align = 0;
+       monster_type align;
 
        cave_type *c_ptr;
 
@@ -2031,22 +2031,22 @@ static void build_type5(int by0, int bx0, bool pit)
        /* Prepare allocation table */
        get_mon_num_prep(n_ptr->hook_func, NULL);
 
+       align.sub_align = SUB_ALIGN_NEUTRAL;
+
        /* Pick some monster types */
        for (i = 0; i < NUM_NEST_MON_TYPE; i++)
        {
                int r_idx = 0, attempts = 100;
+               monster_race *r_ptr = NULL;
 
                while (attempts--)
                {
                        /* Get a (hard) monster type */
                        r_idx = get_mon_num(dun_level + 10);
+                       r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (((align < 0) && (r_info[r_idx].flags3 & RF3_GOOD)) ||
-                                ((align > 0) && (r_info[r_idx].flags3 & RF3_EVIL)))
-                       {
-                               continue;
-                       }
+                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;
@@ -2056,8 +2056,8 @@ static void build_type5(int by0, int bx0, bool pit)
                if (!r_idx || !attempts) return;
 
                /* Note the alignment */
-               if (r_info[r_idx].flags3 & RF3_GOOD) align++;
-               else if (r_info[r_idx].flags3 & RF3_EVIL) align--;
+               if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
+               if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
 
                nest_mon_info[i].r_idx = r_idx;
                nest_mon_info[i].used = FALSE;
@@ -2164,7 +2164,7 @@ static void build_type6(int by0, int bx0, bool nest)
 
        int what[16];
 
-       int align = 0;
+       monster_type align;
 
        cave_type *c_ptr;
 
@@ -2265,22 +2265,22 @@ static void build_type6(int by0, int bx0, bool nest)
        /* Prepare allocation table */
        get_mon_num_prep(n_ptr->hook_func, NULL);
 
+       align.sub_align = SUB_ALIGN_NEUTRAL;
+
        /* Pick some monster types */
        for (i = 0; i < 16; i++)
        {
                int r_idx = 0, attempts = 100;
+               monster_race *r_ptr = NULL;
 
                while (attempts--)
                {
                        /* Get a (hard) monster type */
                        r_idx = get_mon_num(dun_level + 10);
+                       r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (((align < 0) && (r_info[r_idx].flags3 & RF3_GOOD)) ||
-                                ((align > 0) && (r_info[r_idx].flags3 & RF3_EVIL)))
-                       {
-                               continue;
-                       }
+                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;
@@ -2290,8 +2290,8 @@ static void build_type6(int by0, int bx0, bool nest)
                if (!r_idx || !attempts) return;
 
                /* Note the alignment */
-               if (r_info[r_idx].flags3 & RF3_GOOD) align++;
-               else if (r_info[r_idx].flags3 & RF3_EVIL) align--;
+               if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
+               if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
 
                what[i] = r_idx;
        }
@@ -2515,7 +2515,7 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                        case '*':
                                if (randint0(100) < 75)
                                {
-                                       place_object(y, x, FALSE, FALSE);
+                                       place_object(y, x, 0L);
                                }
                                else
                                {
@@ -2571,7 +2571,7 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                        case 'A':
                                /* Reward for Pattern walk */
                                object_level = base_level + 12;
-                               place_object(y, x, TRUE, FALSE);
+                               place_object(y, x, AM_GOOD | AM_GREAT);
                                object_level = base_level;
                                break;
                        }
@@ -2636,7 +2636,7 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                                        place_monster(y, x, PM_ALLOW_SLEEP);
                                        monster_level = base_level;
                                        object_level = base_level + 7;
-                                       place_object(y, x, TRUE, FALSE);
+                                       place_object(y, x, AM_GOOD);
                                        object_level = base_level;
                                        break;
                                }
@@ -2648,7 +2648,7 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                                        place_monster(y, x, PM_ALLOW_SLEEP);
                                        monster_level = base_level;
                                        object_level = base_level + 20;
-                                       place_object(y, x, TRUE, TRUE);
+                                       place_object(y, x, AM_GOOD | AM_GREAT);
                                        object_level = base_level;
                                        break;
                                }
@@ -2665,7 +2665,7 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                                        if (randint0(100) < 50)
                                        {
                                                object_level = base_level + 7;
-                                               place_object(y, x, FALSE, FALSE);
+                                               place_object(y, x, 0L);
                                                object_level = base_level;
                                        }
                                        break;
@@ -3892,7 +3892,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
                                        place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        monster_level = base_level;
                                        object_level = base_level + 20;
-                                       place_object(y, x, TRUE, FALSE);
+                                       place_object(y, x, AM_GOOD);
                                        object_level = base_level;
                                }
                                else if (value < 5)
@@ -3902,7 +3902,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
                                        place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        monster_level = base_level;
                                        object_level = base_level + 10;
-                                       place_object(y, x, TRUE, FALSE);
+                                       place_object(y, x, AM_GOOD);
                                        object_level = base_level;
                                }
                                else if (value < 10)
@@ -3928,7 +3928,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
                                        /* Object or trap */
                                        if (randint0(100) < 25)
                                        {
-                                               place_object(y, x, FALSE, FALSE);
+                                               place_object(y, x, 0L);
                                        }
                                        else
                                        {
@@ -3955,7 +3955,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
                                        if (randint0(100) < 50)
                                        {
                                                object_level = base_level + 7;
-                                               place_object(y, x, FALSE, FALSE);
+                                               place_object(y, x, 0L);
                                                object_level = base_level;
                                        }
                                }
@@ -3979,7 +3979,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
                                        }
                                        else if (randint0(100) < 50)
                                        {
-                                               place_object(y, x, FALSE, FALSE);
+                                               place_object(y, x, 0L);
                                        }
                                }
 
@@ -5314,7 +5314,7 @@ static void build_type12(int by0, int bx0)
                build_small_room(x0, y0);
 
                /* Place a treasure in the vault */
-               place_object(y0, x0, FALSE, FALSE);
+               place_object(y0, x0, 0L);
 
                /* Let's guard the treasure well */
                vault_monsters(y0, x0, randint0(2) + 3);
@@ -5423,7 +5423,7 @@ static void build_type13(int by0, int bx0)
 
        int what[16];
 
-       int align = 0;
+       monster_type align;
 
        cave_type *c_ptr;
 
@@ -5540,29 +5540,31 @@ static void build_type13(int by0, int bx0)
                }
        }
 
+       /* Pre-apply default mimic field */
+       cave[yval][xval].mimic = f_info[cave[yval][xval].feat].mimic;
+
        /* Place the wall open trap */
-       cave[yval][xval].mimic = cave[yval][xval].feat;
        cave[yval][xval].feat = FEAT_TRAP_OPEN;
 
        /* Prepare allocation table */
        get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
 
+       align.sub_align = SUB_ALIGN_NEUTRAL;
+
        /* Pick some monster types */
        for (i = 0; i < 16; i++)
        {
                int r_idx = 0, attempts = 100;
+               monster_race *r_ptr = NULL;
 
                while (attempts--)
                {
                        /* Get a (hard) monster type */
                        r_idx = get_mon_num(dun_level + 0);
+                       r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
-                       if (((align < 0) && (r_info[r_idx].flags3 & RF3_GOOD)) ||
-                                ((align > 0) && (r_info[r_idx].flags3 & RF3_EVIL)))
-                       {
-                               continue;
-                       }
+                       if (monster_has_hostile_align(&align, 0, 0, r_ptr)) continue;
 
                        /* Accept this monster */
                        break;
@@ -5572,8 +5574,8 @@ static void build_type13(int by0, int bx0)
                if (!r_idx || !attempts) return;
 
                /* Note the alignment */
-               if (r_info[r_idx].flags3 & RF3_GOOD) align++;
-               else if (r_info[r_idx].flags3 & RF3_EVIL) align--;
+               if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
+               if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
 
                what[i] = r_idx;
        }
@@ -5716,7 +5718,7 @@ static void build_type14(int by0, int bx0)
 
        /* Place a special trap */
        c_ptr = &cave[rand_spread(yval, ysize/4)][rand_spread(xval, xsize/4)];
-       c_ptr->mimic = c_ptr->feat;
+       c_ptr->mimic = f_info[c_ptr->feat].mimic;
        c_ptr->feat = trap;
 
        /* Message */