OSDN Git Service

Add Doxygen comment to wizard1.c.
[hengband/hengband.git] / src / rooms.c
index ceba2e1..24ecb45 100644 (file)
@@ -1,14 +1,39 @@
-/*
- * File: rooms.c
- * Purpose: make rooms. Used by generate.c when creating dungeons.
- */
-
-/*
- * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke
- *
- * This software may be copied and distributed for educational, research,
- * and not for profit purposes provided that this copyright and statement
- * are included in all such copies.  Other copyrights may also apply.
+/*!
+ * @file rooms.c
+ * @brief ¥À¥ó¥¸¥ç¥ó¥Õ¥í¥¢¤ÎÉô²°À¸À®½èÍý / make rooms. Used by generate.c when creating dungeons.
+ * @date 2014/01/06
+ * @author
+ * Copyright (c) 1997 Ben Harrison, James E. Wilson, Robert A. Koeneke\n
+ * This software may be copied and distributed for educational, research,\n
+ * and not for profit purposes provided that this copyright and statement\n
+ * are included in all such copies.  Other copyrights may also apply.\n
+ * 2014 Deskull rearranged comment for Doxygen. \n
+ * @details
+ * Room building routines.\n
+ *\n
+ * Room types:\n
+ *   1 -- normal\n
+ *   2 -- overlapping\n
+ *   3 -- cross shaped\n
+ *   4 -- large room with features\n
+ *   5 -- monster nests\n
+ *   6 -- monster pits\n
+ *   7 -- simple vaults\n
+ *   8 -- greater vaults\n
+ *   9 -- fractal caves\n
+ *  10 -- random vaults\n
+ *  11 -- circular rooms\n
+ *  12 -- crypts\n
+ *  13 -- trapped monster pits\n
+ *  14 -- trapped room\n
+ *  15 -- glass room\n
+ *  16 -- underground arcade\n
+ *\n
+ * Some functions are used to determine if the given monster\n
+ * is appropriate for inclusion in a monster nest or monster pit or\n
+ * the given type.\n
+ *\n
+ * None of the pits/nests are allowed to include "unique" monsters.\n
  */
 
 #include "angband.h"
 #include "rooms.h"
 
 
-/*
- * [from SAngband (originally from OAngband)]
- *
- * Table of values that control how many times each type of room will
- * appear.  Each type of room has its own row, and each column
- * corresponds to dungeon levels 0, 10, 20, and so on.  The final
- * value is the minimum depth the room can appear at.  -LM-
- *
- * Level 101 and below use the values for level 100.
- *
- * Rooms with lots of monsters or loot may not be generated if the
- * object or monster lists are already nearly full.  Rooms will not
- * appear above their minimum depth.  Tiny levels will not have space
- * for all the rooms you ask for.
+/*!
+ * ³ÆÉô²°¥¿¥¤¥×¤ÎÀ¸À®ÈæÄêµÁ
+ *[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] =
 {
@@ -44,25 +70,29 @@ static room_info_type room_info_normal[ROOM_T_MAX] =
        {{  0,  1,  1,  1,  2,  3,  5,  6,  8, 10, 13}, 10}, /*NEST     */
        {{  0,  1,  1,  2,  3,  4,  6,  8, 10, 13, 16}, 10}, /*PIT      */
        {{  0,  1,  1,  1,  2,  2,  3,  5,  6,  8, 10}, 10}, /*LESSER_V */
-       {{  0,  0,  1,  1,  1,  2,  2,  3,  4,  5,  6}, 20}, /*GREATER_V*/
+       {{  0,  0,  1,  1,  1,  2,  2,  2,  3,  3,  4}, 20}, /*GREATER_V*/
        {{  0,100,200,300,400,500,600,700,800,900,999}, 10}, /*FRACAVE  */
-       {{  0,  1,  1,  1,  1,  1,  1,  2,  2,  3,  3}, 10}, /*RANDOM_V */
+       {{  0,  1,  1,  1,  1,  1,  1,  1,  1,  2,  2}, 10}, /*RANDOM_V */
        {{  0,  4,  8, 12, 16, 20, 24, 28, 32, 36, 40},  3}, /*OVAL     */
        {{  1,  6, 12, 18, 24, 30, 36, 42, 48, 54, 60}, 10}, /*CRYPT    */
        {{  0,  0,  1,  1,  1,  2,  3,  4,  5,  6,  8}, 20}, /*TRAP_PIT */
        {{  0,  0,  1,  1,  1,  2,  3,  4,  5,  6,  8}, 20}, /*TRAP     */
+       {{  0,  0,  0,  0,  1,  1,  1,  2,  2,  2,  2}, 40}, /*GLASS    */
+       {{  1,  1,  1,  1,  1,  1,  1,  2,  2,  3,  3},  1}, /*ARCADE   */
 };
 
 
-/* Build rooms in descending order of difficulty. */
+/*! Éô²°¤ÎÀ¸À®½èÍý½ç / Build rooms in descending order of difficulty. */
 static byte room_build_order[ROOM_T_MAX] = {
        ROOM_T_GREATER_VAULT,
+       ROOM_T_ARCADE,
        ROOM_T_RANDOM_VAULT,
        ROOM_T_LESSER_VAULT,
        ROOM_T_TRAP_PIT,
        ROOM_T_PIT,
        ROOM_T_NEST,
        ROOM_T_TRAP,
+       ROOM_T_GLASS,
        ROOM_T_INNER_FEAT,
        ROOM_T_OVAL,
        ROOM_T_CRYPT,
@@ -72,7 +102,12 @@ static byte room_build_order[ROOM_T_MAX] = {
        ROOM_T_NORMAL,
 };
 
-
+/*!
+ * @brief ¸°¤Î¤«¤«¤Ã¤¿¥É¥¢¤òÇÛÃÖ¤¹¤ë
+ * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
+ * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
+ * @return ¤Ê¤·
+ */
 static void place_locked_door(int y, int x)
 {
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
@@ -81,12 +116,20 @@ static void place_locked_door(int y, int x)
        }
        else
        {
-               set_cave_feat(y, x, FEAT_DOOR_HEAD+randint1(7));
+               set_cave_feat(y, x, feat_locked_door_random((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR));
                cave[y][x].info &= ~(CAVE_FLOOR);
+               delete_monster(y, x);
        }
 }
 
-static void place_secret_door(int y, int x)
+/*!
+ * @brief ±£¤·¥É¥¢¤òÇÛÃÖ¤¹¤ë
+ * @param y ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎYºÂɸ
+ * @param x ÇÛÃÖ¤·¤¿¤¤¥Õ¥í¥¢¤ÎXºÂɸ
+ * @param type #DOOR_DEFAULT / #DOOR_DOOR / #DOOR_GLASS_DOOR / #DOOR_CURTAIN ¤Î¤¤¤º¤ì¤«
+ * @return ¤Ê¤·
+ */
+static void place_secret_door(int y, int x, int type)
 {
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
        {
@@ -96,24 +139,42 @@ static void place_secret_door(int y, int x)
        {
                cave_type *c_ptr = &cave[y][x];
 
-               /* Create secret door */
-               place_closed_door(y, x);
+               if (type == DOOR_DEFAULT)
+               {
+                       type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+                               one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+                               ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+               }
 
-               /* Hide by inner wall because this is used in rooms only */
-               c_ptr->mimic = feat_wall_inner;
+               /* Create secret door */
+               place_closed_door(y, x, type);
 
-               /* Floor type terrain cannot hide a door */
-               if (feat_floor(c_ptr->mimic))
+               if (type != DOOR_CURTAIN)
                {
-                       c_ptr->feat = c_ptr->mimic;
-                       c_ptr->mimic = 0;
+                       /* Hide by inner wall because this is used in rooms only */
+                       c_ptr->mimic = feat_wall_inner;
+
+                       /* Floor type terrain cannot hide a door */
+                       if (feat_supports_los(c_ptr->mimic) && !feat_supports_los(c_ptr->feat))
+                       {
+                               if (have_flag(f_info[c_ptr->mimic].flags, FF_MOVE) || have_flag(f_info[c_ptr->mimic].flags, FF_CAN_FLY))
+                               {
+                                       c_ptr->feat = one_in_(2) ? c_ptr->mimic : floor_type[randint0(100)];
+                               }
+                               c_ptr->mimic = 0;
+                       }
                }
 
                c_ptr->info &= ~(CAVE_FLOOR);
+               delete_monster(y, x);
        }
 }
 
-/*
+/*!
+ * @brief 1¥Þ¥¹¤À¤±¤ÎÉô²°¤òºîÀ®¤·¡¢¾å²¼º¸±¦¤¤¤º¤ì¤«°ì¤Ä¤Ë±£¤·¥É¥¢¤òÇÛÃÖ¤¹¤ë¡£
+ * @param y0 ÇÛÃÖ¤·¤¿¤¤Ãæ¿´¤ÎYºÂɸ
+ * @param x0 ÇÛÃÖ¤·¤¿¤¤Ãæ¿´¤ÎXºÂɸ
+ * @details
  * This funtion makes a very small room centred at (x0, y0)
  * This is used in crypts, and random elemental vaults.
  *
@@ -139,10 +200,10 @@ static void build_small_room(int x0, int y0)
        /* Place a secret door on one side */
        switch (randint0(4))
        {
-               case 0: place_secret_door(y0, x0 - 1); break;
-               case 1: place_secret_door(y0, x0 + 1); break;
-               case 2: place_secret_door(y0 - 1, x0); break;
-               case 3: place_secret_door(y0 + 1, x0); break;
+               case 0: place_secret_door(y0, x0 - 1, DOOR_DEFAULT); break;
+               case 1: place_secret_door(y0, x0 + 1, DOOR_DEFAULT); break;
+               case 2: place_secret_door(y0 - 1, x0, DOOR_DEFAULT); break;
+               case 3: place_secret_door(y0 + 1, x0, DOOR_DEFAULT); break;
        }
 
        /* Clear mimic type */
@@ -152,10 +213,15 @@ static void build_small_room(int x0, int y0)
        place_floor_bold(y0, x0);
 }
 
-
-/*
- * This function tunnels around a room if
- * it will cut off part of a cave system.
+/*!
+ * @brief
+ * »ØÄêÈϰϤËÄÌÏ©¤¬Ä̤äƤ¤¤ë¤³¤È¤ò³Îǧ¤·¤¿¾å¤Ç¾²¤ÇËä¤á¤ë
+ * This function tunnels around a room if it will cut off part of a cave system.
+ * @param x1 ÈϰϤκ¸Ã¼
+ * @param y1 ÈϰϤξåü
+ * @param x2 ÈϰϤα¦Ã¼
+ * @param y2 ÈϰϤβ¼Ã¼
+ * @return ¤Ê¤·
  */
 static void check_room_boundary(int x1, int y1, int x2, int y2)
 {
@@ -233,10 +299,15 @@ static void check_room_boundary(int x1, int y1, int x2, int y2)
 }
 
 
-/*
- *  Helper function for find_space().
- *
- *  Is this a good location?
+/*!
+ * @brief
+ * find_space()¤ÎͽÈ÷½èÍý¤È¤·¤ÆÉô²°¤ÎÀ¸À®¤¬²Äǽ¤«¤òȽÄꤹ¤ë /
+ * Helper function for find_space(). Is this a good location?
+ * @param blocks_high ÈϰϤι⤵
+ * @param blocks_wide ÈϰϤÎÉý
+ * @param block_y ÈϰϤξåü
+ * @param block_x ÈϰϤκ¸Ã¼
+ * @return ¤Ê¤·
  */
 static bool find_space_aux(int blocks_high, int blocks_wide, int block_y, int block_x)
 {
@@ -309,20 +380,25 @@ static bool find_space_aux(int blocks_high, int blocks_wide, int block_y, int bl
 }
 
 
-/*
- * Find a good spot for the next room.  -LM-
- *
- * Find and allocate a free space in the dungeon large enough to hold
- * the room calling this function.
- *
- * We allocate space in 11x11 blocks, but want to make sure that rooms
- * align neatly on the standard screen.  Therefore, we make them use
- * blocks in few 11x33 rectangles as possible.
- *
- * Be careful to include the edges of the room in height and width!
- *
- * Return TRUE and values for the center of the room if all went well.
- * Otherwise, return FALSE.
+/*!
+ * @brief Éô²°À¸À®¤¬²Äǽ¤Ê¥¹¥Ú¡¼¥¹¤ò³ÎÊݤ¹¤ë / Find a good spot for the next room.  -LM-
+ * @param y Éô²°¤ÎÀ¸À®¤¬²Äǽ¤ÊÃæ¿´YºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param x Éô²°¤ÎÀ¸À®¤¬²Äǽ¤ÊÃæ¿´XºÂɸ¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param height ³ÎÊݤ·¤¿¤¤Îΰè¤Î¹â¤µ
+ * @param width ³ÎÊݤ·¤¿¤¤Îΰè¤ÎÉý
+ * @return ½êÄê¤ÎÈϰϤ¬³ÎÊݤǤ­¤¿¾ì¹çTRUE¤òÊÖ¤¹
+ * @details
+ * Find and allocate a free space in the dungeon large enough to hold\n
+ * the room calling this function.\n
+ *\n
+ * We allocate space in 11x11 blocks, but want to make sure that rooms\n
+ * align neatly on the standard screen.  Therefore, we make them use\n
+ * blocks in few 11x33 rectangles as possible.\n
+ *\n
+ * Be careful to include the edges of the room in height and width!\n
+ *\n
+ * Return TRUE and values for the center of the room if all went well.\n
+ * Otherwise, return FALSE.\n
  */
 static bool find_space(int *y, int *x, int height, int width)
 {
@@ -339,29 +415,17 @@ static bool find_space(int *y, int *x, int height, int width)
        if (dun->row_rooms < blocks_high) return FALSE;
        if (dun->col_rooms < blocks_wide) return FALSE;
 
-#if 0
-       /* Sometimes, little rooms like to have more space. */
-       if (blocks_wide == 2)
-       {
-               if (one_in_(3)) blocks_wide = 3;
-       }
-       else if (blocks_wide == 1)
-       {
-               if (one_in_(2)) blocks_wide = rand_range(2, 3);
-       }
-#endif
-
        /* Initiallize */
        candidates = 0;
 
-       /* Count the number of varid places */
+       /* Count the number of valid places */
        for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--)
        {
                for (block_x = dun->col_rooms - blocks_wide; block_x >= 0; block_x--)
                {
                        if (find_space_aux(blocks_high, blocks_wide, block_y, block_x))
                        {
-                               /* Find a varid place */
+                               /* Find a valid place */
                                candidates++;
                        }
                }
@@ -373,8 +437,19 @@ static bool find_space(int *y, int *x, int height, int width)
                return FALSE;
        }
 
-       /* Choose a random one */
-       pick = randint1(candidates);
+       /* Normal dungeon */
+       if (!(d_info[dungeon_type].flags1 & DF1_NO_CAVE))
+       {
+               /* Choose a random one */
+               pick = randint1(candidates);
+       }
+
+       /* NO_CAVE dungeon (Castle) */
+       else
+       {
+               /* Always choose the center one */
+               pick = candidates/2 + 1;
+       }
 
        /* Pick up the choosen location */
        for (block_y = dun->row_rooms - blocks_high; block_y >= 0; block_y--)
@@ -440,30 +515,9 @@ static bool find_space(int *y, int *x, int height, int width)
 }
 
 
-
-/*
- * Room building routines.
- *
- * Room types:
- *   1 -- normal
- *   2 -- overlapping
- *   3 -- cross shaped
- *   4 -- large room with features
- *   5 -- monster nests
- *   6 -- monster pits
- *   7 -- simple vaults
- *   8 -- greater vaults
- *   9 -- fractal caves
- *  10 -- random vaults
- *  11 -- circular rooms
- *  12 -- crypts
- *  13 -- trapped monster pits
- *  14 -- trapped room
- */
-
-
-/*
- * Type 1 -- normal rectangular rooms
+/*!
+ * @brief ¥¿¥¤¥×1¤ÎÉô²°¡ÄÄ̾ï²ÄÊÑĹÊý·Á¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 1 -- normal rectangular rooms
+ * @return ¤Ê¤·
  */
 static bool build_type1(void)
 {
@@ -474,6 +528,9 @@ static bool build_type1(void)
 
        cave_type *c_ptr;
 
+       bool curtain = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+               one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 48 : 512);
+
        /* Pick a room size */
        y1 = randint1(4);
        x1 = randint1(11);
@@ -484,7 +541,20 @@ static bool build_type1(void)
        ysize = y1 + y2 + 1;
 
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
+       if (!find_space(&yval, &xval, ysize + 2, xsize + 2))
+       {
+               /* Limit to the minimum room size, and retry */
+               y1 = 1;
+               x1 = 1;
+               y2 = 1;
+               x2 = 1;
+
+               xsize = x1 + x2 + 1;
+               ysize = y1 + y2 + 1;
+
+               /* Find and reserve some space in the dungeon.  Get center of room. */
+               if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
+       }
 
        /* Choose lite or dark */
        light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
@@ -526,6 +596,30 @@ static bool build_type1(void)
        }
 
 
+       /* Hack -- Occasional curtained room */
+       if (curtain && (y2 - y1 > 2) && (x2 - x1 > 2))
+       {
+               for (y = y1; y <= y2; y++)
+               {
+                       c_ptr = &cave[y][x1];
+                       c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
+                       c_ptr->info &= ~(CAVE_MASK);
+                       c_ptr = &cave[y][x2];
+                       c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
+                       c_ptr->info &= ~(CAVE_MASK);
+               }
+               for (x = x1; x <= x2; x++)
+               {
+                       c_ptr = &cave[y1][x];
+                       c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
+                       c_ptr->info &= ~(CAVE_MASK);
+                       c_ptr = &cave[y2][x];
+                       c_ptr->feat = feat_door[DOOR_CURTAIN].closed;
+                       c_ptr->info &= ~(CAVE_MASK);
+               }
+       }
+
+
        /* Hack -- Occasional pillar room */
        if (one_in_(20))
        {
@@ -579,12 +673,16 @@ static bool build_type1(void)
        /* Hack -- Occasional divided room */
        else if (one_in_(50))
        {
+               bool curtain2 = (d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+                       one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 2 : 128);
+
                if (randint1(100) < 50)
                {
                        /* Horizontal wall */
                        for (x = x1; x <= x2; x++)
                        {
                                place_inner_bold(yval, x);
+                               if (curtain2) cave[yval][x].feat = feat_door[DOOR_CURTAIN].closed;
                        }
 
                        /* Prevent edge of wall from being tunneled */
@@ -597,6 +695,7 @@ static bool build_type1(void)
                        for (y = y1; y <= y2; y++)
                        {
                                place_inner_bold(y, xval);
+                               if (curtain2) cave[y][xval].feat = feat_door[DOOR_CURTAIN].closed;
                        }
 
                        /* Prevent edge of wall from being tunneled */
@@ -605,14 +704,15 @@ static bool build_type1(void)
                }
 
                place_random_door(yval, xval, TRUE);
+               if (curtain2) cave[yval][xval].feat = feat_door[DOOR_CURTAIN].closed;
        }
 
        return TRUE;
 }
 
-
-/*
- * Type 2 -- Overlapping rectangular rooms
+/*!
+ * @brief ¥¿¥¤¥×2¤ÎÉô²°¡ÄÆó½ÅĹÊý·Á¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 2 -- Overlapping rectangular rooms
+ * @return ¤Ê¤·
  */
 static bool build_type2(void)
 {
@@ -725,17 +825,18 @@ static bool build_type2(void)
 
 
 
-/*
- * Type 3 -- Cross shaped rooms
- *
- * Builds a room at a row, column coordinate
- *
- * Room "a" runs north/south, and Room "b" runs east/east
- * So the "central pillar" runs from x1a, y1b to x2a, y2b.
- *
- * Note that currently, the "center" is always 3x3, but I think that
- * the code below will work (with "bounds checking") for 5x5, or even
- * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.
+/*!
+ * @brief ¥¿¥¤¥×2¤ÎÉô²°¡Ä½½»ú·¿¤ÎÉô²°¤òÀ¸À®¤¹¤ë / Type 3 -- Cross shaped rooms
+ * @return ¤Ê¤·
+ * @details
+ * Builds a room at a row, column coordinate\n
+ *\n
+ * Room "a" runs north/south, and Room "b" runs east/east\n
+ * So the "central pillar" runs from x1a, y1b to x2a, y2b.\n
+ *\n
+ * Note that currently, the "center" is always 3x3, but I think that\n
+ * the code below will work (with "bounds checking") for 5x5, or even\n
+ * for unsymetric values like 4x3 or 5x3 or 3x4 or 3x5, or even larger.\n
  */
 static bool build_type3(void)
 {
@@ -896,10 +997,10 @@ static bool build_type3(void)
                        /* Place a secret door on the inner room */
                        switch (randint0(4))
                        {
-                               case 0: place_secret_door(y1b, xval); break;
-                               case 1: place_secret_door(y2b, xval); break;
-                               case 2: place_secret_door(yval, x1a); break;
-                               case 3: place_secret_door(yval, x2a); break;
+                               case 0: place_secret_door(y1b, xval, DOOR_DEFAULT); break;
+                               case 1: place_secret_door(y2b, xval, DOOR_DEFAULT); break;
+                               case 2: place_secret_door(yval, x1a, DOOR_DEFAULT); break;
+                               case 3: place_secret_door(yval, x2a, DOOR_DEFAULT); break;
                        }
 
                        /* Place a treasure in the vault */
@@ -943,10 +1044,14 @@ static bool build_type3(void)
                                /* Sometimes shut using secret doors */
                                if (one_in_(3))
                                {
-                                       place_secret_door(yval, x1a - 1);
-                                       place_secret_door(yval, x2a + 1);
-                                       place_secret_door(y1b - 1, xval);
-                                       place_secret_door(y2b + 1, xval);
+                                       int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+                                               one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+                                               ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+
+                                       place_secret_door(yval, x1a - 1, door_type);
+                                       place_secret_door(yval, x2a + 1, door_type);
+                                       place_secret_door(y1b - 1, xval, door_type);
+                                       place_secret_door(y2b + 1, xval, door_type);
                                }
                        }
 
@@ -980,15 +1085,16 @@ static bool build_type3(void)
 }
 
 
-/*
- * Type 4 -- Large room with inner features
- *
- * Possible sub-types:
- *     1 - Just an inner room with one door
- *     2 - An inner room within an inner room
- *     3 - An inner room with pillar(s)
- *     4 - Inner room has a maze
- *     5 - A set of four inner rooms
+/*!
+ * @brief ¥¿¥¤¥×4¤ÎÉô²°¡Ä¸ÇÄꥵ¥¤¥º¤ÎÆó½Å¹½Â¤Éô²°¤òÀ¸À®¤¹¤ë / Type 4 -- Large room with inner features
+ * @return ¤Ê¤·
+ * @details
+ * Possible sub-types:\n
+ *     1 - Just an inner room with one door\n
+ *     2 - An inner room within an inner room\n
+ *     3 - An inner room with pillar(s)\n
+ *     4 - Inner room has a maze\n
+ *     5 - A set of four inner rooms\n
  */
 static bool build_type4(void)
 {
@@ -1071,10 +1177,10 @@ static bool build_type4(void)
                        /* Place a secret door */
                        switch (randint1(4))
                        {
-                               case 1: place_secret_door(y1 - 1, xval); break;
-                               case 2: place_secret_door(y2 + 1, xval); break;
-                               case 3: place_secret_door(yval, x1 - 1); break;
-                               case 4: place_secret_door(yval, x2 + 1); break;
+                               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;
                        }
 
                        /* Place a monster in the room */
@@ -1089,10 +1195,10 @@ static bool build_type4(void)
                        /* Place a secret door */
                        switch (randint1(4))
                        {
-                               case 1: place_secret_door(y1 - 1, xval); break;
-                               case 2: place_secret_door(y2 + 1, xval); break;
-                               case 3: place_secret_door(yval, x1 - 1); break;
-                               case 4: place_secret_door(yval, x2 + 1); break;
+                               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;
                        }
 
                        /* Place another inner room */
@@ -1142,10 +1248,10 @@ static bool build_type4(void)
                        /* Place a secret door */
                        switch (randint1(4))
                        {
-                               case 1: place_secret_door(y1 - 1, xval); break;
-                               case 2: place_secret_door(y2 + 1, xval); break;
-                               case 3: place_secret_door(yval, x1 - 1); break;
-                               case 4: place_secret_door(yval, x2 + 1); break;
+                               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;
                        }
 
                        /* Large Inner Pillar */
@@ -1180,6 +1286,10 @@ static bool build_type4(void)
                        /* Occasionally, some Inner rooms */
                        if (one_in_(3))
                        {
+                               int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+                                       one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+                                       ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+
                                /* Long horizontal walls */
                                for (x = xval - 5; x <= xval + 5; x++)
                                {
@@ -1196,8 +1306,8 @@ static bool build_type4(void)
                                place_inner_grid(c_ptr);
 
                                /* Secret doors (random top/bottom) */
-                               place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3);
-                               place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3);
+                               place_secret_door(yval - 3 + (randint1(2) * 2), xval - 3, door_type);
+                               place_secret_door(yval - 3 + (randint1(2) * 2), xval + 3, door_type);
 
                                /* Monsters */
                                vault_monsters(yval, xval - 2, randint1(2));
@@ -1217,10 +1327,10 @@ static bool build_type4(void)
                        /* Place a secret door */
                        switch (randint1(4))
                        {
-                               case 1: place_secret_door(y1 - 1, xval); break;
-                               case 2: place_secret_door(y2 + 1, xval); break;
-                               case 3: place_secret_door(yval, x1 - 1); break;
-                               case 4: place_secret_door(yval, x2 + 1); break;
+                               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;
                        }
 
                        /* Maze (really a checkerboard) */
@@ -1253,6 +1363,10 @@ static bool build_type4(void)
                /* Four small rooms. */
                case 5:
                {
+                       int door_type = ((d_info[dungeon_type].flags1 & DF1_CURTAIN) &&
+                               one_in_((d_info[dungeon_type].flags1 & DF1_NO_CAVE) ? 16 : 256)) ? DOOR_CURTAIN :
+                               ((d_info[dungeon_type].flags1 & DF1_GLASS_DOOR) ? DOOR_GLASS_DOOR : DOOR_DOOR);
+
                        /* Inner "cross" */
                        for (y = y1; y <= y2; y++)
                        {
@@ -1269,18 +1383,18 @@ static bool build_type4(void)
                        if (randint0(100) < 50)
                        {
                                int i = randint1(10);
-                               place_secret_door(y1 - 1, xval - i);
-                               place_secret_door(y1 - 1, xval + i);
-                               place_secret_door(y2 + 1, xval - i);
-                               place_secret_door(y2 + 1, xval + i);
+                               place_secret_door(y1 - 1, xval - i, door_type);
+                               place_secret_door(y1 - 1, xval + i, door_type);
+                               place_secret_door(y2 + 1, xval - i, door_type);
+                               place_secret_door(y2 + 1, xval + i, door_type);
                        }
                        else
                        {
                                int i = randint1(3);
-                               place_secret_door(yval + i, x1 - 1);
-                               place_secret_door(yval - i, x1 - 1);
-                               place_secret_door(yval + i, x2 + 1);
-                               place_secret_door(yval - i, x2 + 1);
+                               place_secret_door(yval + i, x1 - 1, door_type);
+                               place_secret_door(yval - i, x1 - 1, door_type);
+                               place_secret_door(yval + i, x2 + 1, door_type);
+                               place_secret_door(yval - i, x2 + 1, door_type);
                        }
 
                        /* Treasure, centered at the center of the cross */
@@ -1300,17 +1414,9 @@ static bool build_type4(void)
 }
 
 
-/*
- * The following functions are used to determine if the given monster
- * is appropriate for inclusion in a monster nest or monster pit or
- * the given type.
- *
- * None of the pits/nests are allowed to include "unique" monsters.
- */
-
 
-/*
- * Monster validation macro
+/*!
+ * vault¤ËÇÛÃÖ²Äǽ¤Ê¥â¥ó¥¹¥¿¡¼¤Î¾ò·ï¤ò»ØÄꤹ¤ë¥Þ¥¯¥í / Monster validation macro
  *
  * Line 1 -- forbid town monsters
  * Line 2 -- forbid uniques
@@ -1324,18 +1430,21 @@ static bool build_type4(void)
         !(r_info[I].flags7 & RF7_AQUATIC))
 
 
-/* Race index for "monster pit (clone)" */
+/*! Ä̾ïpitÀ¸À®»þ¤Î¥â¥ó¥¹¥¿¡¼¤Î¹½À®¾ò·ïID / Race index for "monster pit (clone)" */
 static int vault_aux_race;
 
-/* Race index for "monster pit (symbol clone)" */
+/*! Ã±°ì¥·¥ó¥Ü¥ëpitÀ¸À®»þ¤Î»ØÄꥷ¥ó¥Ü¥ë / Race index for "monster pit (symbol clone)" */
 static char vault_aux_char;
 
-/* Breath mask for "monster pit (dragon)" */
+/*! ¥Ö¥ì¥¹Â°À­¤Ë´ð¤Å¤¯¥É¥é¥´¥ópitÀ¸À®»þ¾ò·ï¥Þ¥¹¥¯ / Breath mask for "monster pit (dragon)" */
 static u32b vault_aux_dragon_mask4;
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬VaultÀ¸À®¤ÎºÇÄãɬÍ×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper monster selection function
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return VaultÀ¸À®¤ÎºÇÄãɬÍ×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_simple(int r_idx)
 {
@@ -1344,8 +1453,11 @@ static bool vault_aux_simple(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥¼¥ê¡¼nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (jelly)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_jelly(int r_idx)
 {
@@ -1360,15 +1472,17 @@ static bool vault_aux_jelly(int r_idx)
        if (r_ptr->flags3 & (RF3_EVIL)) return (FALSE);
 
        /* Require icky thing, jelly, mold, or mushroom */
-       if (!strchr("ijm,", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("ijm,", r_ptr->d_char)) return (FALSE);
 
        /* Okay */
        return (TRUE);
 }
 
-
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬Æ°Êªnest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (animal)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_animal(int r_idx)
 {
@@ -1385,8 +1499,11 @@ static bool vault_aux_animal(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥¢¥ó¥Ç¥Ã¥Énest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (undead)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_undead(int r_idx)
 {
@@ -1402,9 +1519,11 @@ static bool vault_aux_undead(int r_idx)
        return (TRUE);
 }
 
-
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬À»Æ²nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (chapel)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_chapel_g(int r_idx)
 {
@@ -1434,9 +1553,11 @@ static bool vault_aux_chapel_g(int r_idx)
        return FALSE;
 }
 
-
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¸¤¾®²°nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (kennel)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_kennel(int r_idx)
 {
@@ -1446,15 +1567,17 @@ static bool vault_aux_kennel(int r_idx)
        if (!vault_monster_okay(r_idx)) return (FALSE);
 
        /* Require a Zephyr Hound or a dog */
-       if (!strchr("CZ", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("CZ", r_ptr->d_char)) return (FALSE);
   
        /* Okay */
        return (TRUE);
 }
 
-
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥ß¥ß¥Ã¥¯nest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (mimic)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_mimic(int r_idx)
 {
@@ -1462,16 +1585,19 @@ static bool vault_aux_mimic(int r_idx)
 
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
-  
+
        /* Require mimic */
-       if (!strchr("!|$?=", r_ptr->d_char)) return (FALSE);
+       if (!my_strchr("!$&(/=?[\\|", r_ptr->d_char)) return (FALSE);
 
        /* Okay */
        return (TRUE);
 }
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬Ã±°ì¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (clone)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_clone(int r_idx)
 {
@@ -1482,8 +1608,11 @@ static bool vault_aux_clone(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¼Ù°­Â°À­¥·¥ó¥Ü¥ë¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (symbol clone)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_symbol_e(int r_idx)
 {
@@ -1504,8 +1633,11 @@ static bool vault_aux_symbol_e(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬Á±ÎÉ°À­¥·¥ó¥Ü¥ë¥¯¥í¡¼¥ónest¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster nest (symbol clone)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_symbol_g(int r_idx)
 {
@@ -1526,8 +1658,11 @@ static bool vault_aux_symbol_g(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥ª¡¼¥¯pit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (orc)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_orc(int r_idx)
 {
@@ -1547,8 +1682,11 @@ static bool vault_aux_orc(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥È¥í¥ëpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (troll)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_troll(int r_idx)
 {
@@ -1568,8 +1706,11 @@ static bool vault_aux_troll(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬µð¿Ípit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (giant)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_giant(int r_idx)
 {
@@ -1591,8 +1732,11 @@ static bool vault_aux_giant(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥É¥é¥´¥ópit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (dragon)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_dragon(int r_idx)
 {
@@ -1615,8 +1759,11 @@ static bool vault_aux_dragon(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬°­Ëâpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (demon)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_demon(int r_idx)
 {
@@ -1635,8 +1782,11 @@ static bool vault_aux_demon(int r_idx)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¶¸µ¤pit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (lovecraftian)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_cthulhu(int r_idx)
 {
@@ -1655,8 +1805,9 @@ static bool vault_aux_cthulhu(int r_idx)
 }
 
 
-/*
- * Helper function for "monster pit (clone)"
+/*!
+ * @brief pit/nest¤Î´ð½à¤È¤Ê¤ëñ¼ï¥â¥ó¥¹¥¿¡¼¤ò·è¤á¤ë /
+ * @return ¤Ê¤·
  */
 static void vault_prep_clone(void)
 {
@@ -1671,8 +1822,9 @@ static void vault_prep_clone(void)
 }
 
 
-/*
- * Helper function for "monster pit (symbol clone)"
+/*!
+ * @brief pit/nest¤Î´ð½à¤È¤Ê¤ë¥â¥ó¥¹¥¿¡¼¥·¥ó¥Ü¥ë¤ò·è¤á¤ë /
+ * @return ¤Ê¤·
  */
 static void vault_prep_symbol(void)
 {
@@ -1691,9 +1843,9 @@ static void vault_prep_symbol(void)
        vault_aux_char = r_info[r_idx].d_char;
 }
 
-
-/*
- * Helper function for "monster pit (dragon)"
+/*!
+ * @brief pit/nest¤Î´ð½à¤È¤Ê¤ë¥É¥é¥´¥ó¤Î¼ïÎà¤ò·è¤á¤ë /
+ * @return ¤Ê¤·
  */
 static void vault_prep_dragon(void)
 {
@@ -1765,8 +1917,11 @@ static void vault_prep_dragon(void)
 }
 
 
-/*
+/*!
+ * @brief ¥â¥ó¥¹¥¿¡¼¤¬¥À¡¼¥¯¥¨¥ë¥Õpit¤ÎÀ¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤«¤òÊÖ¤¹ /
  * Helper function for "monster pit (dark elf)"
+ * @param r_idx ³Îǧ¤·¤¿¤¤¥â¥ó¥¹¥¿¡¼¼ï²ID
+ * @return À¸À®É¬Í×¾ò·ï¤òËþ¤¿¤·¤Æ¤¤¤ë¤Ê¤éTRUE¤òÊÖ¤¹¡£
  */
 static bool vault_aux_dark_elf(int r_idx)
 {
@@ -1789,10 +1944,10 @@ static bool vault_aux_dark_elf(int r_idx)
        return FALSE;
 }
 
-
+/*! pit/nest·¿¾ðÊó¤Îtypedef */
 typedef struct vault_aux_type vault_aux_type;
 
-
+/*! pit/nest·¿¾ðÊó¤Î¹½Â¤ÂÎÄêµÁ */
 struct vault_aux_type
 {
        cptr name;
@@ -1802,7 +1957,12 @@ struct vault_aux_type
        int chance;
 };
 
-
+/*!
+ * @brief ¥À¥ó¥¸¥ç¥óËè¤Ë»ØÄꤵ¤ì¤¿¥Ô¥Ã¥ÈÇÛÎó¤ò´ð½à¤Ë¥é¥ó¥À¥à¤Êpit/nest¥¿¥¤¥×¤ò·è¤á¤ë
+ * @param l_ptr ÁªÂò¤µ¤ì¤¿pit/nest¾ðÊó¤òÊÖ¤¹»²¾È¥Ý¥¤¥ó¥¿
+ * @param allow_flag_mask À¸À®¤¬µö¤µ¤ì¤ëpit/nest¤Î¥Ó¥Ã¥ÈÇÛÎó
+ * @return ÁªÂò¤µ¤ì¤¿pit/nest¤ÎID¡¢ÁªÂò¼ºÇÔ¤·¤¿¾ì¹ç-1¤òÊÖ¤¹¡£
+ */
 static int pick_vault_type(vault_aux_type *l_ptr, s16b allow_flag_mask)
 {
        int tmp, total, count;
@@ -1850,6 +2010,7 @@ static int pick_vault_type(vault_aux_type *l_ptr, s16b allow_flag_mask)
        return n_ptr->name ? count : -1;
 }
 
+/*!nest¾ðÊó¥Æ¡¼¥Ö¥ë*/
 static vault_aux_type nest_types[] =
 {
 #ifdef JP
@@ -1879,6 +2040,7 @@ static vault_aux_type nest_types[] =
 #endif
 };
 
+/*!pit¾ðÊó¥Æ¡¼¥Ö¥ë*/
 static vault_aux_type pit_types[] =
 {
 #ifdef JP
@@ -1909,7 +2071,7 @@ static vault_aux_type pit_types[] =
 };
 
 
-/* Nest types code */
+/*! nest¤ÎIDÄêµÁ /  Nest types code */
 #define NEST_TYPE_CLONE        0
 #define NEST_TYPE_JELLY        1
 #define NEST_TYPE_SYMBOL_GOOD  2
@@ -1921,7 +2083,7 @@ static vault_aux_type pit_types[] =
 #define NEST_TYPE_CHAPEL       8
 #define NEST_TYPE_UNDEAD       9
 
-/* Pit types code */
+/*! pit¤ÎIDÄêµÁ / Pit types code */
 #define PIT_TYPE_ORC           0
 #define PIT_TYPE_TROLL         1
 #define PIT_TYPE_GIANT         2
@@ -1934,7 +2096,12 @@ static vault_aux_type pit_types[] =
 #define PIT_TYPE_DARK_ELF      9
 
 
-/*
+/*!
+ * @brief ¥Ç¥Ð¥Ã¥°»þ¤ËÀ¸À®¤µ¤ì¤¿pit/nest¤Î·¿¤ò½ÐÎϤ¹¤ë½èÍý
+ * @param type pit/nest¤Î·¿ID
+ * @param nest TRUE¤Ê¤é¤Ðnest¡¢FALSE¤Ê¤é¤Ðpit
+ * @return ¥Ç¥Ð¥Ã¥°É½¼¨Ê¸»úÎó¤Î»²¾È¥Ý¥¤¥ó¥¿
+ * @details
  * Hack -- Get the string describing subtype of pit/nest
  * Determined in prepare function (some pit/nest only)
  */
@@ -1996,7 +2163,7 @@ static cptr pit_subtype_string(int type, bool nest)
 }
 
 
-/* A struct for nest monster information with cheat_hear */
+/*! ¥Ç¥Ð¥Ã¥°»þ¤Ënest¤Î¥â¥ó¥¹¥¿¡¼¾ðÊó¤ò³Îǧ¤¹¤ë¤¿¤á¤Î¹½Â¤ÂΠ/ A struct for nest monster information with cheat_hear */
 typedef struct
 {
        s16b r_idx;
@@ -2006,7 +2173,12 @@ nest_mon_info_type;
 
 
 /*
- * Comp function for sorting nest monster information
+ *! @brief nest¤Î¥â¥ó¥¹¥¿¡¼¥ê¥¹¥È¤ò¥½¡¼¥È¤¹¤ë¤¿¤á¤Î´Ø¿ô /
+ *  Comp function for sorting nest monster information
+ *  @param u ¥½¡¼¥È½èÍýÂоÝÇÛÎó¥Ý¥¤¥ó¥¿
+ *  @param v Ì¤»ÈÍÑ
+ *  @param a Èæ³ÓÂоݻ²¾ÈID1
+ *  @param b Èæ³ÓÂоݻ²¾ÈID2
  */
 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -2040,9 +2212,13 @@ static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
        return w1 <= w2;
 }
 
-
-/*
+/*!
+ * @brief nest¤Î¥â¥ó¥¹¥¿¡¼¥ê¥¹¥È¤ò¥¹¥ï¥Ã¥×¤¹¤ë¤¿¤á¤Î´Ø¿ô /
  * Swap function for sorting nest monster information
+ * @param u ¥¹¥ï¥Ã¥×½èÍýÂоÝÇÛÎó¥Ý¥¤¥ó¥¿
+ * @param v Ì¤»ÈÍÑ
+ * @param a ¥¹¥ï¥Ã¥×Âоݻ²¾ÈID1
+ * @param b ¥¹¥ï¥Ã¥×Âоݻ²¾ÈID2
  */
 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -2059,26 +2235,28 @@ static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
 }
 
 
-#define NUM_NEST_MON_TYPE 64
-
-/*
- * Type 5 -- Monster nests
- *
- * A monster nest is a "big" room, with an "inner" room, containing
- * a "collection" of monsters of a given type strewn about the room.
- *
- * The monsters are chosen from a set of 64 randomly selected monster
- * races, to allow the nest creation to fail instead of having "holes".
- *
- * Note the use of the "get_mon_num_prep()" function, and the special
- * "get_mon_num_hook()" restriction function, to prepare the "monster
- * allocation table" in such a way as to optimize the selection of
- * "appropriate" non-unique monsters for the nest.
- *
- * Note that the "get_mon_num()" function may (rarely) fail, in which
- * case the nest will be empty, and will not affect the level rating.
- *
- * Note that "monster nests" will never contain "unique" monsters.
+#define NUM_NEST_MON_TYPE 64 /*!<nest¤Î¼ïÊÌ¿ô */
+
+
+/*!
+ * @brief ¥¿¥¤¥×5¤ÎÉô²°¡Änest¤òÀ¸À®¤¹¤ë / Type 5 -- Monster nests
+ * @return ¤Ê¤·
+ * @details
+ * A monster nest is a "big" room, with an "inner" room, containing\n
+ * a "collection" of monsters of a given type strewn about the room.\n
+ *\n
+ * The monsters are chosen from a set of 64 randomly selected monster\n
+ * races, to allow the nest creation to fail instead of having "holes".\n
+ *\n
+ * Note the use of the "get_mon_num_prep()" function, and the special\n
+ * "get_mon_num_hook()" restriction function, to prepare the "monster\n
+ * allocation table" in such a way as to optimize the selection of\n
+ * "appropriate" non-unique monsters for the nest.\n
+ *\n
+ * Note that the "get_mon_num()" function may (rarely) fail, in which\n
+ * case the nest will be empty.\n
+ *\n
+ * Note that "monster nests" will never contain "unique" monsters.\n
  */
 static bool build_type5(void)
 {
@@ -2115,7 +2293,7 @@ static bool build_type5(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 10);
+                       r_idx = get_mon_num(dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -2206,10 +2384,10 @@ static bool build_type5(void)
        /* Place a secret door */
        switch (randint1(4))
        {
-               case 1: place_secret_door(y1 - 1, xval); break;
-               case 2: place_secret_door(y2 + 1, xval); break;
-               case 3: place_secret_door(yval, x1 - 1); break;
-               case 4: place_secret_door(yval, x2 + 1); break;
+               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;
        }
 
        /* Describe */
@@ -2223,15 +2401,6 @@ static bool build_type5(void)
 #endif
        }
 
-       /* Increase the level rating */
-       rating += 10;
-
-       /* (Sometimes) Cause a "special feeling" (for "Monster Nests") */
-       if ((dun_level <= 40) && (randint1(dun_level * dun_level + 50) < 300))
-       {
-               good_item_flag = TRUE;
-       }
-
        /* Place some monsters */
        for (y = yval - 2; y <= yval + 2; y++)
        {
@@ -2272,41 +2441,42 @@ static bool build_type5(void)
 }
 
 
-/*
- * Type 6 -- Monster pits
- *
- * A monster pit is a "big" room, with an "inner" room, containing
- * a "collection" of monsters of a given type organized in the room.
- *
- * The inside room in a monster pit appears as shown below, where the
- * actual monsters in each location depend on the type of the pit
- *
- *   #####################
- *   #0000000000000000000#
- *   #0112233455543322110#
- *   #0112233467643322110#
- *   #0112233455543322110#
- *   #0000000000000000000#
- *   #####################
- *
- * Note that the monsters in the pit are now chosen by using "get_mon_num()"
- * to request 16 "appropriate" monsters, sorting them by level, and using
- * the "even" entries in this sorted list for the contents of the pit.
- *
- * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",
- * which is handled by requiring a specific "breath" attack for all of the
- * dragons.  This may include "multi-hued" breath.  Note that "wyrms" may
- * be present in many of the dragon pits, if they have the proper breath.
- *
- * Note the use of the "get_mon_num_prep()" function, and the special
- * "get_mon_num_hook()" restriction function, to prepare the "monster
- * allocation table" in such a way as to optimize the selection of
- * "appropriate" non-unique monsters for the pit.
- *
- * Note that the "get_mon_num()" function may (rarely) fail, in which case
- * the pit will be empty, and will not effect the level rating.
- *
- * Note that "monster pits" will never contain "unique" monsters.
+/*!
+ * @brief ¥¿¥¤¥×6¤ÎÉô²°¡Äpit¤òÀ¸À®¤¹¤ë / Type 6 -- Monster pits
+ * @return ¤Ê¤·
+ * @details
+ * A monster pit is a "big" room, with an "inner" room, containing\n
+ * a "collection" of monsters of a given type organized in the room.\n
+ *\n
+ * The inside room in a monster pit appears as shown below, where the\n
+ * actual monsters in each location depend on the type of the pit\n
+ *\n
+ *   XXXXXXXXXXXXXXXXXXXXX\n
+ *   X0000000000000000000X\n
+ *   X0112233455543322110X\n
+ *   X0112233467643322110X\n
+ *   X0112233455543322110X\n
+ *   X0000000000000000000X\n
+ *   XXXXXXXXXXXXXXXXXXXXX\n
+ *\n
+ * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
+ * to request 16 "appropriate" monsters, sorting them by level, and using\n
+ * the "even" entries in this sorted list for the contents of the pit.\n
+ *\n
+ * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
+ * which is handled by requiring a specific "breath" attack for all of the\n
+ * dragons.  This may include "multi-hued" breath.  Note that "wyrms" may\n
+ * be present in many of the dragon pits, if they have the proper breath.\n
+ *\n
+ * Note the use of the "get_mon_num_prep()" function, and the special\n
+ * "get_mon_num_hook()" restriction function, to prepare the "monster\n
+ * allocation table" in such a way as to optimize the selection of\n
+ * "appropriate" non-unique monsters for the pit.\n
+ *\n
+ * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
+ * the pit will be empty.\n
+ *\n
+ * Note that "monster pits" will never contain "unique" monsters.\n
  */
 static bool build_type6(void)
 {
@@ -2344,7 +2514,7 @@ static bool build_type6(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 10);
+                       r_idx = get_mon_num(dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -2432,10 +2602,10 @@ static bool build_type6(void)
        /* Place a secret door */
        switch (randint1(4))
        {
-               case 1: place_secret_door(y1 - 1, xval); break;
-               case 2: place_secret_door(y2 + 1, xval); break;
-               case 3: place_secret_door(yval, x1 - 1); break;
-               case 4: place_secret_door(yval, x2 + 1); break;
+               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;
        }
 
        /* Sort the entries */
@@ -2484,15 +2654,6 @@ static bool build_type6(void)
                }
        }
 
-       /* Increase the level rating */
-       rating += 10;
-
-       /* (Sometimes) Cause a "special feeling" (for "Monster Pits") */
-       if ((dun_level <= 40) && (randint1(dun_level * dun_level + 50) < 300))
-       {
-               good_item_flag = TRUE;
-       }
-
        /* Top and bottom rows */
        for (x = xval - 9; x <= xval + 9; x++)
        {
@@ -2546,7 +2707,15 @@ static bool build_type6(void)
 }
 
 
-/* coordinate translation code */
+/*!
+ * @brief VaultÃÏ·Á¤ò²óž¡¢¾å²¼º¸±¦È¿Å¾¤¹¤ë¤¿¤á¤ÎºÂɸÊÑ´¹¤òÊÖ¤¹ / coordinate translation code
+ * @param x ÊÑ´¹¤·¤¿¤¤ÅÀ¤ÎXºÂɸ»²¾È¥Ý¥¤¥ó¥¿
+ * @param y ÊÑ´¹¤·¤¿¤¤ÅÀ¤ÎYºÂɸ»²¾È¥Ý¥¤¥ó¥¿
+ * @param xoffset VaultÀ¸À®»þ¤Î´ð½àXºÂɸ
+ * @param yoffset VaultÀ¸À®»þ¤Î´ð½àYºÂɸ
+ * @param transno ½èÍýID
+ * @return ¤Ê¤·
+ */
 static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
 {
        int i;
@@ -2580,9 +2749,17 @@ static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
        *y += yoffset;
 }
 
-
-/*
- * Hack -- fill in "vault" rooms
+/*!
+ * @brief Vault¤ò¥Õ¥í¥¢¤ËÇÛÃÖ¤¹¤ë / Hack -- fill in "vault" rooms
+ * @param yval À¸À®´ð½àYºÂɸ
+ * @param xval À¸À®´ð½àXºÂɸ
+ * @param ymax Vault¤ÎY¥µ¥¤¥º
+ * @param xmax Vault¤ÎX¥µ¥¤¥º
+ * @param data Vault¤Î¥Ç¡¼¥¿Ê¸»úÎó
+ * @param xoffset ÊÑ´¹´ð½àXºÂɸ
+ * @param yoffset ÊÑ´¹´ð½àYºÂɸ
+ * @param transno ÊÑ´¹ID
+ * @return ¤Ê¤·
  */
 static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                int xoffset, int yoffset, int transno)
@@ -2648,11 +2825,21 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
                                place_inner_grid(c_ptr);
                                break;
 
+                               /* Glass wall (inner) */
+                       case '$':
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                               break;
+
                                /* Permanent wall (inner) */
                        case 'X':
-                               c_ptr->feat = FEAT_PERM_INNER;
-                               c_ptr->info &= ~(CAVE_MASK);
-                               c_ptr->info |= CAVE_INNER;
+                               place_inner_perm_grid(c_ptr);
+                               break;
+
+                               /* Permanent glass wall (inner) */
+                       case 'Y':
+                               place_inner_perm_grid(c_ptr);
+                               c_ptr->feat = feat_permanent_glass_wall;
                                break;
 
                                /* Treasure/trap */
@@ -2669,7 +2856,18 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
 
                                /* Secret doors */
                        case '+':
-                               place_secret_door(y, x);
+                               place_secret_door(y, x, DOOR_DEFAULT);
+                               break;
+
+                               /* Secret glass doors */
+                       case '-':
+                               place_secret_door(y, x, DOOR_GLASS_DOOR);
+                               if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
+                               break;
+
+                               /* Curtains */
+                       case '\'':
+                               place_secret_door(y, x, DOOR_CURTAIN);
                                break;
 
                                /* Trap */
@@ -2679,37 +2877,37 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
 
                                /* Black market in a dungeon */
                        case 'S':
-                               set_cave_feat(y, x, FEAT_SHOP_HEAD + STORE_BLACK);
+                               set_cave_feat(y, x, feat_black_market);
                                store_init(NO_TOWN, STORE_BLACK);
                                break;
-                               
+
                                /* The Pattern */
                        case 'p':
-                               set_cave_feat(y, x, FEAT_PATTERN_START);
+                               set_cave_feat(y, x, feat_pattern_start);
                                break;
-                               
+
                        case 'a':
-                               set_cave_feat(y, x, FEAT_PATTERN_1);
+                               set_cave_feat(y, x, feat_pattern_1);
                                break;
-                               
+
                        case 'b':
-                               set_cave_feat(y, x, FEAT_PATTERN_2);
+                               set_cave_feat(y, x, feat_pattern_2);
                                break;
-                               
+
                        case 'c':
-                               set_cave_feat(y, x, FEAT_PATTERN_3);
+                               set_cave_feat(y, x, feat_pattern_3);
                                break;
-                               
+
                        case 'd':
-                               set_cave_feat(y, x, FEAT_PATTERN_4);
+                               set_cave_feat(y, x, feat_pattern_4);
                                break;
-                               
+
                        case 'P':
-                               set_cave_feat(y, x, FEAT_PATTERN_END);
+                               set_cave_feat(y, x, feat_pattern_end);
                                break;
-                               
+
                        case 'B':
-                               set_cave_feat(y, x, FEAT_PATTERN_XTRA1);
+                               set_cave_feat(y, x, feat_pattern_exit);
                                break;
 
                        case 'A':
@@ -2821,8 +3019,9 @@ static void build_vault(int yval, int xval, int ymax, int xmax, cptr data,
 }
 
 
-/*
- * Type 7 -- simple vaults (see "v_info.txt")
+/*!
+ * @brief ¥¿¥¤¥×7¤ÎÉô²°¡Äv_info.txt¤è¤ê¾®·¿vault¤òÀ¸À®¤¹¤ë / Type 7 -- simple vaults (see "v_info.txt")
+ * @return ¤Ê¤·
  */
 static bool build_type7(void)
 {
@@ -2905,16 +3104,6 @@ static bool build_type7(void)
        if (cheat_room) msg_format("Lesser vault (%s)", v_name + v_ptr->name);
 #endif
 
-       /* Boost the rating */
-       rating += v_ptr->rat;
-
-       /* (Sometimes) Cause a special feeling */
-       if ((dun_level <= 50) ||
-               (randint1((dun_level - 40) * (dun_level - 40) + 50) < 400))
-       {
-               good_item_flag = TRUE;
-       }
-
        /* Hack -- Build the vault */
        build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
                    v_text + v_ptr->text, xoffset, yoffset, transno);
@@ -2922,9 +3111,9 @@ static bool build_type7(void)
        return TRUE;
 }
 
-
-/*
- * Type 8 -- greater vaults (see "v_info.txt")
+/*!
+ * @brief ¥¿¥¤¥×8¤ÎÉô²°¡Äv_info.txt¤è¤êÂç·¿vault¤òÀ¸À®¤¹¤ë / Type 8 -- greater vaults (see "v_info.txt")
+ * @return ¤Ê¤·
  */
 static bool build_type8(void)
 {
@@ -3013,16 +3202,6 @@ static bool build_type8(void)
        if (cheat_room) msg_format("Greater vault (%s)", v_name + v_ptr->name);
 #endif
 
-       /* Boost the rating */
-       rating += v_ptr->rat;
-
-       /* (Sometimes) Cause a special feeling */
-       if ((dun_level <= 50) ||
-           (randint1((dun_level - 40) * (dun_level - 40) + 50) < 400))
-       {
-               good_item_flag = TRUE;
-       }
-
        /* Hack -- Build the vault */
        build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
                    v_text + v_ptr->text, xoffset, yoffset, transno);
@@ -3119,7 +3298,7 @@ static void store_height(int x, int y, int val)
 * The tricky part is making sure the created cave is connected.  This
 * is done by 'filling' from the inside and only keeping the 'filled'
 * floor.  Walls bounding the 'filled' floor are also kept.  Everything
-* else is converted to the normal granite FEAT_WALL_EXTRA.
+* else is converted to the normal _extra_.
  */
 
 
@@ -3173,10 +3352,10 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
        fill_data.ymin = y0 - yhsize;
        fill_data.xmax = x0 + xhsize;
        fill_data.ymax = y0 + yhsize;
-       
+
        /* Store cutoff in global for quick access */
        fill_data.c1 = cutoff;
-       
+
        /*
        * Scale factor for middle points:
        * About sqrt(2) * 256 - correct for a square lattice
@@ -3192,8 +3371,8 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
        {
                for (j = 0; j <= ysize; j++)
                {
-                       /* 255 is a flag for "not done yet" */
-                       cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].feat = 255;
+                       /* -1 is a flag for "not done yet" */
+                       cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].feat = -1;
                        /* Clear icky flag because may be redoing the cave */
                        cave[(int)(fill_data.ymin + j)][(int)(fill_data.xmin + i)].info &= ~(CAVE_ICKY);
                }
@@ -3225,11 +3404,11 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
                xhstep /= 2;
                ystep = yhstep;
                yhstep /= 2;
-               
+
                /* cache well used values */
                xstep2 = xstep / 256;
                ystep2 = ystep / 256;
-               
+
                xhstep2 = xhstep / 256;
                yhstep2 = yhstep / 256;
 
@@ -3241,10 +3420,10 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
                                /* cache often used values */
                                ii = i / 256 + fill_data.xmin;
                                jj = j / 256 + fill_data.ymin;
-                               
+
                                /* Test square */
-                               if (cave[jj][ii].feat == 255)
-                               {                               
+                               if (cave[jj][ii].feat == -1)
+                               {
                                        if (xhstep2 > grd)
                                        {
                                                /* If greater than 'grid' level then is random */
@@ -3271,9 +3450,9 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
                                /* cache often used values */
                                ii = i / 256 + fill_data.xmin;
                                jj = j / 256 + fill_data.ymin;
-                               
+
                                /* Test square */
-                               if (cave[jj][ii].feat == 255)
+                               if (cave[jj][ii].feat == -1)
                                {
                                        if (xhstep2 > grd)
                                        {
@@ -3300,10 +3479,10 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
                                /* cache often used values */
                                ii = i / 256 + fill_data.xmin;
                                jj = j / 256 + fill_data.ymin;
-                               
+
                                /* Test square */
-                               if (cave[jj][ii].feat == 255)
-                               {                               
+                               if (cave[jj][ii].feat == -1)
+                               {
                                        if (xhstep2 > grd)
                                        {
                                                /* If greater than 'grid' level then is random */
@@ -3315,12 +3494,12 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
                                                xm = fill_data.xmin + (i - xhstep) / 256;
                                                xp = fill_data.xmin + (i + xhstep) / 256;
                                                ym = fill_data.ymin + (j - yhstep) / 256;
-                                               yp = 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(ii, jj,
                                                        (cave[ym][xm].feat + cave[yp][xm].feat
                                                        + cave[ym][xp].feat + cave[yp][xp].feat) / 4
@@ -3389,6 +3568,7 @@ static bool hack_isnt_wall(int y, int x, int c1, int c2, int c3, int feat1, int
                else if (cave[y][x].feat <= c3)
                {
                        cave[y][x].feat = feat3;
+                       cave[y][x].info &= ~(CAVE_MASK);
                        cave[y][x].info |= info3;
                        return TRUE;
                }
@@ -3493,7 +3673,6 @@ static void cave_fill(byte y, byte x)
 static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, bool light, bool room)
 {
        int x, y, i, xhsize, yhsize;
-       
 
        /* offsets to middle from corner */
        xhsize = xsize / 2;
@@ -3665,7 +3844,7 @@ static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, b
         * XXX XXX XXX There is a slight problem when tunnels pierce the caves:
         * Extra doors appear inside the system.  (Its not very noticeable though.)
         * This can be removed by "filling" from the outside in.  This allows a separation
-        * from FEAT_WALL_OUTER with FEAT_WALL_INNER.  (Internal walls are  F.W.OUTER instead.)
+        * from _outer_ with _inner_.  (Internal walls are  _outer_ instead.)
         * The extra effort for what seems to be only a minor thing (even non-existant if you
         * think of the caves not as normal rooms, but as holes in the dungeon), doesn't seem
         * worth it.
@@ -3675,8 +3854,9 @@ static bool generate_fracave(int y0, int x0, int xsize, int ysize, int cutoff, b
 }
 
 
-/*
- * Driver routine to create fractal cave system
+/*!
+ * @brief ¥¿¥¤¥×9¤ÎÉô²°¡Ä¥Õ¥é¥¯¥¿¥ë¥«¡¼¥Ö¤Ë¤è¤ëƶ·¢À¸À® / Type 9 -- Driver routine to create fractal cave system
+ * @return ¤Ê¤·
  */
 static bool build_type9(void)
 {
@@ -3689,7 +3869,22 @@ static bool build_type9(void)
        ysize = randint1(15) * 2 + 6;
 
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
+       if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
+       {
+               /* Limit to the minimum room size, and retry */
+               xsize = 8;
+               ysize = 8;
+
+               /* Find and reserve some space in the dungeon.  Get center of room. */
+               if (!find_space(&y0, &x0, ysize + 1, xsize + 1))
+               {
+                       /*
+                        * Still no space?!
+                        * Try normal room
+                        */
+                       return build_type1();
+               }
+       }
 
        light = done = FALSE;
        room = TRUE;
@@ -3775,39 +3970,39 @@ static bool generate_lake(int y0, int x0, int xsize, int ysize, int c1, int c2,
        switch (type)
        {
        case LAKE_T_LAVA: /* Lava */
-               feat1 = FEAT_DEEP_LAVA;
-               feat2 = FEAT_SHAL_LAVA;
+               feat1 = feat_deep_lava;
+               feat2 = feat_shallow_lava;
                feat3 = floor_type[randint0(100)];
                break;
        case LAKE_T_WATER: /* Water */
-               feat1 = FEAT_DEEP_WATER;
-               feat2 = FEAT_SHAL_WATER;
+               feat1 = feat_deep_water;
+               feat2 = feat_shallow_water;
                feat3 = floor_type[randint0(100)];
                break;
        case LAKE_T_CAVE: /* Collapsed cave */
                feat1 = floor_type[randint0(100)];
                feat2 = floor_type[randint0(100)];
-               feat3 = FEAT_RUBBLE;
+               feat3 = feat_rubble;
                break;
        case LAKE_T_EARTH_VAULT: /* Earth vault */
-               feat1 = FEAT_RUBBLE;
+               feat1 = feat_rubble;
                feat2 = floor_type[randint0(100)];
-               feat3 = FEAT_RUBBLE;
+               feat3 = feat_rubble;
                break;
        case LAKE_T_AIR_VAULT: /* Air vault */
-               feat1 = FEAT_GRASS;
-               feat2 = FEAT_TREES;
-               feat3 = FEAT_GRASS;
+               feat1 = feat_grass;
+               feat2 = feat_tree;
+               feat3 = feat_grass;
                break;
        case LAKE_T_WATER_VAULT: /* Water vault */
-               feat1 = FEAT_SHAL_WATER;
-               feat2 = FEAT_DEEP_WATER;
-               feat3 = FEAT_SHAL_WATER;
+               feat1 = feat_shallow_water;
+               feat2 = feat_deep_water;
+               feat3 = feat_shallow_water;
                break;
        case LAKE_T_FIRE_VAULT: /* Fire Vault */
-               feat1 = FEAT_SHAL_LAVA;
-               feat2 = FEAT_DEEP_LAVA;
-               feat3 = FEAT_SHAL_LAVA;
+               feat1 = feat_shallow_lava;
+               feat2 = feat_deep_lava;
+               feat3 = feat_shallow_lava;
                break;
 
        /* Paranoia */
@@ -3894,9 +4089,8 @@ static bool generate_lake(int y0, int x0, int xsize, int ysize, int c1, int c2,
                        /* turn off icky flag (no longer needed.) */
                        cave[y0 + y - yhsize][x0 + x - xhsize].info &= ~(CAVE_ICKY | CAVE_ROOM);
 
-                       /* Light lava and trees */
-                       if ((cave[y0 + y - yhsize][x0 + x - xhsize].feat == FEAT_DEEP_LAVA) ||
-                               (cave[y0 + y - yhsize][x0 + x - xhsize].feat == FEAT_SHAL_LAVA))
+                       /* Light lava */
+                       if (cave_have_flag_bold(y0 + y - yhsize, x0 + x - xhsize, FF_LAVA))
                        {
                                if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) cave[y0 + y - yhsize][x0 + x - xhsize].info |= CAVE_GLOW;
                        }
@@ -3985,7 +4179,7 @@ static void add_door(int x, int y)
            (is_outer_bold(y, x - 1) && is_outer_bold(y, x + 1)))
        {
                /* secret door */
-               place_secret_door(y, x);
+               place_secret_door(y, x, DOOR_DEFAULT);
 
                /* set boundarys so don't get wide doors */
                place_solid_bold(y, x - 1);
@@ -4005,7 +4199,7 @@ static void add_door(int x, int y)
            is_floor_bold(y,x-1) && is_floor_bold(y,x+1))
        {
                /* secret door */
-               place_secret_door(y, x);
+               place_secret_door(y, x, DOOR_DEFAULT);
 
                /* set boundarys so don't get wide doors */
                place_solid_bold(y - 1, x);
@@ -4042,8 +4236,7 @@ static void fill_treasure(int x1, int x2, int y1, int y2, int difficulty)
 
                         /* if floor, shallow water and lava */
                        if (is_floor_bold(y, x) ||
-                           (cave[y][x].feat == FEAT_SHAL_WATER) ||
-                           (cave[y][x].feat == FEAT_SHAL_LAVA))
+                           (cave_have_flag_bold(y, x, FF_PLACE) && cave_have_flag_bold(y, x, FF_DROP)))
                        {
                                /* The smaller 'value' is, the better the stuff */
                                if (value < 0)
@@ -4180,8 +4373,8 @@ static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
        if (cheat_room) msg_print("Bubble Vault");
 
        /* Allocate center of bubbles */
-       center[0].x = randint1(xsize - 3) + 1;
-       center[0].y = randint1(ysize - 3) + 1;
+       center[0].x = (byte)randint1(xsize - 3) + 1;
+       center[0].y = (byte)randint1(ysize - 3) + 1;
 
        for (i = 1; i < BUBBLENUM; i++)
        {
@@ -4706,9 +4899,7 @@ static void build_mini_c_vault(int x0, int y0, int xsize, int ysize)
                        c_ptr->info |= (CAVE_ROOM | CAVE_ICKY);
 
                        /* Permanent walls */
-                       c_ptr->feat = FEAT_PERM_INNER;
-                       c_ptr->info &= ~(CAVE_MASK);
-                       c_ptr->info |= CAVE_INNER;
+                       place_inner_perm_grid(c_ptr);
                }
        }
 
@@ -5015,19 +5206,24 @@ static void build_castle_vault(int x0, int y0, int xsize, int ysize)
  * Note: no range checking is done so must be inside dungeon
  * This routine also stomps on doors
  */
-static void add_outer_wall(int x, int y, int light,
-                                                                       int x1, int y1, int x2, int y2)
+static void add_outer_wall(int x, int y, int light, int x1, int y1, int x2, int y2)
 {
+       cave_type *c_ptr;
+       feature_type *f_ptr;
        int i, j;
 
        if (!in_bounds(y, x)) return;
 
+       c_ptr = &cave[y][x];
+
        /* hack- check to see if square has been visited before
        * if so, then exit (use room flag to do this) */
-       if (cave[y][x].info & CAVE_ROOM) return;
+       if (c_ptr->info & CAVE_ROOM) return;
 
        /* set room flag */
-       cave[y][x].info |= CAVE_ROOM;
+       c_ptr->info |= CAVE_ROOM;
+
+       f_ptr = &f_info[c_ptr->feat];
 
        if (is_floor_bold(y, x))
        {
@@ -5039,7 +5235,7 @@ static void add_outer_wall(int x, int y, int light,
                                         (y + j >= y1) && (y + j <= y2))
                                {
                                        add_outer_wall(x + i, y + j, light, x1, y1, x2, y2);
-                                       if (light) cave[y][x].info |= CAVE_GLOW;
+                                       if (light) c_ptr->info |= CAVE_GLOW;
                                }
                        }
                }
@@ -5048,12 +5244,12 @@ static void add_outer_wall(int x, int y, int light,
        {
                /* Set bounding walls */
                place_outer_bold(y, x);
-               if (light) cave[y][x].info |= CAVE_GLOW;
+               if (light) c_ptr->info |= CAVE_GLOW;
        }
-       else if (cave[y][x].feat == FEAT_PERM_OUTER)
+       else if (permanent_wall(f_ptr))
        {
                /* Set bounding walls */
-               if (light) cave[y][x].info |= CAVE_GLOW;
+               if (light) c_ptr->info |= CAVE_GLOW;
        }
 }
 
@@ -5300,8 +5496,9 @@ static void build_elemental_vault(int x0, int y0, int xsiz, int ysiz)
 #endif /* ALLOW_CAVERNS_AND_LAKES */
 
 
-/*
- * Random vaults
+/*!
+ * @brief ¥¿¥¤¥×10¤ÎÉô²°¡Ä¥é¥ó¥À¥àÀ¸À®vault / Type 10 -- Random vaults
+ * @return ¤Ê¤·
  */
 static bool build_type10(void)
 {
@@ -5315,21 +5512,21 @@ static bool build_type10(void)
        /* Find and reserve some space in the dungeon.  Get center of room. */
        if (!find_space(&y0, &x0, ysize + 1, xsize + 1)) return FALSE;
 
-       /* Boost the rating- higher than lesser vaults and lower than greater vaults */
-       rating += 10;
-
-       /* (Sometimes) Cause a special feeling */
-       if ((dun_level <= 50) ||
-           (randint1((dun_level - 40) * (dun_level - 40) + 1) < 400))
-       {
-               good_item_flag = TRUE;
-       }
-
        /* Select type of vault */
 #ifdef ALLOW_CAVERNS_AND_LAKES
-       vtype = randint1(15);
+       do
+       {
+               vtype = randint1(15);
+       }
+       while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
+               ((vtype == 1) || (vtype == 3) || (vtype == 8) || (vtype == 9) || (vtype == 11)));
 #else /* ALLOW_CAVERNS_AND_LAKES */
-       vtype = randint1(7);
+       do
+       {
+               vtype = randint1(7);
+       }
+       while ((d_info[dungeon_type].flags1 & DF1_NO_CAVE) &&
+               ((vtype == 1) || (vtype == 3)));
 #endif /* ALLOW_CAVERNS_AND_LAKES */
 
        switch (vtype)
@@ -5355,12 +5552,14 @@ static bool build_type10(void)
 }
 
 
-/*
- * Build an vertical oval room.
- * For every grid in the possible square, check the distance.
- * If it's less than the radius, make it a room square.
- *
- * When done fill from the inside to find the walls,
+/*!
+ * @brief ¥¿¥¤¥×11¤ÎÉô²°¡Ä±ß·ÁÉô²°¤ÎÀ¸À® / Type 11 -- Build an vertical oval room.
+ * @return ¤Ê¤·
+ * @details
+ * For every grid in the possible square, check the distance.\n
+ * If it's less than the radius, make it a room square.\n
+ *\n
+ * When done fill from the inside to find the walls,\n
  */
 static bool build_type11(void)
 {
@@ -5400,12 +5599,14 @@ static bool build_type11(void)
 }
 
 
-/*
- * Build crypt room.
- * For every grid in the possible square, check the (fake) distance.
- * If it's less than the radius, make it a room square.
- *
- * When done fill from the inside to find the walls,
+/*!
+ * @brief ¥¿¥¤¥×12¤ÎÉô²°¡Ä¥É¡¼¥à·¿Éô²°¤ÎÀ¸À® / Type 12 -- Build crypt room.
+ * @return ¤Ê¤·
+ * @details
+ * For every grid in the possible square, check the (fake) distance.\n
+ * If it's less than the radius, make it a room square.\n
+ *\n
+ * When done fill from the inside to find the walls,\n
  */
 static bool build_type12(void)
 {
@@ -5514,49 +5715,50 @@ static bool vault_aux_trapped_pit(int r_idx)
 }
 
 
-/*
- * Type 12 -- Trapped monster pits
- *
- * A trapped monster pit is a "big" room with a straight corridor in
- * which wall opening traps are placed, and with two "inner" rooms
- * containing a "collection" of monsters of a given type organized in
- * the room.
- *
- * The trapped monster pit appears as shown below, where the actual
- * monsters in each location depend on the type of the pit
- *
- *  #########################
- *  #                       #
- *  ####################### #
- *  #####001123454321100### #
- *  ###0012234567654322100# #
- *  ####################### #
- *  #           ^           #
- *  # #######################
- *  # #0012234567654322100###
- *  # ###001123454321100#####
- *  # #######################
- *  #                       #
- *  #########################
- *
- * Note that the monsters in the pit are now chosen by using "get_mon_num()"
- * to request 16 "appropriate" monsters, sorting them by level, and using
- * the "even" entries in this sorted list for the contents of the pit.
- *
- * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",
- * which is handled by requiring a specific "breath" attack for all of the
- * dragons.  This may include "multi-hued" breath.  Note that "wyrms" may
- * be present in many of the dragon pits, if they have the proper breath.
- *
- * Note the use of the "get_mon_num_prep()" function, and the special
- * "get_mon_num_hook()" restriction function, to prepare the "monster
- * allocation table" in such a way as to optimize the selection of
- * "appropriate" non-unique monsters for the pit.
- *
- * Note that the "get_mon_num()" function may (rarely) fail, in which case
- * the pit will be empty, and will not effect the level rating.
- *
- * Note that "monster pits" will never contain "unique" monsters.
+/*!
+ * @brief ¥¿¥¤¥×13¤ÎÉô²°¡Ä¥È¥é¥Ã¥×pit¤ÎÀ¸À® / Type 13 -- Trapped monster pits
+ * @return ¤Ê¤·
+ * @details
+ * A trapped monster pit is a "big" room with a straight corridor in\n
+ * which wall opening traps are placed, and with two "inner" rooms\n
+ * containing a "collection" of monsters of a given type organized in\n
+ * the room.\n
+ *\n
+ * The trapped monster pit appears as shown below, where the actual\n
+ * monsters in each location depend on the type of the pit\n
+ *\n
+ *  XXXXXXXXXXXXXXXXXXXXXXXXX\n
+ *  X                       X\n
+ *  XXXXXXXXXXXXXXXXXXXXXXX X\n
+ *  XXXXX001123454321100XXX X\n
+ *  XXX0012234567654322100X X\n
+ *  XXXXXXXXXXXXXXXXXXXXXXX X\n
+ *  X           ^           X\n
+ *  X XXXXXXXXXXXXXXXXXXXXXXX\n
+ *  X X0012234567654322100XXX\n
+ *  X XXX001123454321100XXXXX\n
+ *  X XXXXXXXXXXXXXXXXXXXXXXX\n
+ *  X                       X\n
+ *  XXXXXXXXXXXXXXXXXXXXXXXXX\n
+ *\n
+ * Note that the monsters in the pit are now chosen by using "get_mon_num()"\n
+ * to request 16 "appropriate" monsters, sorting them by level, and using\n
+ * the "even" entries in this sorted list for the contents of the pit.\n
+ *\n
+ * Hack -- all of the "dragons" in a "dragon" pit must be the same "color",\n
+ * which is handled by requiring a specific "breath" attack for all of the\n
+ * dragons.  This may include "multi-hued" breath.  Note that "wyrms" may\n
+ * be present in many of the dragon pits, if they have the proper breath.\n
+ *\n
+ * Note the use of the "get_mon_num_prep()" function, and the special\n
+ * "get_mon_num_hook()" restriction function, to prepare the "monster\n
+ * allocation table" in such a way as to optimize the selection of\n
+ * "appropriate" non-unique monsters for the pit.\n
+ *\n
+ * Note that the "get_mon_num()" function may (rarely) fail, in which case\n
+ * the pit will be empty.\n
+ *\n
+ * Note that "monster pits" will never contain "unique" monsters.\n
  */
 static bool build_type13(void)
 {
@@ -5747,7 +5949,7 @@ static bool build_type13(void)
 
        /* Place the wall open trap */
        cave[yval][xval].mimic = cave[yval][xval].feat;
-       cave[yval][xval].feat = FEAT_TRAP_OPEN;
+       cave[yval][xval].feat = feat_trap_open;
 
        /* Sort the entries */
        for (i = 0; i < 16 - 1; i++)
@@ -5795,15 +5997,6 @@ static bool build_type13(void)
                }
        }
 
-       /* Increase the level rating */
-       rating += 20;
-
-       /* (Sometimes) Cause a "special feeling" (for "Monster Pits") */
-       if ((dun_level <= 40) && (randint1(dun_level * dun_level + 50) < 300))
-       {
-               good_item_flag = TRUE;
-       }
-
        for (i = 0; placing[i][2] >= 0; i++)
        {
                y = yval + placing[i][0];
@@ -5815,9 +6008,10 @@ static bool build_type13(void)
 }
 
 
-/*
- * Type 14 -- trapped rooms
- *
+/*!
+ * @brief ¥¿¥¤¥×14¤ÎÉô²°¡ÄÆüì¥È¥é¥Ã¥×Éô²°¤ÎÀ¸À® / Type 14 -- trapped rooms
+ * @return ¤Ê¤·
+ * @details
  * A special trap is placed at center of the room
  */
 static bool build_type14(void)
@@ -5828,7 +6022,7 @@ static bool build_type14(void)
        bool light;
 
        cave_type *c_ptr;
-       byte trap;
+       s16b trap;
 
        /* Pick a room size */
        y1 = randint1(4);
@@ -5882,9 +6076,9 @@ static bool build_type14(void)
        }
 
        if (dun_level < 30 + randint1(30))
-               trap = FEAT_TRAP_PIRANHA;
+               trap = feat_trap_piranha;
        else
-               trap = FEAT_TRAP_ARMAGEDDON;
+               trap = feat_trap_armageddon;
 
        /* Place a special trap */
        c_ptr = &cave[rand_spread(yval, ysize/4)][rand_spread(xval, xsize/4)];
@@ -5906,32 +6100,624 @@ static bool build_type14(void)
 
 
 /*
- * Attempt to build a room of the given type at the given block
- *
- * Note that we restrict the number of "crowded" rooms to reduce
- * the chance of overflowing the monster list during level creation.
+ * Helper function for "glass room"
  */
-bool room_build(int typ)
+static bool vault_aux_lite(int r_idx)
 {
-       /* Build a room */
-       switch (typ)
-       {
-       /* Build an appropriate room */
-       case ROOM_T_NORMAL:        return build_type1();
-       case ROOM_T_OVERLAP:       return build_type2();
-       case ROOM_T_CROSS:         return build_type3();
-       case ROOM_T_INNER_FEAT:    return build_type4();
-       case ROOM_T_NEST:          return build_type5();
-       case ROOM_T_PIT:           return build_type6();
-       case ROOM_T_LESSER_VAULT:  return build_type7();
-       case ROOM_T_GREATER_VAULT: return build_type8();
-       case ROOM_T_FRACAVE:       return build_type9();
-       case ROOM_T_RANDOM_VAULT:  return build_type10();
-       case ROOM_T_OVAL:          return build_type11();
-       case ROOM_T_CRYPT:         return build_type12();
-       case ROOM_T_TRAP_PIT:      return build_type13();
-       case ROOM_T_TRAP:          return build_type14();
-       }
+       monster_race *r_ptr = &r_info[r_idx];
+
+       /* Validate the monster */
+       if (!vault_monster_okay(r_idx)) return FALSE;
+
+       /* Require lite attack */
+       if (!(r_ptr->flags4 & RF4_BR_LITE) && !(r_ptr->flags5 & RF5_BA_LITE)) return FALSE;
+
+       /* No wall passing monsters */
+       if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
+
+       /* No disintegrating monsters */
+       if (r_ptr->flags4 & RF4_BR_DISI) return FALSE;
+
+       return TRUE;
+}
+
+/*
+ * Helper function for "glass room"
+ */
+static bool vault_aux_shards(int r_idx)
+{
+       monster_race *r_ptr = &r_info[r_idx];
+
+       /* Validate the monster */
+       if (!vault_monster_okay(r_idx)) return FALSE;
+
+       /* Require shards breath attack */
+       if (!(r_ptr->flags4 & RF4_BR_SHAR)) return FALSE;
+
+       return TRUE;
+}
+
+/*
+ * Hack -- determine if a template is potion
+ */
+static bool kind_is_potion(int k_idx)
+{
+       return k_info[k_idx].tval == TV_POTION;
+}
+
+/*!
+ * @brief ¥¿¥¤¥×15¤ÎÉô²°¡Ä¥¬¥é¥¹Éô²°¤ÎÀ¸À® / Type 15 -- glass rooms
+ * @return ¤Ê¤·
+ */
+static bool build_type15(void)
+{
+       int y, x, y2, x2, yval, xval;
+       int y1, x1, xsize, ysize;
+       bool light;
+
+       cave_type *c_ptr;
+
+       /* Pick a room size */
+       xsize = rand_range(9, 13);
+       ysize = rand_range(9, 13);
+
+       /* Find and reserve some space in the dungeon.  Get center of room. */
+       if (!find_space(&yval, &xval, ysize + 2, xsize + 2)) return FALSE;
+
+       /* Choose lite or dark */
+       light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
+
+       /* Get corner values */
+       y1 = yval - ysize / 2;
+       x1 = xval - xsize / 2;
+       y2 = yval + (ysize - 1) / 2;
+       x2 = xval + (xsize - 1) / 2;
+
+       /* Place a full floor under the room */
+       for (y = y1 - 1; y <= y2 + 1; y++)
+       {
+               for (x = x1 - 1; x <= x2 + 1; x++)
+               {
+                       c_ptr = &cave[y][x];
+                       place_floor_grid(c_ptr);
+                       c_ptr->feat = feat_glass_floor;
+                       c_ptr->info |= (CAVE_ROOM);
+                       if (light) c_ptr->info |= (CAVE_GLOW);
+               }
+       }
+
+       /* Walls around the room */
+       for (y = y1 - 1; y <= y2 + 1; y++)
+       {
+               c_ptr = &cave[y][x1 - 1];
+               place_outer_grid(c_ptr);
+               c_ptr->feat = feat_glass_wall;
+               c_ptr = &cave[y][x2 + 1];
+               place_outer_grid(c_ptr);
+               c_ptr->feat = feat_glass_wall;
+       }
+       for (x = x1 - 1; x <= x2 + 1; x++)
+       {
+               c_ptr = &cave[y1 - 1][x];
+               place_outer_grid(c_ptr);
+               c_ptr->feat = feat_glass_wall;
+               c_ptr = &cave[y2 + 1][x];
+               place_outer_grid(c_ptr);
+               c_ptr->feat = feat_glass_wall;
+       }
+
+       switch (randint1(3))
+       {
+       case 1: /* 4 lite breathers + potion */
+               {
+                       int dir1, dir2;
+
+                       /* Prepare allocation table */
+                       get_mon_num_prep(vault_aux_lite, NULL);
+
+                       /* Place fixed lite berathers */
+                       for (dir1 = 4; dir1 < 8; dir1++)
+                       {
+                               int r_idx = get_mon_num(dun_level);
+
+                               y = yval + 2 * ddy_ddd[dir1];
+                               x = xval + 2 * ddx_ddd[dir1];
+                               if (r_idx) place_monster_aux(0, y, x, r_idx, PM_ALLOW_SLEEP);
+
+                               /* Walls around the breather */
+                               for (dir2 = 0; dir2 < 8; dir2++)
+                               {
+                                       c_ptr = &cave[y + ddy_ddd[dir2]][x + ddx_ddd[dir2]];
+                                       place_inner_grid(c_ptr);
+                                       c_ptr->feat = feat_glass_wall;
+                               }
+                       }
+
+                       /* Walls around the potion */
+                       for (dir1 = 0; dir1 < 4; dir1++)
+                       {
+                               y = yval + 2 * ddy_ddd[dir1];
+                               x = xval + 2 * ddx_ddd[dir1];
+                               c_ptr = &cave[y][x];
+                               place_inner_perm_grid(c_ptr);
+                               c_ptr->feat = feat_permanent_glass_wall;
+                               cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]].info |= (CAVE_ICKY);
+                       }
+
+                       /* Glass door */
+                       dir1 = randint0(4);
+                       y = yval + 2 * ddy_ddd[dir1];
+                       x = xval + 2 * ddx_ddd[dir1];
+                       place_secret_door(y, x, DOOR_GLASS_DOOR);
+                       c_ptr = &cave[y][x];
+                       if (is_closed_door(c_ptr->feat)) c_ptr->mimic = feat_glass_wall;
+
+                       /* Place a potion */
+                       get_obj_num_hook = kind_is_potion;
+                       place_object(yval, xval, AM_NO_FIXED_ART);
+                       cave[yval][xval].info |= (CAVE_ICKY);
+               }
+               break;
+
+       case 2: /* 1 lite breather + random object */
+               {
+                       int r_idx, dir1;
+
+                       /* Pillars */
+                       c_ptr = &cave[y1 + 1][x1 + 1];
+                       place_inner_grid(c_ptr);
+                       c_ptr->feat = feat_glass_wall;
+
+                       c_ptr = &cave[y1 + 1][x2 - 1];
+                       place_inner_grid(c_ptr);
+                       c_ptr->feat = feat_glass_wall;
+
+                       c_ptr = &cave[y2 - 1][x1 + 1];
+                       place_inner_grid(c_ptr);
+                       c_ptr->feat = feat_glass_wall;
+
+                       c_ptr = &cave[y2 - 1][x2 - 1];
+                       place_inner_grid(c_ptr);
+                       c_ptr->feat = feat_glass_wall;
+
+                       /* Prepare allocation table */
+                       get_mon_num_prep(vault_aux_lite, NULL);
+
+                       r_idx = get_mon_num(dun_level);
+                       if (r_idx) place_monster_aux(0, yval, xval, r_idx, 0L);
+
+                       /* Walls around the breather */
+                       for (dir1 = 0; dir1 < 8; dir1++)
+                       {
+                               c_ptr = &cave[yval + ddy_ddd[dir1]][xval + ddx_ddd[dir1]];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                       }
+
+                       /* Curtains around the breather */
+                       for (y = yval - 1; y <= yval + 1; y++)
+                       {
+                               place_closed_door(y, xval - 2, DOOR_CURTAIN);
+                               place_closed_door(y, xval + 2, DOOR_CURTAIN);
+                       }
+                       for (x = xval - 1; x <= xval + 1; x++)
+                       {
+                               place_closed_door(yval - 2, x, DOOR_CURTAIN);
+                               place_closed_door(yval + 2, x, DOOR_CURTAIN);
+                       }
+
+                       /* Place an object */
+                       place_object(yval, xval, AM_NO_FIXED_ART);
+                       cave[yval][xval].info |= (CAVE_ICKY);
+               }
+               break;
+
+       case 3: /* 4 shards breathers + 2 potions */
+               {
+                       int dir1;
+
+                       /* Walls around the potion */
+                       for (y = yval - 2; y <= yval + 2; y++)
+                       {
+                               c_ptr = &cave[y][xval - 3];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                               c_ptr = &cave[y][xval + 3];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                       }
+                       for (x = xval - 2; x <= xval + 2; x++)
+                       {
+                               c_ptr = &cave[yval - 3][x];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                               c_ptr = &cave[yval + 3][x];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                       }
+                       for (dir1 = 4; dir1 < 8; dir1++)
+                       {
+                               c_ptr = &cave[yval + 2 * ddy_ddd[dir1]][xval + 2 * ddx_ddd[dir1]];
+                               place_inner_grid(c_ptr);
+                               c_ptr->feat = feat_glass_wall;
+                       }
+
+                       /* Prepare allocation table */
+                       get_mon_num_prep(vault_aux_shards, NULL);
+
+                       /* Place shard berathers */
+                       for (dir1 = 4; dir1 < 8; dir1++)
+                       {
+                               int r_idx = get_mon_num(dun_level);
+
+                               y = yval + ddy_ddd[dir1];
+                               x = xval + ddx_ddd[dir1];
+                               if (r_idx) place_monster_aux(0, y, x, r_idx, 0L);
+                       }
+
+                       /* Place two potions */
+                       if (one_in_(2))
+                       {
+                               get_obj_num_hook = kind_is_potion;
+                               place_object(yval, xval - 1, AM_NO_FIXED_ART);
+                               get_obj_num_hook = kind_is_potion;
+                               place_object(yval, xval + 1, AM_NO_FIXED_ART);
+                       }
+                       else
+                       {
+                               get_obj_num_hook = kind_is_potion;
+                               place_object(yval - 1, xval, AM_NO_FIXED_ART);
+                               get_obj_num_hook = kind_is_potion;
+                               place_object(yval + 1, xval, AM_NO_FIXED_ART);
+                       }
+
+                       for (y = yval - 2; y <= yval + 2; y++)
+                               for (x = xval - 2; x <= xval + 2; x++)
+                                       cave[y][x].info |= (CAVE_ICKY);
+
+               }
+               break;
+       }
+
+       /* Message */
+       if (cheat_room)
+       {
+#ifdef JP
+               msg_print("¥¬¥é¥¹¤ÎÉô²°");
+#else
+               msg_print("Glass room");
+#endif
+       }
+
+       return TRUE;
+}
+
+
+/* Create a new floor room with optional light */
+void generate_room_floor(int y1, int x1, int y2, int x2, int light)
+{
+       int y, x;
+       
+       cave_type *c_ptr;
+
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
+                       /* Point to grid */
+                       c_ptr = &cave[y][x];
+                       place_floor_grid(c_ptr);
+                       c_ptr->info |= (CAVE_ROOM);
+                       if (light) c_ptr->info |= (CAVE_GLOW);
+               }
+       }
+}
+
+void generate_fill_perm_bold(int y1, int x1, int y2, int x2)
+{
+       int y, x;
+
+       for (y = y1; y <= y2; y++)
+       {
+               for (x = x1; x <= x2; x++)
+               {
+                       /* Point to grid */
+                       place_inner_perm_bold(y, x);
+               }
+       }
+}
+
+/* Minimum & maximum town size */
+#define MIN_TOWN_WID ((MAX_WID / 3) / 2)
+#define MIN_TOWN_HGT ((MAX_HGT / 3) / 2)
+#define MAX_TOWN_WID ((MAX_WID / 3) * 2 / 3)
+#define MAX_TOWN_HGT ((MAX_HGT / 3) * 2 / 3)
+
+/* Struct for build underground buildings */
+typedef struct
+{
+       int y0, x0; /* North-west corner (relative) */
+       int y1, x1; /* South-east corner (relative) */
+}
+ugbldg_type;
+
+ugbldg_type *ugbldg;
+
+/*
+ * Precalculate buildings' location of underground arcade
+ */
+static bool precalc_ugarcade(int town_hgt, int town_wid, int n)
+{
+       int i, y, x, center_y, center_x, tmp, attempt = 10000;
+       int max_bldg_hgt = 3 * town_hgt / MAX_TOWN_HGT;
+       int max_bldg_wid = 5 * town_wid / MAX_TOWN_WID;
+       ugbldg_type *cur_ugbldg;
+       bool **ugarcade_used, abort;
+
+       /* Allocate "ugarcade_used" array (2-dimension) */
+       C_MAKE(ugarcade_used, town_hgt, bool *);
+       C_MAKE(*ugarcade_used, town_hgt * town_wid, bool);
+       for (y = 1; y < town_hgt; y++) ugarcade_used[y] = *ugarcade_used + y * town_wid;
+
+       /* Calculate building locations */
+       for (i = 0; i < n; i++)
+       {
+               cur_ugbldg = &ugbldg[i];
+               (void)WIPE(cur_ugbldg, ugbldg_type);
+
+               do
+               {
+                       /* Find the "center" of the store */
+                       center_y = rand_range(2, town_hgt - 3);
+                       center_x = rand_range(2, town_wid - 3);
+
+                       /* Determine the store boundaries */
+                       tmp = center_y - randint1(max_bldg_hgt);
+                       cur_ugbldg->y0 = MAX(tmp, 1);
+                       tmp = center_x - randint1(max_bldg_wid);
+                       cur_ugbldg->x0 = MAX(tmp, 1);
+                       tmp = center_y + randint1(max_bldg_hgt);
+                       cur_ugbldg->y1 = MIN(tmp, town_hgt - 2);
+                       tmp = center_x + randint1(max_bldg_wid);
+                       cur_ugbldg->x1 = MIN(tmp, town_wid - 2);
+
+                       /* Scan this building's area */
+                       for (abort = FALSE, y = cur_ugbldg->y0; (y <= cur_ugbldg->y1) && !abort; y++)
+                       {
+                               for (x = cur_ugbldg->x0; x <= cur_ugbldg->x1; x++)
+                               {
+                                       if (ugarcade_used[y][x])
+                                       {
+                                               abort = TRUE;
+                                               break;
+                                       }
+                               }
+                       }
+
+                       attempt--;
+               }
+               while (abort && attempt); /* Accept this building if no overlapping */
+
+               /* Failed to generate underground arcade */
+               if (!attempt) break;
+
+               /*
+                * Mark to ugarcade_used[][] as "used"
+                * Note: Building-adjacent grids are included for preventing
+                * connected bulidings.
+                */
+               for (y = cur_ugbldg->y0 - 1; y <= cur_ugbldg->y1 + 1; y++)
+               {
+                       for (x = cur_ugbldg->x0 - 1; x <= cur_ugbldg->x1 + 1; x++)
+                       {
+                               ugarcade_used[y][x] = TRUE;
+                       }
+               }
+       }
+
+       /* Free "ugarcade_used" array (2-dimension) */
+       C_KILL(*ugarcade_used, town_hgt * town_wid, bool);
+       C_KILL(ugarcade_used, town_hgt, bool *);
+
+       /* If i < n, generation is not allowed */
+       return i == n;
+}
+
+/*
+ * Actually create buildings
+ * Note: ltcy and ltcx indicate "left top corner".
+ */
+static void build_stores(int ltcy, int ltcx, int stores[], int n)
+{
+       int i, j, y, x;
+       ugbldg_type *cur_ugbldg;
+
+       for (i = 0; i < n; i++)
+       {
+               cur_ugbldg = &ugbldg[i];
+
+               /* Generate new room */
+               generate_room_floor(
+                       ltcy + cur_ugbldg->y0 - 2, ltcx + cur_ugbldg->x0 - 2,
+                       ltcy + cur_ugbldg->y1 + 2, ltcx + cur_ugbldg->x1 + 2,
+                       FALSE);
+       }
+
+       for (i = 0; i < n; i++)
+       {
+               cur_ugbldg = &ugbldg[i];
+
+               /* Build an invulnerable rectangular building */
+               generate_fill_perm_bold(
+                       ltcy + cur_ugbldg->y0, ltcx + cur_ugbldg->x0,
+                       ltcy + cur_ugbldg->y1, ltcx + cur_ugbldg->x1);
+
+               /* Pick a door direction (S,N,E,W) */
+               switch (randint0(4))
+               {
+               /* Bottom side */
+               case 0:
+                       y = cur_ugbldg->y1;
+                       x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
+                       break;
+
+               /* Top side */
+               case 1:
+                       y = cur_ugbldg->y0;
+                       x = rand_range(cur_ugbldg->x0, cur_ugbldg->x1);
+                       break;
+
+               /* Right side */
+               case 2:
+                       y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
+                       x = cur_ugbldg->x1;
+                       break;
+
+               /* Left side */
+               default:
+                       y = rand_range(cur_ugbldg->y0, cur_ugbldg->y1);
+                       x = cur_ugbldg->x0;
+                       break;
+               }
+
+               for (j = 0; j < max_f_idx; j++)
+               {
+                       if (have_flag(f_info[j].flags, FF_STORE))
+                       {
+                               if (f_info[j].subtype == stores[i]) break;
+                       }
+               }
+
+               /* Clear previous contents, add a store door */
+               if (j < max_f_idx)
+               {
+                       cave_set_feat(ltcy + y, ltcx + x, j);
+
+                       /* Init store */
+                       store_init(NO_TOWN, stores[i]);
+               }
+       }
+}
+
+
+/*!
+ * @brief ¥¿¥¤¥×16¤ÎÉô²°¡ÄÃϲ¼ÅÔ»Ô¤ÎÀ¸À® / Type 16 -- Underground Arcade
+ * @return ¤Ê¤·
+ * @details
+ * Town logic flow for generation of new town\n
+ * Originally from Vanilla 3.0.3\n
+ *\n
+ * We start with a fully wiped cave of normal floors.\n
+ *\n
+ * Note that town_gen_hack() plays games with the R.N.G.\n
+ *\n
+ * This function does NOT do anything about the owners of the stores,\n
+ * nor the contents thereof.  It only handles the physical layout.\n
+ */
+static bool build_type16(void)
+{
+       int stores[] =
+       {
+               STORE_GENERAL, STORE_ARMOURY, STORE_WEAPON, STORE_TEMPLE,
+               STORE_ALCHEMIST, STORE_MAGIC, STORE_BLACK, STORE_BOOK,
+       };
+       int n = sizeof stores / sizeof (int);
+       int i, y, x, y1, x1, yval, xval;
+       int town_hgt = rand_range(MIN_TOWN_HGT, MAX_TOWN_HGT);
+       int town_wid = rand_range(MIN_TOWN_WID, MAX_TOWN_WID);
+       bool prevent_bm = FALSE;
+
+       /* Hack -- If already exist black market, prevent building */
+       for (y = 0; (y < cur_hgt) && !prevent_bm; y++)
+       {
+               for (x = 0; x < cur_wid; x++)
+               {
+                       if (cave[y][x].feat == FF_STORE)
+                       {
+                               prevent_bm = (f_info[cave[y][x].feat].subtype == STORE_BLACK);
+                               break;
+                       }
+               }
+       }
+       for (i = 0; i < n; i++)
+       {
+               if ((stores[i] == STORE_BLACK) && prevent_bm) stores[i] = stores[--n];
+       }
+       if (!n) return FALSE;
+
+       /* Allocate buildings array */
+       C_MAKE(ugbldg, n, ugbldg_type);
+
+       /* If cannot build stores, abort */
+       if (!precalc_ugarcade(town_hgt, town_wid, n))
+       {
+               /* Free buildings array */
+               C_KILL(ugbldg, n, ugbldg_type);
+               return FALSE;
+       }
+
+       /* Find and reserve some space in the dungeon.  Get center of room. */
+       if (!find_space(&yval, &xval, town_hgt + 4, town_wid + 4))
+       {
+               /* Free buildings array */
+               C_KILL(ugbldg, n, ugbldg_type);
+               return FALSE;
+       }
+
+       /* Get top left corner */
+       y1 = yval - (town_hgt / 2);
+       x1 = xval - (town_wid / 2);
+
+       /* Generate new room */
+       generate_room_floor(
+               y1 + town_hgt / 3, x1 + town_wid / 3,
+               y1 + town_hgt * 2 / 3, x1 + town_wid * 2 / 3, FALSE);
+
+       /* Build stores */
+       build_stores(y1, x1, stores, n);
+
+#ifdef JP
+       if (cheat_room) msg_print("Ãϲ¼³¹");
+#else
+       if (cheat_room) msg_print("Underground Arcade");
+#endif
+
+       /* Free buildings array */
+       C_KILL(ugbldg, n, ugbldg_type);
+
+       return TRUE;
+}
+
+
+/*
+ * Attempt to build a room of the given type at the given block
+ *
+ * Note that we restrict the number of "crowded" rooms to reduce
+ * the chance of overflowing the monster list during level creation.
+ */
+static bool room_build(int typ)
+{
+       /* Build a room */
+       switch (typ)
+       {
+       /* Build an appropriate room */
+       case ROOM_T_NORMAL:        return build_type1();
+       case ROOM_T_OVERLAP:       return build_type2();
+       case ROOM_T_CROSS:         return build_type3();
+       case ROOM_T_INNER_FEAT:    return build_type4();
+       case ROOM_T_NEST:          return build_type5();
+       case ROOM_T_PIT:           return build_type6();
+       case ROOM_T_LESSER_VAULT:  return build_type7();
+       case ROOM_T_GREATER_VAULT: return build_type8();
+       case ROOM_T_FRACAVE:       return build_type9();
+       case ROOM_T_RANDOM_VAULT:  return build_type10();
+       case ROOM_T_OVAL:          return build_type11();
+       case ROOM_T_CRYPT:         return build_type12();
+       case ROOM_T_TRAP_PIT:      return build_type13();
+       case ROOM_T_TRAP:          return build_type14();
+       case ROOM_T_GLASS:         return build_type15();
+       case ROOM_T_ARCADE:        return build_type16();
+       }
 
        /* Paranoia */
        return FALSE;
@@ -5945,7 +6731,7 @@ bool room_build(int typ)
  * 
  * Generate rooms in dungeon.  Build bigger rooms at first.
  */
-void generate_rooms(void)
+bool generate_rooms(void)
 {
        int i;
        bool remain;
@@ -5960,12 +6746,11 @@ void generate_rooms(void)
        s16b room_num[ROOM_T_MAX];
 
        /* Limit number of rooms */
-       int dun_rooms = rand_range(DUN_ROOMS_MIN, DUN_ROOMS_MAX * area_size / 100);
+       int dun_rooms = DUN_ROOMS_MAX * area_size / 100;
 
        /* Assume normal cave */
        room_info_type *room_info_ptr = room_info_normal;
 
-
        /*
         * Initialize probability list.
         */
@@ -5987,7 +6772,7 @@ void generate_rooms(void)
         */
 
        /* Ironman sees only Greater Vaults */
-       if (ironman_rooms && !((d_info[dungeon_type].flags1 & (DF1_BEGINNER | DF1_CHAMELEON))))
+       if (ironman_rooms && !((d_info[dungeon_type].flags1 & (DF1_BEGINNER | DF1_CHAMELEON | DF1_SMALLEST))))
        {
                for (i = 0; i < ROOM_T_MAX; i++)
                {
@@ -6025,6 +6810,16 @@ void generate_rooms(void)
                prob_list[ROOM_T_FRACAVE] = 0;
        }
 
+       /* Forbidden glass rooms */
+       if (!(d_info[dungeon_type].flags1 & DF1_GLASS_ROOM))
+       {
+               prob_list[ROOM_T_GLASS] = 0;
+       }
+
+       if (!(d_info[dungeon_type].flags1 & DF1_ARCADE))
+       {
+               prob_list[ROOM_T_ARCADE] = 0;
+       }
 
        /*
         * Initialize number of rooms,
@@ -6064,6 +6859,8 @@ void generate_rooms(void)
                case ROOM_T_PIT:
                case ROOM_T_LESSER_VAULT:
                case ROOM_T_TRAP_PIT:
+               case ROOM_T_GLASS:
+               case ROOM_T_ARCADE:
 
                        /* Large room */
                        i -= 2;
@@ -6120,13 +6917,14 @@ void generate_rooms(void)
                                                room_num[ROOM_T_NEST] = 0;
                                                room_num[ROOM_T_TRAP_PIT] = 0;
                                        }
-                               }
-                       }
+                                       break;
 
-                       /* Stop building this type on failure. */
-                       else
-                       {
-                               room_num[room_type] = 0;
+                               case ROOM_T_ARCADE:
+
+                                       /* Avoid double-town */
+                                       room_num[ROOM_T_ARCADE] = 0;
+                                       break;
+                               }
                        }
                }
 
@@ -6134,6 +6932,8 @@ void generate_rooms(void)
                if (!remain) break;
        }
 
+       if (rooms_built < 2) return FALSE;
+
        if (cheat_room)
        {
 #ifdef JP
@@ -6142,4 +6942,6 @@ void generate_rooms(void)
                msg_format("Number of Rooms: %d", rooms_built);
 #endif
        }
+
+       return TRUE;
 }