OSDN Git Service

[Refactor] #37353 cave 配列を grid_array に改名。 / Rename cave array to grid_array().
[hengband/hengband.git] / src / wild.c
index b55ac64..f253a5e 100644 (file)
@@ -98,7 +98,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. */
-       cave[ymid][xmid].feat = (FEAT_IDX)avg;
+       grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
 }
 
 
@@ -133,7 +133,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. */
-       cave[ymid][xmid].feat = (FEAT_IDX)avg;
+       grid_array[ymid][xmid].feat = (FEAT_IDX)avg;
 }
 
 
@@ -165,19 +165,19 @@ static void plasma_recursive(POSITION x1, POSITION y1, POSITION x2, POSITION y2,
        /* Are we done? */
        if (x1 + 1 == x2) return;
 
-       perturb_point_mid(cave[y1][x1].feat, cave[y2][x1].feat, cave[y1][x2].feat,
-               cave[y2][x2].feat, xmid, ymid, rough, depth_max);
+       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_end(cave[y1][x1].feat, cave[y1][x2].feat, cave[ymid][xmid].feat,
+       perturb_point_end(grid_array[y1][x1].feat, grid_array[y1][x2].feat, grid_array[ymid][xmid].feat,
                xmid, y1, rough, depth_max);
 
-       perturb_point_end(cave[y1][x2].feat, cave[y2][x2].feat, cave[ymid][xmid].feat,
+       perturb_point_end(grid_array[y1][x2].feat, grid_array[y2][x2].feat, grid_array[ymid][xmid].feat,
                x2, ymid, rough, depth_max);
 
-       perturb_point_end(cave[y2][x2].feat, cave[y2][x1].feat, cave[ymid][xmid].feat,
+       perturb_point_end(grid_array[y2][x2].feat, grid_array[y2][x1].feat, grid_array[ymid][xmid].feat,
                xmid, y2, rough, depth_max);
 
-       perturb_point_end(cave[y2][x1].feat, cave[y1][x1].feat, cave[ymid][xmid].feat,
+       perturb_point_end(grid_array[y2][x1].feat, grid_array[y1][x1].feat, grid_array[ymid][xmid].feat,
                x1, ymid, rough, depth_max);
 
 
@@ -222,7 +222,7 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
                {
                        for (x1 = 0; x1 < MAX_WID; x1++)
                        {
-                               cave[y1][x1].feat = feat_permanent;
+                               grid_array[y1][x1].feat = feat_permanent;
                        }
                }
 
@@ -244,7 +244,7 @@ static void generate_wilderness_area(int terrain, u32b seed, bool border, bool c
                {
                        for (x1 = 0; x1 < MAX_WID; x1++)
                        {
-                               cave[y1][x1].feat = table_size / 2;
+                               grid_array[y1][x1].feat = table_size / 2;
                        }
                }
        }
@@ -254,42 +254,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.
         */
-       cave[1][1].feat = (s16b)randint0(table_size);
-       cave[MAX_HGT-2][1].feat = (s16b)randint0(table_size);
-       cave[1][MAX_WID-2].feat = (s16b)randint0(table_size);
-       cave[MAX_HGT-2][MAX_WID-2].feat = (s16b)randint0(table_size);
+       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);
 
        if (!corner)
        {
                /* Hack -- preserve four corners */
-               s16b north_west = cave[1][1].feat;
-               s16b south_west = cave[MAX_HGT - 2][1].feat;
-               s16b north_east = cave[1][MAX_WID - 2].feat;
-               s16b south_east = cave[MAX_HGT - 2][MAX_WID - 2].feat;
+               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;
 
                /* 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 */
-               cave[1][1].feat = north_west;
-               cave[MAX_HGT - 2][1].feat = south_west;
-               cave[1][MAX_WID - 2].feat = north_east;
-               cave[MAX_HGT - 2][MAX_WID - 2].feat = south_east;
+               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;
 
                for (y1 = 1; y1 < MAX_HGT - 1; y1++)
                {
                        for (x1 = 1; x1 < MAX_WID - 1; x1++)
                        {
-                               cave[y1][x1].feat = terrain_table[terrain][cave[y1][x1].feat];
+                               grid_array[y1][x1].feat = terrain_table[terrain][grid_array[y1][x1].feat];
                        }
                }
        }
        else /* Hack -- only four corners */
        {
-               cave[1][1].feat = terrain_table[terrain][cave[1][1].feat];
-               cave[MAX_HGT - 2][1].feat = terrain_table[terrain][cave[MAX_HGT - 2][1].feat];
-               cave[1][MAX_WID - 2].feat = terrain_table[terrain][cave[1][MAX_WID - 2].feat];
-               cave[MAX_HGT - 2][MAX_WID - 2].feat = terrain_table[terrain][cave[MAX_HGT - 2][MAX_WID - 2].feat];
+               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];
        }
 
        /* Hack -- Restore the RNG state */
@@ -368,7 +368,7 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                 */
                if (wilderness[y][x].road)
                {
-                       cave[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
+                       grid_array[MAX_HGT/2][MAX_WID/2].feat = feat_floor;
 
                        if (wilderness[y-1][x].road)
                        {
@@ -376,7 +376,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;
-                                       cave[y1][x1].feat = feat_floor;
+                                       grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -386,7 +386,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;
-                                       cave[y1][x1].feat = feat_floor;
+                                       grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -396,7 +396,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;
-                                       cave[y1][x1].feat = feat_floor;
+                                       grid_array[y1][x1].feat = feat_floor;
                                }
                        }
 
@@ -406,7 +406,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;
-                                       cave[y1][x1].feat = feat_floor;
+                                       grid_array[y1][x1].feat = feat_floor;
                                }
                        }
                }
@@ -426,8 +426,8 @@ static void generate_area(POSITION y, POSITION x, bool border, bool corner)
                dy = rand_range(6, cur_hgt - 6);
                dx = rand_range(6, cur_wid - 6);
 
-               cave[dy][dx].feat = feat_entrance;
-               cave[dy][dx].special = wilderness[y][x].entrance;
+               grid_array[dy][dx].feat = feat_entrance;
+               grid_array[dy][dx].special = wilderness[y][x].entrance;
 
                /* Hack -- Restore the RNG state */
                Rand_state_restore(state_backup);
@@ -473,7 +473,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_WID - 1; i++)
        {
-               border.north[i] = cave[MAX_HGT - 2][i].feat;
+               border.north[i] = grid_array[MAX_HGT - 2][i].feat;
        }
 
        /* South border */
@@ -481,7 +481,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_WID - 1; i++)
        {
-               border.south[i] = cave[1][i].feat;
+               border.south[i] = grid_array[1][i].feat;
        }
 
        /* West border */
@@ -489,7 +489,7 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_HGT - 1; i++)
        {
-               border.west[i] = cave[i][MAX_WID - 2].feat;
+               border.west[i] = grid_array[i][MAX_WID - 2].feat;
        }
 
        /* East border */
@@ -497,24 +497,24 @@ void wilderness_gen(void)
 
        for (i = 1; i < MAX_HGT - 1; i++)
        {
-               border.east[i] = cave[i][1].feat;
+               border.east[i] = grid_array[i][1].feat;
        }
 
        /* North west corner */
        generate_area(y - 1, x - 1, FALSE, TRUE);
-       border.north_west = cave[MAX_HGT - 2][MAX_WID - 2].feat;
+       border.north_west = grid_array[MAX_HGT - 2][MAX_WID - 2].feat;
 
        /* North east corner */
        generate_area(y - 1, x + 1, FALSE, TRUE);
-       border.north_east = cave[MAX_HGT - 2][1].feat;
+       border.north_east = grid_array[MAX_HGT - 2][1].feat;
 
        /* South west corner */
        generate_area(y + 1, x - 1, FALSE, TRUE);
-       border.south_west = cave[1][MAX_WID - 2].feat;
+       border.south_west = grid_array[1][MAX_WID - 2].feat;
 
        /* South east corner */
        generate_area(y + 1, x + 1, FALSE, TRUE);
-       border.south_east = cave[1][1].feat;
+       border.south_east = grid_array[1][1].feat;
 
 
        /* Create terrain of the current area */
@@ -524,50 +524,50 @@ void wilderness_gen(void)
        /* Special boundary walls -- North */
        for (i = 0; i < MAX_WID; i++)
        {
-               cave[0][i].feat = feat_permanent;
-               cave[0][i].mimic = border.north[i];
+               grid_array[0][i].feat = feat_permanent;
+               grid_array[0][i].mimic = border.north[i];
        }
 
        /* Special boundary walls -- South */
        for (i = 0; i < MAX_WID; i++)
        {
-               cave[MAX_HGT - 1][i].feat = feat_permanent;
-               cave[MAX_HGT - 1][i].mimic = border.south[i];
+               grid_array[MAX_HGT - 1][i].feat = feat_permanent;
+               grid_array[MAX_HGT - 1][i].mimic = border.south[i];
        }
 
        /* Special boundary walls -- West */
        for (i = 0; i < MAX_HGT; i++)
        {
-               cave[i][0].feat = feat_permanent;
-               cave[i][0].mimic = border.west[i];
+               grid_array[i][0].feat = feat_permanent;
+               grid_array[i][0].mimic = border.west[i];
        }
 
        /* Special boundary walls -- East */
        for (i = 0; i < MAX_HGT; i++)
        {
-               cave[i][MAX_WID - 1].feat = feat_permanent;
-               cave[i][MAX_WID - 1].mimic = border.east[i];
+               grid_array[i][MAX_WID - 1].feat = feat_permanent;
+               grid_array[i][MAX_WID - 1].mimic = border.east[i];
        }
 
        /* North west corner */
-       cave[0][0].mimic = border.north_west;
+       grid_array[0][0].mimic = border.north_west;
 
        /* North east corner */
-       cave[0][MAX_WID - 1].mimic = border.north_east;
+       grid_array[0][MAX_WID - 1].mimic = border.north_east;
 
        /* South west corner */
-       cave[MAX_HGT - 1][0].mimic = border.south_west;
+       grid_array[MAX_HGT - 1][0].mimic = border.south_west;
 
        /* South east corner */
-       cave[MAX_HGT - 1][MAX_WID - 1].mimic = border.south_east;
+       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 (x = 0; x < cur_wid; x++)
                {
-                       /* Get the cave grid */
-                       c_ptr = &cave[y][x];
+                       /* Get the grid */
+                       c_ptr = &grid_array[y][x];
 
                        if (is_daytime())
                        {
@@ -613,8 +613,8 @@ void wilderness_gen(void)
                {
                        for (x = 0; x < cur_wid; x++)
                        {
-                               /* Get the cave grid */
-                               c_ptr = &cave[y][x];
+                               /* Get the grid */
+                               c_ptr = &grid_array[y][x];
 
                                /* Seeing true feature code (ignore mimic) */
                                f_ptr = &f_info[c_ptr->feat];
@@ -639,8 +639,8 @@ void wilderness_gen(void)
                {
                        for (x = 0; x < cur_wid; x++)
                        {
-                               /* Get the cave grid */
-                               c_ptr = &cave[y][x];
+                               /* Get the grid */
+                               c_ptr = &grid_array[y][x];
 
                                if (cave_have_flag_grid(c_ptr, FF_ENTRANCE))
                                {
@@ -700,7 +700,7 @@ void wilderness_gen_small(void)
        for (i = 0; i < MAX_WID; i++)
        for (j = 0; j < MAX_HGT; j++)
        {
-               cave[j][i].feat = feat_permanent;
+               grid_array[j][i].feat = feat_permanent;
        }
 
        /* Init the wilderness */
@@ -712,18 +712,18 @@ void wilderness_gen_small(void)
        {
                if (wilderness[j][i].town && (wilderness[j][i].town != NO_TOWN))
                {
-                       cave[j][i].feat = (s16b)feat_town;
-                       cave[j][i].special = (s16b)wilderness[j][i].town;
+                       grid_array[j][i].feat = (s16b)feat_town;
+                       grid_array[j][i].special = (s16b)wilderness[j][i].town;
                }
-               else if (wilderness[j][i].road) cave[j][i].feat = feat_floor;
+               else if (wilderness[j][i].road) 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)))
                {
-                       cave[j][i].feat = feat_entrance;
-                       cave[j][i].special = (byte)wilderness[j][i].entrance;
+                       grid_array[j][i].feat = feat_entrance;
+                       grid_array[j][i].special = (byte)wilderness[j][i].entrance;
                }
-               else cave[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
+               else grid_array[j][i].feat = conv_terrain2feat[wilderness[j][i].terrain];
 
-               cave[j][i].info |= (CAVE_GLOW | CAVE_MARK);
+               grid_array[j][i].info |= (CAVE_GLOW | CAVE_MARK);
        }
 
        cur_hgt = (s16b) max_wild_y;