OSDN Git Service

[Refactor] #37353 ファイル名修正。
[hengband/hengband.git] / src / rooms.c
index 024b696..361cb25 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 "grid.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.
+#include "rooms-normal.h"
+
+
+/*!
+ * 各部屋タイプの生成比定義
+ *[from SAngband (originally from OAngband)]\n
+ *\n
+ * Table of values that control how many times each type of room will\n
+ * appear.  Each type of room has its own row, and each column\n
+ * corresponds to dungeon levels 0, 10, 20, and so on.  The final\n
+ * value is the minimum depth the room can appear at.  -LM-\n
+ *\n
+ * Level 101 and below use the values for level 100.\n
+ *\n
+ * Rooms with lots of monsters or loot may not be generated if the\n
+ * object or monster lists are already nearly full.  Rooms will not\n
+ * appear above their minimum depth.  Tiny levels will not have space\n
+ * for all the rooms you ask for.\n
  */
 static room_info_type room_info_normal[ROOM_T_MAX] =
 {
@@ -56,7 +84,7 @@ static room_info_type room_info_normal[ROOM_T_MAX] =
 };
 
 
-/* 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,
@@ -76,8 +104,13 @@ static byte room_build_order[ROOM_T_MAX] = {
        ROOM_T_NORMAL,
 };
 
-
-static void place_locked_door(int y, int x)
+/*!
+ * @brief 鍵のかかったドアを配置する
+ * @param y 配置したいフロアのY座標
+ * @param x 配置したいフロアのX座標
+ * @return なし
+ */
+void place_locked_door(int y, int x)
 {
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
        {
@@ -91,7 +124,14 @@ static void place_locked_door(int y, int x)
        }
 }
 
-static void place_secret_door(int y, int x, int type)
+/*!
+ * @brief 隠しドアを配置する
+ * @param y 配置したいフロアのY座標
+ * @param x 配置したいフロアのX座標
+ * @param type DOOR_DEFAULT / DOOR_DOOR / DOOR_GLASS_DOOR / DOOR_CURTAIN のいずれか
+ * @return なし
+ */
+void place_secret_door(int y, int x, int type)
 {
        if (d_info[dungeon_type].flags1 & DF1_NO_DOORS)
        {
@@ -132,7 +172,11 @@ static void place_secret_door(int y, int x, int type)
        }
 }
 
-/*
+/*!
+ * @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.
  *
@@ -171,10 +215,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)
 {
@@ -252,10 +301,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)
 {
@@ -328,22 +382,27 @@ 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)
+bool find_space(POSITION *y, POSITION *x, POSITION height, POSITION width)
 {
        int candidates, pick;
        int by, bx, by1, bx1, by2, bx2;
@@ -377,1018 +436,93 @@ static bool find_space(int *y, int *x, int height, int width)
        /* No place! */
        if (!candidates)
        {
-               return FALSE;
-       }
-
-       /* 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--)
-       {
-               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))
-                       {
-                               pick--;
-
-                               /* This one is picked? */
-                               if (!pick) break;
-                       }
-               }
-
-               if (!pick) break;
-       }
-
-       /* Extract blocks */
-       by1 = block_y + 0;
-       bx1 = block_x + 0;
-       by2 = block_y + blocks_high;
-       bx2 = block_x + blocks_wide;
-
-       /*
-        * It is *extremely* important that the following calculation
-        * be *exactly* correct to prevent memory errors
-        */
-
-       /* Acquire the location of the room */
-       (*y) = ((by1 + by2) * BLOCK_HGT) / 2;
-       (*x) = ((bx1 + bx2) * BLOCK_WID) / 2;
-
-       /* Save the room location */
-       if (dun->cent_n < CENT_MAX)
-       {
-               dun->cent[dun->cent_n].y = *y;
-               dun->cent[dun->cent_n].x = *x;
-               dun->cent_n++;
-       }
-
-       /* Reserve some blocks. */
-       for (by = by1; by < by2; by++)
-       {
-               for (bx = bx1; bx < bx2; bx++)
-               {
-                       dun->room_map[by][bx] = TRUE;
-               }
-       }
-
-
-       /*
-        * Hack- See if room will cut off a cavern.
-        *
-        * If so, fix by tunneling outside the room in such a
-        * way as to connect the caves.
-        */
-       check_room_boundary(*x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
-
-
-       /* Success. */
-       return TRUE;
-}
-
-
-
-/*
- * 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
- *  15 -- glass room
- *  16 -- underground arcade
- */
-
-
-/*
- * Type 1 -- normal rectangular rooms
- */
-static bool build_type1(void)
-{
-       int y, x, y2, x2, yval, xval;
-       int y1, x1, xsize, ysize;
-
-       bool light;
-
-       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);
-       y2 = randint1(3);
-       x2 = randint1(11);
-
-       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))
-       {
-               /* 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));
-
-
-       /* 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->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 = &cave[y][x2 + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1 - 1; x <= x2 + 1; x++)
-       {
-               c_ptr = &cave[y1 - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-
-       /* 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))
-       {
-               for (y = y1; y <= y2; y += 2)
-               {
-                       for (x = x1; x <= x2; x += 2)
-                       {
-                               c_ptr = &cave[y][x];
-                               place_inner_grid(c_ptr);
-                       }
-               }
-       }
-
-       /* Hack -- Occasional room with four pillars */
-       else if (one_in_(20))
-       {
-               if ((y1 + 4 < y2) && (x1 + 4 < x2))
-               {
-                       c_ptr = &cave[y1 + 1][x1 + 1];
-                       place_inner_grid(c_ptr);
-
-                       c_ptr = &cave[y1 + 1][x2 - 1];
-                       place_inner_grid(c_ptr);
-
-                       c_ptr = &cave[y2 - 1][x1 + 1];
-                       place_inner_grid(c_ptr);
-
-                       c_ptr = &cave[y2 - 1][x2 - 1];
-                       place_inner_grid(c_ptr);
-               }
-       }
-
-       /* Hack -- Occasional ragged-edge room */
-       else if (one_in_(50))
-       {
-               for (y = y1 + 2; y <= y2 - 2; y += 2)
-               {
-                       c_ptr = &cave[y][x1];
-                       place_inner_grid(c_ptr);
-                       c_ptr = &cave[y][x2];
-                       place_inner_grid(c_ptr);
-               }
-               for (x = x1 + 2; x <= x2 - 2; x += 2)
-               {
-                       c_ptr = &cave[y1][x];
-                       place_inner_grid(c_ptr);
-                       c_ptr = &cave[y2][x];
-                       place_inner_grid(c_ptr);
-               }
-       }
-       /* 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 */
-                       place_solid_bold(yval, x1 - 1);
-                       place_solid_bold(yval, x2 + 1);
-               }
-               else
-               {
-                       /* Vertical wall */
-                       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 */
-                       place_solid_bold(y1 - 1, xval);
-                       place_solid_bold(y2 + 1, xval);
-               }
-
-               place_random_door(yval, xval, TRUE);
-               if (curtain2) cave[yval][xval].feat = feat_door[DOOR_CURTAIN].closed;
-       }
-
-       return TRUE;
-}
-
-
-/*
- * Type 2 -- Overlapping rectangular rooms
- */
-static bool build_type2(void)
-{
-       int                     y, x, xval, yval;
-       int                     y1a, x1a, y2a, x2a;
-       int                     y1b, x1b, y2b, x2b;
-       bool            light;
-       cave_type   *c_ptr;
-
-       /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
-       /* Choose lite or dark */
-       light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
-
-       /* Determine extents of the first room */
-       y1a = yval - randint1(4);
-       y2a = yval + randint1(3);
-       x1a = xval - randint1(11);
-       x2a = xval + randint1(10);
-
-       /* Determine extents of the second room */
-       y1b = yval - randint1(3);
-       y2b = yval + randint1(4);
-       x1b = xval - randint1(10);
-       x2b = xval + randint1(11);
-
-
-       /* Place a full floor for room "a" */
-       for (y = y1a - 1; y <= y2a + 1; y++)
-       {
-               for (x = x1a - 1; x <= x2a + 1; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
-                       if (light) c_ptr->info |= (CAVE_GLOW);
-               }
-       }
-
-       /* Place a full floor for room "b" */
-       for (y = y1b - 1; y <= y2b + 1; y++)
-       {
-               for (x = x1b - 1; x <= x2b + 1; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
-                       if (light) c_ptr->info |= (CAVE_GLOW);
-               }
-       }
-
-
-       /* Place the walls around room "a" */
-       for (y = y1a - 1; y <= y2a + 1; y++)
-       {
-               c_ptr = &cave[y][x1a - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2a + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1a - 1; x <= x2a + 1; x++)
-       {
-               c_ptr = &cave[y1a - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2a + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-       /* Place the walls around room "b" */
-       for (y = y1b - 1; y <= y2b + 1; y++)
-       {
-               c_ptr = &cave[y][x1b - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2b + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1b - 1; x <= x2b + 1; x++)
-       {
-               c_ptr = &cave[y1b - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2b + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-
-
-       /* Replace the floor for room "a" */
-       for (y = y1a; y <= y2a; y++)
-       {
-               for (x = x1a; x <= x2a; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-               }
-       }
-
-       /* Replace the floor for room "b" */
-       for (y = y1b; y <= y2b; y++)
-       {
-               for (x = x1b; x <= x2b; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-               }
-       }
-
-       return TRUE;
-}
-
-
-
-/*
- * 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.
- */
-static bool build_type3(void)
-{
-       int                     y, x, dy, dx, wy, wx;
-       int                     y1a, x1a, y2a, x2a;
-       int                     y1b, x1b, y2b, x2b;
-       int                     yval, xval;
-       bool            light;
-       cave_type   *c_ptr;
-
-
-       /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
-
-       /* Choose lite or dark */
-       light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
-
-       /* For now, always 3x3 */
-       wx = wy = 1;
-
-       /* Pick max vertical size (at most 4) */
-       dy = rand_range(3, 4);
-
-       /* Pick max horizontal size (at most 15) */
-       dx = rand_range(3, 11);
-
-
-       /* Determine extents of the north/south room */
-       y1a = yval - dy;
-       y2a = yval + dy;
-       x1a = xval - wx;
-       x2a = xval + wx;
-
-       /* Determine extents of the east/west room */
-       y1b = yval - wy;
-       y2b = yval + wy;
-       x1b = xval - dx;
-       x2b = xval + dx;
-
-
-       /* Place a full floor for room "a" */
-       for (y = y1a - 1; y <= y2a + 1; y++)
-       {
-               for (x = x1a - 1; x <= x2a + 1; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
-                       if (light) c_ptr->info |= (CAVE_GLOW);
-               }
-       }
-
-       /* Place a full floor for room "b" */
-       for (y = y1b - 1; y <= y2b + 1; y++)
-       {
-               for (x = x1b - 1; x <= x2b + 1; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
-                       if (light) c_ptr->info |= (CAVE_GLOW);
-               }
-       }
-
-
-       /* Place the walls around room "a" */
-       for (y = y1a - 1; y <= y2a + 1; y++)
-       {
-               c_ptr = &cave[y][x1a - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2a + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1a - 1; x <= x2a + 1; x++)
-       {
-               c_ptr = &cave[y1a - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2a + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-       /* Place the walls around room "b" */
-       for (y = y1b - 1; y <= y2b + 1; y++)
-       {
-               c_ptr = &cave[y][x1b - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2b + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1b - 1; x <= x2b + 1; x++)
-       {
-               c_ptr = &cave[y1b - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2b + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-
-       /* Replace the floor for room "a" */
-       for (y = y1a; y <= y2a; y++)
-       {
-               for (x = x1a; x <= x2a; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-               }
-       }
-
-       /* Replace the floor for room "b" */
-       for (y = y1b; y <= y2b; y++)
-       {
-               for (x = x1b; x <= x2b; x++)
-               {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-               }
-       }
-
-
-
-       /* Special features (3/4) */
-       switch (randint0(4))
-       {
-               /* Large solid middle pillar */
-               case 1:
-               {
-                       for (y = y1b; y <= y2b; y++)
-                       {
-                               for (x = x1a; x <= x2a; x++)
-                               {
-                                       c_ptr = &cave[y][x];
-                                       place_inner_grid(c_ptr);
-                               }
-                       }
-                       break;
-               }
-
-               /* Inner treasure vault */
-               case 2:
-               {
-                       /* Build the vault */
-                       for (y = y1b; y <= y2b; y++)
-                       {
-                               c_ptr = &cave[y][x1a];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[y][x2a];
-                               place_inner_grid(c_ptr);
-                       }
-                       for (x = x1a; x <= x2a; x++)
-                       {
-                               c_ptr = &cave[y1b][x];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[y2b][x];
-                               place_inner_grid(c_ptr);
-                       }
-
-                       /* Place a secret door on the inner room */
-                       switch (randint0(4))
-                       {
-                               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 */
-                       place_object(yval, xval, 0L);
-
-                       /* Let's guard the treasure well */
-                       vault_monsters(yval, xval, randint0(2) + 3);
-
-                       /* Traps naturally */
-                       vault_traps(yval, xval, 4, 4, randint0(3) + 2);
-
-                       break;
-               }
-
-               /* Something else */
-               case 3:
-               {
-                       /* Occasionally pinch the center shut */
-                       if (one_in_(3))
-                       {
-                               /* Pinch the east/west sides */
-                               for (y = y1b; y <= y2b; y++)
-                               {
-                                       if (y == yval) continue;
-                                       c_ptr = &cave[y][x1a - 1];
-                                       place_inner_grid(c_ptr);
-                                       c_ptr = &cave[y][x2a + 1];
-                                       place_inner_grid(c_ptr);
-                               }
-
-                               /* Pinch the north/south sides */
-                               for (x = x1a; x <= x2a; x++)
-                               {
-                                       if (x == xval) continue;
-                                       c_ptr = &cave[y1b - 1][x];
-                                       place_inner_grid(c_ptr);
-                                       c_ptr = &cave[y2b + 1][x];
-                                       place_inner_grid(c_ptr);
-                               }
-
-                               /* Sometimes shut using secret doors */
-                               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);
-
-                                       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);
-                               }
-                       }
-
-                       /* Occasionally put a "plus" in the center */
-                       else if (one_in_(3))
-                       {
-                               c_ptr = &cave[yval][xval];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[y1b][xval];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[y2b][xval];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[yval][x1a];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[yval][x2a];
-                               place_inner_grid(c_ptr);
-                       }
-
-                       /* Occasionally put a pillar in the center */
-                       else if (one_in_(3))
-                       {
-                               c_ptr = &cave[yval][xval];
-                               place_inner_grid(c_ptr);
-                       }
-
-                       break;
-               }
-       }
-
-       return TRUE;
-}
-
-
-/*
- * 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
- */
-static bool build_type4(void)
-{
-       int         y, x, y1, x1;
-       int         y2, x2, tmp, yval, xval;
-       bool        light;
-       cave_type   *c_ptr;
-
-
-       /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, 11, 25)) return FALSE;
-
-       /* Choose lite or dark */
-       light = ((dun_level <= randint1(25)) && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
-
-       /* Large room */
-       y1 = yval - 4;
-       y2 = yval + 4;
-       x1 = xval - 11;
-       x2 = xval + 11;
-
-       /* 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->info |= (CAVE_ROOM);
-                       if (light) c_ptr->info |= (CAVE_GLOW);
-               }
-       }
-
-       /* Outer Walls */
-       for (y = y1 - 1; y <= y2 + 1; y++)
-       {
-               c_ptr = &cave[y][x1 - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_outer_grid(c_ptr);
-       }
-       for (x = x1 - 1; x <= x2 + 1; x++)
-       {
-               c_ptr = &cave[y1 - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_outer_grid(c_ptr);
-       }
-
-
-       /* The inner room */
-       y1 = y1 + 2;
-       y2 = y2 - 2;
-       x1 = x1 + 2;
-       x2 = x2 - 2;
-
-       /* The inner walls */
-       for (y = y1 - 1; y <= y2 + 1; y++)
-       {
-               c_ptr = &cave[y][x1 - 1];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_inner_grid(c_ptr);
-       }
-       for (x = x1 - 1; x <= x2 + 1; x++)
-       {
-               c_ptr = &cave[y1 - 1][x];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_inner_grid(c_ptr);
-       }
-
-
-       /* Inner room variations */
-       switch (randint1(5))
-       {
-               /* Just an inner room with a monster */
-               case 1:
-               {
-                       /* Place a secret door */
-                       switch (randint1(4))
-                       {
-                               case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
-                               case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
-                               case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
-                               case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
-                       }
-
-                       /* Place a monster in the room */
-                       vault_monsters(yval, xval, 1);
-
-                       break;
-               }
-
-               /* Treasure Vault (with a door) */
-               case 2:
-               {
-                       /* Place a secret door */
-                       switch (randint1(4))
-                       {
-                               case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
-                               case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
-                               case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
-                               case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
-                       }
-
-                       /* Place another inner room */
-                       for (y = yval - 1; y <= yval + 1; y++)
-                       {
-                               for (x = xval -  1; x <= xval + 1; x++)
-                               {
-                                       if ((x == xval) && (y == yval)) continue;
-                                       c_ptr = &cave[y][x];
-                                       place_inner_grid(c_ptr);
-                               }
-                       }
-
-                       /* Place a locked door on the inner room */
-                       switch (randint1(4))
-                       {
-                               case 1: place_locked_door(yval - 1, xval); break;
-                               case 2: place_locked_door(yval + 1, xval); break;
-                               case 3: place_locked_door(yval, xval - 1); break;
-                               case 4: place_locked_door(yval, xval + 1); break;
-                       }
-
-                       /* Monsters to guard the "treasure" */
-                       vault_monsters(yval, xval, randint1(3) + 2);
-
-                       /* Object (80%) */
-                       if (randint0(100) < 80)
-                       {
-                               place_object(yval, xval, 0L);
-                       }
-
-                       /* Stairs (20%) */
-                       else
-                       {
-                               place_random_stairs(yval, xval);
-                       }
-
-                       /* Traps to protect the treasure */
-                       vault_traps(yval, xval, 4, 10, 2 + randint1(3));
-
-                       break;
-               }
-
-               /* Inner pillar(s). */
-               case 3:
-               {
-                       /* Place a secret door */
-                       switch (randint1(4))
-                       {
-                               case 1: place_secret_door(y1 - 1, xval, DOOR_DEFAULT); break;
-                               case 2: place_secret_door(y2 + 1, xval, DOOR_DEFAULT); break;
-                               case 3: place_secret_door(yval, x1 - 1, DOOR_DEFAULT); break;
-                               case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
-                       }
-
-                       /* Large Inner Pillar */
-                       for (y = yval - 1; y <= yval + 1; y++)
-                       {
-                               for (x = xval - 1; x <= xval + 1; x++)
-                               {
-                               c_ptr = &cave[y][x];
-                               place_inner_grid(c_ptr);
-                               }
-                       }
-
-                       /* Occasionally, two more Large Inner Pillars */
-                       if (one_in_(2))
-                       {
-                               tmp = randint1(2);
-                               for (y = yval - 1; y <= yval + 1; y++)
-                               {
-                                       for (x = xval - 5 - tmp; x <= xval - 3 - tmp; x++)
-                                       {
-                                       c_ptr = &cave[y][x];
-                                       place_inner_grid(c_ptr);
-                                       }
-                                       for (x = xval + 3 + tmp; x <= xval + 5 + tmp; x++)
-                                       {
-                                       c_ptr = &cave[y][x];
-                                       place_inner_grid(c_ptr);
-                                       }
-                               }
-                       }
-
-                       /* 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++)
-                               {
-                               c_ptr = &cave[yval - 1][x];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[yval + 1][x];
-                               place_inner_grid(c_ptr);
-                               }
-
-                               /* Close off the left/right edges */
-                               c_ptr = &cave[yval][xval - 5];
-                               place_inner_grid(c_ptr);
-                               c_ptr = &cave[yval][xval + 5];
-                               place_inner_grid(c_ptr);
-
-                               /* Secret doors (random top/bottom) */
-                               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));
-                               vault_monsters(yval, xval + 2, randint1(2));
+               return FALSE;
+       }
 
-                               /* Objects */
-                               if (one_in_(3)) place_object(yval, xval - 2, 0L);
-                               if (one_in_(3)) place_object(yval, xval + 2, 0L);
-                       }
+       /* Normal dungeon */
+       if (!(d_info[dungeon_type].flags1 & DF1_NO_CAVE))
+       {
+               /* Choose a random one */
+               pick = randint1(candidates);
+       }
 
-                       break;
-               }
+       /* NO_CAVE dungeon (Castle) */
+       else
+       {
+               /* Always choose the center one */
+               pick = candidates/2 + 1;
+       }
 
-               /* Maze inside. */
-               case 4:
+       /* Pick up the choosen location */
+       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--)
                {
-                       /* Place a secret door */
-                       switch (randint1(4))
+                       if (find_space_aux(blocks_high, blocks_wide, block_y, block_x))
                        {
-                               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;
-                       }
+                               pick--;
 
-                       /* Maze (really a checkerboard) */
-                       for (y = y1; y <= y2; y++)
-                       {
-                               for (x = x1; x <= x2; x++)
-                               {
-                                       if (0x1 & (x + y))
-                                       {
-                                               c_ptr = &cave[y][x];
-                                               place_inner_grid(c_ptr);
-                                       }
-                               }
+                               /* This one is picked? */
+                               if (!pick) break;
                        }
-
-                       /* Monsters just love mazes. */
-                       vault_monsters(yval, xval - 5, randint1(3));
-                       vault_monsters(yval, xval + 5, randint1(3));
-
-                       /* Traps make them entertaining. */
-                       vault_traps(yval, xval - 3, 2, 8, randint1(3));
-                       vault_traps(yval, xval + 3, 2, 8, randint1(3));
-
-                       /* Mazes should have some treasure too. */
-                       vault_objects(yval, xval, 3);
-
-                       break;
                }
 
-               /* 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);
+               if (!pick) break;
+       }
 
-                       /* Inner "cross" */
-                       for (y = y1; y <= y2; y++)
-                       {
-                               c_ptr = &cave[y][xval];
-                               place_inner_grid(c_ptr);
-                       }
-                       for (x = x1; x <= x2; x++)
-                       {
-                               c_ptr = &cave[yval][x];
-                               place_inner_grid(c_ptr);
-                       }
+       /* Extract blocks */
+       by1 = block_y + 0;
+       bx1 = block_x + 0;
+       by2 = block_y + blocks_high;
+       bx2 = block_x + blocks_wide;
 
-                       /* Doors into the rooms */
-                       if (randint0(100) < 50)
-                       {
-                               int i = randint1(10);
-                               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, 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);
-                       }
+       /*
+        * It is *extremely* important that the following calculation
+        * be *exactly* correct to prevent memory errors
+        */
 
-                       /* Treasure, centered at the center of the cross */
-                       vault_objects(yval, xval, 2 + randint1(2));
+       /* Acquire the location of the room */
+       (*y) = ((by1 + by2) * BLOCK_HGT) / 2;
+       (*x) = ((bx1 + bx2) * BLOCK_WID) / 2;
 
-                       /* Gotta have some monsters. */
-                       vault_monsters(yval + 1, xval - 4, randint1(4));
-                       vault_monsters(yval + 1, xval + 4, randint1(4));
-                       vault_monsters(yval - 1, xval - 4, randint1(4));
-                       vault_monsters(yval - 1, xval + 4, randint1(4));
+       /* Save the room location */
+       if (dun->cent_n < CENT_MAX)
+       {
+               dun->cent[dun->cent_n].y = (byte_hack)*y;
+               dun->cent[dun->cent_n].x = (byte_hack)*x;
+               dun->cent_n++;
+       }
 
-                       break;
+       /* Reserve some blocks. */
+       for (by = by1; by < by2; by++)
+       {
+               for (bx = bx1; bx < bx2; bx++)
+               {
+                       dun->room_map[by][bx] = TRUE;
                }
        }
 
+
+       /*
+        * Hack- See if room will cut off a cavern.
+        *
+        * If so, fix by tunneling outside the room in such a
+        * way as to connect the caves.
+        */
+       check_room_boundary(*x - width / 2 - 1, *y - height / 2 - 1, *x + (width - 1) / 2 + 1, *y + (height - 1) / 2 + 1);
+
+
+       /* Success. */
        return TRUE;
 }
 
 
-/*
- * 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
@@ -1402,30 +536,36 @@ 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)
+static bool vault_aux_simple(MONRACE_IDX r_idx)
 {
        /* Okay */
        return (vault_monster_okay(r_idx));
 }
 
 
-/*
+/*!
+ * @brief モンスターがゼリーnestの生成必要条件を満たしているかを返す /
  * Helper function for "monster nest (jelly)"
+ * @param r_idx 確認したいモンスター種族ID
+ * @return 生成必要条件を満たしているならTRUEを返す。
  */
-static bool vault_aux_jelly(int r_idx)
+static bool vault_aux_jelly(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1444,11 +584,13 @@ static bool vault_aux_jelly(int r_idx)
        return (TRUE);
 }
 
-
-/*
+/*!
+ * @brief モンスターが動物nestの生成必要条件を満たしているかを返す /
  * Helper function for "monster nest (animal)"
+ * @param r_idx 確認したいモンスター種族ID
+ * @return 生成必要条件を満たしているならTRUEを返す。
  */
-static bool vault_aux_animal(int r_idx)
+static bool vault_aux_animal(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1463,10 +605,13 @@ 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)
+static bool vault_aux_undead(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1480,11 +625,13 @@ 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)
+static bool vault_aux_chapel_g(MONRACE_IDX r_idx)
 {
        static int chapel_list[] = {
                MON_NOV_PRIEST, MON_NOV_PALADIN, MON_NOV_PRIEST_G, MON_NOV_PALADIN_G, 
@@ -1512,11 +659,13 @@ 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)
+static bool vault_aux_kennel(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1530,11 +679,13 @@ static bool vault_aux_kennel(int r_idx)
        return (TRUE);
 }
 
-
-/*
+/*!
+ * @brief モンスターがミミックnestの生成必要条件を満たしているかを返す /
  * Helper function for "monster nest (mimic)"
+ * @param r_idx 確認したいモンスター種族ID
+ * @return 生成必要条件を満たしているならTRUEを返す。
  */
-static bool vault_aux_mimic(int r_idx)
+static bool vault_aux_mimic(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1548,10 +699,13 @@ static bool vault_aux_mimic(int r_idx)
        return (TRUE);
 }
 
-/*
+/*!
+ * @brief モンスターが単一クローンnestの生成必要条件を満たしているかを返す /
  * Helper function for "monster nest (clone)"
+ * @param r_idx 確認したいモンスター種族ID
+ * @return 生成必要条件を満たしているならTRUEを返す。
  */
-static bool vault_aux_clone(int r_idx)
+static bool vault_aux_clone(MONRACE_IDX r_idx)
 {
        /* Validate the monster */
        if (!vault_monster_okay(r_idx)) return (FALSE);
@@ -1560,10 +714,13 @@ 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)
+static bool vault_aux_symbol_e(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1582,10 +739,13 @@ 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)
+static bool vault_aux_symbol_g(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1604,10 +764,13 @@ 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)
+static bool vault_aux_orc(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1625,10 +788,13 @@ 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)
+static bool vault_aux_troll(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1646,10 +812,13 @@ 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)
+static bool vault_aux_giant(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1669,10 +838,13 @@ 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)
+static bool vault_aux_dragon(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1693,10 +865,13 @@ 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)
+static bool vault_aux_demon(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1713,10 +888,13 @@ 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)
+static bool vault_aux_cthulhu(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -1733,8 +911,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)
 {
@@ -1749,12 +928,13 @@ static void vault_prep_clone(void)
 }
 
 
-/*
- * Helper function for "monster pit (symbol clone)"
+/*!
+ * @brief pit/nestの基準となるモンスターシンボルを決める /
+ * @return なし
  */
 static void vault_prep_symbol(void)
 {
-       int r_idx;
+       MONRACE_IDX r_idx;
 
        /* Apply the monster restriction */
        get_mon_num_prep(vault_aux_simple, NULL);
@@ -1769,9 +949,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)
 {
@@ -1843,10 +1023,13 @@ 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)
+static bool vault_aux_dark_elf(MONRACE_IDX r_idx)
 {
        int i;
        static int dark_elf_list[] =
@@ -1867,20 +1050,25 @@ 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;
-       bool (*hook_func)(int r_idx);
+       bool (*hook_func)(MONRACE_IDX r_idx);
        void (*prep_func)(void);
        int level;
        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;
@@ -1928,19 +1116,20 @@ 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
-       {"¥¯¥í¡¼¥ó",     vault_aux_clone,    vault_prep_clone,   5, 3},
-       {"¥¼¥ê¡¼",       vault_aux_jelly,    NULL,               5, 6},
-       {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
-       {"¥·¥ó¥Ü¥ë(°­)", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
-       {"¥ß¥ß¥Ã¥¯",     vault_aux_mimic,    NULL,              30, 4},
-       {"¶¸µ¤",         vault_aux_cthulhu,  NULL,              70, 2},
-       {"¸¤¾®²°",       vault_aux_kennel,   NULL,              45, 4},
-       {"ưʪ±à",       vault_aux_animal,   NULL,              35, 5},
-       {"¶µ²ñ",         vault_aux_chapel_g, NULL,              75, 4},
-       {"¥¢¥ó¥Ç¥Ã¥É",   vault_aux_undead,   NULL,              75, 5},
+       {"クローン",     vault_aux_clone,    vault_prep_clone,   5, 3},
+       {"ã\82¼ã\83ªã\83¼",       vault_aux_jelly,    NULL,               5, 6},
+       {"シンボル(善)", vault_aux_symbol_g, vault_prep_symbol, 25, 2},
+       {"シンボル(悪)", vault_aux_symbol_e, vault_prep_symbol, 25, 2},
+       {"ã\83\9fã\83\9fã\83\83ã\82¯",     vault_aux_mimic,    NULL,              30, 4},
+       {"狂気",         vault_aux_cthulhu,  NULL,              70, 2},
+       {"犬小屋",       vault_aux_kennel,   NULL,              45, 4},
+       {"動物園",       vault_aux_animal,   NULL,              35, 5},
+       {"教会",         vault_aux_chapel_g, NULL,              75, 4},
+       {"アンデッド",   vault_aux_undead,   NULL,              75, 5},
        {NULL,           NULL,               NULL,               0, 0},
 #else
        {"clone",        vault_aux_clone,    vault_prep_clone,   5, 3},
@@ -1957,19 +1146,20 @@ static vault_aux_type nest_types[] =
 #endif
 };
 
+/*!pit情報テーブル*/
 static vault_aux_type pit_types[] =
 {
 #ifdef JP
-       {"¥ª¡¼¥¯",       vault_aux_orc,      NULL,               5, 6},
-       {"¥È¥í¥ë",       vault_aux_troll,    NULL,              20, 6},
-       {"¥¸¥ã¥¤¥¢¥ó¥È", vault_aux_giant,    NULL,              50, 6},
-       {"¶¸µ¤",         vault_aux_cthulhu,  NULL,              80, 2},
-       {"¥·¥ó¥Ü¥ë(Á±)", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
-       {"¥·¥ó¥Ü¥ë(°­)", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
-       {"¶µ²ñ",         vault_aux_chapel_g, NULL,              65, 2},
-       {"¥É¥é¥´¥ó",     vault_aux_dragon,   vault_prep_dragon, 70, 6},
-       {"¥Ç¡¼¥â¥ó",     vault_aux_demon,    NULL,              80, 6},
-       {"¥À¡¼¥¯¥¨¥ë¥Õ", vault_aux_dark_elf, NULL,              45, 4},
+       {"ã\82ªã\83¼ã\82¯",       vault_aux_orc,      NULL,               5, 6},
+       {"トロル",       vault_aux_troll,    NULL,              20, 6},
+       {"ジャイアント", vault_aux_giant,    NULL,              50, 6},
+       {"狂気",         vault_aux_cthulhu,  NULL,              80, 2},
+       {"シンボル(善)", vault_aux_symbol_g, vault_prep_symbol, 70, 1},
+       {"シンボル(悪)", vault_aux_symbol_e, vault_prep_symbol, 70, 1},
+       {"教会",         vault_aux_chapel_g, NULL,              65, 2},
+       {"ドラゴン",     vault_aux_dragon,   vault_prep_dragon, 70, 6},
+       {"デーモン",     vault_aux_demon,    NULL,              80, 6},
+       {"ダークエルフ", vault_aux_dark_elf, NULL,              45, 4},
        {NULL,           NULL,               NULL,               0, 0},
 #else
        {"orc",          vault_aux_orc,      NULL,               5, 6},
@@ -1987,7 +1177,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
@@ -1999,7 +1189,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
@@ -2012,7 +1202,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)
  */
@@ -2047,14 +1242,14 @@ static cptr pit_subtype_string(int type, bool nest)
                        switch (vault_aux_dragon_mask4)
                        {
 #ifdef JP
-                       case RF4_BR_ACID: strcpy(inner_buf, "(»À)");   break;
-                       case RF4_BR_ELEC: strcpy(inner_buf, "(°ðºÊ)"); break;
-                       case RF4_BR_FIRE: strcpy(inner_buf, "(²Ð±ê)"); break;
-                       case RF4_BR_COLD: strcpy(inner_buf, "(Î䵤)"); break;
-                       case RF4_BR_POIS: strcpy(inner_buf, "(ÆÇ)");   break;
+                       case RF4_BR_ACID: strcpy(inner_buf, "()");   break;
+                       case RF4_BR_ELEC: strcpy(inner_buf, "(稲妻)"); break;
+                       case RF4_BR_FIRE: strcpy(inner_buf, "(火炎)"); break;
+                       case RF4_BR_COLD: strcpy(inner_buf, "(冷気)"); break;
+                       case RF4_BR_POIS: strcpy(inner_buf, "()");   break;
                        case (RF4_BR_ACID | RF4_BR_ELEC | RF4_BR_FIRE | RF4_BR_COLD | RF4_BR_POIS):
-                               strcpy(inner_buf, "(Ëü¿§)"); break;
-                       default: strcpy(inner_buf, "(̤ÄêµÁ)"); break;
+                               strcpy(inner_buf, "(万色)"); break;
+                       default: strcpy(inner_buf, "(未定義)"); break;
 #else
                        case RF4_BR_ACID: strcpy(inner_buf, "(acid)");      break;
                        case RF4_BR_ELEC: strcpy(inner_buf, "(lightning)"); break;
@@ -2074,7 +1269,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;
@@ -2084,7 +1279,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)
 {
@@ -2118,9 +1318,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)
 {
@@ -2137,30 +1341,32 @@ 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.
- *
- * 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)
 {
-       int y, x, y1, x1, y2, x2, xval, yval;
+       POSITION y, x, y1, x1, y2, x2, xval, yval;
        int i;
        nest_mon_info_type nest_mon_info[NUM_NEST_MON_TYPE];
 
@@ -2187,7 +1393,8 @@ static bool build_type5(void)
        /* Pick some monster types */
        for (i = 0; i < NUM_NEST_MON_TYPE; i++)
        {
-               int r_idx = 0, attempts = 100;
+               MONRACE_IDX r_idx = 0;
+               int attempts = 100;
                monster_race *r_ptr = NULL;
 
                while (attempts--)
@@ -2210,7 +1417,7 @@ static bool build_type5(void)
                if (r_ptr->flags3 & RF3_EVIL) align.sub_align |= SUB_ALIGN_EVIL;
                if (r_ptr->flags3 & RF3_GOOD) align.sub_align |= SUB_ALIGN_GOOD;
 
-               nest_mon_info[i].r_idx = r_idx;
+               nest_mon_info[i].r_idx = (s16b)r_idx;
                nest_mon_info[i].used = FALSE;
        }
 
@@ -2290,23 +1497,14 @@ static bool build_type5(void)
                case 4: place_secret_door(yval, x2 + 1, DOOR_DEFAULT); break;
        }
 
-       /* Describe */
-       if (cheat_room)
-       {
-               /* Room type */
-#ifdef JP
-               msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(nest)(%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
-#else
-               msg_format("Monster nest (%s%s)", n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
-#endif
-       }
+       msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(nest)(%s%s)を生成します。", "Monster nest (%s%s)"), n_ptr->name, pit_subtype_string(cur_nest_type, TRUE));
 
        /* Place some monsters */
        for (y = yval - 2; y <= yval + 2; y++)
        {
                for (x = xval - 9; x <= xval + 9; x++)
                {
-                       int r_idx;
+                       MONRACE_IDX r_idx;
 
                        i = randint0(NUM_NEST_MON_TYPE);
                        r_idx = nest_mon_info[i].r_idx;
@@ -2318,7 +1516,7 @@ static bool build_type5(void)
                }
        }
 
-       if (cheat_room && cheat_hear)
+       if (cheat_room)
        {
                ang_sort_comp = ang_sort_comp_nest_mon_info;
                ang_sort_swap = ang_sort_swap_nest_mon_info;
@@ -2333,7 +1531,7 @@ static bool build_type5(void)
                                if (nest_mon_info[i].r_idx != nest_mon_info[i + 1].r_idx) break;
                                if (!nest_mon_info[i + 1].used) break;
                        }
-                       msg_print(r_name + r_info[nest_mon_info[i].r_idx].name);
+                       msg_format_wizard(CHEAT_DUNGEON, "Nest構成モンスターNo.%d:%s", i, r_name + r_info[nest_mon_info[i].r_idx].name);
                }
        }
 
@@ -2341,48 +1539,49 @@ 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.
- *
- * 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)
 {
-       int y, x, y1, x1, y2, x2, xval, yval;
+       POSITION y, x, y1, x1, y2, x2, xval, yval;
        int i, j;
 
-       int what[16];
+       MONRACE_IDX what[16];
 
        monster_type align;
 
@@ -2407,7 +1606,8 @@ static bool build_type6(void)
        /* Pick some monster types */
        for (i = 0; i < 16; i++)
        {
-               int r_idx = 0, attempts = 100;
+               MONRACE_IDX r_idx = 0;
+               int attempts = 100;
                monster_race *r_ptr = NULL;
 
                while (attempts--)
@@ -2522,35 +1722,21 @@ static bool build_type6(void)
                        /* Bubble */
                        if (p1 > p2)
                        {
-                               int tmp = what[i1];
+                               MONRACE_IDX tmp = what[i1];
                                what[i1] = what[i2];
                                what[i2] = tmp;
                        }
                }
        }
 
-       /* Message */
-       if (cheat_room)
-       {
-               /* Room type */
-#ifdef JP
-               msg_format("¥â¥ó¥¹¥¿¡¼Éô²°(pit)(%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#else
-               msg_format("Monster pit (%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#endif
-       }
+       msg_format_wizard(CHEAT_DUNGEON, _("モンスター部屋(pit)(%s%s)を生成します。", "Monster pit (%s%s)"), n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
 
        /* Select the entries */
        for (i = 0; i < 8; i++)
        {
                /* Every other entry */
                what[i] = what[i * 2];
-
-               if (cheat_hear)
-               {
-                       /* Message */
-                       msg_print(r_name + r_info[what[i]].name);
-               }
+               msg_format_wizard(CHEAT_DUNGEON, _("Nest構成モンスター選択No.%d:%s", "Nest Monster Select No.%d:%s"), i, r_name + r_info[what[i]].name);
        }
 
        /* Top and bottom rows */
@@ -2606,8 +1792,16 @@ static bool build_type6(void)
 }
 
 
-/* coordinate translation code */
-static void coord_trans(int *x, int *y, int xoffset, int yoffset, int transno)
+/*!
+ * @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(POSITION *x, POSITION *y, POSITION xoffset, POSITION yoffset, int transno)
 {
        int i;
        int temp;
@@ -2640,20 +1834,25 @@ 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)
+static void build_vault(POSITION yval, POSITION xval, POSITION ymax, POSITION xmax, cptr data,
+               POSITION xoffset, POSITION yoffset, int transno)
 {
-       int dx, dy, x, y, i, j;
-
+       POSITION dx, dy, x, y, i, j;
        cptr t;
-
        cave_type *c_ptr;
 
-
        /* Place dungeon features and objects */
        for (t = data, dy = 0; dy < ymax; dy++)
        {
@@ -2902,16 +2101,17 @@ 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)
 {
-       vault_type *v_ptr;
+       vault_type *v_ptr = NULL;
        int dummy;
-       int x, y;
-       int xval, yval;
-       int xoffset, yoffset;
+       POSITION x, y;
+       POSITION xval, yval;
+       POSITION xoffset, yoffset;
        int transno;
 
        /* Pick a lesser vault */
@@ -2927,14 +2127,7 @@ static bool build_type7(void)
        /* No lesser vault found */
        if (dummy >= SAFE_MAX_ATTEMPTS)
        {
-               if (cheat_room)
-               {
-#ifdef JP
-                       msg_print("·Ù¹ð¡ª¾®¤µ¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ­¤Þ¤»¤ó¡ª");
-#else
-                       msg_print("Warning! Could not place lesser vault!");
-#endif
-               }
+               msg_print_wizard(CHEAT_DUNGEON, _("小型固定Vaultを配置できませんでした。", "Could not place lesser vault."));
                return FALSE;
        }
 
@@ -2980,11 +2173,7 @@ static bool build_type7(void)
 #endif
 
        /* Message */
-#ifdef JP
-       if (cheat_room) msg_format("¾®¤µ¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
-#else
-       if (cheat_room) msg_format("Lesser vault (%s)", v_name + v_ptr->name);
-#endif
+       msg_format_wizard(CHEAT_DUNGEON, _("小型Vault(%s)を生成しました。", "Lesser vault (%s)."), v_name + v_ptr->name);
 
        /* Hack -- Build the vault */
        build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
@@ -2993,16 +2182,16 @@ 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)
 {
        vault_type *v_ptr;
        int dummy;
-       int xval, yval;
-       int x, y;
+       POSITION xval, yval;
+       POSITION x, y;
        int transno;
        int xoffset, yoffset;
 
@@ -3019,14 +2208,7 @@ static bool build_type8(void)
        /* No greater vault found */
        if (dummy >= SAFE_MAX_ATTEMPTS)
        {
-               if (cheat_room)
-               {
-#ifdef JP
-                       msg_print("·Ù¹ð¡ªµðÂç¤ÊÃϲ¼¼¼¤òÇÛÃ֤Ǥ­¤Þ¤»¤ó¡ª");
-#else
-                       msg_print("Warning! Could not place greater vault!");
-#endif
-               }
+               msg_print_wizard(CHEAT_DUNGEON, _("大型固定Vaultを配置できませんでした。", "Could not place greater vault."));
                return FALSE;
        }
 
@@ -3071,18 +2253,13 @@ static bool build_type8(void)
         * prevent generation of vaults with no-entrance.
         */
        /* Find and reserve some space in the dungeon.  Get center of room. */
-       if (!find_space(&yval, &xval, abs(y) + 2, abs(x) + 2)) return FALSE;
+       if (!find_space(&yval, &xval, (POSITION)(abs(y) + 2), (POSITION)(abs(x) + 2))) return FALSE;
 
 #ifdef FORCE_V_IDX
        v_ptr = &v_info[76 + randint1(3)];
 #endif
 
-       /* Message */
-#ifdef JP
-       if (cheat_room) msg_format("µðÂç¤ÊÃϲ¼¼¼(%s)", v_name + v_ptr->name);
-#else
-       if (cheat_room) msg_format("Greater vault (%s)", v_name + v_ptr->name);
-#endif
+       msg_format_wizard(CHEAT_DUNGEON, _("大型固定Vault(%s)を生成しました。", "Greater vault (%s)."), v_name + v_ptr->name);
 
        /* Hack -- Build the vault */
        build_vault(yval, xval, v_ptr->hgt, v_ptr->wid,
@@ -3136,7 +2313,7 @@ static void store_height(int x, int y, int val)
            (val <= fill_data.c1)) val = fill_data.c1 + 1;
 
        /* store the value in height-map format */
-       cave[y][x].feat = val;
+       cave[y][x].feat = (s16b)val;
 
        return;
 }
@@ -3261,10 +2438,10 @@ static void generate_hmap(int y0, int x0, int xsiz, int ysiz, int grd, int roug,
        }
 
        /* Boundaries are walls */
-       cave[fill_data.ymin][fill_data.xmin].feat = maxsize;
-       cave[fill_data.ymax][fill_data.xmin].feat = maxsize;
-       cave[fill_data.ymin][fill_data.xmax].feat = maxsize;
-       cave[fill_data.ymax][fill_data.xmax].feat = maxsize;
+       cave[fill_data.ymin][fill_data.xmin].feat = (s16b)maxsize;
+       cave[fill_data.ymax][fill_data.xmin].feat = (s16b)maxsize;
+       cave[fill_data.ymin][fill_data.xmax].feat = (s16b)maxsize;
+       cave[fill_data.ymax][fill_data.xmax].feat = (s16b)maxsize;
 
        /* Set the middle square to be an open area. */
        cave[y0][x0].feat = 0;
@@ -3416,14 +2593,14 @@ static bool hack_isnt_wall(int y, int x, int c1, int c2, int c3, int feat1, int
                        /* 25% of the time use the other tile : it looks better this way */
                        if (randint1(100) < 75)
                        {
-                               cave[y][x].feat = feat1;
+                               cave[y][x].feat = (s16b)feat1;
                                cave[y][x].info &= ~(CAVE_MASK);
                                cave[y][x].info |= info1;
                                return TRUE;
                        }
                        else
                        {
-                               cave[y][x].feat = feat2;
+                               cave[y][x].feat = (s16b)feat2;
                                cave[y][x].info &= ~(CAVE_MASK);
                                cave[y][x].info |= info2;
                                return TRUE;
@@ -3434,14 +2611,14 @@ static bool hack_isnt_wall(int y, int x, int c1, int c2, int c3, int feat1, int
                        /* 25% of the time use the other tile : it looks better this way */
                        if (randint1(100) < 75)
                        {
-                               cave[y][x].feat = feat2;
+                               cave[y][x].feat = (s16b)feat2;
                                cave[y][x].info &= ~(CAVE_MASK);
                                cave[y][x].info |= info2;
                                return TRUE;
                        }
                        else
                        {
-                               cave[y][x].feat = feat1;
+                               cave[y][x].feat = (s16b)feat1;
                                cave[y][x].info &= ~(CAVE_MASK);
                                cave[y][x].info |= info1;
                                return TRUE;
@@ -3449,7 +2626,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].feat = (s16b)feat3;
                        cave[y][x].info &= ~(CAVE_MASK);
                        cave[y][x].info |= info3;
                        return TRUE;
@@ -3470,7 +2647,7 @@ static bool hack_isnt_wall(int y, int x, int c1, int c2, int c3, int feat1, int
  * Quick and nasty fill routine used to find the connected region
  * of floor in the middle of the cave
  */
-static void cave_fill(byte y, byte x)
+static void cave_fill(POSITION y, POSITION x)
 {
        int i, j, d;
        int ty, tx;
@@ -3524,8 +2701,8 @@ static void cave_fill(byte y, byte x)
                                        fill_data.info1, fill_data.info2, fill_data.info3))
                                {
                                        /* Enqueue that entry */
-                                       temp_y[flow_tail] = j;
-                                       temp_x[flow_tail] = i;
+                                       temp_y[flow_tail] = (byte_hack)j;
+                                       temp_x[flow_tail] = (byte_hack)i;
 
                                        /* Advance the queue */
                                        if (++flow_tail == TEMP_MAX) flow_tail = 0;
@@ -3736,12 +2913,14 @@ 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)
 {
-       int grd, roug, cutoff, xsize, ysize, y0, x0;
+       int grd, roug, cutoff;
+       POSITION xsize, ysize, y0, x0;
 
        bool done, light, room;
 
@@ -4250,8 +3429,7 @@ static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
        int xhsize = xsize / 2;
        int yhsize = ysize / 2;
 
-
-       if (cheat_room) msg_print("Bubble Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("泡型ランダムVaultを生成しました。", "Room Vault."));
 
        /* Allocate center of bubbles */
        center[0].x = (byte)randint1(xsize - 3) + 1;
@@ -4276,31 +3454,31 @@ static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
                        }
                }
 
-               center[i].x = x;
-               center[i].y = y;
+               center[i].x = (byte_hack)x;
+               center[i].y = (byte_hack)y;
        }
 
 
        /* Top and bottom boundaries */
        for (i = 0; i < xsize; i++)
        {
-               int x = x0 - xhsize + i;
+               int side_x = x0 - xhsize + i;
 
-               place_outer_noperm_bold(y0 - yhsize + 0, x);
-               cave[y0 - yhsize + 0][x].info |= (CAVE_ROOM | CAVE_ICKY);
-               place_outer_noperm_bold(y0 - yhsize + ysize - 1, x);
-               cave[y0 - yhsize + ysize - 1][x].info |= (CAVE_ROOM | CAVE_ICKY);
+               place_outer_noperm_bold(y0 - yhsize + 0, side_x);
+               cave[y0 - yhsize + 0][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
+               place_outer_noperm_bold(y0 - yhsize + ysize - 1, side_x);
+               cave[y0 - yhsize + ysize - 1][side_x].info |= (CAVE_ROOM | CAVE_ICKY);
        }
 
        /* Left and right boundaries */
        for (i = 1; i < ysize - 1; i++)
        {
-               int y = y0 - yhsize + i;
+               int side_y = y0 - yhsize + i;
 
-               place_outer_noperm_bold(y, x0 - xhsize + 0);
-               cave[y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
-               place_outer_noperm_bold(y, x0 - xhsize + xsize - 1);
-               cave[y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
+               place_outer_noperm_bold(side_y, x0 - xhsize + 0);
+               cave[side_y][x0 - xhsize + 0].info |= (CAVE_ROOM | CAVE_ICKY);
+               place_outer_noperm_bold(side_y, x0 - xhsize + xsize - 1);
+               cave[side_y][x0 - xhsize + xsize - 1].info |= (CAVE_ROOM | CAVE_ICKY);
        }
 
        /* Fill in middle with bubbles */
@@ -4311,8 +3489,8 @@ static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
                        /* Get distances to two closest centers */
 
                        /* initialize */
-                       min1 = distance(x, y, center[0].x, center[0].y);
-                       min2 = distance(x, y, center[1].x, center[1].y);
+                       min1 = (u16b)distance(x, y, center[0].x, center[0].y);
+                       min2 = (u16b)distance(x, y, center[1].x, center[1].y);
 
                        if (min1 > min2)
                        {
@@ -4325,7 +3503,7 @@ static void build_bubble_vault(int x0, int y0, int xsize, int ysize)
                        /* Scan the rest */
                        for (i = 2; i < BUBBLENUM; i++)
                        {
-                               temp = distance(x, y, center[i].x, center[i].y);
+                               temp = (u16b)distance(x, y, center[i].x, center[i].y);
 
                                if (temp < min1)
                                {
@@ -4452,7 +3630,7 @@ static void build_room_vault(int x0, int y0, int xsize, int ysize)
        xhsize = xsize / 2;
        yhsize = ysize / 2;
 
-       if (cheat_room) msg_print("Room Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("部屋型ランダムVaultを生成しました。", "Room Vault."));
 
        /* fill area so don't get problems with arena levels */
        for (x1 = 0; x1 < xsize; x1++)
@@ -4503,7 +3681,7 @@ static void build_cave_vault(int x0, int y0, int xsiz, int ysiz)
        xsize = xhsize * 2;
        ysize = yhsize * 2;
 
-       if (cheat_room) msg_print("Cave Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("洞穴ランダムVaultを生成しました。", "Cave Vault."));
 
        light = done = FALSE;
        room = TRUE;
@@ -4651,8 +3829,7 @@ void build_maze_vault(int x0, int y0, int xsize, int ysize, bool is_vault)
        bool light;
        cave_type *c_ptr;
 
-
-       if (cheat_room && is_vault) msg_print("Maze Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("迷路ランダムVaultを生成しました。", "Maze Vault."));
 
        /* Choose lite or dark */
        light = ((dun_level <= randint1(25)) && is_vault && !(d_info[dungeon_type].flags1 & DF1_DARKNESS));
@@ -4722,7 +3899,7 @@ static void build_mini_c_vault(int x0, int y0, int xsize, int ysize)
        int m, n, num_vertices;
        int *visited;
 
-       if (cheat_room) msg_print("Mini Checker Board Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("小型チェッカーランダムVaultを生成しました。", "Mini Checker Board Vault."));
 
        /* Pick a random room size */
        dy = ysize / 2 - 1;
@@ -5061,7 +4238,7 @@ static void build_castle_vault(int x0, int y0, int xsize, int ysize)
        y2 = y0 + dy;
        x2 = x0 + dx;
 
-       if (cheat_room) msg_print("Castle Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("城型ランダムVaultを生成しました。", "Castle Vault"));
 
        /* generate the room */
        for (y = y1 - 1; y <= y2 + 1; y++)
@@ -5178,7 +4355,7 @@ static void build_target_vault(int x0, int y0, int xsize, int ysize)
        h3 = randint1(32);
        h4 = randint1(32) - 16;
 
-       if (cheat_room) msg_print("Target Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("対称形ランダムVaultを生成しました。", "Elemental Vault"));
 
        /* work out outer radius */
        if (xsize > ysize)
@@ -5299,8 +4476,7 @@ static void build_elemental_vault(int x0, int y0, int xsiz, int ysiz)
        int xsize, ysize, xhsize, yhsize, x, y, i;
        int type;
 
-
-       if (cheat_room) msg_print("Elemental Vault");
+       msg_print_wizard(CHEAT_DUNGEON, _("精霊界ランダムVaultを生成しました。", "Elemental Vault"));
 
        /* round to make sizes even */
        xhsize = xsiz / 2;
@@ -5377,12 +4553,13 @@ 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)
 {
-       int y0, x0, xsize, ysize, vtype;
+       POSITION y0, x0, xsize, ysize, vtype;
 
        /* Get size */
        /* big enough to look good, small enough to be fairly common. */
@@ -5432,16 +4609,18 @@ 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)
 {
-       int rad, x, y, x0, y0;
+       POSITION rad, x, y, x0, y0;
        int light = FALSE;
 
        /* Occasional light */
@@ -5477,16 +4656,18 @@ 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)
 {
-       int rad, x, y, x0, y0;
+       POSITION rad, x, y, x0, y0;
        int light = FALSE;
        bool emptyflag = TRUE;
 
@@ -5576,7 +4757,7 @@ static bool build_type12(void)
 /*
  * Helper function for "trapped monster pit"
  */
-static bool vault_aux_trapped_pit(int r_idx)
+static bool vault_aux_trapped_pit(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -5591,49 +4772,50 @@ static bool vault_aux_trapped_pit(int r_idx)
 }
 
 
-/*
- * Type 13 -- 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.
- *
- * 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)
 {
@@ -5666,10 +4848,10 @@ static bool build_type13(void)
                {0, 0, -1}
        };
 
-       int y, x, y1, x1, y2, x2, xval, yval;
+       POSITION y, x, y1, x1, y2, x2, xval, yval;
        int i, j;
 
-       int what[16];
+       MONRACE_IDX what[16];
 
        monster_type align;
 
@@ -5697,7 +4879,8 @@ static bool build_type13(void)
        /* Pick some monster types */
        for (i = 0; i < 16; i++)
        {
-               int r_idx = 0, attempts = 100;
+               MONRACE_IDX r_idx = 0;
+               int attempts = 100;
                monster_race *r_ptr = NULL;
 
                while (attempts--)
@@ -5841,23 +5024,15 @@ static bool build_type13(void)
                        /* Bubble */
                        if (p1 > p2)
                        {
-                               int tmp = what[i1];
+                               MONRACE_IDX tmp = what[i1];
                                what[i1] = what[i2];
                                what[i2] = tmp;
                        }
                }
        }
 
-       /* Message */
-       if (cheat_room)
-       {
-               /* Room type */
-#ifdef JP
-               msg_format("%s%s¤Î櫥ԥåÈ", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#else
-               msg_format("Trapped monster pit (%s%s)", n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
-#endif
-       }
+       msg_format_wizard(CHEAT_DUNGEON, _("%s%sの罠ピットが生成されました。", "Trapped monster pit (%s%s)"),
+               n_ptr->name, pit_subtype_string(cur_pit_type, FALSE));
 
        /* Select the entries */
        for (i = 0; i < 8; i++)
@@ -5883,15 +5058,16 @@ 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)
 {
-       int y, x, y2, x2, yval, xval;
-       int y1, x1, xsize, ysize;
+       POSITION y, x, y2, x2, yval, xval;
+       POSITION y1, x1, xsize, ysize;
 
        bool light;
 
@@ -5959,15 +5135,7 @@ static bool build_type14(void)
        c_ptr->mimic = c_ptr->feat;
        c_ptr->feat = trap;
 
-       /* Message */
-       if (cheat_room)
-       {
-#ifdef JP
-               msg_format("%s¤ÎÉô²°", f_name + f_info[trap].name);
-#else
-               msg_format("Room of %s", f_name + f_info[trap].name);
-#endif
-       }
+       msg_format_wizard(CHEAT_DUNGEON, _("%sの部屋が生成されました。", "Room of %s was generated."), f_name + f_info[trap].name);
 
        return TRUE;
 }
@@ -5976,7 +5144,7 @@ static bool build_type14(void)
 /*
  * Helper function for "glass room"
  */
-static bool vault_aux_lite(int r_idx)
+static bool vault_aux_lite(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -5984,7 +5152,7 @@ static bool vault_aux_lite(int r_idx)
        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;
+       if (!(r_ptr->flags4 & RF4_BR_LITE) && !(r_ptr->a_ability_flags1 & RF5_BA_LITE)) return FALSE;
 
        /* No wall passing monsters */
        if (r_ptr->flags2 & (RF2_PASS_WALL | RF2_KILL_WALL)) return FALSE;
@@ -5998,7 +5166,7 @@ static bool vault_aux_lite(int r_idx)
 /*
  * Helper function for "glass room"
  */
-static bool vault_aux_shards(int r_idx)
+static bool vault_aux_shards(MONRACE_IDX r_idx)
 {
        monster_race *r_ptr = &r_info[r_idx];
 
@@ -6014,18 +5182,19 @@ static bool vault_aux_shards(int r_idx)
 /*
  * Hack -- determine if a template is potion
  */
-static bool kind_is_potion(int k_idx)
+static bool kind_is_potion(KIND_OBJECT_IDX k_idx)
 {
        return k_info[k_idx].tval == TV_POTION;
 }
 
-/*
- * Type 15 -- glass rooms
+/*!
+ * @brief タイプ15の部屋…ガラス部屋の生成 / Type 15 -- glass rooms
+ * @return なし
  */
 static bool build_type15(void)
 {
-       int y, x, y2, x2, yval, xval;
-       int y1, x1, xsize, ysize;
+       POSITION y, x, y2, x2, yval, xval;
+       POSITION y1, x1, xsize, ysize;
        bool light;
 
        cave_type *c_ptr;
@@ -6091,7 +5260,7 @@ static bool build_type15(void)
                        /* Place fixed lite berathers */
                        for (dir1 = 4; dir1 < 8; dir1++)
                        {
-                               int r_idx = get_mon_num(dun_level);
+                               MONRACE_IDX r_idx = get_mon_num(dun_level);
 
                                y = yval + 2 * ddy_ddd[dir1];
                                x = xval + 2 * ddx_ddd[dir1];
@@ -6134,7 +5303,8 @@ static bool build_type15(void)
 
        case 2: /* 1 lite breather + random object */
                {
-                       int r_idx, dir1;
+                       MONRACE_IDX r_idx;
+                       DIRECTION dir1;
 
                        /* Pillars */
                        c_ptr = &cave[y1 + 1][x1 + 1];
@@ -6221,7 +5391,7 @@ static bool build_type15(void)
                        /* Place shard berathers */
                        for (dir1 = 4; dir1 < 8; dir1++)
                        {
-                               int r_idx = get_mon_num(dun_level);
+                               MONRACE_IDX r_idx = get_mon_num(dun_level);
 
                                y = yval + ddy_ddd[dir1];
                                x = xval + ddx_ddd[dir1];
@@ -6252,15 +5422,7 @@ static bool build_type15(void)
                break;
        }
 
-       /* Message */
-       if (cheat_room)
-       {
-#ifdef JP
-               msg_print("¥¬¥é¥¹¤ÎÉô²°");
-#else
-               msg_print("Glass room");
-#endif
-       }
+       msg_print_wizard(CHEAT_DUNGEON, _("ガラスの部屋が生成されました。", "Glass room was generated."));
 
        return TRUE;
 }
@@ -6396,13 +5558,20 @@ static bool precalc_ugarcade(int town_hgt, int town_wid, int n)
        return i == n;
 }
 
-/*
- * Actually create buildings
+/*!
+ * @brief タイプ16の部屋…地下都市生成のサブルーチン / Actually create buildings
+ * @return なし
+ * @param ltcy 生成基準Y座標
+ * @param ltcx 生成基準X座標
+ * @param stotes[] 生成する店舗のリスト
+ * @param n 生成する店舗の数
+ * @note
  * 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;
+       int i, y, x;
+       IDX j;
        ugbldg_type *cur_ugbldg;
 
        for (i = 0; i < n; i++)
@@ -6473,18 +5642,19 @@ static void build_stores(int ltcy, int ltcx, int stores[], int n)
 }
 
 
-/*
- * Type 16 -- Underground Arcade
- *
- * Town logic flow for generation of new town
- * Originally from Vanilla 3.0.3
- *
- * We start with a fully wiped cave of normal floors.
- *
- * Note that town_gen_hack() plays games with the R.N.G.
- *
- * This function does NOT do anything about the owners of the stores,
- * nor the contents thereof.  It only handles the physical layout.
+/*!
+ * @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)
 {
@@ -6494,7 +5664,7 @@ static bool build_type16(void)
                STORE_ALCHEMIST, STORE_MAGIC, STORE_BLACK, STORE_BOOK,
        };
        int n = sizeof stores / sizeof (int);
-       int i, y, x, y1, x1, yval, xval;
+       POSITION 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;
@@ -6548,11 +5718,7 @@ static bool build_type16(void)
        /* Build stores */
        build_stores(y1, x1, stores, n);
 
-#ifdef JP
-       if (cheat_room) msg_print("Ãϲ¼³¹");
-#else
-       if (cheat_room) msg_print("Underground Arcade");
-#endif
+       msg_print_wizard(CHEAT_DUNGEON, _("地下街を生成しました", "Underground arcade was generated."));
 
        /* Free buildings array */
        C_KILL(ugbldg, n, ugbldg_type);
@@ -6561,11 +5727,11 @@ static bool build_type16(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.
+/*!
+ * @brief 与えられた部屋型IDに応じて部屋の生成処理分岐を行い結果を返す / Attempt to build a room of the given type at the given block
+ * @param type 部屋型ID
+ * @note that we restrict the number of "crowded" rooms to reduce the chance of overflowing the monster list during level creation.
+ * @return 部屋の精製に成功した場合 TRUE を返す。
  */
 static bool room_build(int typ)
 {
@@ -6595,13 +5761,16 @@ static bool room_build(int typ)
        return FALSE;
 }
 
+/*!
+ * @brief 指定した部屋の生成確率を別の部屋に加算し、指定した部屋の生成率を0にする
+ * @param dst 確率を移す先の部屋種ID
+ * @param src 確率を与える元の部屋種ID
+ */
+#define MOVE_PLIST(dst, src) (prob_list[dst] += prob_list[src], prob_list[src] = 0) 
 
-#define MOVE_PLIST(dst, src) (prob_list[dst] += prob_list[src], prob_list[src] = 0)
-
-/*
- * [from SAngband (originally from OAngband)]
- * 
- * Generate rooms in dungeon.  Build bigger rooms at first.
+/*!
+ * @brief 部屋生成処理のメインルーチン(Sangbandを経由してOangbandからの実装を引用) / Generate rooms in dungeon.  Build bigger rooms at first. [from SAngband (originally from OAngband)]
+ * @return 部屋生成に成功した場合 TRUE を返す。
  */
 bool generate_rooms(void)
 {
@@ -6643,7 +5812,7 @@ bool generate_rooms(void)
         * XXX -- Various dungeon types and options.
         */
 
-       /* Ironman sees only Greater Vaults */
+       /*! @details ダンジョンにBEGINNER、CHAMELEON、SMALLESTいずれのフラグもなく、かつ「常に通常でない部屋を生成する」フラグがONならば、GRATER_VAULTのみを生成対象とする。 / Ironman sees only Greater Vaults */
        if (ironman_rooms && !((d_info[dungeon_type].flags1 & (DF1_BEGINNER | DF1_CHAMELEON | DF1_SMALLEST))))
        {
                for (i = 0; i < ROOM_T_MAX; i++)
@@ -6653,7 +5822,7 @@ bool generate_rooms(void)
                }
        }
 
-       /* Forbidden vaults */
+       /*! @details ダンジョンにNO_VAULTフラグがあるならば、LESSER_VAULT / GREATER_VAULT/ RANDOM_VAULTを除外 / Forbidden vaults */
        else if (d_info[dungeon_type].flags1 & DF1_NO_VAULT)
        {
                prob_list[ROOM_T_LESSER_VAULT] = 0;
@@ -6661,8 +5830,7 @@ bool generate_rooms(void)
                prob_list[ROOM_T_RANDOM_VAULT] = 0;
        }
 
-
-       /* NO_CAVE dungeon (Castle)*/
+       /*! @details ダンジョンにNO_CAVEフラグがある場合、FRACAVEの生成枠がNORMALに与えられる。CRIPT、OVALの生成枠がINNER_Fに与えられる。/ NO_CAVE dungeon (Castle)*/
        if (d_info[dungeon_type].flags1 & DF1_NO_CAVE)
        {
                MOVE_PLIST(ROOM_T_NORMAL, ROOM_T_FRACAVE);
@@ -6670,24 +5838,25 @@ bool generate_rooms(void)
                MOVE_PLIST(ROOM_T_INNER_FEAT, ROOM_T_OVAL);
        }
 
-       /* CAVE dungeon (Orc cave etc.) */
+       /*! @details ダンジョンにCAVEフラグがある場合、NORMALの生成枠がFRACAVEに与えられる。/ CAVE dungeon (Orc cave etc.) */
        else if (d_info[dungeon_type].flags1 & DF1_CAVE)
        {
                MOVE_PLIST(ROOM_T_FRACAVE, ROOM_T_NORMAL);
        }
 
-       /* No caves when a (random) cavern exists: they look bad */
+       /*! @details ダンジョンの基本地形が最初から渓谷かアリーナ型の場合 FRACAVE は生成から除外。 /  No caves when a (random) cavern exists: they look bad */
        else if (dun->cavern || dun->empty_level)
        {
                prob_list[ROOM_T_FRACAVE] = 0;
        }
 
-       /* Forbidden glass rooms */
+       /*! @details ダンジョンに最初からGLASS_ROOMフラグがある場合、GLASS を生成から除外。/ Forbidden glass rooms */
        if (!(d_info[dungeon_type].flags1 & DF1_GLASS_ROOM))
        {
                prob_list[ROOM_T_GLASS] = 0;
        }
 
+       /*! @details ARCADEは同フラグがダンジョンにないと生成されない。 / Forbidden glass rooms */
        if (!(d_info[dungeon_type].flags1 & DF1_ARCADE))
        {
                prob_list[ROOM_T_ARCADE] = 0;
@@ -6804,16 +5973,14 @@ bool generate_rooms(void)
                if (!remain) break;
        }
 
-       if (rooms_built < 2) return FALSE;
-
-       if (cheat_room)
+       /*! @details 部屋生成数が2未満の場合生成失敗を返す */
+       if (rooms_built < 2)
        {
-#ifdef JP
-               msg_format("Éô²°¿ô: %d", rooms_built);
-#else
-               msg_format("Number of Rooms: %d", rooms_built);
-#endif
+               msg_format_wizard(CHEAT_DUNGEON, _("部屋数が2未満でした。生成を再試行します。", "Number of rooms was under 2. Retry."), rooms_built);
+               return FALSE;
        }
 
+       msg_format_wizard(CHEAT_DUNGEON, _("このダンジョンの部屋数は %d です。", "Number of Rooms: %d"), rooms_built);
+
        return TRUE;
 }