OSDN Git Service

[Refactor] #39077 IDX の *_IDX への移行。
[hengband/hengband.git] / src / floor-streams.c
index 46e5600..b2364c8 100644 (file)
@@ -19,6 +19,8 @@
 #include "generate.h"
 #include "floor-streams.h"
 #include "grid.h"
+#include "monster.h"
+#include "feature.h"
 
 
 /*!
@@ -39,7 +41,7 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2,
        POSITION changex, changey;
        POSITION ty, tx;
        bool done;
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        length = distance(x1, y1, x2, y2);
 
@@ -108,36 +110,36 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2,
                                        {
                                                if (!in_bounds2(ty, tx)) continue;
 
-                                               c_ptr = &cave[ty][tx];
+                                               g_ptr = &current_floor_ptr->grid_array[ty][tx];
 
-                                               if (c_ptr->feat == feat1) continue;
-                                               if (c_ptr->feat == feat2) continue;
+                                               if (g_ptr->feat == feat1) continue;
+                                               if (g_ptr->feat == feat2) continue;
 
                                                if (distance(ty, tx, y, x) > rand_spread(width, 1)) continue;
 
                                                /* Do not convert permanent features */
-                                               if (cave_perma_grid(c_ptr)) continue;
+                                               if (cave_perma_grid(g_ptr)) continue;
 
                                                /*
                                                 * Clear previous contents, add feature
                                                 * The border mainly gets feat2, while the center gets feat1
                                                 */
                                                if (distance(ty, tx, y, x) > width)
-                                                       c_ptr->feat = feat2;
+                                                       g_ptr->feat = feat2;
                                                else
-                                                       c_ptr->feat = feat1;
+                                                       g_ptr->feat = feat1;
 
                                                /* Clear garbage of hidden trap or door */
-                                               c_ptr->mimic = 0;
+                                               g_ptr->mimic = 0;
 
                                                /* Lava terrain glows */
                                                if (have_flag(f_info[feat1].flags, FF_LAVA))
                                                {
-                                                       if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) c_ptr->info |= CAVE_GLOW;
+                                                       if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) g_ptr->info |= CAVE_GLOW;
                                                }
 
                                                /* Hack -- don't teleport here */
-                                               c_ptr->info |= CAVE_ICKY;
+                                               g_ptr->info |= CAVE_ICKY;
                                        }
                                }
 
@@ -155,7 +157,7 @@ static void recursive_river(POSITION x1, POSITION y1, POSITION x2, POSITION y2,
  * @param feat2 境界部地形ID
  * @return なし
  */
-void add_river(IDX feat1, IDX feat2)
+void add_river(FEAT_IDX feat1, FEAT_IDX feat2)
 {
        POSITION y2, x2;
        POSITION y1 = 0, x1 = 0;
@@ -163,8 +165,8 @@ void add_river(IDX feat1, IDX feat2)
 
 
        /* Hack -- Choose starting point */
-       y2 = randint1(cur_hgt / 2 - 2) + cur_hgt / 2;
-       x2 = randint1(cur_wid / 2 - 2) + cur_wid / 2;
+       y2 = randint1(current_floor_ptr->height / 2 - 2) + current_floor_ptr->height / 2;
+       x2 = randint1(current_floor_ptr->width / 2 - 2) + current_floor_ptr->width / 2;
 
        /* Hack -- Choose ending point somewhere on boundary */
        switch(randint1(4))
@@ -172,7 +174,7 @@ void add_river(IDX feat1, IDX feat2)
                case 1:
                {
                        /* top boundary */
-                       x1 = randint1(cur_wid-2)+1;
+                       x1 = randint1(current_floor_ptr->width-2)+1;
                        y1 = 1;
                        break;
                }
@@ -180,21 +182,21 @@ void add_river(IDX feat1, IDX feat2)
                {
                        /* left boundary */
                        x1 = 1;
-                       y1 = randint1(cur_hgt-2)+1;
+                       y1 = randint1(current_floor_ptr->height-2)+1;
                        break;
                }
                case 3:
                {
                        /* right boundary */
-                       x1 = cur_wid-1;
-                       y1 = randint1(cur_hgt-2)+1;
+                       x1 = current_floor_ptr->width-1;
+                       y1 = randint1(current_floor_ptr->height-2)+1;
                        break;
                }
                case 4:
                {
                        /* bottom boundary */
-                       x1 = randint1(cur_wid-2)+1;
-                       y1 = cur_hgt-1;
+                       x1 = randint1(current_floor_ptr->width-2)+1;
+                       y1 = current_floor_ptr->height-1;
                        break;
                }
        }
@@ -226,13 +228,14 @@ void add_river(IDX feat1, IDX feat2)
  * hidden gold types are currently unused.
  * </pre>
  */
-void build_streamer(IDX feat, int chance)
+void build_streamer(FEAT_IDX feat, int chance)
 {
-       int             i, tx, ty;
-       int             y, x, dir;
+       int i;
+       POSITION y, x, tx, ty;
+       DIRECTION dir;
        int dummy = 0;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
        feature_type *f_ptr;
 
        feature_type *streamer_ptr = &f_info[feat];
@@ -240,8 +243,8 @@ void build_streamer(IDX feat, int chance)
        bool streamer_may_have_gold = have_flag(streamer_ptr->flags, FF_MAY_HAVE_GOLD);
 
        /* Hack -- Choose starting point */
-       y = rand_spread(cur_hgt / 2, cur_hgt / 6);
-       x = rand_spread(cur_wid / 2, cur_wid / 6);
+       y = rand_spread(current_floor_ptr->height / 2, current_floor_ptr->height / 6);
+       x = rand_spread(current_floor_ptr->width / 2, current_floor_ptr->width / 6);
 
        /* Choose a random compass direction */
        dir = randint0(8);
@@ -264,8 +267,8 @@ void build_streamer(IDX feat, int chance)
                                if (!in_bounds2(ty, tx)) continue;
                                break;
                        }
-                       c_ptr = &cave[ty][tx];
-                       f_ptr = &f_info[c_ptr->feat];
+                       g_ptr = &current_floor_ptr->grid_array[ty][tx];
+                       f_ptr = &f_info[g_ptr->feat];
 
                        if (have_flag(f_ptr->flags, FF_MOVE) && (have_flag(f_ptr->flags, FF_WATER) || have_flag(f_ptr->flags, FF_LAVA)))
                                continue;
@@ -276,26 +279,24 @@ void build_streamer(IDX feat, int chance)
                        /* Only convert "granite" walls */
                        if (streamer_is_wall)
                        {
-                               if (!is_extra_grid(c_ptr) && !is_inner_grid(c_ptr) && !is_outer_grid(c_ptr) && !is_solid_grid(c_ptr)) continue;
-                               if (is_closed_door(c_ptr->feat)) continue;
+                               if (!is_extra_grid(g_ptr) && !is_inner_grid(g_ptr) && !is_outer_grid(g_ptr) && !is_solid_grid(g_ptr)) continue;
+                               if (is_closed_door(g_ptr->feat)) continue;
                        }
 
-                       if (c_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[m_list[c_ptr->m_idx].r_idx], 0)))
+                       if (g_ptr->m_idx && !(have_flag(streamer_ptr->flags, FF_PLACE) && monster_can_cross_terrain(feat, &r_info[current_floor_ptr->m_list[g_ptr->m_idx].r_idx], 0)))
                        {
                                /* Delete the monster (if any) */
                                delete_monster(ty, tx);
                        }
 
-                       if (c_ptr->o_idx && !have_flag(streamer_ptr->flags, FF_DROP))
+                       if (g_ptr->o_idx && !have_flag(streamer_ptr->flags, FF_DROP))
                        {
                                OBJECT_IDX this_o_idx, next_o_idx = 0;
 
                                /* Scan all objects in the grid */
-                               for (this_o_idx = c_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
+                               for (this_o_idx = g_ptr->o_idx; this_o_idx; this_o_idx = next_o_idx)
                                {
-                                       object_type *o_ptr = &o_list[this_o_idx];
-
-                                       /* Acquire next object */
+                                       object_type *o_ptr = &current_floor_ptr->o_list[this_o_idx];
                                        next_o_idx = o_ptr->next_o_idx;
 
                                        /* Hack -- Preserve unknown artifacts */
@@ -319,15 +320,14 @@ void build_streamer(IDX feat, int chance)
                                        }
                                }
 
-                               /* Delete objects */
                                delete_object(ty, tx);
                        }
 
                        /* Clear previous contents, add proper vein type */
-                       c_ptr->feat = feat;
+                       g_ptr->feat = feat;
 
                        /* Paranoia: Clear mimic field */
-                       c_ptr->mimic = 0;
+                       g_ptr->mimic = 0;
 
                        if (streamer_may_have_gold)
                        {
@@ -383,7 +383,7 @@ void build_streamer(IDX feat, int chance)
 void place_trees(POSITION x, POSITION y)
 {
        int i, j;
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        /* place trees/ rubble in ovalish distribution */
        for (i = x - 3; i < x + 4; i++)
@@ -391,13 +391,13 @@ void place_trees(POSITION x, POSITION y)
                for (j = y - 3; j < y + 4; j++)
                {
                        if (!in_bounds(j, i)) continue;
-                       c_ptr = &cave[j][i];
+                       g_ptr = &current_floor_ptr->grid_array[j][i];
 
-                       if (c_ptr->info & CAVE_ICKY) continue;
-                       if (c_ptr->o_idx) continue;
+                       if (g_ptr->info & CAVE_ICKY) continue;
+                       if (g_ptr->o_idx) continue;
 
                        /* Want square to be in the circle and accessable. */
-                       if ((distance(j, i, y, x) < 4) && !cave_perma_grid(c_ptr))
+                       if ((distance(j, i, y, x) < 4) && !cave_perma_grid(g_ptr))
                        {
                                /*
                                 * Clear previous contents, add feature
@@ -406,18 +406,18 @@ void place_trees(POSITION x, POSITION y)
                                if ((distance(j, i, y, x) > 1) || (randint1(100) < 25))
                                {
                                        if (randint1(100) < 75)
-                                               cave[j][i].feat = feat_tree;
+                                               current_floor_ptr->grid_array[j][i].feat = feat_tree;
                                }
                                else
                                {
-                                       cave[j][i].feat = feat_rubble;
+                                       current_floor_ptr->grid_array[j][i].feat = feat_rubble;
                                }
 
                                /* Clear garbage of hidden trap or door */
-                               c_ptr->mimic = 0;
+                               g_ptr->mimic = 0;
 
                                /* Light area since is open above */
-                               if (!(d_info[dungeon_type].flags1 & DF1_DARKNESS)) cave[j][i].info |= (CAVE_GLOW | CAVE_ROOM);
+                               if (!(d_info[p_ptr->dungeon_idx].flags1 & DF1_DARKNESS)) current_floor_ptr->grid_array[j][i].info |= (CAVE_GLOW | CAVE_ROOM);
                        }
                }
        }
@@ -426,7 +426,7 @@ void place_trees(POSITION x, POSITION y)
        if (!ironman_downward && one_in_(3))
        {
                /* up stair */
-               cave[y][x].feat = feat_up_stair;
+               current_floor_ptr->grid_array[y][x].feat = feat_up_stair;
        }
 }
 
@@ -448,8 +448,8 @@ void destroy_level(void)
        for (n = 0; n < randint1(5); n++)
        {
                /* Pick an epi-center */
-               x1 = rand_range(5, cur_wid - 1 - 5);
-               y1 = rand_range(5, cur_hgt - 1 - 5);
+               x1 = rand_range(5, current_floor_ptr->width - 1 - 5);
+               y1 = rand_range(5, current_floor_ptr->height - 1 - 5);
 
                (void)destroy_area(y1, x1, 15, TRUE);
        }