OSDN Git Service

生い立ち設定ファイル読み込みで, 読み込みに成功しても有効な"H:<str>"行
[hengband/hengband.git] / src / grid.c
index 79cbc84..6895d78 100644 (file)
@@ -128,18 +128,23 @@ void place_random_stairs(int y, int x)
  */
 void place_random_door(int y, int x, bool room)
 {
-       int tmp;
+       int tmp, type;
+       s16b feat = feat_none;
        cave_type *c_ptr = &cave[y][x];
 
        /* Initialize mimic info */
        c_ptr->mimic = 0;
-       
+
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
        {
                place_floor_bold(y, x);
                return;
        }
 
+       type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+               one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+               ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+
        /* Choose an object */
        tmp = randint0(1000);
 
@@ -147,38 +152,53 @@ void place_random_door(int y, int x, bool room)
        if (tmp < 300)
        {
                /* Create open door */
-               set_cave_feat(y, x, feat_open_door);
+               feat = feat_door[type].open;
        }
 
        /* Broken doors (100/1000) */
        else if (tmp < 400)
        {
                /* Create broken door */
-               set_cave_feat(y, x, feat_broken_door);
+               feat = feat_door[type].broken;
        }
 
        /* Secret doors (200/1000) */
        else if (tmp < 600)
        {
                /* Create secret door */
-               place_closed_door(y, x);
-
-               /* Hide. If on the edge of room, use outer wall. */
-               c_ptr->mimic = room ? feat_wall_outer : fill_type[randint0(100)];
+               place_closed_door(y, x, type);
 
-               /* Floor type terrain cannot hide a door */
-               if (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
+               if (type != DOOR_CURTAIN)
                {
-                       if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
+                       /* 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 (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
                        {
-                               c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
+                               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;
                        }
-                       c_ptr->mimic = 0;
                }
        }
 
        /* Closed, locked, or stuck doors (400/1000) */
-       else place_closed_door(y, x);
+       else place_closed_door(y, x, type);
+
+       if (tmp < 400)
+       {
+               if (feat != feat_none)
+               {
+                       set_cave_feat(y, x, feat);
+               }
+               else
+               {
+                       place_floor_bold(y, x);
+               }
+       }
 
        delete_monster(y, x);
 }
@@ -187,9 +207,10 @@ void place_random_door(int y, int x, bool room)
 /*
  * Place a random type of normal door at the given location.
  */
-void place_closed_door(int y, int x)
+void place_closed_door(int y, int x, int type)
 {
        int tmp;
+       s16b feat = feat_none;
 
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
        {
@@ -204,25 +225,34 @@ void place_closed_door(int y, int x)
        if (tmp < 300)
        {
                /* Create closed door */
-               cave_set_feat(y, x, feat_closed_door);
+               feat = feat_door[type].closed;
        }
 
        /* Locked doors (99/400) */
        else if (tmp < 399)
        {
                /* Create locked door */
-               cave_set_feat(y, x, feat_locked_door[randint0(num_locked_door)]);
+               feat = feat_locked_door_random(type);
        }
 
        /* Stuck doors (1/400) */
        else
        {
                /* Create jammed door */
-               cave_set_feat(y, x, feat_jammed_door[randint0(num_jammed_door)]);
+               feat = feat_jammed_door_random(type);
        }
 
-       /* Now it is not floor */
-       cave[y][x].info &= ~(CAVE_MASK);
+       if (feat != feat_none)
+       {
+               cave_set_feat(y, x, feat);
+
+               /* Now it is not floor */
+               cave[y][x].info &= ~(CAVE_MASK);
+       }
+       else
+       {
+               place_floor_bold(y, x);
+       }
 }
 
 
@@ -532,7 +562,7 @@ void set_floor(int x, int y)
  *   outer -- outer room walls
  *   solid -- solid room walls
  */
-void build_tunnel(int row1, int col1, int row2, int col2)
+bool build_tunnel(int row1, int col1, int row2, int col2)
 {
        int y, x;
        int tmp_row, tmp_col;
@@ -555,7 +585,7 @@ void build_tunnel(int row1, int col1, int row2, int col2)
        while ((row1 != row2) || (col1 != col2))
        {
                /* Mega-Hack -- Paranoia -- prevent infinite loops */
-               if (main_loop_count++ > 2000) break;
+               if (main_loop_count++ > 2000) return FALSE;
 
                /* Allow bends in the tunnel */
                if (randint0(100) < dun_tun_chg)
@@ -596,12 +626,6 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                /* Access the location */
                c_ptr = &cave[tmp_row][tmp_col];
 
-               if (permanent_wall(&f_info[c_ptr->feat]))
-               {
-                       /* Avoid the edge of vaults */
-                       if (is_inner_grid(c_ptr)) continue;
-               }
-
                /* Avoid "solid" walls */
                if (is_solid_grid(c_ptr)) continue;
 
@@ -627,6 +651,7 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                                dun->wall[dun->wall_n].x = col1;
                                dun->wall_n++;
                        }
+                       else return FALSE;
 
                        /* Forbid re-entry near this piercing */
                        for (y = row1 - 1; y <= row1 + 1; y++)
@@ -665,6 +690,7 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                                dun->tunn[dun->tunn_n].x = col1;
                                dun->tunn_n++;
                        }
+                       else return FALSE;
 
                        /* Allow door in next grid */
                        door_flag = FALSE;
@@ -687,6 +713,7 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                                        dun->door[dun->door_n].x = col1;
                                        dun->door_n++;
                                }
+                               else return FALSE;
 
                                /* No door in next grid */
                                door_flag = TRUE;
@@ -708,6 +735,8 @@ void build_tunnel(int row1, int col1, int row2, int col2)
                        }
                }
        }
+
+       return TRUE;
 }
 
 
@@ -743,9 +772,10 @@ static bool set_tunnel(int *x, int *y, bool affectwall)
                        dun->tunn[dun->tunn_n].y = *y;
                        dun->tunn[dun->tunn_n].x = *x;
                        dun->tunn_n++;
-               }
 
-               return TRUE;
+                       return TRUE;
+               }
+               else return FALSE;
        }
 
        if (is_floor_bold(*y, *x))
@@ -763,6 +793,7 @@ static bool set_tunnel(int *x, int *y, bool affectwall)
                        dun->wall[dun->wall_n].x = *x;
                        dun->wall_n++;
                }
+               else return FALSE;
 
                /* Forbid re-entry near this piercing */
                for (j = *y - 1; j <= *y + 1; j++)
@@ -1090,6 +1121,7 @@ bool build_tunnel2(int x1, int y1, int x2, int y2, int type, int cutoff)
                                                dun->door[dun->door_n].x = x3;
                                                dun->door_n++;
                                        }
+                                       else return FALSE;
                                }
                                firstsuccede = TRUE;
                        }