OSDN Git Service

[Refactor] #38993 cur_wid/hgt を floor_type に取り込み width/heightに改名。 / Move cur_wid...
[hengband/hengband.git] / src / floor-generate.c
index 01ee484..015cd7c 100644 (file)
@@ -149,7 +149,7 @@ static int next_to_walls(POSITION y, POSITION x)
  */
 static bool alloc_stairs_aux(POSITION y, POSITION x, int walls)
 {
-       grid_type *g_ptr = &grid_array[y][x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
 
        /* Require "naked" floor grid */
        if (!is_floor_grid(g_ptr)) return FALSE;
@@ -180,17 +180,17 @@ static bool alloc_stairs(IDX feat, int num, int walls)
        if (have_flag(f_ptr->flags, FF_LESS))
        {
                /* No up stairs in town or in ironman mode */
-               if (ironman_downward || !dun_level) return TRUE;
+               if (ironman_downward || !current_floor_ptr->dun_level) return TRUE;
 
-               if (dun_level > d_info[p_ptr->dungeon_idx].mindepth)
+               if (current_floor_ptr->dun_level > d_info[p_ptr->dungeon_idx].mindepth)
                        shaft_num = (randint1(num+1))/2;
        }
        else if (have_flag(f_ptr->flags, FF_MORE))
        {
-               QUEST_IDX q_idx = quest_number(dun_level);
+               QUEST_IDX q_idx = quest_number(current_floor_ptr->dun_level);
 
                /* No downstairs on quest levels */
-               if (dun_level > 1 && q_idx)
+               if (current_floor_ptr->dun_level > 1 && q_idx)
                {
                        monster_race *r_ptr = &r_info[quest[q_idx].r_idx];
 
@@ -200,9 +200,9 @@ static bool alloc_stairs(IDX feat, int num, int walls)
                }
 
                /* No downstairs at the bottom */
-               if (dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) return TRUE;
+               if (current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth) return TRUE;
 
-               if ((dun_level < d_info[p_ptr->dungeon_idx].maxdepth-1) && !quest_number(dun_level+1))
+               if ((current_floor_ptr->dun_level < d_info[p_ptr->dungeon_idx].maxdepth-1) && !quest_number(current_floor_ptr->dun_level+1))
                        shaft_num = (randint1(num)+1)/2;
        }
 
@@ -221,9 +221,9 @@ static bool alloc_stairs(IDX feat, int num, int walls)
                        int candidates = 0;
                        int pick;
 
-                       for (y = 1; y < cur_hgt - 1; y++)
+                       for (y = 1; y < current_floor_ptr->height - 1; y++)
                        {
-                               for (x = 1; x < cur_wid - 1; x++)
+                               for (x = 1; x < current_floor_ptr->width - 1; x++)
                                {
                                        if (alloc_stairs_aux(y, x, walls))
                                        {
@@ -247,9 +247,9 @@ static bool alloc_stairs(IDX feat, int num, int walls)
                        /* Choose a random one */
                        pick = randint1(candidates);
 
-                       for (y = 1; y < cur_hgt - 1; y++)
+                       for (y = 1; y < current_floor_ptr->height - 1; y++)
                        {
-                               for (x = 1; x < cur_wid - 1; x++)
+                               for (x = 1; x < current_floor_ptr->width - 1; x++)
                                {
                                        if (alloc_stairs_aux(y, x, walls))
                                        {
@@ -262,7 +262,7 @@ static bool alloc_stairs(IDX feat, int num, int walls)
 
                                if (!pick) break;
                        }
-                       g_ptr = &grid_array[y][x];
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Clear possible garbage of hidden trap */
                        g_ptr->mimic = 0;
@@ -295,7 +295,7 @@ static void alloc_object(int set, EFFECT_ID typ, int num)
        grid_type *g_ptr;
 
        /* A small level has few objects. */
-       num = num * cur_hgt * cur_wid / (MAX_HGT*MAX_WID) +1;
+       num = num * current_floor_ptr->height * current_floor_ptr->width / (MAX_HGT*MAX_WID) +1;
 
        /* Place some objects */
        for (k = 0; k < num; k++)
@@ -307,10 +307,10 @@ static void alloc_object(int set, EFFECT_ID typ, int num)
 
                        dummy++;
 
-                       y = randint0(cur_hgt);
-                       x = randint0(cur_wid);
+                       y = randint0(current_floor_ptr->height);
+                       x = randint0(current_floor_ptr->width);
 
-                       g_ptr = &grid_array[y][x];
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        /* Require "naked" floor grid */
                        if (!is_floor_grid(g_ptr) || g_ptr->o_idx || g_ptr->m_idx) continue;
@@ -319,7 +319,7 @@ static void alloc_object(int set, EFFECT_ID typ, int num)
                        if (player_bold(y, x)) continue;
 
                        /* Check for "room" */
-                       room = (grid_array[y][x].info & CAVE_ROOM) ? TRUE : FALSE;
+                       room = (current_floor_ptr->grid_array[y][x].info & CAVE_ROOM) ? TRUE : FALSE;
 
                        /* Require corridor? */
                        if ((set == ALLOC_SET_CORR) && room) continue;
@@ -344,14 +344,14 @@ static void alloc_object(int set, EFFECT_ID typ, int num)
                        case ALLOC_TYP_RUBBLE:
                        {
                                place_rubble(y, x);
-                               grid_array[y][x].info &= ~(CAVE_FLOOR);
+                               current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
                                break;
                        }
 
                        case ALLOC_TYP_TRAP:
                        {
                                place_trap(y, x);
-                               grid_array[y][x].info &= ~(CAVE_FLOOR);
+                               current_floor_ptr->grid_array[y][x].info &= ~(CAVE_FLOOR);
                                break;
                        }
 
@@ -391,7 +391,7 @@ bool place_quest_monsters(void)
                if (quest[i].status != QUEST_STATUS_TAKEN ||
                    (quest[i].type != QUEST_TYPE_KILL_LEVEL &&
                     quest[i].type != QUEST_TYPE_RANDOM) ||
-                   quest[i].level != dun_level ||
+                   quest[i].level != current_floor_ptr->dun_level ||
                    p_ptr->dungeon_idx != quest[i].dungeon ||
                    (quest[i].flags & QUEST_FLAG_PRESET))
                {
@@ -425,10 +425,10 @@ bool place_quest_monsters(void)
                                        grid_type    *g_ptr;
                                        feature_type *f_ptr;
 
-                                       y = randint0(cur_hgt);
-                                       x = randint0(cur_wid);
+                                       y = randint0(current_floor_ptr->height);
+                                       x = randint0(current_floor_ptr->width);
 
-                                       g_ptr = &grid_array[y][x];
+                                       g_ptr = &current_floor_ptr->grid_array[y][x];
                                        f_ptr = &f_info[g_ptr->feat];
 
                                        if (!have_flag(f_ptr->flags, FF_MOVE) && !have_flag(f_ptr->flags, FF_CAN_FLY)) continue;
@@ -471,7 +471,7 @@ static void gen_caverns_and_lakes(void)
 {
 #ifdef ALLOW_CAVERNS_AND_LAKES
        /* Possible "destroyed" level */
-       if ((dun_level > 30) && one_in_(DUN_DEST*2) && (small_levels) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_DESTROY))
+       if ((current_floor_ptr->dun_level > 30) && one_in_(DUN_DEST*2) && (small_levels) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_DESTROY))
        {
                dun->destroyed = TRUE;
 
@@ -492,38 +492,38 @@ static void gen_caverns_and_lakes(void)
                if (d_info[p_ptr->dungeon_idx].flags1 & DF1_LAKE_LAVA)
                {
                        /* Lake of Lava */
-                       if ((dun_level > 80) && (randint0(count) < 2)) dun->laketype = LAKE_T_LAVA;
+                       if ((current_floor_ptr->dun_level > 80) && (randint0(count) < 2)) dun->laketype = LAKE_T_LAVA;
                        count -= 2;
 
                        /* Lake of Lava2 */
-                       if (!dun->laketype && (dun_level > 80) && one_in_(count)) dun->laketype = LAKE_T_FIRE_VAULT;
+                       if (!dun->laketype && (current_floor_ptr->dun_level > 80) && one_in_(count)) dun->laketype = LAKE_T_FIRE_VAULT;
                        count--;
                }
 
                if ((d_info[p_ptr->dungeon_idx].flags1 & DF1_LAKE_WATER) && !dun->laketype)
                {
                        /* Lake of Water */
-                       if ((dun_level > 50) && randint0(count) < 2) dun->laketype = LAKE_T_WATER;
+                       if ((current_floor_ptr->dun_level > 50) && randint0(count) < 2) dun->laketype = LAKE_T_WATER;
                        count -= 2;
 
                        /* Lake of Water2 */
-                       if (!dun->laketype && (dun_level > 50) && one_in_(count)) dun->laketype = LAKE_T_WATER_VAULT;
+                       if (!dun->laketype && (current_floor_ptr->dun_level > 50) && one_in_(count)) dun->laketype = LAKE_T_WATER_VAULT;
                        count--;
                }
 
                if ((d_info[p_ptr->dungeon_idx].flags1 & DF1_LAKE_RUBBLE) && !dun->laketype)
                {
                        /* Lake of rubble */
-                       if ((dun_level > 35) && (randint0(count) < 2)) dun->laketype = LAKE_T_CAVE;
+                       if ((current_floor_ptr->dun_level > 35) && (randint0(count) < 2)) dun->laketype = LAKE_T_CAVE;
                        count -= 2;
 
                        /* Lake of rubble2 */
-                       if (!dun->laketype && (dun_level > 35) && one_in_(count)) dun->laketype = LAKE_T_EARTH_VAULT;
+                       if (!dun->laketype && (current_floor_ptr->dun_level > 35) && one_in_(count)) dun->laketype = LAKE_T_EARTH_VAULT;
                        count--;
                }
 
                /* Lake of tree */
-               if ((dun_level > 5) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_LAKE_TREE) && !dun->laketype) dun->laketype = LAKE_T_AIR_VAULT;
+               if ((current_floor_ptr->dun_level > 5) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_LAKE_TREE) && !dun->laketype) dun->laketype = LAKE_T_AIR_VAULT;
 
                if (dun->laketype)
                {
@@ -532,13 +532,13 @@ static void gen_caverns_and_lakes(void)
                }
        }
 
-       if ((dun_level > DUN_CAVERN) && !dun->empty_level &&
+       if ((current_floor_ptr->dun_level > DUN_CAVERN) && !dun->empty_level &&
            (d_info[p_ptr->dungeon_idx].flags1 & DF1_CAVERN) &&
-           !dun->laketype && !dun->destroyed && (randint1(1000) < dun_level))
+           !dun->laketype && !dun->destroyed && (randint1(1000) < current_floor_ptr->dun_level))
        {
                dun->cavern = TRUE;
 
-               /* make a large fractal grid_array in the middle of the dungeon */
+               /* make a large fractal current_floor_ptr->grid_array in the middle of the dungeon */
 
                msg_print_wizard(CHEAT_DUNGEON, _("洞窟を生成。", "Cavern on level."));
                build_cavern();
@@ -546,7 +546,7 @@ static void gen_caverns_and_lakes(void)
 #endif /* ALLOW_CAVERNS_AND_LAKES */
 
        /* Hack -- No destroyed "quest" levels */
-       if (quest_number(dun_level)) dun->destroyed = FALSE;
+       if (quest_number(current_floor_ptr->dun_level)) dun->destroyed = FALSE;
 }
 
 
@@ -581,8 +581,8 @@ static bool cave_gen(void)
        dun_tun_jct = rand_range(DUN_TUN_JCT_MIN, DUN_TUN_JCT_MAX);
 
        /* Actual maximum number of rooms on this level */
-       dun->row_rooms = cur_hgt / BLOCK_HGT;
-       dun->col_rooms = cur_wid / BLOCK_WID;
+       dun->row_rooms = current_floor_ptr->height / BLOCK_HGT;
+       dun->col_rooms = current_floor_ptr->width / BLOCK_WID;
 
        /* Initialize the room table */
        for (y = 0; y < dun->row_rooms; y++)
@@ -606,34 +606,34 @@ static bool cave_gen(void)
        if (dun->empty_level)
        {
                /* Start with floors */
-               for (y = 0; y < cur_hgt; y++)
+               for (y = 0; y < current_floor_ptr->height; y++)
                {
-                       for (x = 0; x < cur_wid; x++)
+                       for (x = 0; x < current_floor_ptr->width; x++)
                        {
                                place_floor_bold(y, x);
                        }
                }
 
                /* Special boundary walls -- Top and bottom */
-               for (x = 0; x < cur_wid; x++)
+               for (x = 0; x < current_floor_ptr->width; x++)
                {
                        place_extra_bold(0, x);
-                       place_extra_bold(cur_hgt - 1, x);
+                       place_extra_bold(current_floor_ptr->height - 1, x);
                }
 
                /* Special boundary walls -- Left and right */
-               for (y = 1; y < (cur_hgt - 1); y++)
+               for (y = 1; y < (current_floor_ptr->height - 1); y++)
                {
                        place_extra_bold(y, 0);
-                       place_extra_bold(y, cur_wid - 1);
+                       place_extra_bold(y, current_floor_ptr->width - 1);
                }
        }
        else
        {
                /* Start with walls */
-               for (y = 0; y < cur_hgt; y++)
+               for (y = 0; y < current_floor_ptr->height; y++)
                {
-                       for (x = 0; x < cur_wid; x++)
+                       for (x = 0; x < current_floor_ptr->width; x++)
                        {
                                place_extra_bold(y, x);
                        }
@@ -646,7 +646,7 @@ static bool cave_gen(void)
        /* Build maze */
        if (d_info[p_ptr->dungeon_idx].flags1 & DF1_MAZE)
        {
-               build_maze_vault(cur_wid/2-1, cur_hgt/2-1, cur_wid-4, cur_hgt-4, FALSE);
+               build_maze_vault(current_floor_ptr->width/2-1, current_floor_ptr->height/2-1, current_floor_ptr->width-4, current_floor_ptr->height-4, FALSE);
 
                /* Place 3 or 4 down stairs near some walls */
                if (!alloc_stairs(feat_down_stair, rand_range(2, 3), 3)) return FALSE;
@@ -667,11 +667,11 @@ static bool cave_gen(void)
 
 
                /* Make a hole in the dungeon roof sometimes at level 1 */
-               if (dun_level == 1)
+               if (current_floor_ptr->dun_level == 1)
                {
                        while (one_in_(DUN_MOS_DEN))
                        {
-                               place_trees(randint1(cur_wid - 2), randint1(cur_hgt - 2));
+                               place_trees(randint1(current_floor_ptr->width - 2), randint1(current_floor_ptr->height - 2));
                        }
                }
 
@@ -679,12 +679,12 @@ static bool cave_gen(void)
                if (dun->destroyed) destroy_level();
 
                /* Hack -- Add some rivers */
-               if (one_in_(3) && (randint1(dun_level) > 5))
+               if (one_in_(3) && (randint1(current_floor_ptr->dun_level) > 5))
                {
                        FEAT_IDX feat1 = 0, feat2 = 0;
 
                        /* Choose water mainly */
-                       if ((randint1(MAX_DEPTH * 2) - 1 > dun_level) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_WATER_RIVER))
+                       if ((randint1(MAX_DEPTH * 2) - 1 > current_floor_ptr->dun_level) && (d_info[p_ptr->dungeon_idx].flags1 & DF1_WATER_RIVER))
                        {
                                feat1 = feat_deep_water;
                                feat2 = feat_shallow_water;
@@ -764,7 +764,7 @@ static bool cave_gen(void)
                        dun->wall_n = 0;
 
                        /* Connect the room to the previous room */
-                       if (randint1(dun_level) > d_info[p_ptr->dungeon_idx].tunnel_percent)
+                       if (randint1(current_floor_ptr->dun_level) > d_info[p_ptr->dungeon_idx].tunnel_percent)
                        {
                                /* make cavelike tunnel */
                                (void)build_tunnel2(dun->cent[i].x, dun->cent[i].y, x, y, 2, 2);
@@ -784,7 +784,7 @@ static bool cave_gen(void)
                                feature_type *f_ptr;
                                y = dun->tunn[j].y;
                                x = dun->tunn[j].x;
-                               g_ptr = &grid_array[y][x];
+                               g_ptr = &current_floor_ptr->grid_array[y][x];
                                f_ptr = &f_info[g_ptr->feat];
 
                                /* Clear previous contents (if not a lake), add a floor */
@@ -803,7 +803,7 @@ static bool cave_gen(void)
                                grid_type *g_ptr;
                                y = dun->wall[j].y;
                                x = dun->wall[j].x;
-                               g_ptr = &grid_array[y][x];
+                               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                                /* Clear mimic type */
                                g_ptr->mimic = 0;
@@ -867,17 +867,17 @@ static bool cave_gen(void)
        }
 
        /* Special boundary walls -- Top and bottom */
-       for (x = 0; x < cur_wid; x++)
+       for (x = 0; x < current_floor_ptr->width; x++)
        {
-               place_bound_perm_wall(&grid_array[0][x]);
-               place_bound_perm_wall(&grid_array[cur_hgt - 1][x]);
+               place_bound_perm_wall(&current_floor_ptr->grid_array[0][x]);
+               place_bound_perm_wall(&current_floor_ptr->grid_array[current_floor_ptr->height - 1][x]);
        }
 
        /* Special boundary walls -- Left and right */
-       for (y = 1; y < (cur_hgt - 1); y++)
+       for (y = 1; y < (current_floor_ptr->height - 1); y++)
        {
-               place_bound_perm_wall(&grid_array[y][0]);
-               place_bound_perm_wall(&grid_array[y][cur_wid - 1]);
+               place_bound_perm_wall(&current_floor_ptr->grid_array[y][0]);
+               place_bound_perm_wall(&current_floor_ptr->grid_array[y][current_floor_ptr->width - 1]);
        }
 
        /* Determine the character location */
@@ -886,7 +886,7 @@ static bool cave_gen(void)
        if (!place_quest_monsters()) return FALSE;
 
        /* Basic "amount" */
-       k = (dun_level / 3);
+       k = (current_floor_ptr->dun_level / 3);
        if (k > 10) k = 10;
        if (k < 2) k = 2;
 
@@ -894,12 +894,12 @@ static bool cave_gen(void)
        i = d_info[p_ptr->dungeon_idx].min_m_alloc_level;
 
        /* To make small levels a bit more playable */
-       if (cur_hgt < MAX_HGT || cur_wid < MAX_WID)
+       if (current_floor_ptr->height < MAX_HGT || current_floor_ptr->width < MAX_WID)
        {
                int small_tester = i;
 
-               i = (i * cur_hgt) / MAX_HGT;
-               i = (i * cur_wid) / MAX_WID;
+               i = (i * current_floor_ptr->height) / MAX_HGT;
+               i = (i * current_floor_ptr->width) / MAX_WID;
                i += 1;
 
                if (i > small_tester) i = small_tester;
@@ -923,7 +923,7 @@ static bool cave_gen(void)
        if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_NO_CAVE)) alloc_object(ALLOC_SET_CORR, ALLOC_TYP_RUBBLE, randint1(k));
 
        /* Mega Hack -- No object at first level of deeper dungeon */
-       if (p_ptr->enter_dungeon && dun_level > 1)
+       if (p_ptr->enter_dungeon && current_floor_ptr->dun_level > 1)
        {
                /* No stair scum! */
                object_level = 1;
@@ -937,19 +937,19 @@ static bool cave_gen(void)
        alloc_object(ALLOC_SET_BOTH, ALLOC_TYP_GOLD, randnor(DUN_AMT_GOLD, 3));
 
        /* Set back to default */
-       object_level = base_level;
+       object_level = current_floor_ptr->base_level;
 
        /* Put the Guardian */
        if (!alloc_guardian(TRUE)) return FALSE;
 
-       if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > dun_level)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
+       if (dun->empty_level && (!one_in_(DARK_EMPTY) || (randint1(100) > current_floor_ptr->dun_level)) && !(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS))
        {
-               /* Lite the grid_array */
-               for (y = 0; y < cur_hgt; y++)
+               /* Lite the current_floor_ptr->grid_array */
+               for (y = 0; y < current_floor_ptr->height; y++)
                {
-                       for (x = 0; x < cur_wid; x++)
+                       for (x = 0; x < current_floor_ptr->width; x++)
                        {
-                               grid_array[y][x].info |= (CAVE_GLOW);
+                               current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW);
                        }
                }
        }
@@ -977,56 +977,56 @@ static void build_arena(void)
                for (j = x_left; j <= x_right; j++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (i = y_depth; i >= y_depth - 5; i--)
                for (j = x_left; j <= x_right; j++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (j = x_left; j <= x_left + 17; j++)
                for (i = y_height; i <= y_depth; i++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (j = x_right; j >= x_right - 17; j--)
                for (i = y_height; i <= y_depth; i++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
 
        place_extra_perm_bold(y_height+6, x_left+18);
-       grid_array[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_depth-6, x_left+18);
-       grid_array[y_depth-6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_depth-6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_height+6, x_right-18);
-       grid_array[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_depth-6, x_right-18);
-       grid_array[y_depth-6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_depth-6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
 
        i = y_height + 5;
        j = xval;
-       grid_array[i][j].feat = f_tag_to_index("ARENA_GATE");
-       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[i][j].feat = f_tag_to_index("ARENA_GATE");
+       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
        player_place(i, j);
 }
 
 /*!
- * @brief 闘技場への入場処理 / Town logic flow for generation of arena -KMW-
+ * @brief 挑戦時闘技場への入場処理 / Town logic flow for generation of arena -KMW-
  * @return なし
  */
-static void arena_gen(void)
+static void generate_challenge_arena(void)
 {
        POSITION y, x;
        POSITION qy = 0;
        POSITION qx = 0;
 
        /* Smallest area */
-       cur_hgt = SCREEN_HGT;
-       cur_wid = SCREEN_WID;
+       current_floor_ptr->height = SCREEN_HGT;
+       current_floor_ptr->width = SCREEN_WID;
 
        /* Start with solid walls */
        for (y = 0; y < MAX_HGT; y++)
@@ -1037,7 +1037,7 @@ static void arena_gen(void)
                        place_solid_perm_bold(y, x);
 
                        /* Illuminate and memorize the walls */
-                       grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
                }
        }
 
@@ -1047,7 +1047,7 @@ static void arena_gen(void)
                for (x = qx + 1; x < qx + SCREEN_WID - 1; x++)
                {
                        /* Create empty floor */
-                       grid_array[y][x].feat = feat_floor;
+                       current_floor_ptr->grid_array[y][x].feat = feat_floor;
                }
        }
 
@@ -1082,46 +1082,46 @@ static void build_battle(void)
                for (j = x_left; j <= x_right; j++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (i = y_depth; i >= y_depth - 3; i--)
                for (j = x_left; j <= x_right; j++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (j = x_left; j <= x_left + 17; j++)
                for (i = y_height; i <= y_depth; i++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
        for (j = x_right; j >= x_right - 17; j--)
                for (i = y_height; i <= y_depth; i++)
                {
                        place_extra_perm_bold(i, j);
-                       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
                }
 
        place_extra_perm_bold(y_height+6, x_left+18);
-       grid_array[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_height+6][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_depth-4, x_left+18);
-       grid_array[y_depth-4][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_depth-4][x_left+18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_height+6, x_right-18);
-       grid_array[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_height+6][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
        place_extra_perm_bold(y_depth-4, x_right-18);
-       grid_array[y_depth-4][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[y_depth-4][x_right-18].info |= (CAVE_GLOW | CAVE_MARK);
 
        for (i = y_height + 1; i <= y_height + 5; i++)
                for (j = x_left + 20 + 2 * (y_height + 5 - i); j <= x_right - 20 - 2 * (y_height + 5 - i); j++)
                {
-                       grid_array[i][j].feat = feat_permanent_glass_wall;
+                       current_floor_ptr->grid_array[i][j].feat = feat_permanent_glass_wall;
                }
 
        i = y_height + 1;
        j = xval;
-       grid_array[i][j].feat = f_tag_to_index("BUILDING_3");
-       grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
+       current_floor_ptr->grid_array[i][j].feat = f_tag_to_index("BUILDING_3");
+       current_floor_ptr->grid_array[i][j].info |= (CAVE_GLOW | CAVE_MARK);
        player_place(i, j);
 }
 
@@ -1129,7 +1129,7 @@ static void build_battle(void)
  * @brief モンスター闘技場への導入処理 / Town logic flow for generation of arena -KMW-
  * @return なし
  */
-static void battle_gen(void)
+static void generate_gambling_arena(void)
 {
        POSITION y, x;
        MONSTER_IDX i;
@@ -1145,7 +1145,7 @@ static void battle_gen(void)
                        place_solid_perm_bold(y, x);
 
                        /* Illuminate and memorize the walls */
-                       grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
+                       current_floor_ptr->grid_array[y][x].info |= (CAVE_GLOW | CAVE_MARK);
                }
        }
 
@@ -1155,7 +1155,7 @@ static void battle_gen(void)
                for (x = qx + 1; x < qx + SCREEN_WID - 1; x++)
                {
                        /* Create empty floor */
-                       grid_array[y][x].feat = feat_floor;
+                       current_floor_ptr->grid_array[y][x].feat = feat_floor;
                }
        }
 
@@ -1164,7 +1164,7 @@ static void battle_gen(void)
        for(i = 0; i < 4; i++)
        {
                place_monster_aux(0, p_ptr->y + 8 + (i/2)*4, p_ptr->x - 2 + (i%2)*4, battle_mon[i], (PM_NO_KAGE | PM_NO_PET));
-               set_friendly(&m_list[grid_array[p_ptr->y+8+(i/2)*4][p_ptr->x-2+(i%2)*4].m_idx]);
+               set_friendly(&m_list[current_floor_ptr->grid_array[p_ptr->y+8+(i/2)*4][p_ptr->x-2+(i%2)*4].m_idx]);
        }
        for(i = 1; i < m_max; i++)
        {
@@ -1181,24 +1181,24 @@ static void battle_gen(void)
  * @brief 固定マップクエストのフロア生成 / Generate a quest level
  * @return なし
  */
-static void quest_gen(void)
+static void generate_fixed_floor(void)
 {
        POSITION x, y;
 
        /* Start with perm walls */
-       for (y = 0; y < cur_hgt; y++)
+       for (y = 0; y < current_floor_ptr->height; y++)
        {
-               for (x = 0; x < cur_wid; x++)
+               for (x = 0; x < current_floor_ptr->width; x++)
                {
                        place_solid_perm_bold(y, x);
                }
        }
 
        /* Set the quest level */
-       base_level = quest[p_ptr->inside_quest].level;
-       dun_level = base_level;
-       object_level = base_level;
-       monster_level = base_level;
+       current_floor_ptr->base_level = quest[p_ptr->inside_quest].level;
+       current_floor_ptr->dun_level = current_floor_ptr->base_level;
+       object_level = current_floor_ptr->base_level;
+       monster_level = current_floor_ptr->base_level;
 
        if (record_stair) do_cmd_write_nikki(NIKKI_TO_QUEST, p_ptr->inside_quest, NULL);
        get_mon_num_prep(get_monster_hook(), NULL);
@@ -1242,26 +1242,26 @@ static bool level_gen(concptr *why)
                        while ((level_height == MAX_HGT/SCREEN_HGT) && (level_width == MAX_WID/SCREEN_WID));
                }
 
-               cur_hgt = level_height * SCREEN_HGT;
-               cur_wid = level_width * SCREEN_WID;
+               current_floor_ptr->height = level_height * SCREEN_HGT;
+               current_floor_ptr->width = level_width * SCREEN_WID;
 
                /* Assume illegal panel */
-               panel_row_min = cur_hgt;
-               panel_col_min = cur_wid;
+               panel_row_min = current_floor_ptr->height;
+               panel_col_min = current_floor_ptr->width;
 
                msg_format_wizard(CHEAT_DUNGEON,
                        _("小さなフロア: X:%d, Y:%d", "A 'small' dungeon level: X:%d, Y:%d."),
-                       cur_wid, cur_hgt);
+                       current_floor_ptr->width, current_floor_ptr->height);
        }
        else
        {
                /* Big dungeon */
-               cur_hgt = MAX_HGT;
-               cur_wid = MAX_WID;
+               current_floor_ptr->height = MAX_HGT;
+               current_floor_ptr->width = MAX_WID;
 
                /* Assume illegal panel */
-               panel_row_min = cur_hgt;
-               panel_col_min = cur_wid;
+               panel_row_min = current_floor_ptr->height;
+               panel_col_min = current_floor_ptr->width;
        }
 
        /* Make a dungeon */
@@ -1274,37 +1274,37 @@ static bool level_gen(concptr *why)
 }
 
 /*!
- * @brief フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after grid_array generation
+ * @brief フロアに存在する全マスの記憶状態を初期化する / Wipe all unnecessary flags after current_floor_ptr->grid_array generation
  * @return なし
  */
 void wipe_generate_random_floor_flags(void)
 {
        POSITION x, y;
 
-       for (y = 0; y < cur_hgt; y++)
+       for (y = 0; y < current_floor_ptr->height; y++)
        {
-               for (x = 0; x < cur_wid; x++)
+               for (x = 0; x < current_floor_ptr->width; x++)
                {
                        /* Wipe unused flags */
-                       grid_array[y][x].info &= ~(CAVE_MASK);
+                       current_floor_ptr->grid_array[y][x].info &= ~(CAVE_MASK);
                }
        }
 
-       if (dun_level)
+       if (current_floor_ptr->dun_level)
        {
-               for (y = 1; y < cur_hgt - 1; y++)
+               for (y = 1; y < current_floor_ptr->height - 1; y++)
                {
-                       for (x = 1; x < cur_wid - 1; x++)
+                       for (x = 1; x < current_floor_ptr->width - 1; x++)
                        {
                                /* There might be trap */
-                               grid_array[y][x].info |= CAVE_UNSAFE;
+                               current_floor_ptr->grid_array[y][x].info |= CAVE_UNSAFE;
                        }
                }
        }
 }
 
 /*!
- * @brief フロアの全情報を初期化する / Clear and empty the grid_array
+ * @brief フロアの全情報を初期化する / Clear and empty the current_floor_ptr->grid_array
  * @return なし
  */
 void clear_cave(void)
@@ -1329,12 +1329,12 @@ void clear_cave(void)
        precalc_cur_num_of_pet();
 
 
-       /* Start with a blank grid_array */
+       /* Start with a blank current_floor_ptr->grid_array */
        for (y = 0; y < MAX_HGT; y++)
        {
                for (x = 0; x < MAX_WID; x++)
                {
-                       grid_type *g_ptr = &grid_array[y][x];
+                       grid_type *g_ptr = &current_floor_ptr->grid_array[y][x];
                        g_ptr->info = 0;
                        g_ptr->feat = 0;
                        g_ptr->o_idx = 0;
@@ -1351,13 +1351,13 @@ void clear_cave(void)
        p_ptr->x = p_ptr->y = 0;
 
        /* Set the base level */
-       base_level = dun_level;
+       current_floor_ptr->base_level = current_floor_ptr->dun_level;
 
        /* Reset the monster generation level */
-       monster_level = base_level;
+       monster_level = current_floor_ptr->base_level;
 
        /* Reset the object generation level */
-       object_level = base_level;
+       object_level = current_floor_ptr->base_level;
 }
 
 
@@ -1380,30 +1380,30 @@ void generate_random_floor(void)
 
                concptr why = NULL;
 
-               /* Clear and empty the grid_array */
+               /* Clear and empty the current_floor_ptr->grid_array */
                clear_cave();
 
                /* Build the arena -KMW- */
                if (p_ptr->inside_arena)
                {
                        /* Small arena */
-                       arena_gen();
+                       generate_challenge_arena();
                }
 
                /* Build the battle -KMW- */
                else if (p_ptr->inside_battle)
                {
                        /* Small arena */
-                       battle_gen();
+                       generate_gambling_arena();
                }
 
                else if (p_ptr->inside_quest)
                {
-                       quest_gen();
+                       generate_fixed_floor();
                }
 
                /* Build the town */
-               else if (!dun_level)
+               else if (!current_floor_ptr->dun_level)
                {
                        /* Make the wilderness */
                        if (p_ptr->wild_mode) wilderness_gen_small();
@@ -1587,7 +1587,7 @@ bool build_tunnel(POSITION row1, POSITION col1, POSITION row2, POSITION col2)
 
 
                /* Access the location */
-               g_ptr = &grid_array[tmp_row][tmp_col];
+               g_ptr = &current_floor_ptr->grid_array[tmp_row][tmp_col];
 
                /* Avoid "solid" walls */
                if (is_solid_grid(g_ptr)) continue;
@@ -1604,8 +1604,8 @@ bool build_tunnel(POSITION row1, POSITION col1, POSITION row2, POSITION col2)
                        if (is_solid_bold(y, x)) continue;
 
                        /* Accept this location */
-                       row1 = (POSITION)tmp_row;
-                       col1 = (POSITION)tmp_col;
+                       row1 = tmp_row;
+                       col1 = tmp_col;
 
                        /* Save the wall location */
                        if (dun->wall_n < WALL_MAX)
@@ -1725,7 +1725,7 @@ static bool set_tunnel(POSITION *x, POSITION *y, bool affectwall)
 {
        int i, j, dx, dy;
 
-       grid_type *g_ptr = &grid_array[*y][*x];
+       grid_type *g_ptr = &current_floor_ptr->grid_array[*y][*x];
 
        if (!in_bounds(*y, *x)) return TRUE;
 
@@ -1780,7 +1780,7 @@ static bool set_tunnel(POSITION *x, POSITION *y, bool affectwall)
                }
 
                /* Clear mimic type */
-               grid_array[*y][*x].mimic = 0;
+               current_floor_ptr->grid_array[*y][*x].mimic = 0;
 
                place_floor_bold(*y, *x);
 
@@ -2046,7 +2046,7 @@ bool build_tunnel2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type,
                        y3 = (y1 + y2) / 2;
                }
                /* cache g_ptr */
-               g_ptr = &grid_array[y3][x3];
+               g_ptr = &current_floor_ptr->grid_array[y3][x3];
                if (is_solid_grid(g_ptr))
                {
                        /* move midpoint a bit to avoid problem. */
@@ -2076,14 +2076,14 @@ bool build_tunnel2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type,
                        }
                        y3 += dy;
                        x3 += dx;
-                       g_ptr = &grid_array[y3][x3];
+                       g_ptr = &current_floor_ptr->grid_array[y3][x3];
                }
 
                if (is_floor_grid(g_ptr))
                {
                        if (build_tunnel2(x1, y1, x3, y3, type, cutoff))
                        {
-                               if ((grid_array[y3][x3].info & CAVE_ROOM) || (randint1(100) > 95))
+                               if ((current_floor_ptr->grid_array[y3][x3].info & CAVE_ROOM) || (randint1(100) > 95))
                                {
                                        /* do second half only if works + if have hit a room */
                                        retval = build_tunnel2(x3, y3, x2, y2, type, cutoff);
@@ -2096,8 +2096,8 @@ bool build_tunnel2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type,
                                        /* Save the door location */
                                        if (dun->door_n < DOOR_MAX)
                                        {
-                                               dun->door[dun->door_n].y = (POSITION)y3;
-                                               dun->door[dun->door_n].x = (POSITION)x3;
+                                               dun->door[dun->door_n].y = y3;
+                                               dun->door[dun->door_n].x = x3;
                                                dun->door_n++;
                                        }
                                        else return FALSE;
@@ -2114,9 +2114,9 @@ bool build_tunnel2(POSITION x1, POSITION y1, POSITION x2, POSITION y2, int type,
                else
                {
                        /* tunnel through walls */
-                       if (build_tunnel2(x1, y1, (POSITION)x3, (POSITION)y3, type, cutoff))
+                       if (build_tunnel2(x1, y1, x3, y3, type, cutoff))
                        {
-                               retval = build_tunnel2((POSITION)x3, (POSITION)y3, x2, y2, type, cutoff);
+                               retval = build_tunnel2(x3, y3, x2, y2, type, cutoff);
                                firstsuccede = TRUE;
                        }
                        else