OSDN Git Service

[Refactor] #38997 place_outer_noperm_bold() を削除し、place_grid() に統合 / Removed place_out...
[hengband/hengband.git] / src / rooms.c
index 58ce605..e3a9c4c 100644 (file)
 #include "monster.h"
 
 
-/*!
- * 各部屋タイプの生成比定義
- *[from SAngband (originally from OAngband)]\n
- *\n
- * Table of values that control how many times each type of room will\n
- * appear.  Each type of room has its own row, and each column\n
- * corresponds to dungeon levels 0, 10, 20, and so on.  The final\n
- * value is the minimum depth the room can appear at.  -LM-\n
- *\n
- * Level 101 and below use the values for level 100.\n
- *\n
- * Rooms with lots of monsters or loot may not be generated if the\n
- * object or monster lists are already nearly full.  Rooms will not\n
- * appear above their minimum depth.  Tiny levels will not have space\n
- * for all the rooms you ask for.\n
- */
-
-#if 1
+ /*!
+  * 各部屋タイプの生成比定義
+  *[from SAngband (originally from OAngband)]\n
+  *\n
+  * Table of values that control how many times each type of room will\n
+  * appear.  Each type of room has its own row, and each column\n
+  * corresponds to dungeon levels 0, 10, 20, and so on.  The final\n
+  * value is the minimum depth the room can appear at.  -LM-\n
+  *\n
+  * Level 101 and below use the values for level 100.\n
+  *\n
+  * Rooms with lots of monsters or loot may not be generated if the\n
+  * object or monster lists are already nearly full.  Rooms will not\n
+  * appear above their minimum depth.  Tiny levels will not have space\n
+  * for all the rooms you ask for.\n
+  */
 
 static room_info_type room_info_normal[ROOM_T_MAX] =
 {
@@ -101,35 +99,6 @@ static room_info_type room_info_normal[ROOM_T_MAX] =
        {{  1,  8, 16, 24, 32, 40, 48, 56, 64, 72, 80},  1}, /*FIX      */
 };
 
-#endif
-
-#if 0
-static room_info_type room_info_normal[ROOM_T_MAX] =
-{
-/*デバッグ用配列*/
-{ {999, 900, 800, 700, 600, 500, 400, 300, 200, 100, 0}, 0}, /*NORMAL   */
-{ {  1, 10, 20, 30, 40, 50, 60, 70, 80, 90,  0},  1 }, /*OVERLAP  */
-{ {  1, 10, 20, 30, 40, 50, 60, 70, 80, 90,  0},  3 }, /*CROSS    */
-{ {  1, 10, 20, 30, 40, 50, 60, 70, 80, 90,  0},  3 }, /*INNER_F  */
-{ {  0,  1,  1,  1,  2,  3,  5,  6,  8, 10,  0}, 10 }, /*NEST     */
-{ {  0,  1,  1,  2,  3,  4,  6,  8, 10, 13,  0}, 10 }, /*PIT      */
-{ {  0,  1,  1,  1,  2,  2,  3,  5,  6,  8,  0}, 10 }, /*LESSER_V */
-{ {  0,  0,  1,  1,  1,  2,  2,  2,  3,  3,  0}, 20 }, /*GREATER_V*/
-{ {  0,100,200,300,400,500,600,700,800,900,  0}, 10 }, /*FRACAVE  */
-{ {  0,  1,  1,  1,  1,  1,  1,  1,  1,  2,  0}, 10 }, /*RANDOM_V */
-{ {  0,  4,  8, 12, 16, 20, 24, 28, 32, 36,  0},  3 }, /*OVAL     */
-{ {  1,  6, 12, 18, 24, 30, 36, 42, 48, 54,  0}, 10 }, /*CRYPT    */
-{ {  0,  0,  1,  1,  1,  2,  3,  4,  5,  6,  0}, 20 }, /*TRAP_PIT */
-{ {  0,  0,  1,  1,  1,  2,  3,  4,  5,  6,  0}, 20 }, /*TRAP     */
-{ {  0,  0,  0,  0,  1,  1,  1,  2,  2,  2,  0}, 40 }, /*GLASS    */
-{ {  1,  1,  1,  1,  1,  1,  1,  2,  2,  3,  0},  1 }, /*ARCADE   */
-{ { 20, 40, 60, 80,100,100,100,100,100,100,100},  1 }, /*FIX      */
-};
-
-#endif
-
-
-
 /*! 部屋の生成処理順 / Build rooms in descending order of difficulty. */
 static byte room_build_order[ROOM_T_MAX] = {
        ROOM_T_GREATER_VAULT,
@@ -153,7 +122,7 @@ static byte room_build_order[ROOM_T_MAX] = {
 
 /*!
  * @brief 1マスだけの部屋を作成し、上下左右いずれか一つに隠しドアを配置する。
- * @param floor_ptr 配置するフロアの参照ポインタ
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param y0 配置したい中心のY座標
  * @param x0 配置したい中心のX座標
  * @details
@@ -163,55 +132,58 @@ static byte room_build_order[ROOM_T_MAX] = {
  * Note - this should be used only on allocated regions
  * within another room.
  */
-void build_small_room(floor_type *floor_ptr, POSITION x0, POSITION y0)
+void build_small_room(player_type *player_ptr, POSITION x0, POSITION y0)
 {
        POSITION x, y;
 
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        for (y = y0 - 1; y <= y0 + 1; y++)
        {
-               place_inner_bold(floor_ptr, y, x0 - 1);
-               place_inner_bold(floor_ptr, y, x0 + 1);
+               place_bold(player_ptr, y, x0 - 1, inner);
+               place_bold(player_ptr, y, x0 + 1, inner);
        }
 
        for (x = x0 - 1; x <= x0 + 1; x++)
        {
-               place_inner_bold(floor_ptr, y0 - 1, x);
-               place_inner_bold(floor_ptr, y0 + 1, x);
+               place_bold(player_ptr, y0 - 1, x, inner);
+               place_bold(player_ptr, y0 + 1, x, inner);
        }
 
        /* Place a secret door on one side */
        switch (randint0(4))
        {
-               case 0: place_secret_door(floor_ptr, y0, x0 - 1, DOOR_DEFAULT); break;
-               case 1: place_secret_door(floor_ptr, y0, x0 + 1, DOOR_DEFAULT); break;
-               case 2: place_secret_door(floor_ptr, y0 - 1, x0, DOOR_DEFAULT); break;
-               case 3: place_secret_door(floor_ptr, y0 + 1, x0, DOOR_DEFAULT); break;
+       case 0: place_secret_door(player_ptr, y0, x0 - 1, DOOR_DEFAULT); break;
+       case 1: place_secret_door(player_ptr, y0, x0 + 1, DOOR_DEFAULT); break;
+       case 2: place_secret_door(player_ptr, y0 - 1, x0, DOOR_DEFAULT); break;
+       case 3: place_secret_door(player_ptr, y0 + 1, x0, DOOR_DEFAULT); break;
        }
 
        /* Clear mimic type */
        floor_ptr->grid_array[y0][x0].mimic = 0;
 
        /* Add inner open space */
-       place_floor_bold(floor_ptr, y0, x0);
+       place_bold(player_ptr, y0, x0, floor);
 }
 
 /*!
  * @brief
  * 指定範囲に通路が通っていることを確認した上で床で埋める
  * This function tunnels around a room if it will cut off part of a grid system.
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param x1 範囲の左端
  * @param y1 範囲の上端
  * @param x2 範囲の右端
  * @param y2 範囲の下端
  * @return なし
  */
-static void check_room_boundary(floor_type *floor_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2)
+static void check_room_boundary(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2)
 {
        int count;
        POSITION x, y;
        bool old_is_floor, new_is_floor;
        count = 0;
 
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        old_is_floor = get_is_floor(floor_ptr, x1 - 1, y1);
 
        /*
@@ -220,7 +192,7 @@ static void check_room_boundary(floor_type *floor_ptr, POSITION x1, POSITION y1,
         * to bypass these if needed.
         */
 
-       /* Above the top boundary */
+        /* Above the top boundary */
        for (x = x1; x <= x2; x++)
        {
                new_is_floor = get_is_floor(floor_ptr, x, y1 - 1);
@@ -273,7 +245,7 @@ static void check_room_boundary(floor_type *floor_ptr, POSITION x1, POSITION y1,
        {
                for (x = x1; x <= x2; x++)
                {
-                       set_floor(x, y);
+                       set_floor(player_ptr, x, y);
                }
        }
 }
@@ -342,7 +314,7 @@ static bool find_space_aux(POSITION blocks_high, POSITION blocks_wide, POSITION
        /* Never run off the screen */
        if ((by1 < 0) || (by2 > dun->row_rooms)) return FALSE;
        if ((bx1 < 0) || (bx2 > dun->col_rooms)) return FALSE;
-       
+
        /* Verify available space */
        for (by = by1; by < by2; by++)
        {
@@ -362,6 +334,7 @@ static bool find_space_aux(POSITION blocks_high, POSITION blocks_wide, POSITION
 
 /*!
  * @brief 部屋生成が可能なスペースを確保する / Find a good spot for the next room.  -LM-
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param y 部屋の生成が可能な中心Y座標を返す参照ポインタ
  * @param x 部屋の生成が可能な中心X座標を返す参照ポインタ
  * @param height 確保したい領域の高さ
@@ -380,7 +353,7 @@ static bool find_space_aux(POSITION blocks_high, POSITION blocks_wide, POSITION
  * Return TRUE and values for the center of the room if all went well.\n
  * Otherwise, return FALSE.\n
  */
-bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
+bool find_space(player_type *player_ptr, POSITION *y, POSITION *x, POSITION height, POSITION width)
 {
        int candidates, pick;
        POSITION by, bx, by1, bx1, by2, bx2;
@@ -417,7 +390,7 @@ bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
        }
 
        /* Normal dungeon */
-       if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE))
+       if (!(d_info[player_ptr->current_floor_ptr->dungeon_idx].flags1 & DF1_NO_CAVE))
        {
                /* Choose a random one */
                pick = randint1(candidates);
@@ -427,7 +400,7 @@ bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
        else
        {
                /* Always choose the center one */
-               pick = candidates/2 + 1;
+               pick = candidates / 2 + 1;
        }
 
        /* Pick up the choosen location */
@@ -458,7 +431,7 @@ bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
         * be *exactly* correct to prevent memory errors
         */
 
-       /* Acquire the location of the room */
+        /* Acquire the location of the room */
        (*y) = ((by1 + by2) * BLOCK_HGT) / 2;
        (*x) = ((bx1 + bx2) * BLOCK_WID) / 2;
 
@@ -485,7 +458,7 @@ bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
         * If so, fix by tunneling outside the room in such a
         * way as to connect the caves.
         */
-       check_room_boundary(p_ptr->current_floor_ptr, *x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
+       check_room_boundary(player_ptr, *x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
 
        /* Success. */
        return TRUE;
@@ -585,17 +558,17 @@ static void store_height(floor_type *floor_ptr, POSITION x, POSITION y, FEAT_IDX
  */
 
 
-/*
- *  Note that this uses the floor array in a very hackish way
- *  the values are first set to zero, and then each array location
- *  is used as a "heightmap"
- *  The heightmap then needs to be converted back into the "feat" format.
- *
- *  grd=level at which fractal turns on.  smaller gives more mazelike caves
- *  roug=roughness level.  16=normal.  higher values make things more convoluted
- *    small values are good for smooth walls.
- *  size=length of the side of the square grid system.
- */
+ /*
 *  Note that this uses the floor array in a very hackish way
 *  the values are first set to zero, and then each array location
 *  is used as a "heightmap"
 *  The heightmap then needs to be converted back into the "feat" format.
 *
 *  grd=level at which fractal turns on.  smaller gives more mazelike caves
 *  roug=roughness level.  16=normal.  higher values make things more convoluted
 *    small values are good for smooth walls.
 *  size=length of the side of the square grid system.
 */
 void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsiz, POSITION ysiz, int grd, int roug, int cutoff)
 {
        POSITION xhsize, yhsize, xsize, ysize, maxsize;
@@ -608,7 +581,7 @@ void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
        POSITION xstep, xhstep, ystep, yhstep;
        POSITION xstep2, xhstep2, ystep2, yhstep2;
        POSITION i, j, ii, jj, diagsize, xxsize, yysize;
-       
+
        /* Cache for speed */
        POSITION xm, xp, ym, yp;
 
@@ -717,8 +690,8 @@ void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                                                /* Average of left and right points +random bit */
                                                store_height(floor_ptr, ii, jj,
                                                        (floor_ptr->grid_array[jj][fill_data.xmin + (i - xhstep) / 256].feat
-                                                        + floor_ptr->grid_array[jj][fill_data.xmin + (i + xhstep) / 256].feat) / 2
-                                                        + (randint1(xstep2) - xhstep2) * roug / 16);
+                                                               + floor_ptr->grid_array[jj][fill_data.xmin + (i + xhstep) / 256].feat) / 2
+                                                       + (randint1(xstep2) - xhstep2) * roug / 16);
                                        }
                                }
                        }
@@ -747,7 +720,7 @@ void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                                                /* Average of up and down points +random bit */
                                                store_height(floor_ptr, ii, jj,
                                                        (floor_ptr->grid_array[fill_data.ymin + (j - yhstep) / 256][ii].feat
-                                                       + floor_ptr->grid_array[fill_data.ymin + (j + yhstep) / 256][ii].feat) / 2
+                                                               + floor_ptr->grid_array[fill_data.ymin + (j + yhstep) / 256][ii].feat) / 2
                                                        + (randint1(ystep2) - yhstep2) * roug / 16);
                                        }
                                }
@@ -779,13 +752,13 @@ void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                                                ym = fill_data.ymin + (j - yhstep) / 256;
                                                yp = fill_data.ymin + (j + yhstep) / 256;
 
-                                               /* 
+                                               /*
                                                 * Average over all four corners + scale by diagsize to
                                                 * reduce the effect of the square grid on the shape of the fractal
                                                 */
                                                store_height(floor_ptr, ii, jj,
                                                        (floor_ptr->grid_array[ym][xm].feat + floor_ptr->grid_array[yp][xm].feat
-                                                       + floor_ptr->grid_array[ym][xp].feat + floor_ptr->grid_array[yp][xp].feat) / 4
+                                                               + floor_ptr->grid_array[ym][xp].feat + floor_ptr->grid_array[yp][xp].feat) / 4
                                                        + (randint1(xstep2) - xhstep2) * (diagsize / 16) / 256 * roug);
                                        }
                                }
@@ -795,12 +768,13 @@ void generate_hmap(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
 }
 
 
-static bool hack_isnt_wall(floor_type *floor_ptr, POSITION y, POSITION x, int c1, int c2, int c3, FEAT_IDX feat1, FEAT_IDX feat2, FEAT_IDX feat3, BIT_FLAGS info1, BIT_FLAGS info2, BIT_FLAGS info3)
+static bool hack_isnt_wall(player_type *player_ptr, POSITION y, POSITION x, int c1, int c2, int c3, FEAT_IDX feat1, FEAT_IDX feat2, FEAT_IDX feat3, BIT_FLAGS info1, BIT_FLAGS info2, BIT_FLAGS info3)
 {
        /*
         * function used to convert from height-map back to the
         *  normal angband floor_ptr->grid_array format
         */
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        if (floor_ptr->grid_array[y][x].info & CAVE_ICKY)
        {
                /* already done */
@@ -809,7 +783,7 @@ static bool hack_isnt_wall(floor_type *floor_ptr, POSITION y, POSITION x, int c1
        else
        {
                /* Show that have looked at this square */
-               floor_ptr->grid_array[y][x].info|= (CAVE_ICKY);
+               floor_ptr->grid_array[y][x].info |= (CAVE_ICKY);
 
                /* Use cutoffs c1-c3 to allocate regions of floor /water/ lava etc. */
                if (floor_ptr->grid_array[y][x].feat <= c1)
@@ -858,7 +832,7 @@ static bool hack_isnt_wall(floor_type *floor_ptr, POSITION y, POSITION x, int c1
                /* if greater than cutoff then is a wall */
                else
                {
-                       place_outer_bold(floor_ptr, y, x);
+                       place_bold(player_ptr, y, x, outer);
                        return FALSE;
                }
        }
@@ -871,7 +845,7 @@ static bool hack_isnt_wall(floor_type *floor_ptr, POSITION y, POSITION x, int c1
  * Quick and nasty fill routine used to find the connected region
  * of floor in the middle of the grids
  */
-static void cave_fill(floor_type *floor_ptr, POSITION y, POSITION x)
+static void cave_fill(player_type *player_ptr, POSITION y, POSITION x)
 {
        int i, j, d;
        POSITION ty, tx;
@@ -887,6 +861,7 @@ static void cave_fill(floor_type *floor_ptr, POSITION y, POSITION x)
        tmp_pos.x[0] = x;
 
        /* Now process the queue */
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        while (flow_head != flow_tail)
        {
                /* Extract the next entry */
@@ -910,7 +885,7 @@ static void cave_fill(floor_type *floor_ptr, POSITION y, POSITION x)
                        {
                                /* affect boundary */
                                floor_ptr->grid_array[j][i].info |= CAVE_ICKY;
-/*                             return; */
+                               /*                              return; */
                        }
 
                        /* If within bounds */
@@ -918,7 +893,7 @@ static void cave_fill(floor_type *floor_ptr, POSITION y, POSITION x)
                                && (j > fill_data.ymin) && (j < fill_data.ymax))
                        {
                                /* If not a wall or floor done before */
-                               if (hack_isnt_wall(floor_ptr, j, i,
+                               if (hack_isnt_wall(player_ptr, j, i,
                                        fill_data.c1, fill_data.c2, fill_data.c3,
                                        fill_data.feat1, fill_data.feat2, fill_data.feat3,
                                        fill_data.info1, fill_data.info2, fill_data.info3))
@@ -952,7 +927,7 @@ static void cave_fill(floor_type *floor_ptr, POSITION y, POSITION x)
 }
 
 
-bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsize, POSITION ysize, int cutoff, bool light, bool room)
+bool generate_fracave(player_type *player_ptr, POSITION y0, POSITION x0, POSITION xsize, POSITION ysize, int cutoff, bool light, bool room)
 {
        POSITION x, y, xhsize, yhsize;
        int i;
@@ -968,7 +943,7 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
         * can make teleport traps instadeaths...
         */
 
-       /* cutoffs */
+        /* cutoffs */
        fill_data.c1 = cutoff;
        fill_data.c2 = 0;
        fill_data.c3 = 0;
@@ -985,7 +960,8 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
        /* number of filled squares */
        fill_data.amount = 0;
 
-       cave_fill(floor_ptr, (byte)y0, (byte)x0);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       cave_fill(player_ptr, (byte)y0, (byte)x0);
 
        /* if tally too small, try again */
        if (fill_data.amount < 10)
@@ -995,7 +971,7 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                {
                        for (y = 0; y <= ysize; ++y)
                        {
-                               place_extra_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize);
+                               place_bold(player_ptr, y0 + y - yhsize, x0 + x - xhsize, extra);
                                floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
                        }
                }
@@ -1013,30 +989,30 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                if ((floor_ptr->grid_array[0 + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
                {
                        /* Next to a 'filled' region? - set to be room walls */
-                       place_outer_bold(floor_ptr, y0 + 0 - yhsize, x0 + i - xhsize);
+                       place_bold(player_ptr, y0 + 0 - yhsize, x0 + i - xhsize, outer);
                        if (light) floor_ptr->grid_array[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_GLOW);
                        floor_ptr->grid_array[y0 + 0 - yhsize][x0 + i - xhsize].info |= (CAVE_ROOM);
-                       place_outer_bold(floor_ptr, y0 + 0 - yhsize, x0 + i - xhsize);
+                       place_bold(player_ptr, y0 + 0 - yhsize, x0 + i - xhsize, outer);
                }
                else
                {
                        /* set to be normal granite */
-                       place_extra_bold(floor_ptr, y0 + 0 - yhsize, x0 + i - xhsize);
+                       place_bold(player_ptr, y0 + 0 - yhsize, x0 + i - xhsize, extra);
                }
 
                /* bottom boundary */
                if ((floor_ptr->grid_array[ysize + y0 - yhsize][i + x0 - xhsize].info & CAVE_ICKY) && (room))
                {
                        /* Next to a 'filled' region? - set to be room walls */
-                       place_outer_bold(floor_ptr, y0 + ysize - yhsize, x0 + i - xhsize);
-                       if (light) floor_ptr->grid_array[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_GLOW);
-                       floor_ptr->grid_array[y0 + ysize - yhsize][x0 + i - xhsize].info|=(CAVE_ROOM);
-                       place_outer_bold(floor_ptr, y0 + ysize - yhsize, x0 + i - xhsize);
+                       place_bold(player_ptr, y0 + ysize - yhsize, x0 + i - xhsize, outer);
+                       if (light) floor_ptr->grid_array[y0 + ysize - yhsize][x0 + i - xhsize].info |= (CAVE_GLOW);
+                       floor_ptr->grid_array[y0 + ysize - yhsize][x0 + i - xhsize].info |= (CAVE_ROOM);
+                       place_bold(player_ptr, y0 + ysize - yhsize, x0 + i - xhsize, outer);
                }
                else
                {
                        /* set to be normal granite */
-                       place_extra_bold(floor_ptr, y0 + ysize - yhsize, x0 + i - xhsize);
+                       place_bold(player_ptr, y0 + ysize - yhsize, x0 + i - xhsize, extra);
                }
 
                /* clear the icky flag-don't need it any more */
@@ -1051,29 +1027,29 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                if ((floor_ptr->grid_array[i + y0 - yhsize][0 + x0 - xhsize].info & CAVE_ICKY) && room)
                {
                        /* room boundary */
-                       place_outer_bold(floor_ptr, y0 + i - yhsize, x0 + 0 - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + 0 - xhsize, outer);
                        if (light) floor_ptr->grid_array[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_GLOW);
                        floor_ptr->grid_array[y0 + i - yhsize][x0 + 0 - xhsize].info |= (CAVE_ROOM);
-                       place_outer_bold(floor_ptr, y0 + i - yhsize, x0 + 0 - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + 0 - xhsize, outer);
                }
                else
                {
                        /* outside room */
-                       place_extra_bold(floor_ptr, y0 + i - yhsize, x0 + 0 - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + 0 - xhsize, extra);
                }
                /* right boundary */
                if ((floor_ptr->grid_array[i + y0 - yhsize][xsize + x0 - xhsize].info & CAVE_ICKY) && room)
                {
                        /* room boundary */
-                       place_outer_bold(floor_ptr, y0 + i - yhsize, x0 + xsize - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + xsize - xhsize, outer);
                        if (light) floor_ptr->grid_array[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_GLOW);
                        floor_ptr->grid_array[y0 + i - yhsize][x0 + xsize - xhsize].info |= (CAVE_ROOM);
-                       place_outer_bold(floor_ptr, y0 + i - yhsize, x0 + xsize - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + xsize - xhsize, outer);
                }
                else
                {
                        /* outside room */
-                       place_extra_bold(floor_ptr, y0 + i - yhsize, x0 + xsize - xhsize);
+                       place_bold(player_ptr, y0 + i - yhsize, x0 + xsize - xhsize, extra);
                }
 
                /* clear icky flag -done with it */
@@ -1088,7 +1064,7 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                for (y = 1; y < ysize; ++y)
                {
                        if (is_floor_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize) &&
-                           (floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
+                               (floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
                        {
                                /* Clear the icky flag in the filled region */
                                floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~CAVE_ICKY;
@@ -1098,7 +1074,7 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                                if (room) floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info |= (CAVE_ROOM);
                        }
                        else if (is_outer_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize) &&
-                                (floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
+                               (floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY))
                        {
                                /* Walls */
                                floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
@@ -1110,14 +1086,14 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
                                else
                                {
 
-                                       place_extra_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize);
+                                       place_bold(player_ptr, y0 + y - yhsize, x0 + x - xhsize, extra);
                                        floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ROOM);
                                }
                        }
                        else
                        {
                                /* Clear the unconnected regions */
-                               place_extra_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize);
+                               place_bold(player_ptr, y0 + y - yhsize, x0 + x - xhsize, extra);
                                floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
                        }
                }
@@ -1141,14 +1117,15 @@ bool generate_fracave(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION
 /*
  * Builds a cave system in the center of the dungeon.
  */
-void build_cavern(floor_type *floor_ptr)
+void build_cavern(player_type *player_ptr)
 {
        int grd, roug, cutoff;
        POSITION xsize, ysize, x0, y0;
        bool done, light;
 
        light = done = FALSE;
-       if ((floor_ptr->dun_level <= randint1(50)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) light = TRUE;
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       if ((floor_ptr->dun_level <= randint1(50)) && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) light = TRUE;
 
        /* Make a cave the size of the dungeon */
        xsize = floor_ptr->width - 1;
@@ -1171,15 +1148,16 @@ void build_cavern(floor_type *floor_ptr)
                /* about size/2 */
                cutoff = xsize / 2;
 
-                /* make it */
+               /* make it */
                generate_hmap(floor_ptr, y0 + 1, x0 + 1, xsize, ysize, grd, roug, cutoff);
 
                /* Convert to normal format+ clean up */
-               done = generate_fracave(floor_ptr, y0 + 1, x0 + 1, xsize, ysize, cutoff, light, FALSE);
+               done = generate_fracave(player_ptr, y0 + 1, x0 + 1, xsize, ysize, cutoff, light, FALSE);
        }
 }
 
-bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsize, POSITION ysize, int c1, int c2, int c3, int type)
+
+bool generate_lake(player_type *player_ptr, POSITION y0, POSITION x0, POSITION xsize, POSITION ysize, int c1, int c2, int c3, int type)
 {
        POSITION x, y, xhsize, yhsize;
        int i;
@@ -1236,7 +1214,7 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
         * can make teleport traps instadeaths...
         */
 
-       /* cutoffs */
+        /* cutoffs */
        fill_data.c1 = c1;
        fill_data.c2 = c2;
        fill_data.c3 = c3;
@@ -1256,7 +1234,8 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
        /* select region connected to center of floor_ptr->grid_array system
        * this gets rid of alot of isolated one-sqaures that
        * can make teleport traps instadeaths... */
-       cave_fill(floor_ptr, (byte)y0, (byte)x0);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       cave_fill(player_ptr, (byte)y0, (byte)x0);
 
        /* if tally too small, try again */
        if (fill_data.amount < 10)
@@ -1266,7 +1245,7 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                {
                        for (y = 0; y <= ysize; ++y)
                        {
-                               place_floor_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize);
+                               place_bold(player_ptr, y0 + y - yhsize, x0 + x - xhsize, floor);
                                floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY);
                        }
                }
@@ -1276,8 +1255,8 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
        /* Do boundarys- set to normal granite */
        for (i = 0; i <= xsize; ++i)
        {
-               place_extra_bold(floor_ptr, y0 + 0 - yhsize, x0 + i - xhsize);
-               place_extra_bold(floor_ptr, y0 + ysize - yhsize, x0 + i - xhsize);
+               place_bold(player_ptr, y0 + 0 - yhsize, x0 + i - xhsize, extra);
+               place_bold(player_ptr, y0 + ysize - yhsize, x0 + i - xhsize, extra);
 
                /* clear the icky flag-don't need it any more */
                floor_ptr->grid_array[y0 + 0 - yhsize][x0 + i - xhsize].info &= ~(CAVE_ICKY);
@@ -1288,8 +1267,8 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
 
        for (i = 1; i < ysize; ++i)
        {
-               place_extra_bold(floor_ptr, y0 + i - yhsize, x0 + 0 - xhsize);
-               place_extra_bold(floor_ptr, y0 + i - yhsize, x0 + xsize - xhsize);
+               place_bold(player_ptr, y0 + i - yhsize, x0 + 0 - xhsize, extra);
+               place_bold(player_ptr, y0 + i - yhsize, x0 + xsize - xhsize, extra);
 
                /* clear icky flag -done with it */
                floor_ptr->grid_array[y0 + i - yhsize][x0 + 0 - xhsize].info &= ~(CAVE_ICKY);
@@ -1305,7 +1284,7 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                        /* Fill unconnected regions with granite */
                        if ((!(floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info & CAVE_ICKY)) ||
                                is_outer_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize))
-                               place_extra_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize);
+                               place_bold(player_ptr, y0 + y - yhsize, x0 + x - xhsize, extra);
 
                        /* turn off icky flag (no longer needed.) */
                        floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
@@ -1313,7 +1292,7 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
                        /* Light lava */
                        if (cave_have_flag_bold(floor_ptr, y0 + y - yhsize, x0 + x - xhsize, FF_LAVA))
                        {
-                               if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info |= CAVE_GLOW;
+                               if (!(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) floor_ptr->grid_array[y0 + y - yhsize][x0 + x - xhsize].info |= CAVE_GLOW;
                        }
                }
        }
@@ -1325,7 +1304,7 @@ bool generate_lake(floor_type *floor_ptr, POSITION y0, POSITION x0, POSITION xsi
 /*
  * makes a lake/collapsed floor in the center of the dungeon
  */
-void build_lake(floor_type *floor_ptr, int type)
+void build_lake(player_type *player_ptr, int type)
 {
        int grd, roug, xsize, ysize, x0, y0;
        bool done = FALSE;
@@ -1339,6 +1318,7 @@ void build_lake(floor_type *floor_ptr, int type)
        }
 
        /* Make the size of the dungeon */
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        xsize = floor_ptr->width - 1;
        ysize = floor_ptr->height - 1;
        x0 = xsize / 2;
@@ -1370,7 +1350,7 @@ void build_lake(floor_type *floor_ptr, int type)
                generate_hmap(floor_ptr, y0 + 1, x0 + 1, xsize, ysize, grd, roug, c3);
 
                /* Convert to normal format+ clean up */
-               done = generate_lake(floor_ptr, y0 + 1, x0 + 1, xsize, ysize, c1, c2, c3, type);
+               done = generate_lake(player_ptr, y0 + 1, x0 + 1, xsize, ysize, c1, c2, c3, type);
        }
 }
 #endif /* ALLOW_CAVERNS_AND_LAKES */
@@ -1380,7 +1360,7 @@ void build_lake(floor_type *floor_ptr, int type)
 /*
  * Routine that fills the empty areas of a room with treasure and monsters.
  */
-void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
+void fill_treasure(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2, int difficulty)
 {
        POSITION x, y, cx, cy, size;
        s32b value;
@@ -1392,6 +1372,7 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
        /* Rough measure of size of vault= sum of lengths of sides */
        size = abs(x2 - x1) + abs(y2 - y1);
 
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        for (x = x1; x <= x2; x++)
        {
                for (y = y1; y <= y2; y++)
@@ -1403,35 +1384,35 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
                        /* hack- empty square part of the time */
                        if ((randint1(100) - difficulty * 3) > 50) value = 20;
 
-                        /* if floor, shallow water and lava */
+                       /* if floor, shallow water and lava */
                        if (is_floor_bold(floor_ptr, y, x) ||
-                           (cave_have_flag_bold(floor_ptr, y, x, FF_PLACE) && cave_have_flag_bold(floor_ptr, y, x, FF_DROP)))
+                               (cave_have_flag_bold(floor_ptr, y, x, FF_PLACE) && cave_have_flag_bold(floor_ptr, y, x, FF_DROP)))
                        {
                                /* The smaller 'value' is, the better the stuff */
                                if (value < 0)
                                {
                                        /* Meanest monster + treasure */
                                        floor_ptr->monster_level = floor_ptr->base_level + 40;
-                                       place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                       place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        floor_ptr->monster_level = floor_ptr->base_level;
                                        floor_ptr->object_level = floor_ptr->base_level + 20;
-                                       place_object(y, x, AM_GOOD);
+                                       place_object(player_ptr, y, x, AM_GOOD);
                                        floor_ptr->object_level = floor_ptr->base_level;
                                }
                                else if (value < 5)
                                {
                                        /* Mean monster +treasure */
                                        floor_ptr->monster_level = floor_ptr->base_level + 20;
-                                       place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                       place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        floor_ptr->monster_level = floor_ptr->base_level;
                                        floor_ptr->object_level = floor_ptr->base_level + 10;
-                                       place_object(y, x, AM_GOOD);
+                                       place_object(player_ptr, y, x, AM_GOOD);
                                        floor_ptr->object_level = floor_ptr->base_level;
                                }
                                else if (value < 10)
                                {
                                        floor_ptr->monster_level = floor_ptr->base_level + 9;
-                                       place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                       place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        floor_ptr->monster_level = floor_ptr->base_level;
                                }
                                else if (value < 17)
@@ -1450,20 +1431,20 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
                                        /* Object or trap */
                                        if (randint0(100) < 25)
                                        {
-                                               place_object(y, x, 0L);
+                                               place_object(player_ptr, y, x, 0L);
                                        }
                                        else
                                        {
-                                               place_trap(floor_ptr, y, x);
+                                               place_trap(player_ptr, y, x);
                                        }
                                }
                                else if (value < 30)
                                {
                                        /* Monster and trap */
                                        floor_ptr->monster_level = floor_ptr->base_level + 5;
-                                       place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                       place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        floor_ptr->monster_level = floor_ptr->base_level;
-                                       place_trap(floor_ptr, y, x);
+                                       place_trap(player_ptr, y, x);
                                }
                                else if (value < 40)
                                {
@@ -1471,20 +1452,20 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
                                        if (randint0(100) < 50)
                                        {
                                                floor_ptr->monster_level = floor_ptr->base_level + 3;
-                                               place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                               place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                                floor_ptr->monster_level = floor_ptr->base_level;
                                        }
                                        if (randint0(100) < 50)
                                        {
                                                floor_ptr->object_level = floor_ptr->base_level + 7;
-                                               place_object(y, x, 0L);
+                                               place_object(player_ptr, y, x, 0L);
                                                floor_ptr->object_level = floor_ptr->base_level;
                                        }
                                }
                                else if (value < 50)
                                {
                                        /* Trap */
-                                       place_trap(floor_ptr, y, x);
+                                       place_trap(player_ptr, y, x);
                                }
                                else
                                {
@@ -1493,15 +1474,15 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
                                        /* 20% monster, 40% trap, 20% object, 20% blank space */
                                        if (randint0(100) < 20)
                                        {
-                                               place_monster(y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
+                                               place_monster(player_ptr, y, x, (PM_ALLOW_SLEEP | PM_ALLOW_GROUP));
                                        }
                                        else if (randint0(100) < 50)
                                        {
-                                               place_trap(floor_ptr, y, x);
+                                               place_trap(player_ptr, y, x);
                                        }
                                        else if (randint0(100) < 50)
                                        {
-                                               place_object(y, x, 0L);
+                                               place_object(player_ptr, y, x, 0L);
                                        }
                                }
 
@@ -1511,14 +1492,13 @@ void fill_treasure(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1,
 }
 
 
-
 /*
  * Overlay a rectangular room given its bounds
  * This routine is used by build_room_vault
  * The area inside the walls is not touched:
  * only granite is removed- normal walls stay
  */
-void build_room(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2)
+void build_room(player_type *player_ptr, POSITION x1, POSITION x2, POSITION y1, POSITION y2)
 {
        POSITION x, y, xsize, ysize;
        int i, temp;
@@ -1548,21 +1528,22 @@ void build_room(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, PO
 
 
        /* Top and bottom boundaries */
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        for (i = 0; i <= xsize; i++)
        {
-               place_outer_noperm_bold(floor_ptr, y1, x1 + i);
+               place_bold(player_ptr, y1, x1 + i, outer_noperm);
                floor_ptr->grid_array[y1][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
-               place_outer_noperm_bold(floor_ptr, y2, x1 + i);
+               place_bold(player_ptr, y2, x1 + i, outer_noperm);
                floor_ptr->grid_array[y2][x1 + i].info |= (CAVE_ROOM | CAVE_ICKY);
        }
 
        /* Left and right boundaries */
        for (i = 1; i < ysize; i++)
        {
-               place_outer_noperm_bold(floor_ptr, y1 + i, x1);
-               floor_ptr->grid_array[y1 + i][x1].info|=(CAVE_ROOM | CAVE_ICKY);
-               place_outer_noperm_bold(floor_ptr, y1 + i, x2);
-               floor_ptr->grid_array[y1 + i][x2].info|=(CAVE_ROOM | CAVE_ICKY);
+               place_bold(player_ptr, y1 + i, x1, outer_noperm);
+               floor_ptr->grid_array[y1 + i][x1].info |= (CAVE_ROOM | CAVE_ICKY);
+               place_bold(player_ptr, y1 + i, x2, outer_noperm);
+               floor_ptr->grid_array[y1 + i][x2].info |= (CAVE_ROOM | CAVE_ICKY);
        }
 
        /* Middle */
@@ -1570,10 +1551,10 @@ void build_room(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, PO
        {
                for (y = 1; y < ysize; y++)
                {
-                       if (is_extra_bold(floor_ptr, y1+y, x1+x))
+                       if (is_extra_bold(floor_ptr, y1 + y, x1 + x))
                        {
                                /* clear the untouched region */
-                               place_floor_bold(floor_ptr, y1 + y, x1 + x);
+                               place_bold(player_ptr, y1 + y, x1 + x, floor);
                                floor_ptr->grid_array[y1 + y][x1 + x].info |= (CAVE_ROOM | CAVE_ICKY);
                        }
                        else
@@ -1605,7 +1586,7 @@ void build_room(floor_type *floor_ptr, POSITION x1, POSITION x2, POSITION y1, PO
  * is the randint0(3) below; it governs the relative density of
  * twists and turns in the labyrinth: smaller number, more twists.
  */
-void r_visit(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int node, DIRECTION dir, int *visited)
+void r_visit(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int node, DIRECTION dir, int *visited)
 {
        int i, j, m, n, temp, x, y, adj[4];
 
@@ -1617,7 +1598,7 @@ void r_visit(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSIT
        visited[node] = 1;
        x = 2 * (node % m) + x1;
        y = 2 * (node / m) + y1;
-       place_floor_bold(floor_ptr, y, x);
+       place_bold(player_ptr, y, x, floor);
 
        /* setup order of adjacent node visits */
        if (one_in_(3))
@@ -1653,43 +1634,43 @@ void r_visit(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSIT
        {
                switch (adj[i])
                {
-                       case 0:
-                               /* (0,+) - check for bottom boundary */
-                               if ((node / m < n - 1) && (visited[node + m] == 0))
-                               {
-                                       place_floor_bold(floor_ptr, y + 1, x);
-                                       r_visit(floor_ptr, y1, x1, y2, x2, node + m, dir, visited);
-                               }
-                               break;
-                       case 1:
-                               /* (0,-) - check for top boundary */
-                               if ((node / m > 0) && (visited[node - m] == 0))
-                               {
-                                       place_floor_bold(floor_ptr, y - 1, x);
-                                       r_visit(floor_ptr, y1, x1, y2, x2, node - m, dir, visited);
-                               }
-                               break;
-                       case 2:
-                               /* (+,0) - check for right boundary */
-                               if ((node % m < m - 1) && (visited[node + 1] == 0))
-                               {
-                                       place_floor_bold(floor_ptr, y, x + 1);
-                                       r_visit(floor_ptr, y1, x1, y2, x2, node + 1, dir, visited);
-                               }
-                               break;
-                       case 3:
-                               /* (-,0) - check for left boundary */
-                               if ((node % m > 0) && (visited[node - 1] == 0))
-                               {
-                                       place_floor_bold(floor_ptr, y, x - 1);
-                                       r_visit(floor_ptr, y1, x1, y2, x2, node - 1, dir, visited);
-                               }
+               case 0:
+                       /* (0,+) - check for bottom boundary */
+                       if ((node / m < n - 1) && (visited[node + m] == 0))
+                       {
+                               place_bold(player_ptr, y + 1, x, floor);
+                               r_visit(player_ptr, y1, x1, y2, x2, node + m, dir, visited);
+                       }
+                       break;
+               case 1:
+                       /* (0,-) - check for top boundary */
+                       if ((node / m > 0) && (visited[node - m] == 0))
+                       {
+                               place_bold(player_ptr, y - 1, x, floor);
+                               r_visit(player_ptr, y1, x1, y2, x2, node - m, dir, visited);
+                       }
+                       break;
+               case 2:
+                       /* (+,0) - check for right boundary */
+                       if ((node % m < m - 1) && (visited[node + 1] == 0))
+                       {
+                               place_bold(player_ptr, y, x + 1, floor);
+                               r_visit(player_ptr, y1, x1, y2, x2, node + 1, dir, visited);
+                       }
+                       break;
+               case 3:
+                       /* (-,0) - check for left boundary */
+                       if ((node % m > 0) && (visited[node - 1] == 0))
+                       {
+                               place_bold(player_ptr, y, x - 1, floor);
+                               r_visit(player_ptr, y1, x1, y2, x2, node - 1, dir, visited);
+                       }
                } /* end switch */
        }
 }
 
 
-void build_maze_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize, bool is_vault)
+void build_maze_vault(player_type *player_ptr, POSITION x0, POSITION y0, POSITION xsize, POSITION ysize, bool is_vault)
 {
        POSITION y, x, dy, dx;
        POSITION y1, x1, y2, x2;
@@ -1700,7 +1681,8 @@ void build_maze_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION
        msg_print_wizard(CHEAT_DUNGEON, _("迷路ランダムVaultを生成しました。", "Maze Vault."));
 
        /* Choose lite or dark */
-       light = ((floor_ptr->dun_level <= randint1(25)) && is_vault && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       light = ((floor_ptr->dun_level <= randint1(25)) && is_vault && !(d_info[floor_ptr->dungeon_idx].flags1 & DF1_DARKNESS));
 
        /* Pick a random room size - randomized by calling routine */
        dy = ysize / 2 - 1;
@@ -1721,15 +1703,15 @@ void build_maze_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION
                        if (is_vault) g_ptr->info |= CAVE_ICKY;
                        if ((x == x1 - 1) || (x == x2 + 1) || (y == y1 - 1) || (y == y2 + 1))
                        {
-                               place_outer_grid(g_ptr);
+                               place_grid(player_ptr, g_ptr, outer);
                        }
                        else if (!is_vault)
                        {
-                               place_extra_grid(g_ptr);
+                               place_grid(player_ptr, g_ptr, extra);
                        }
                        else
                        {
-                               place_inner_grid(g_ptr);
+                               place_grid(player_ptr, g_ptr, inner);
                        }
                        if (light) g_ptr->info |= (CAVE_GLOW);
                }
@@ -1744,10 +1726,10 @@ void build_maze_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION
        C_MAKE(visited, num_vertices, int);
 
        /* traverse the graph to create a spaning tree, pick a random root */
-       r_visit(floor_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
+       r_visit(player_ptr, y1, x1, y2, x2, randint0(num_vertices), 0, visited);
 
        /* Fill with monsters and treasure, low difficulty */
-       if (is_vault) fill_treasure(floor_ptr, x1, x2, y1, y2, randint1(5));
+       if (is_vault) fill_treasure(player_ptr, x1, x2, y1, y2, randint1(5));
 
        C_KILL(visited, num_vertices, int);
 }
@@ -1760,7 +1742,7 @@ void build_maze_vault(floor_type *floor_ptr, POSITION x0, POSITION y0, POSITION
  * The power variable is a measure of how well defended a region is.
  * This alters the possible choices.
  */
-void build_recursive_room(floor_type *floor_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int power)
+void build_recursive_room(player_type *player_ptr, POSITION x1, POSITION y1, POSITION x2, POSITION y2, int power)
 {
        POSITION xsize, ysize;
        POSITION x, y;
@@ -1799,162 +1781,161 @@ void build_recursive_room(floor_type *floor_ptr, POSITION x1, POSITION y1, POSIT
        }
 
        /* Based on the choice made above, do something */
-
        switch (choice)
        {
-               case 1:
+       case 1:
+       {
+               /* Outer walls */
+
+               /* top and bottom */
+               for (x = x1; x <= x2; x++)
                {
-                       /* Outer walls */
+                       place_bold(player_ptr, y1, x, outer);
+                       place_bold(player_ptr, y2, x, outer);
+               }
 
-                       /* top and bottom */
-                       for (x = x1; x <= x2; x++)
-                       {
-                               place_outer_bold(floor_ptr, y1, x);
-                               place_outer_bold(floor_ptr, y2, x);
-                       }
+               /* left and right */
+               for (y = y1 + 1; y < y2; y++)
+               {
+                       place_bold(player_ptr, y, x1, outer);
+                       place_bold(player_ptr, y, x2, outer);
+               }
 
+               /* Make a couple of entrances */
+               if (one_in_(2))
+               {
                        /* left and right */
-                       for (y = y1 + 1; y < y2; y++)
-                       {
-                               place_outer_bold(floor_ptr, y, x1);
-                               place_outer_bold(floor_ptr, y, x2);
-                       }
-
-                       /* Make a couple of entrances */
-                       if (one_in_(2))
-                       {
-                               /* left and right */
-                               y = randint1(ysize) + y1;
-                               place_floor_bold(floor_ptr, y, x1);
-                               place_floor_bold(floor_ptr, y, x2);
-                       }
-                       else
-                       {
-                               /* top and bottom */
-                               x = randint1(xsize) + x1;
-                               place_floor_bold(floor_ptr, y1, x);
-                               place_floor_bold(floor_ptr, y2, x);
-                       }
+                       y = randint1(ysize) + y1;
+                       place_bold(player_ptr, y, x1, floor);
+                       place_bold(player_ptr, y, x2, floor);
+               }
+               else
+               {
+                       /* top and bottom */
+                       x = randint1(xsize) + x1;
+                       place_bold(player_ptr, y1, x, floor);
+                       place_bold(player_ptr, y2, x, floor);
+               }
 
-                       /* Select size of keep */
-                       t1 = randint1(ysize / 3) + y1;
-                       t2 = y2 - randint1(ysize / 3);
-                       t3 = randint1(xsize / 3) + x1;
-                       t4 = x2 - randint1(xsize / 3);
+               /* Select size of keep */
+               t1 = randint1(ysize / 3) + y1;
+               t2 = y2 - randint1(ysize / 3);
+               t3 = randint1(xsize / 3) + x1;
+               t4 = x2 - randint1(xsize / 3);
 
-                       /* Do outside areas */
+               /* Do outside areas */
 
-                       /* Above and below keep */
-                       build_recursive_room(floor_ptr, x1 + 1, y1 + 1, x2 - 1, t1, power + 1);
-                       build_recursive_room(floor_ptr, x1 + 1, t2, x2 - 1, y2, power + 1);
+               /* Above and below keep */
+               build_recursive_room(player_ptr, x1 + 1, y1 + 1, x2 - 1, t1, power + 1);
+               build_recursive_room(player_ptr, x1 + 1, t2, x2 - 1, y2, power + 1);
 
-                       /* Left and right of keep */
-                       build_recursive_room(floor_ptr, x1 + 1, t1 + 1, t3, t2 - 1, power + 3);
-                       build_recursive_room(floor_ptr, t4, t1 + 1, x2 - 1, t2 - 1, power + 3);
+               /* Left and right of keep */
+               build_recursive_room(player_ptr, x1 + 1, t1 + 1, t3, t2 - 1, power + 3);
+               build_recursive_room(player_ptr, t4, t1 + 1, x2 - 1, t2 - 1, power + 3);
 
-                       /* Make the keep itself: */
-                       x1 = t3;
-                       x2 = t4;
-                       y1 = t1;
-                       y2 = t2;
-                       xsize = x2 - x1;
-                       ysize = y2 - y1;
-                       power += 2;
+               /* Make the keep itself: */
+               x1 = t3;
+               x2 = t4;
+               y1 = t1;
+               y2 = t2;
+               xsize = x2 - x1;
+               ysize = y2 - y1;
+               power += 2;
 
-                       /* Fall through */
-               }
-               case 4:
+               /* Fall through */
+       }
+       case 4:
+       {
+               /* Try to build a room */
+               if ((xsize < 3) || (ysize < 3))
                {
-                       /* Try to build a room */
-                       if ((xsize < 3) || (ysize < 3))
+                       for (y = y1; y < y2; y++)
                        {
-                               for (y = y1; y < y2; y++)
+                               for (x = x1; x < x2; x++)
                                {
-                                       for (x = x1; x < x2; x++)
-                                       {
-                                               place_inner_bold(floor_ptr, y, x);
-                                       }
+                                       place_bold(player_ptr, y, x, inner);
                                }
-
-                               /* Too small */
-                               return;
                        }
 
-                       /* Make outside walls */
-                       /* top and bottom */
-                       for (x = x1 + 1; x <= x2 - 1; x++)
-                       {
-                               place_inner_bold(floor_ptr, y1 + 1, x);
-                               place_inner_bold(floor_ptr, y2 - 1, x);
-                       }
+                       /* Too small */
+                       return;
+               }
 
-                       /* left and right */
-                       for (y = y1 + 1; y <= y2 - 1; y++)
-                       {
-                               place_inner_bold(floor_ptr, y, x1 + 1);
-                               place_inner_bold(floor_ptr, y, x2 - 1);
-                       }
+               /* Make outside walls */
+               /* top and bottom */
+               for (x = x1 + 1; x <= x2 - 1; x++)
+               {
+                       place_bold(player_ptr, y1 + 1, x, inner);
+                       place_bold(player_ptr, y2 - 1, x, inner);
+               }
 
-                       /* Make a door */
-                       y = randint1(ysize - 3) + y1 + 1;
+               /* left and right */
+               for (y = y1 + 1; y <= y2 - 1; y++)
+               {
+                       place_bold(player_ptr, y, x1 + 1, inner);
+                       place_bold(player_ptr, y, x2 - 1, inner);
+               }
 
-                       if (one_in_(2))
-                       {
-                               /* left */
-                               place_floor_bold(floor_ptr, y, x1 + 1);
-                       }
-                       else
-                       {
-                               /* right */
-                               place_floor_bold(floor_ptr, y, x2 - 1);
-                       }
+               /* Make a door */
+               y = randint1(ysize - 3) + y1 + 1;
 
-                       /* Build the room */
-                       build_recursive_room(floor_ptr, x1 + 2, y1 + 2, x2 - 2, y2 - 2, power + 3);
-                       break;
+               if (one_in_(2))
+               {
+                       /* left */
+                       place_bold(player_ptr, y, x1 + 1, floor);
                }
-               case 2:
+               else
                {
-                       /* Try and divide vertically */
-                       if (xsize < 3)
+                       /* right */
+                       place_bold(player_ptr, y, x2 - 1, floor);
+               }
+
+               /* Build the room */
+               build_recursive_room(player_ptr, x1 + 2, y1 + 2, x2 - 2, y2 - 2, power + 3);
+               break;
+       }
+       case 2:
+       {
+               /* Try and divide vertically */
+               if (xsize < 3)
+               {
+                       /* Too small */
+                       for (y = y1; y < y2; y++)
                        {
-                               /* Too small */
-                               for (y = y1; y < y2; y++)
+                               for (x = x1; x < x2; x++)
                                {
-                                       for (x = x1; x < x2; x++)
-                                       {
-                                               place_inner_bold(floor_ptr, y, x);
-                                       }
+                                       place_bold(player_ptr, y, x, inner);
                                }
-                               return;
                        }
-
-                       t1 = randint1(xsize - 2) + x1 + 1;
-                       build_recursive_room(floor_ptr, x1, y1, t1, y2, power - 2);
-                       build_recursive_room(floor_ptr, t1 + 1, y1, x2, y2, power - 2);
-                       break;
+                       return;
                }
-               case 3:
+
+               t1 = randint1(xsize - 2) + x1 + 1;
+               build_recursive_room(player_ptr, x1, y1, t1, y2, power - 2);
+               build_recursive_room(player_ptr, t1 + 1, y1, x2, y2, power - 2);
+               break;
+       }
+       case 3:
+       {
+               /* Try and divide horizontally */
+               if (ysize < 3)
                {
-                       /* Try and divide horizontally */
-                       if (ysize < 3)
+                       /* Too small */
+                       for (y = y1; y < y2; y++)
                        {
-                               /* Too small */
-                               for (y = y1; y < y2; y++)
+                               for (x = x1; x < x2; x++)
                                {
-                                       for (x = x1; x < x2; x++)
-                                       {
-                                               place_inner_bold(floor_ptr, y, x);
-                                       }
+                                       place_bold(player_ptr, y, x, inner);
                                }
-                               return;
                        }
-
-                       t1 = randint1(ysize - 2) + y1 + 1;
-                       build_recursive_room(floor_ptr, x1, y1, x2, t1, power - 2);
-                       build_recursive_room(floor_ptr, x1, t1 + 1, x2, y2, power - 2);
-                       break;
+                       return;
                }
+
+               t1 = randint1(ysize - 2) + y1 + 1;
+               build_recursive_room(player_ptr, x1, y1, x2, t1, power - 2);
+               build_recursive_room(player_ptr, x1, t1 + 1, x2, y2, power - 2);
+               break;
+       }
        }
 }
 
@@ -1964,12 +1945,13 @@ void build_recursive_room(floor_type *floor_ptr, POSITION x1, POSITION y1, POSIT
  * Note: no range checking is done so must be inside dungeon
  * This routine also stomps on doors
  */
-void add_outer_wall(floor_type *floor_ptr, POSITION x, POSITION y, int light, POSITION x1, POSITION y1, POSITION x2, POSITION y2)
+void add_outer_wall(player_type *player_ptr, POSITION x, POSITION y, int light, POSITION x1, POSITION y1, POSITION x2, POSITION y2)
 {
        grid_type *g_ptr;
        feature_type *f_ptr;
        int i, j;
 
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        if (!in_bounds(floor_ptr, y, x)) return;
 
        g_ptr = &floor_ptr->grid_array[y][x];
@@ -1991,7 +1973,7 @@ void add_outer_wall(floor_type *floor_ptr, POSITION x, POSITION y, int light, PO
                        {
                                if ((x + i >= x1) && (x + i <= x2) && (y + j >= y1) && (y + j <= y2))
                                {
-                                       add_outer_wall(floor_ptr, x + i, y + j, light, x1, y1, x2, y2);
+                                       add_outer_wall(player_ptr, x + i, y + j, light, x1, y1, x2, y2);
                                        if (light) g_ptr->info |= CAVE_GLOW;
                                }
                        }
@@ -2000,7 +1982,7 @@ void add_outer_wall(floor_type *floor_ptr, POSITION x, POSITION y, int light, PO
        else if (is_extra_bold(floor_ptr, y, x))
        {
                /* Set bounding walls */
-               place_outer_bold(floor_ptr, y, x);
+               place_bold(player_ptr, y, x, outer);
                if (light) g_ptr->info |= CAVE_GLOW;
        }
        else if (permanent_wall(f_ptr))
@@ -2028,7 +2010,7 @@ POSITION dist2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, POSITION h1,
         * trying to fix the circular rooms.)
         */
 
-       /* h1-h4 are constants that describe the metric */
+        /* h1-h4 are constants that describe the metric */
        if (dx >= 2 * dy) return (dx + (dy * h1) / h2);
        if (dy >= 2 * dx) return (dy + (dx * h1) / h2);
        return (((dx + dy) * 128) / 181 +
@@ -2040,10 +2022,10 @@ POSITION dist2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, POSITION h1,
 
 
 /* Create a new floor room with optional light */
-void generate_room_floor(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int light)
+void generate_room_floor(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2, int light)
 {
        POSITION y, x;
-       
+
        grid_type *g_ptr;
 
        for (y = y1; y <= y2; y++)
@@ -2051,15 +2033,15 @@ void generate_room_floor(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITI
                for (x = x1; x <= x2; x++)
                {
                        /* Point to grid */
-                       g_ptr = &floor_ptr->grid_array[y][x];
-                       place_floor_grid(g_ptr);
+                       g_ptr = &player_ptr->current_floor_ptr->grid_array[y][x];
+                       place_grid(player_ptr, g_ptr, floor);
                        g_ptr->info |= (CAVE_ROOM);
                        if (light) g_ptr->info |= (CAVE_GLOW);
                }
        }
 }
 
-void generate_fill_perm_bold(floor_type *floor_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
+void generate_fill_perm_bold(player_type *player_ptr, POSITION y1, POSITION x1, POSITION y2, POSITION x2)
 {
        POSITION y, x;
 
@@ -2068,7 +2050,7 @@ void generate_fill_perm_bold(floor_type *floor_ptr, POSITION y1, POSITION x1, PO
                for (x = x1; x <= x2; x++)
                {
                        /* Point to grid */
-                       place_inner_perm_bold(floor_ptr ,y, x);
+                       place_bold(player_ptr, y, x, inner_perm);
                }
        }
 }
@@ -2076,33 +2058,33 @@ void generate_fill_perm_bold(floor_type *floor_ptr, POSITION y1, POSITION x1, PO
 
 /*!
  * @brief 与えられた部屋型IDに応じて部屋の生成処理分岐を行い結果を返す / Attempt to build a room of the given type at the given block
+ * @param player_ptr プレーヤーへの参照ポインタ
  * @param type 部屋型ID
  * @note that we restrict the number of "crowded" rooms to reduce the chance of overflowing the monster list during level creation.
- * @return é\83¨å±\8bã\81®ç²¾è£½に成功した場合 TRUE を返す。
+ * @return é\83¨å±\8bã\81®ç\94\9fæ\88\90に成功した場合 TRUE を返す。
  */
-static bool room_build(floor_type *floor_ptr, EFFECT_ID typ)
+static bool room_build(player_type *player_ptr, EFFECT_ID typ)
 {
-       /* Build a room */
        switch (typ)
        {
-       /* Build an appropriate room */
-       case ROOM_T_NORMAL:        return build_type1(floor_ptr);
-       case ROOM_T_OVERLAP:       return build_type2(floor_ptr);
-       case ROOM_T_CROSS:         return build_type3(floor_ptr);
-       case ROOM_T_INNER_FEAT:    return build_type4(floor_ptr);
-       case ROOM_T_NEST:          return build_type5(floor_ptr);
-       case ROOM_T_PIT:           return build_type6(floor_ptr);
-       case ROOM_T_LESSER_VAULT:  return build_type7(floor_ptr);
-       case ROOM_T_GREATER_VAULT: return build_type8(floor_ptr);
-       case ROOM_T_FRACAVE:       return build_type9(floor_ptr);
-       case ROOM_T_RANDOM_VAULT:  return build_type10(floor_ptr);
-       case ROOM_T_OVAL:          return build_type11(floor_ptr);
-       case ROOM_T_CRYPT:         return build_type12(floor_ptr);
-       case ROOM_T_TRAP_PIT:      return build_type13(floor_ptr);
-       case ROOM_T_TRAP:          return build_type14(floor_ptr);
-       case ROOM_T_GLASS:         return build_type15(floor_ptr);
-       case ROOM_T_ARCADE:        return build_type16(floor_ptr);
-       case ROOM_T_FIXED:         return build_type17(floor_ptr);
+               /* Build an appropriate room */
+       case ROOM_T_NORMAL:        return build_type1(player_ptr);
+       case ROOM_T_OVERLAP:       return build_type2(player_ptr);
+       case ROOM_T_CROSS:         return build_type3(player_ptr);
+       case ROOM_T_INNER_FEAT:    return build_type4(player_ptr);
+       case ROOM_T_NEST:          return build_type5(player_ptr);
+       case ROOM_T_PIT:           return build_type6(player_ptr);
+       case ROOM_T_LESSER_VAULT:  return build_type7(player_ptr);
+       case ROOM_T_GREATER_VAULT: return build_type8(player_ptr);
+       case ROOM_T_FRACAVE:       return build_type9(player_ptr);
+       case ROOM_T_RANDOM_VAULT:  return build_type10(player_ptr);
+       case ROOM_T_OVAL:          return build_type11(player_ptr);
+       case ROOM_T_CRYPT:         return build_type12(player_ptr);
+       case ROOM_T_TRAP_PIT:      return build_type13(player_ptr);
+       case ROOM_T_TRAP:          return build_type14(player_ptr);
+       case ROOM_T_GLASS:         return build_type15(player_ptr);
+       case ROOM_T_ARCADE:        return build_type16(player_ptr);
+       case ROOM_T_FIXED:         return build_type17(player_ptr);
        }
        return FALSE;
 }
@@ -2114,12 +2096,14 @@ static bool room_build(floor_type *floor_ptr, EFFECT_ID typ)
  */
 #define MOVE_PLIST(dst, src) (prob_list[dst] += prob_list[src], prob_list[src] = 0) 
 
-/*!
- * @brief 部屋生成処理のメインルーチン(Sangbandを経由してOangbandからの実装を引用) / Generate rooms in dungeon.  Build bigger rooms at first. [from SAngband (originally from OAngband)]
- * @return 部屋生成に成功した場合 TRUE を返す。
- */
-bool generate_rooms(floor_type *floor_ptr)
+ /*!
+  * @brief 部屋生成処理のメインルーチン(Sangbandを経由してOangbandからの実装を引用) / Generate rooms in dungeon.  Build bigger rooms at first. [from SAngband (originally from OAngband)]
+  * @param player_ptr プレーヤーへの参照ポインタ
+  * @return 部屋生成に成功した場合 TRUE を返す。
+  */
+bool generate_rooms(player_type *player_ptr)
 {
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
        int i;
        bool remain;
        int crowded = 0;
@@ -2158,9 +2142,9 @@ bool generate_rooms(floor_type *floor_ptr)
         * XXX -- Various dungeon types and options.
         */
 
-       /*! @details ダンジョンにBEGINNER、CHAMELEON、SMALLESTいずれのフラグもなく、
-        * かつ「常に通常でない部屋を生成する」フラグがONならば、
-        * GRATER_VAULTのみを生成対象とする。 / Ironman sees only Greater Vaults */
+        /*! @details ダンジョンにBEGINNER、CHAMELEON、SMALLESTいずれのフラグもなく、
+         * かつ「常に通常でない部屋を生成する」フラグがONならば、
+         * GRATER_VAULTのみを生成対象とする。 / Ironman sees only Greater Vaults */
        if (ironman_rooms && !((d_info[floor_ptr->dungeon_idx].flags1 & (DF1_BEGINNER | DF1_CHAMELEON | DF1_SMALLEST))))
        {
                for (i = 0; i < ROOM_T_MAX; i++)
@@ -2289,7 +2273,7 @@ bool generate_rooms(floor_type *floor_ptr)
                        room_num[room_type]--;
 
                        /* Build the room. */
-                       if (room_build(floor_ptr, room_type))
+                       if (room_build(player_ptr, room_type))
                        {
                                /* Increase the room built count. */
                                rooms_built++;