OSDN Git Service

branch-nothere-terrainflags、゙。シ・ク.
[hengband/hengband.git] / src / grid.c
index af47ed5..fb4894b 100644 (file)
@@ -4,11 +4,11 @@
  */
 
 /*
- * Copyright (c) 1989 James E. Wilson, Robert A. Koeneke
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
  *
- * This software may be copied and distributed for educational, research, and
- * not for profit purposes provided that this copyright and statement are
- * included in all such copies.
+ * This software may be copied and distributed for educational, research,
+ * and not for profit purposes provided that this copyright and statement
+ * are included in all such copies.  Other copyrights may also apply.
  */
 
 #include "angband.h"
@@ -107,7 +107,7 @@ void place_random_stairs(int y, int x)
 /*
  * Place a random type of door at the given location
  */
-void place_random_door(int y, int x)
+void place_random_door(int y, int x, bool room)
 {
        int tmp;
        cave_type *c_ptr = &cave[y][x];
@@ -144,11 +144,11 @@ void place_random_door(int y, int x)
                /* Create secret door */
                place_closed_door(y, x);
 
-               /* Hide */
-               c_ptr->mimic = fill_type[randint0(100)];
+               /* Hide. If on the edge of room, use outer wall. */
+               c_ptr->mimic = room ? feat_wall_outer : fill_type[randint0(100)];
 
                /* Floor type terrain cannot hide a door */
-               if (!(c_ptr->mimic & 0x20))
+               if (feat_supports_los(c_ptr->mimic))
                {
                        c_ptr->feat = c_ptr->mimic;
                        c_ptr->mimic = 0;
@@ -196,6 +196,9 @@ void place_closed_door(int y, int x)
                /* Create jammed door */
                cave_set_feat(y, x, FEAT_DOOR_HEAD + 0x08 + randint0(8));
        }
+
+       /* Now it is not floor */
+       cave[y][x].info &= ~(CAVE_MASK);
 }
 
 
@@ -292,7 +295,7 @@ msg_print("
                        /* Place an item */
                        if (randint0(100) < 75)
                        {
-                               place_object(j, k, FALSE, FALSE);
+                               place_object(j, k, 0L);
                        }
 
                        /* Place gold */
@@ -443,7 +446,6 @@ void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2)
 }
 
 
-
 /*
  * Pick a random direction
  */
@@ -541,6 +543,7 @@ void build_tunnel(int row1, int col1, int row2, int col2)
        bool door_flag = FALSE;
 
        cave_type *c_ptr;
+       feature_type *f_ptr;
 
        /* Save the starting location */
        start_row = row1;
@@ -593,13 +596,16 @@ void build_tunnel(int row1, int col1, int row2, int col2)
 
                /* Access the location */
                c_ptr = &cave[tmp_row][tmp_col];
+               f_ptr = &f_info[c_ptr->feat];
 
+               if (have_flag(f_ptr->flags, FF_WALL) && have_flag(f_ptr->flags, FF_PERMANENT))
+               {
+                       /* Avoid the edge of the dungeon */
+                       if (have_flag(f_ptr->flags, FF_SOLID)) continue;
 
-               /* Avoid the edge of the dungeon */
-               if (c_ptr->feat == FEAT_PERM_SOLID) continue;
-
-               /* Avoid the edge of vaults */
-               if (c_ptr->feat == FEAT_PERM_OUTER) continue;
+                       /* Avoid the edge of vaults */
+                       if (have_flag(f_ptr->flags, FF_OUTER)) continue;
+               }
 
                /* Avoid "solid" granite walls */
                if (is_solid_grid(c_ptr)) continue;
@@ -607,13 +613,20 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                /* Pierce "outer" walls of rooms */
                if (is_outer_grid(c_ptr))
                {
+                       feature_type *ff_ptr;
+
                        /* Acquire the "next" location */
                        y = tmp_row + row_dir;
                        x = tmp_col + col_dir;
 
+                       ff_ptr = &f_info[cave[y][x].feat];
+
                        /* Hack -- Avoid outer/solid permanent walls */
-                       if (cave[y][x].feat == FEAT_PERM_SOLID) continue;
-                       if (cave[y][x].feat == FEAT_PERM_OUTER) continue;
+                       if (have_flag(ff_ptr->flags, FF_WALL) && have_flag(ff_ptr->flags, FF_PERMANENT))
+                       {
+                               if (have_flag(ff_ptr->flags, FF_SOLID)) continue;
+                               if (have_flag(ff_ptr->flags, FF_OUTER)) continue;
+                       }
 
                        /* Hack -- Avoid outer/solid granite walls */
                        if (is_outer_bold(y, x)) continue;
@@ -730,19 +743,26 @@ static bool set_tunnel(int *x, int *y, bool affectwall)
        int feat, i, j, dx, dy;
 
        cave_type *c_ptr = &cave[*y][*x];
+       feature_type *f_ptr;
 
        if (!in_bounds(*y, *x)) return TRUE;
 
        feat = c_ptr->feat;
+       f_ptr = &f_info[feat];
 
-       if ((feat == FEAT_PERM_OUTER) ||
-           (feat == FEAT_PERM_INNER) ||
-           is_inner_grid(c_ptr))
+       if (have_flag(f_ptr->flags, FF_WALL) && have_flag(f_ptr->flags, FF_PERMANENT))
        {
                /*
                 * Ignore permanent walls - sometimes cannot tunnel around them anyway
                 * so don't try - it just complicates things unnecessarily.
                 */
+
+               if (have_flag(f_ptr->flags, FF_OUTER)) return TRUE;
+               if (have_flag(f_ptr->flags, FF_INNER)) return TRUE;
+       }
+
+       if (is_inner_grid(c_ptr))
+       {
                return TRUE;
        }
 
@@ -751,9 +771,9 @@ static bool set_tunnel(int *x, int *y, bool affectwall)
                /* Save the tunnel location */
                if (dun->tunn_n < TUNN_MAX)
                {
-                               dun->tunn[dun->tunn_n].y = *y;
-                               dun->tunn[dun->tunn_n].x = *x;
-                               dun->tunn_n++;
+                       dun->tunn[dun->tunn_n].y = *y;
+                       dun->tunn[dun->tunn_n].x = *x;
+                       dun->tunn_n++;
                }
 
                return TRUE;
@@ -788,6 +808,10 @@ static bool set_tunnel(int *x, int *y, bool affectwall)
                                }
                        }
                }
+
+               /* Clear mimic type */
+               cave[*y][*x].mimic = 0;
+
                place_floor_bold(*y, *x);
 
                return TRUE;
@@ -1011,7 +1035,6 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
 {
        int x3, y3, dx, dy;
        int changex, changey;
-       int midval;
        int length;
        int i;
        bool retval, firstsuccede;
@@ -1043,9 +1066,8 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
                        x3 = (x1 + x2) / 2;
                        y3 = (y1 + y2) / 2;
                }
-               /* cache midvalue */
+               /* cache c_ptr */
                c_ptr = &cave[y3][x3];
-               midval = cave[y3][x3].feat;
                if (is_solid_grid(c_ptr))
                {
                        /* move midpoint a bit to avoid problem. */
@@ -1076,7 +1098,6 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
                        y3 += dy;
                        x3 += dx;
                        c_ptr = &cave[y3][x3];
-                       midval = cave[y3][x3].feat;
                }
 
                if (is_floor_grid(c_ptr))
@@ -1143,3 +1164,4 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
                return TRUE;
        }
 }
+