OSDN Git Service

[Refactor] #38997 place_outer_perm_grid() を削除し、place_grid() に統合 / Removed place_outer...
[hengband/hengband.git] / src / rooms-pitnest.c
index 55d9e3b..6f4d43b 100644 (file)
@@ -1,11 +1,16 @@
 #include "angband.h"
+#include "util.h"
+
 #include "grid.h"
-#include "generate.h"
+#include "floor-generate.h"
 #include "rooms.h"
 #include "rooms-pitnest.h"
 #include "monster.h"
 #include "monsterrace-hook.h"
 #include "sort.h"
+#include "floor.h"
+#include "feature.h"
+#include "dungeon.h"
 
 
 
@@ -19,7 +24,7 @@ struct vault_aux_type
 {
        concptr name;
        bool(*hook_func)(MONRACE_IDX r_idx);
-       void(*prep_func)(void);
+       void(*prep_func)(player_type *player_ptr);
        DEPTH level;
        int chance;
 };
@@ -55,7 +60,7 @@ struct vault_aux_type
 * @param allow_flag_mask 生成が許されるpit/nestのビット配列
 * @return 選択されたpit/nestのID、選択失敗した場合-1を返す。
 */
-static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
+static int pick_vault_type(floor_type *floor_ptr, vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
 {
        int tmp, total, count;
 
@@ -68,13 +73,13 @@ static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
                if (!n_ptr->name) break;
 
                /* Ignore excessive depth */
-               if (n_ptr->level > dun_level) continue;
+               if (n_ptr->level > floor_ptr->dun_level) continue;
 
                /* Not matched with pit/nest flag */
                if (!(allow_flag_mask & (1L << count))) continue;
 
                /* Count this possibility */
-               total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
+               total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
        }
 
        /* Pick a random type */
@@ -87,13 +92,13 @@ static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
                if (!n_ptr->name) break;
 
                /* Ignore excessive depth */
-               if (n_ptr->level > dun_level) continue;
+               if (n_ptr->level > floor_ptr->dun_level) continue;
 
                /* Not matched with pit/nest flag */
                if (!(allow_flag_mask & (1L << count))) continue;
 
                /* Count this possibility */
-               total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
+               total += n_ptr->chance * MAX_DEPTH / (MIN(floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
 
                /* Found the type */
                if (tmp < total) break;
@@ -164,6 +169,7 @@ static concptr pit_subtype_string(int type, bool nest)
 *  @param v 未使用
 *  @param a 比較対象参照ID1
 *  @param b 比較対象参照ID2
+*  TODO: to sort.c
 */
 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -204,6 +210,7 @@ static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 * @param v 未使用
 * @param a スワップ対象参照ID1
 * @param b スワップ対象参照ID2
+* TODO: to sort.c
 */
 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -242,7 +249,7 @@ static vault_aux_type pit_types[] =
 {
        { _("オーク", "orc"),            vault_aux_orc,      NULL,               5, 6 },
        { _("トロル", "troll"),          vault_aux_troll,    NULL,              20, 6 },
-       { _("ジャイアント", "giant"),    vault_aux_giant,    NULL,              50, 6 },
+       { _("巨人", "giant"),    vault_aux_giant,    NULL,              50, 6 },
        { _("狂気", "lovecraftian"),     vault_aux_cthulhu,  NULL,              80, 2 },
        { _("シンボル(善)", "symbol good"), vault_aux_symbol_g, vault_prep_symbol, 70, 1 },
        { _("シンボル(悪)", "symbol evil"), vault_aux_symbol_e, vault_prep_symbol, 70, 1 },
@@ -258,6 +265,7 @@ static vault_aux_type pit_types[] =
 
 /*!
 * @brief タイプ5の部屋…nestを生成する / Type 5 -- Monster nests
+* @param player_ptr プレーヤーへの参照ポインタ
 * @return なし
 * @details
 * A monster nest is a "big" room, with an "inner" room, containing\n
@@ -276,7 +284,7 @@ static vault_aux_type pit_types[] =
 *\n
 * Note that "monster nests" will never contain "unique" monsters.\n
 */
-bool build_type5(void)
+bool build_type5(player_type *player_ptr)
 {
        POSITION y, x, y1, x1, y2, x2, xval, yval;
        int i;
@@ -286,7 +294,8 @@ bool build_type5(void)
 
        grid_type *g_ptr;
 
-       int cur_nest_type = pick_vault_type(nest_types, d_info[p_ptr->dungeon_idx].nest);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       int cur_nest_type = pick_vault_type(floor_ptr, nest_types, d_info[floor_ptr->dungeon_idx].nest);
        vault_aux_type *n_ptr;
 
        /* No type available */
@@ -295,8 +304,8 @@ bool build_type5(void)
        n_ptr = &nest_types[cur_nest_type];
 
        /* Process a preparation function if necessary */
-       if (n_ptr->prep_func) (*(n_ptr->prep_func))();
-       get_mon_num_prep(n_ptr->hook_func, NULL);
+       if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
+       get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
 
        align.sub_align = SUB_ALIGN_NEUTRAL;
 
@@ -310,7 +319,7 @@ bool build_type5(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 11);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -332,7 +341,7 @@ bool build_type5(void)
        }
 
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 11, 25)) return FALSE;
+       if (!find_space(floor_ptr, &yval, &xval, 11, 25)) return FALSE;
 
        /* Large room */
        y1 = yval - 4;
@@ -345,8 +354,8 @@ bool build_type5(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
-                       place_floor_grid(g_ptr);
+                       g_ptr = &floor_ptr->grid_array[y][x];
+                       place_grid(g_ptr, floor);
                        g_ptr->info |= (CAVE_ROOM);
                }
        }
@@ -354,17 +363,17 @@ bool build_type5(void)
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y][x1 - 1];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y][x2 + 1];
+               place_grid(g_ptr, outer);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y1 - 1][x];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y2 + 1][x];
+               place_grid(g_ptr, outer);
        }
 
 
@@ -377,34 +386,34 @@ bool build_type5(void)
        /* The inner walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
-               place_inner_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
-               place_inner_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y][x1 - 1];
+               place_grid(g_ptr, inner);
+               g_ptr = &floor_ptr->grid_array[y][x2 + 1];
+               place_grid(g_ptr, inner);
        }
 
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
-               place_inner_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
-               place_inner_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y1 - 1][x];
+               place_grid(g_ptr, inner);
+               g_ptr = &floor_ptr->grid_array[y2 + 1][x];
+               place_grid(g_ptr, inner);
        }
        for (y = y1; y <= y2; y++)
        {
                for (x = x1; x <= x2; x++)
                {
-                       add_cave_info(y, x, CAVE_ICKY);
+                       add_cave_info(floor_ptr, y, x, CAVE_ICKY);
                }
        }
 
        /* Place a secret door */
        switch (randint1(4))
        {
-       case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
-       case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
-       case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
-       case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
+       case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
+       case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
+       case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
+       case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
        }
 
        msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
@@ -420,7 +429,7 @@ bool build_type5(void)
                        r_idx = nest_mon_info[i].r_idx;
 
                        /* Place that "random" monster (no groups) */
-                       (void)place_monster_aux(0, y, x, r_idx, 0L);
+                       (void)place_monster_aux(player_ptr, 0, y, x, r_idx, 0L);
 
                        nest_mon_info[i].used = TRUE;
                }
@@ -428,9 +437,7 @@ bool build_type5(void)
 
        if (cheat_room)
        {
-               ang_sort_comp = ang_sort_comp_nest_mon_info;
-               ang_sort_swap = ang_sort_swap_nest_mon_info;
-               ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
+               ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
 
                /* Dump the entries (prevent multi-printing) */
                for (i = 0; i < NUM_NEST_MON_TYPE; i++)
@@ -486,7 +493,7 @@ bool build_type5(void)
 *\n
 * Note that "monster pits" will never contain "unique" monsters.\n
 */
-bool build_type6(void)
+bool build_type6(player_type *player_ptr)
 {
        POSITION y, x, y1, x1, y2, x2, xval, yval;
        int i, j;
@@ -497,7 +504,8 @@ bool build_type6(void)
 
        grid_type *g_ptr;
 
-       int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
        vault_aux_type *n_ptr;
 
        /* No type available */
@@ -506,8 +514,8 @@ bool build_type6(void)
        n_ptr = &pit_types[cur_pit_type];
 
        /* Process a preparation function if necessary */
-       if (n_ptr->prep_func) (*(n_ptr->prep_func))();
-       get_mon_num_prep(n_ptr->hook_func, NULL);
+       if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
+       get_mon_num_prep(player_ptr, n_ptr->hook_func, NULL);
 
        align.sub_align = SUB_ALIGN_NEUTRAL;
 
@@ -521,7 +529,7 @@ bool build_type6(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 11);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -542,7 +550,7 @@ bool build_type6(void)
        }
 
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 11, 25)) return FALSE;
+       if (!find_space(floor_ptr, &yval, &xval, 11, 25)) return FALSE;
 
        /* Large room */
        y1 = yval - 4;
@@ -555,8 +563,8 @@ bool build_type6(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
-                       place_floor_grid(g_ptr);
+                       g_ptr = &floor_ptr->grid_array[y][x];
+                       place_grid(g_ptr, floor);
                        g_ptr->info |= (CAVE_ROOM);
                }
        }
@@ -564,17 +572,17 @@ bool build_type6(void)
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y][x1 - 1];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y][x2 + 1];
+               place_grid(g_ptr, outer);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y1 - 1][x];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y2 + 1][x];
+               place_grid(g_ptr, outer);
        }
 
        /* Advance to the center room */
@@ -586,33 +594,33 @@ bool build_type6(void)
        /* The inner walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
-               place_inner_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
-               place_inner_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y][x1 - 1];
+               place_grid(g_ptr, inner);
+               g_ptr = &floor_ptr->grid_array[y][x2 + 1];
+               place_grid(g_ptr, inner);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
-               place_inner_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
-               place_inner_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y1 - 1][x];
+               place_grid(g_ptr, inner);
+               g_ptr = &floor_ptr->grid_array[y2 + 1][x];
+               place_grid(g_ptr, inner);
        }
        for (y = y1; y <= y2; y++)
        {
                for (x = x1; x <= x2; x++)
                {
-                       add_cave_info(y, x, CAVE_ICKY);
+                       add_cave_info(floor_ptr, y, x, CAVE_ICKY);
                }
        }
 
        /* Place a secret door */
        switch (randint1(4))
        {
-       case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
-       case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
-       case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
-       case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
+       case 1: place_secret_door(player_ptr, y1 - 1, xval, DOOR_DEFAULT); break;
+       case 2: place_secret_door(player_ptr, y2 + 1, xval, DOOR_DEFAULT); break;
+       case 3: place_secret_door(player_ptr, yval, x1 - 1, DOOR_DEFAULT); break;
+       case 4: place_secret_door(player_ptr, yval, x2 + 1, DOOR_DEFAULT); break;
        }
 
        /* Sort the entries */
@@ -650,51 +658,51 @@ bool build_type6(void)
        /* Top and bottom rows */
        for (x = xval - 9; x <= xval + 9; x++)
        {
-               place_monster_aux(0, yval - 2, x, what[0], PM_NO_KAGE);
-               place_monster_aux(0, yval + 2, x, what[0], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, yval - 2, x, what[0], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, yval + 2, x, what[0], PM_NO_KAGE);
        }
 
        /* Middle columns */
        for (y = yval - 1; y <= yval + 1; y++)
        {
-               place_monster_aux(0, y, xval - 9, what[0], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 9, what[0], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 9, what[0], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 9, what[0], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 8, what[1], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 8, what[1], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 8, what[1], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 8, what[1], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 7, what[1], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 7, what[1], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 7, what[1], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 7, what[1], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 6, what[2], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 6, what[2], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 6, what[2], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 6, what[2], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 5, what[2], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 5, what[2], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 5, what[2], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 5, what[2], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 4, what[3], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 4, what[3], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 4, what[3], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 4, what[3], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 3, what[3], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 3, what[3], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 3, what[3], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 3, what[3], PM_NO_KAGE);
 
-               place_monster_aux(0, y, xval - 2, what[4], PM_NO_KAGE);
-               place_monster_aux(0, y, xval + 2, what[4], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval - 2, what[4], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, xval + 2, what[4], PM_NO_KAGE);
        }
 
        /* Above/Below the center monster */
        for (x = xval - 1; x <= xval + 1; x++)
        {
-               place_monster_aux(0, yval + 1, x, what[5], PM_NO_KAGE);
-               place_monster_aux(0, yval - 1, x, what[5], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, yval + 1, x, what[5], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, yval - 1, x, what[5], PM_NO_KAGE);
        }
 
        /* Next to the center monster */
-       place_monster_aux(0, yval, xval + 1, what[6], PM_NO_KAGE);
-       place_monster_aux(0, yval, xval - 1, what[6], PM_NO_KAGE);
+       place_monster_aux(player_ptr, 0, yval, xval + 1, what[6], PM_NO_KAGE);
+       place_monster_aux(player_ptr, 0, yval, xval - 1, what[6], PM_NO_KAGE);
 
        /* Center monster */
-       place_monster_aux(0, yval, xval, what[7], PM_NO_KAGE);
+       place_monster_aux(player_ptr, 0, yval, xval, what[7], PM_NO_KAGE);
 
        return TRUE;
 }
@@ -708,12 +716,12 @@ static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
-       if (!vault_monster_okay(r_idx)) return (FALSE);
+       if (!vault_monster_okay(r_idx)) return FALSE;
 
        /* No wall passing monster */
-       if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return (FALSE);
+       if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
 
-       return (TRUE);
+       return TRUE;
 }
 
 
@@ -762,7 +770,7 @@ static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
 *\n
 * Note that "monster pits" will never contain "unique" monsters.\n
 */
-bool build_type13(void)
+bool build_type13(player_type *player_ptr)
 {
        static int placing[][3] = {
                { -2, -9, 0 },{ -2, -8, 0 },{ -3, -7, 0 },{ -3, -6, 0 },
@@ -802,11 +810,12 @@ bool build_type13(void)
 
        grid_type *g_ptr;
 
-       int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
+       floor_type *floor_ptr = player_ptr->current_floor_ptr;
+       int cur_pit_type = pick_vault_type(floor_ptr, pit_types, d_info[floor_ptr->dungeon_idx].pit);
        vault_aux_type *n_ptr;
 
        /* Only in Angband */
-       if (p_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
+       if (floor_ptr->dungeon_idx != DUNGEON_ANGBAND) return FALSE;
 
        /* No type available */
        if (cur_pit_type < 0) return FALSE;
@@ -814,8 +823,8 @@ bool build_type13(void)
        n_ptr = &pit_types[cur_pit_type];
 
        /* Process a preparation function if necessary */
-       if (n_ptr->prep_func) (*(n_ptr->prep_func))();
-       get_mon_num_prep(n_ptr->hook_func, vault_aux_trapped_pit);
+       if (n_ptr->prep_func) (*(n_ptr->prep_func))(player_ptr);
+       get_mon_num_prep(player_ptr, n_ptr->hook_func, vault_aux_trapped_pit);
 
        align.sub_align = SUB_ALIGN_NEUTRAL;
 
@@ -829,7 +838,7 @@ bool build_type13(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 0);
+                       r_idx = get_mon_num(player_ptr, floor_ptr->dun_level + 0);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -850,7 +859,7 @@ bool build_type13(void)
        }
 
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 13, 25)) return FALSE;
+       if (!find_space(floor_ptr, &yval, &xval, 13, 25)) return FALSE;
 
        /* Large room */
        y1 = yval - 5;
@@ -863,8 +872,8 @@ bool build_type13(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       g_ptr = &current_floor_ptr->grid_array[y][x];
-                       place_inner_grid(g_ptr);
+                       g_ptr = &floor_ptr->grid_array[y][x];
+                       place_grid(g_ptr, inner);
                        g_ptr->info |= (CAVE_ROOM);
                }
        }
@@ -872,52 +881,52 @@ bool build_type13(void)
        /* Place the floor area 1 */
        for (x = x1 + 3; x <= x2 - 3; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[yval - 2][x];
-               place_floor_grid(g_ptr);
-               add_cave_info(yval - 2, x, CAVE_ICKY);
+               g_ptr = &floor_ptr->grid_array[yval - 2][x];
+               place_grid(g_ptr, floor);
+               add_cave_info(floor_ptr, yval - 2, x, CAVE_ICKY);
 
-               g_ptr = &current_floor_ptr->grid_array[yval + 2][x];
-               place_floor_grid(g_ptr);
-               add_cave_info(yval + 2, x, CAVE_ICKY);
+               g_ptr = &floor_ptr->grid_array[yval + 2][x];
+               place_grid(g_ptr, floor);
+               add_cave_info(floor_ptr, yval + 2, x, CAVE_ICKY);
        }
 
        /* Place the floor area 2 */
        for (x = x1 + 5; x <= x2 - 5; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[yval - 3][x];
-               place_floor_grid(g_ptr);
-               add_cave_info(yval - 3, x, CAVE_ICKY);
+               g_ptr = &floor_ptr->grid_array[yval - 3][x];
+               place_grid(g_ptr, floor);
+               add_cave_info(floor_ptr, yval - 3, x, CAVE_ICKY);
 
-               g_ptr = &current_floor_ptr->grid_array[yval + 3][x];
-               place_floor_grid(g_ptr);
-               add_cave_info(yval + 3, x, CAVE_ICKY);
+               g_ptr = &floor_ptr->grid_array[yval + 3][x];
+               place_grid(g_ptr, floor);
+               add_cave_info(floor_ptr, yval + 3, x, CAVE_ICKY);
        }
 
        /* Corridor */
        for (x = x1; x <= x2; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[yval][x];
-               place_floor_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y1][x];
-               place_floor_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2][x];
-               place_floor_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[yval][x];
+               place_grid(g_ptr, floor);
+               g_ptr = &floor_ptr->grid_array[y1][x];
+               place_grid(g_ptr, floor);
+               g_ptr = &floor_ptr->grid_array[y2][x];
+               place_grid(g_ptr, floor);
        }
 
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y][x1 - 1];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y][x2 + 1];
+               place_grid(g_ptr, outer);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
-               place_outer_grid(g_ptr);
-               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
-               place_outer_grid(g_ptr);
+               g_ptr = &floor_ptr->grid_array[y1 - 1][x];
+               place_grid(g_ptr, outer);
+               g_ptr = &floor_ptr->grid_array[y2 + 1][x];
+               place_grid(g_ptr, outer);
        }
 
        /* Random corridor */
@@ -925,32 +934,32 @@ bool build_type13(void)
        {
                for (y = y1; y <= yval; y++)
                {
-                       place_floor_bold(y, x2);
-                       place_solid_bold(y, x1 - 1);
+                       place_floor_bold(floor_ptr, y, x2);
+                       place_solid_bold(floor_ptr, y, x1 - 1);
                }
                for (y = yval; y <= y2 + 1; y++)
                {
-                       place_floor_bold(y, x1);
-                       place_solid_bold(y, x2 + 1);
+                       place_floor_bold(floor_ptr, y, x1);
+                       place_solid_bold(floor_ptr, y, x2 + 1);
                }
        }
        else
        {
                for (y = yval; y <= y2 + 1; y++)
                {
-                       place_floor_bold(y, x1);
-                       place_solid_bold(y, x2 + 1);
+                       place_floor_bold(floor_ptr, y, x1);
+                       place_solid_bold(floor_ptr, y, x2 + 1);
                }
                for (y = y1; y <= yval; y++)
                {
-                       place_floor_bold(y, x2);
-                       place_solid_bold(y, x1 - 1);
+                       place_floor_bold(floor_ptr, y, x2);
+                       place_solid_bold(floor_ptr, y, x1 - 1);
                }
        }
 
        /* Place the wall open trap */
-       current_floor_ptr->grid_array[yval][xval].mimic = current_floor_ptr->grid_array[yval][xval].feat;
-       current_floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
+       floor_ptr->grid_array[yval][xval].mimic = floor_ptr->grid_array[yval][xval].feat;
+       floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
 
        /* Sort the entries */
        for (i = 0; i < 16 - 1; i++)
@@ -993,7 +1002,7 @@ bool build_type13(void)
        {
                y = yval + placing[i][0];
                x = xval + placing[i][1];
-               place_monster_aux(0, y, x, what[placing[i][2]], PM_NO_KAGE);
+               place_monster_aux(player_ptr, 0, y, x, what[placing[i][2]], PM_NO_KAGE);
        }
 
        return TRUE;