OSDN Git Service

隠しドアを隠せない地形で隠しドアを潰す判定をMOVE || CAN_FLYとした. 潰
[hengband/hengband.git] / src / grid.c
index 6a545f6..f59c8fb 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"
@@ -36,8 +36,10 @@ bool new_player_spot(void)
                c_ptr = &cave[y][x];
 
                /* Must be a "naked" floor grid */
-               if (!cave_clean_bold(y, x) || c_ptr->m_idx) continue;
-               if (!in_bounds(y,x)) continue;
+               if (c_ptr->m_idx) continue;
+               if (!have_flag(f_flags_grid(c_ptr), FF_MOVE)) continue;
+               if (!player_can_enter(c_ptr->feat, 0)) continue;
+               if (!in_bounds(y, x)) continue;
 
                /* Refuse to start on anti-teleport grids */
                if (c_ptr->info & (CAVE_ICKY)) continue;
@@ -107,7 +109,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,13 +146,16 @@ 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) && !feat_supports_los(c_ptr->feat))
                {
-                       c_ptr->feat = c_ptr->mimic;
+                       if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
+                       {
+                               c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
+                       }
                        c_ptr->mimic = 0;
                }
        }
@@ -295,7 +300,7 @@ msg_print("
                        /* Place an item */
                        if (randint0(100) < 75)
                        {
-                               place_object(j, k, FALSE, FALSE);
+                               place_object(j, k, 0L);
                        }
 
                        /* Place gold */
@@ -446,7 +451,6 @@ void correct_dir(int *rdir, int *cdir, int y1, int x1, int y2, int x2)
 }
 
 
-
 /*
  * Pick a random direction
  */
@@ -523,15 +527,11 @@ void set_floor(int x, int y)
  * corners of rooms off, as well as "silly" door placement, and
  * "excessively wide" room entrances.
  *
- * Useful "feat" values:
- *   FEAT_WALL_EXTRA -- granite walls
- *   FEAT_WALL_INNER -- inner room walls
- *   FEAT_WALL_OUTER -- outer room walls
- *   FEAT_WALL_SOLID -- solid room walls
- *   FEAT_PERM_EXTRA -- shop walls (perma)
- *   FEAT_PERM_INNER -- inner room walls (perma)
- *   FEAT_PERM_OUTER -- outer room walls (perma)
- *   FEAT_PERM_SOLID -- dungeon border (perma)
+ * Kind of walls:
+ *   extra -- walls
+ *   inner -- inner room walls
+ *   outer -- outer room walls
+ *   solid -- solid room walls
  */
 void build_tunnel(int row1, int col1, int row2, int col2)
 {
@@ -544,6 +544,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;
@@ -596,29 +597,29 @@ 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 (permanent_wall(f_ptr))
+               {
+                       /* Avoid the edge of vaults */
+                       if (is_inner_grid(c_ptr)) 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 "solid" granite walls */
+               /* Avoid "solid" walls */
                if (is_solid_grid(c_ptr)) continue;
 
                /* 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;
 
-                       /* Hack -- Avoid outer/solid permanent walls */
-                       if (cave[y][x].feat == FEAT_PERM_SOLID) continue;
-                       if (cave[y][x].feat == FEAT_PERM_OUTER) continue;
+                       ff_ptr = &f_info[cave[y][x].feat];
 
-                       /* Hack -- Avoid outer/solid granite walls */
+                       /* Hack -- Avoid outer/solid walls */
                        if (is_outer_bold(y, x)) continue;
                        if (is_solid_bold(y, x)) continue;
 
@@ -733,19 +734,15 @@ 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 (is_inner_grid(c_ptr))
        {
-               /*
-                * Ignore permanent walls - sometimes cannot tunnel around them anyway
-                * so don't try - it just complicates things unnecessarily.
-                */
                return TRUE;
        }
 
@@ -754,9 +751,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;
@@ -1018,7 +1015,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;
@@ -1050,9 +1046,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. */
@@ -1083,7 +1078,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))
@@ -1150,3 +1144,4 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
                return TRUE;
        }
 }
+