OSDN Git Service

Changed to match the For2.2.2-Refactoring-Cocoa2 branch. Put se_maoudamashii_voice_m...
[hengbandforosx/hengbandosx.git] / src / wild.c
index 118ba64..9badd59 100644 (file)
  */
 
 #include "angband.h"
+#include "wild.h"
 #include "world.h"
 #include "monster.h"
 #include "realm-hex.h"
 #include "player-status.h"
+#include "grid.h"
+#include "monster-status.h"
+
+ /*
+  * Wilderness
+  */
+wilderness_type **wilderness;
+
 
 /*!
  * @brief 地形生成確率を決める要素100の配列を確率テーブルから作成する
@@ -28,8 +37,6 @@ static void set_floor_and_wall_aux(s16b feat_type[100], feat_prob prob[DUNGEON_F
 
        lim[0] = prob[0].percent;
        for (i = 1; i < DUNGEON_FEAT_PROB_NUM; i++) lim[i] = lim[i - 1] + prob[i].percent;
-
-       /* Paranoia */
        if (lim[DUNGEON_FEAT_PROB_NUM - 1] < 100) lim[DUNGEON_FEAT_PROB_NUM - 1] = 100;
 
        for (i = 0; i < 100; i++)
@@ -98,7 +105,7 @@ static void perturb_point_mid(FEAT_IDX x1, FEAT_IDX x2, FEAT_IDX x3, FEAT_IDX x4
        if (avg > depth_max) avg = depth_max;
 
        /* Set the new value. */
-       grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
+       current_floor_ptr->grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
 }
 
 
@@ -133,7 +140,7 @@ static void perturb_point_end(FEAT_IDX x1, FEAT_IDX x2, FEAT_IDX x3, POSITION xm
        if (avg > depth_max) avg = depth_max;
 
        /* Set the new value. */
-       grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
+       current_floor_ptr->grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
 }
 
 
@@ -165,19 +172,19 @@ static void plasma_recursive(POSITION x1, POSITION y1, POSITION x2, POSITION y2,
        /* Are we done? */
        if (x1 + 1 == x2) return;
 
-       perturb_point_mid(grid_array[y1][x1].feat, grid_array[y2][x1].feat, grid_array[y1][x2].feat,
-               grid_array[y2][x2].feat, xmid, ymid, rough, depth_max);
+       perturb_point_mid(current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[y1][x2].feat,
+               current_floor_ptr->grid_array[y2][x2].feat, xmid, ymid, rough, depth_max);
 
-       perturb_point_end(grid_array[y1][x1].feat, grid_array[y1][x2].feat, grid_array[ymid][xmid].feat,
+       perturb_point_end(current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[y1][x2].feat, current_floor_ptr->grid_array[ymid][xmid].feat,
                xmid, y1, rough, depth_max);
 
-       perturb_point_end(grid_array[y1][x2].feat, grid_array[y2][x2].feat, grid_array[ymid][xmid].feat,
+       perturb_point_end(current_floor_ptr->grid_array[y1][x2].feat, current_floor_ptr->grid_array[y2][x2].feat, current_floor_ptr->grid_array[ymid][xmid].feat,
                x2, ymid, rough, depth_max);
 
-       perturb_point_end(grid_array[y2][x2].feat, grid_array[y2][x1].feat, grid_array[ymid][xmid].feat,
+       perturb_point_end(current_floor_ptr->grid_array[y2][x2].feat, current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[ymid][xmid].feat,
                xmid, y2, rough, depth_max);
 
-       perturb_point_end(grid_array[y2][x1].feat, grid_array[y1][x1].feat, grid_array[ymid][xmid].feat,
+       perturb_point_end(current_floor_ptr->grid_array[y2][x1].feat, current_floor_ptr->grid_array[y1][x1].feat, current_floor_ptr->grid_array[ymid][xmid].feat,
                x1, ymid, rough, depth_max);
 
 
@@ -222,7 +229,7 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
                {
                        for (x1 = 0; x1 < MAX_WID; x1++)
                        {
-                               grid_array[y1][x1].feat = feat_permanent;
+                               current_floor_ptr->grid_array[y1][x1].feat = feat_permanent;
                        }
                }
 
@@ -244,7 +251,7 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
                {
                        for (x1 = 0; x1 < MAX_WID; x1++)
                        {
-                               grid_array[y1][x1].feat = table_size / 2;
+                               current_floor_ptr->grid_array[y1][x1].feat = table_size / 2;
                        }
                }
        }
@@ -254,42 +261,42 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
         * ToDo: calculate the medium height of the adjacent
         * terrains for every corner.
         */
-       grid_array[1][1].feat = (s16b)randint0(table_size);
-       grid_array[MAX_HGT-2][1].feat = (s16b)randint0(table_size);
-       grid_array[1][MAX_WID-2].feat = (s16b)randint0(table_size);
-       grid_array[MAX_HGT-2][MAX_WID-2].feat = (s16b)randint0(table_size);
+       current_floor_ptr->grid_array[1][1].feat = (s16b)randint0(table_size);
+       current_floor_ptr->grid_array[MAX_HGT-2][1].feat = (s16b)randint0(table_size);
+       current_floor_ptr->grid_array[1][MAX_WID-2].feat = (s16b)randint0(table_size);
+       current_floor_ptr->grid_array[MAX_HGT-2][MAX_WID-2].feat = (s16b)randint0(table_size);
 
        if (!corner)
        {
                /* Hack -- preserve four corners */
-               s16b north_west = grid_array[1][1].feat;
-               s16b south_west = grid_array[MAX_HGT - 2][1].feat;
-               s16b north_east = grid_array[1][MAX_WID - 2].feat;
-               s16b south_east = grid_array[MAX_HGT - 2][MAX_WID - 2].feat;
+               s16b north_west = current_floor_ptr->grid_array[1][1].feat;
+               s16b south_west = current_floor_ptr->grid_array[MAX_HGT - 2][1].feat;
+               s16b north_east = current_floor_ptr->grid_array[1][MAX_WID - 2].feat;
+               s16b south_east = current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat;
 
                /* x1, y1, x2, y2, num_depths, roughness */
                plasma_recursive(1, 1, MAX_WID-2, MAX_HGT-2, table_size-1, roughness);
 
                /* Hack -- copyback four corners */
-               grid_array[1][1].feat = north_west;
-               grid_array[MAX_HGT - 2][1].feat = south_west;
-               grid_array[1][MAX_WID - 2].feat = north_east;
-               grid_array[MAX_HGT - 2][MAX_WID - 2].feat = south_east;
+               current_floor_ptr->grid_array[1][1].feat = north_west;
+               current_floor_ptr->grid_array[MAX_HGT - 2][1].feat = south_west;
+               current_floor_ptr->grid_array[1][MAX_WID - 2].feat = north_east;
+               current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat = south_east;
 
                for (y1 = 1; y1 < MAX_HGT - 1; y1++)
                {
                        for (x1 = 1; x1 < MAX_WID - 1; x1++)
                        {
-                               grid_array[y1][x1].feat = terrain_table[terrain][grid_array[y1][x1].feat];
+                               current_floor_ptr->grid_array[y1][x1].feat = terrain_table[terrain][current_floor_ptr->grid_array[y1][x1].feat];
                        }
                }
        }
        else /* Hack -- only four corners */
        {
-               grid_array[1][1].feat = terrain_table[terrain][grid_array[1][1].feat];
-               grid_array[MAX_HGT - 2][1].feat = terrain_table[terrain][grid_array[MAX_HGT - 2][1].feat];
-               grid_array[1][MAX_WID - 2].feat = terrain_table[terrain][grid_array[1][MAX_WID - 2].feat];
-               grid_array[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][grid_array[MAX_HGT - 2][MAX_WID - 2].feat];
+               current_floor_ptr->grid_array[1][1].feat = terrain_table[terrain][current_floor_ptr->grid_array[1][1].feat];
+               current_floor_ptr->grid_array[MAX_HGT - 2][1].feat = terrain_table[terrain][current_floor_ptr->grid_array[MAX_HGT - 2][1].feat];
+               current_floor_ptr->grid_array[1][MAX_WID - 2].feat = terrain_table[terrain][current_floor_ptr->grid_array[1][MAX_WID - 2].feat];
+               current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat];
        }
 
        /* Hack -- Restore the RNG state */
@@ -324,16 +331,16 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
        p_ptr->town_num = wilderness[y][x].town;
 
        /* Set the base level */
-       base_level = wilderness[y][x].level;
+       current_floor_ptr->base_level = wilderness[y][x].level;
 
        /* Set the dungeon level */
-       dun_level = 0;
+       current_floor_ptr->dun_level = 0;
 
        /* Set the monster generation level */
-       monster_level = base_level;
+       current_floor_ptr->monster_level = current_floor_ptr->base_level;
 
        /* Set the object generation level */
-       object_level = base_level;
+       current_floor_ptr->object_level = current_floor_ptr->base_level;
 
 
        /* Create the town */
@@ -368,7 +375,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                 */
                if (wilderness[y][x].road)
                {
-                       grid_array[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
+                       current_floor_ptr->grid_array[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
 
                        if (wilderness[y-1][x].road)
                        {
@@ -376,7 +383,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                                for (y1 = 1; y1 < MAX_HGT/2; y1++)
                                {
                                        x1 = MAX_WID/2;
-                                       grid_array[y1][x1].feat = feat_floor;
+                                       current_floor_ptr->grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -386,7 +393,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                                for (y1 = MAX_HGT/2; y1 < MAX_HGT - 1; y1++)
                                {
                                        x1 = MAX_WID/2;
-                                       grid_array[y1][x1].feat = feat_floor;
+                                       current_floor_ptr->grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -396,7 +403,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                                for (x1 = MAX_WID/2; x1 < MAX_WID - 1; x1++)
                                {
                                        y1 = MAX_HGT/2;
-                                       grid_array[y1][x1].feat = feat_floor;
+                                       current_floor_ptr->grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -406,7 +413,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                                for (x1 = 1; x1 < MAX_WID/2; x1++)
                                {
                                        y1 = MAX_HGT/2;
-                                       grid_array[y1][x1].feat = feat_floor;
+                                       current_floor_ptr->grid_array[y1][x1].feat = feat_floor;
                                }
                        }
                }
@@ -423,11 +430,11 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                /* Hack -- Induce consistant flavors */
                Rand_state_set(wilderness[y][x].seed);
 
-               dy = rand_range(6, cur_hgt - 6);
-               dx = rand_range(6, cur_wid - 6);
+               dy = rand_range(6, current_floor_ptr->height - 6);
+               dx = rand_range(6, current_floor_ptr->width - 6);
 
-               grid_array[dy][dx].feat = feat_entrance;
-               grid_array[dy][dx].special = wilderness[y][x].entrance;
+               current_floor_ptr->grid_array[dy][dx].feat = feat_entrance;
+               current_floor_ptr->grid_array[dy][dx].special = wilderness[y][x].entrance;
 
                /* Hack -- Restore the RNG state */
                Rand_state_restore(state_backup);
@@ -454,16 +461,16 @@ void wilderness_gen(void)
        feature_type *f_ptr;
 
        /* Big town */
-       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;
 
        /* Init the wilderness */
 
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        x = p_ptr->wilderness_x;
        y = p_ptr->wilderness_y;
@@ -474,7 +481,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_WID - 1; i++)
        {
-               border.north[i] = grid_array[MAX_HGT - 2][i].feat;
+               border.north[i] = current_floor_ptr->grid_array[MAX_HGT - 2][i].feat;
        }
 
        /* South border */
@@ -482,7 +489,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_WID - 1; i++)
        {
-               border.south[i] = grid_array[1][i].feat;
+               border.south[i] = current_floor_ptr->grid_array[1][i].feat;
        }
 
        /* West border */
@@ -490,7 +497,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_HGT - 1; i++)
        {
-               border.west[i] = grid_array[i][MAX_WID - 2].feat;
+               border.west[i] = current_floor_ptr->grid_array[i][MAX_WID - 2].feat;
        }
 
        /* East border */
@@ -498,24 +505,24 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_HGT - 1; i++)
        {
-               border.east[i] = grid_array[i][1].feat;
+               border.east[i] = current_floor_ptr->grid_array[i][1].feat;
        }
 
        /* North west corner */
        generate_area(y - 1, x - 1, FALSE, TRUE);
-       border.north_west = grid_array[MAX_HGT - 2][MAX_WID - 2].feat;
+       border.north_west = current_floor_ptr->grid_array[MAX_HGT - 2][MAX_WID - 2].feat;
 
        /* North east corner */
        generate_area(y - 1, x + 1, FALSE, TRUE);
-       border.north_east = grid_array[MAX_HGT - 2][1].feat;
+       border.north_east = current_floor_ptr->grid_array[MAX_HGT - 2][1].feat;
 
        /* South west corner */
        generate_area(y + 1, x - 1, FALSE, TRUE);
-       border.south_west = grid_array[1][MAX_WID - 2].feat;
+       border.south_west = current_floor_ptr->grid_array[1][MAX_WID - 2].feat;
 
        /* South east corner */
        generate_area(y + 1, x + 1, FALSE, TRUE);
-       border.south_east = grid_array[1][1].feat;
+       border.south_east = current_floor_ptr->grid_array[1][1].feat;
 
 
        /* Create terrain of the current area */
@@ -525,49 +532,49 @@ void wilderness_gen(void)
        /* Special boundary walls -- North */
        for (i = 0; i < MAX_WID; i++)
        {
-               grid_array[0][i].feat = feat_permanent;
-               grid_array[0][i].mimic = border.north[i];
+               current_floor_ptr->grid_array[0][i].feat = feat_permanent;
+               current_floor_ptr->grid_array[0][i].mimic = border.north[i];
        }
 
        /* Special boundary walls -- South */
        for (i = 0; i < MAX_WID; i++)
        {
-               grid_array[MAX_HGT - 1][i].feat = feat_permanent;
-               grid_array[MAX_HGT - 1][i].mimic = border.south[i];
+               current_floor_ptr->grid_array[MAX_HGT - 1][i].feat = feat_permanent;
+               current_floor_ptr->grid_array[MAX_HGT - 1][i].mimic = border.south[i];
        }
 
        /* Special boundary walls -- West */
        for (i = 0; i < MAX_HGT; i++)
        {
-               grid_array[i][0].feat = feat_permanent;
-               grid_array[i][0].mimic = border.west[i];
+               current_floor_ptr->grid_array[i][0].feat = feat_permanent;
+               current_floor_ptr->grid_array[i][0].mimic = border.west[i];
        }
 
        /* Special boundary walls -- East */
        for (i = 0; i < MAX_HGT; i++)
        {
-               grid_array[i][MAX_WID - 1].feat = feat_permanent;
-               grid_array[i][MAX_WID - 1].mimic = border.east[i];
+               current_floor_ptr->grid_array[i][MAX_WID - 1].feat = feat_permanent;
+               current_floor_ptr->grid_array[i][MAX_WID - 1].mimic = border.east[i];
        }
 
        /* North west corner */
-       grid_array[0][0].mimic = border.north_west;
+       current_floor_ptr->grid_array[0][0].mimic = border.north_west;
 
        /* North east corner */
-       grid_array[0][MAX_WID - 1].mimic = border.north_east;
+       current_floor_ptr->grid_array[0][MAX_WID - 1].mimic = border.north_east;
 
        /* South west corner */
-       grid_array[MAX_HGT - 1][0].mimic = border.south_west;
+       current_floor_ptr->grid_array[MAX_HGT - 1][0].mimic = border.south_west;
 
        /* South east corner */
-       grid_array[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
+       current_floor_ptr->grid_array[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
 
        /* Light up or darken the area */
-       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++)
                {
-                       g_ptr = &grid_array[y][x];
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
 
                        if (is_daytime())
                        {
@@ -609,11 +616,11 @@ void wilderness_gen(void)
 
        if (p_ptr->teleport_town)
        {
-               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++)
                        {
-                               g_ptr = &grid_array[y][x];
+                               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                                /* Seeing true feature code (ignore mimic) */
                                f_ptr = &f_info[g_ptr->feat];
@@ -634,11 +641,11 @@ void wilderness_gen(void)
 
        else if (p_ptr->leaving_dungeon)
        {
-               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++)
                        {
-                               g_ptr = &grid_array[y][x];
+                               g_ptr = &current_floor_ptr->grid_array[y][x];
 
                                if (cave_have_flag_grid(g_ptr, FF_ENTRANCE))
                                {
@@ -668,7 +675,7 @@ void wilderness_gen(void)
                (void)alloc_monster(generate_encounter ? 0 : 3, mode);
        }
 
-       if(generate_encounter) ambush_flag = TRUE;
+       if(generate_encounter) p_ptr->ambush_flag = TRUE;
        generate_encounter = FALSE;
 
        /* Fill the arrays of floors and walls in the good proportions */
@@ -698,41 +705,41 @@ void wilderness_gen_small(void)
        for (i = 0; i < MAX_WID; i++)
        for (j = 0; j < MAX_HGT; j++)
        {
-               grid_array[j][i].feat = feat_permanent;
+               current_floor_ptr->grid_array[j][i].feat = feat_permanent;
        }
 
        /* Init the wilderness */
-       process_dungeon_file("w_info.txt", 0, 0, max_wild_y, max_wild_x);
+       process_dungeon_file("w_info.txt", 0, 0, current_world_ptr->max_wild_y, current_world_ptr->max_wild_x);
 
        /* Fill the map */
-       for (i = 0; i < max_wild_x; i++)
-       for (j = 0; j < max_wild_y; j++)
+       for (i = 0; i < current_world_ptr->max_wild_x; i++)
+       for (j = 0; j < current_world_ptr->max_wild_y; j++)
        {
                if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
                {
-                       grid_array[j][i].feat = (s16b)feat_town;
-                       grid_array[j][i].special = (s16b)wilderness[j][i].town;
+                       current_floor_ptr->grid_array[j][i].feat = (s16b)feat_town;
+                       current_floor_ptr->grid_array[j][i].special = (s16b)wilderness[j][i].town;
                }
-               else if (wilderness[j][i].road) grid_array[j][i].feat = feat_floor;
+               else if (wilderness[j][i].road) current_floor_ptr->grid_array[j][i].feat = feat_floor;
                else if (wilderness[j][i].entrance && (p_ptr->total_winner || !(d_info[wilderness[j][i].entrance].flags1 & DF1_WINNER)))
                {
-                       grid_array[j][i].feat = feat_entrance;
-                       grid_array[j][i].special = (byte)wilderness[j][i].entrance;
+                       current_floor_ptr->grid_array[j][i].feat = feat_entrance;
+                       current_floor_ptr->grid_array[j][i].special = (byte)wilderness[j][i].entrance;
                }
-               else grid_array[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
+               else current_floor_ptr->grid_array[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
 
-               grid_array[j][i].info |= (CAVE_GLOW | CAVE_MARK);
+               current_floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_MARK);
        }
 
-       cur_hgt = (s16b) max_wild_y;
-       cur_wid = (s16b) max_wild_x;
+       current_floor_ptr->height = (s16b) current_world_ptr->max_wild_y;
+       current_floor_ptr->width = (s16b) current_world_ptr->max_wild_x;
 
-       if (cur_hgt > MAX_HGT) cur_hgt = MAX_HGT;
-       if (cur_wid > MAX_WID) cur_wid = MAX_WID;
+       if (current_floor_ptr->height > MAX_HGT) current_floor_ptr->height = MAX_HGT;
+       if (current_floor_ptr->width > MAX_WID) 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;
 
        /* Place the player */
        p_ptr->x = p_ptr->wilderness_x;
@@ -777,8 +784,6 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in
        /* Unused */
        (void)ymin;
        (void)ymax;
-
-       /* Paranoia */
        if (!(buf[0] == 'W')) return (PARSE_ERROR_GENERIC);
 
        switch (buf[2])
@@ -871,9 +876,9 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in
                                p_ptr->wilderness_x = atoi(zz[1]);
                                
                                if ((p_ptr->wilderness_x < 1) ||
-                                   (p_ptr->wilderness_x > max_wild_x) ||
+                                   (p_ptr->wilderness_x > current_world_ptr->max_wild_x) ||
                                    (p_ptr->wilderness_y < 1) ||
-                                   (p_ptr->wilderness_y > max_wild_y))
+                                   (p_ptr->wilderness_y > current_world_ptr->max_wild_y))
                                {
                                        return (PARSE_ERROR_OUT_OF_BOUNDS);
                                }
@@ -916,9 +921,9 @@ void seed_wilderness(void)
        POSITION x, y;
 
        /* Init wilderness seeds */
-       for (x = 0; x < max_wild_x; x++)
+       for (x = 0; x < current_world_ptr->max_wild_x; x++)
        {
-               for (y = 0; y < max_wild_y; y++)
+               for (y = 0; y < current_world_ptr->max_wild_y; y++)
                {
                        wilderness[y][x].seed = randint0(0x10000000);
                        wilderness[y][x].entrance = 0;
@@ -943,12 +948,12 @@ errr init_wilderness(void)
        int i;
 
        /* Allocate the wilderness (two-dimension array) */
-       C_MAKE(wilderness, max_wild_y, wilderness_type_ptr);
-       C_MAKE(wilderness[0], max_wild_x * max_wild_y, wilderness_type);
+       C_MAKE(wilderness, current_world_ptr->max_wild_y, wilderness_type_ptr);
+       C_MAKE(wilderness[0], current_world_ptr->max_wild_x * current_world_ptr->max_wild_y, wilderness_type);
 
        /* Init the other pointers */
-       for (i = 1; i < max_wild_y; i++)
-               wilderness[i] = wilderness[0] + i * max_wild_x;
+       for (i = 1; i < current_world_ptr->max_wild_y; i++)
+               wilderness[i] = wilderness[0] + i * current_world_ptr->max_wild_x;
 
        generate_encounter = FALSE;
 
@@ -995,13 +1000,11 @@ static void init_terrain_table(int terrain, s16b feat_global, concptr fmt, ...)
 
                        check++;
                }
-               else /* Paranoia */
+               else
                {
                        plog_fmt("Format error");
                }
        }
-
-       /* Paranoia */
        if (cur < MAX_FEAT_IN_TERRAIN)
        {
                plog_fmt("Too few parameters");
@@ -1108,11 +1111,7 @@ bool change_wild_mode(void)
 
        if (lite_town || vanilla_town)
        {
-#ifdef JP
-               msg_print("荒野なんてない。");
-#else
-               msg_print("No global map.");
-#endif
+               msg_print(_("荒野なんてない。", "No global map."));
                return FALSE;
        }
 
@@ -1127,8 +1126,6 @@ bool change_wild_mode(void)
 
                /* Go back to the ordinary map */
                p_ptr->wild_mode = FALSE;
-
-               /* Leaving */
                p_ptr->leaving = TRUE;
 
                /* Succeed */
@@ -1137,29 +1134,23 @@ bool change_wild_mode(void)
 
        for (i = 1; i < m_max; i++)
        {
-               monster_type *m_ptr = &m_list[i];
+               monster_type *m_ptr = &current_floor_ptr->m_list[i];
 
-               if (!m_ptr->r_idx) continue;
+               if (!monster_is_valid(m_ptr)) continue;
                if (is_pet(m_ptr) && i != p_ptr->riding) have_pet = TRUE;
                if (MON_CSLEEP(m_ptr)) continue;
                if (m_ptr->cdis > MAX_SIGHT) continue;
                if (!is_hostile(m_ptr)) continue;
-#ifdef JP
-               msg_print("敵がすぐ近くにいるときは広域マップに入れない!");
-#else
-               msg_print("You cannot enter global map, since there is some monsters nearby!");
-#endif
+               msg_print(_("敵がすぐ近くにいるときは広域マップに入れない!",
+                       "You cannot enter global map, since there is some monsters nearby!"));
                free_turn(p_ptr);
                return FALSE;
        }
 
        if (have_pet)
        {
-#ifdef JP
-               concptr msg = "ペットを置いて広域マップに入りますか?";
-#else
-               concptr msg = "Do you leave your pets behind? ";
-#endif
+               concptr msg = _("ペットを置いて広域マップに入りますか?",
+                       "Do you leave your pets behind? ");
 
                if (!get_check_strict(msg, CHECK_OKAY_CANCEL))
                {
@@ -1168,8 +1159,7 @@ bool change_wild_mode(void)
                }
        }
 
-       /* HACK */
-       p_ptr->energy_use = 1000;
+       take_turn(p_ptr, 1000);
 
        /* Remember the position */
        p_ptr->oldpx = p_ptr->x;
@@ -1183,8 +1173,6 @@ bool change_wild_mode(void)
 
        /* Go into the global map */
        p_ptr->wild_mode = TRUE;
-
-       /* Leaving */
        p_ptr->leaving = TRUE;
 
        /* Succeed */