OSDN Git Service

[Refactor] #37353 VARTUE_LARGE, VARTUE_SMALL を avatar.h へ移動.
[hengband/hengband.git] / src / rooms-pitnest.c
index cd3dfa7..1e922f5 100644 (file)
@@ -1,11 +1,16 @@
 #include "angband.h"
+#include "util.h"
+
 #include "grid.h"
-#include "generate.h"
+#include "floor-generate.h"
 #include "rooms.h"
 #include "rooms-pitnest.h"
 #include "monster.h"
 #include "monsterrace-hook.h"
 #include "sort.h"
+#include "floor.h"
+#include "feature.h"
+#include "dungeon.h"
 
 
 
@@ -68,13 +73,13 @@ static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
                if (!n_ptr->name) break;
 
                /* Ignore excessive depth */
-               if (n_ptr->level > dun_level) continue;
+               if (n_ptr->level > current_floor_ptr->dun_level) continue;
 
                /* Not matched with pit/nest flag */
                if (!(allow_flag_mask & (1L << count))) continue;
 
                /* Count this possibility */
-               total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
+               total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
        }
 
        /* Pick a random type */
@@ -87,13 +92,13 @@ static int pick_vault_type(vault_aux_type *l_ptr, BIT_FLAGS16 allow_flag_mask)
                if (!n_ptr->name) break;
 
                /* Ignore excessive depth */
-               if (n_ptr->level > dun_level) continue;
+               if (n_ptr->level > current_floor_ptr->dun_level) continue;
 
                /* Not matched with pit/nest flag */
                if (!(allow_flag_mask & (1L << count))) continue;
 
                /* Count this possibility */
-               total += n_ptr->chance * MAX_DEPTH / (MIN(dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
+               total += n_ptr->chance * MAX_DEPTH / (MIN(current_floor_ptr->dun_level, MAX_DEPTH - 1) - n_ptr->level + 5);
 
                /* Found the type */
                if (tmp < total) break;
@@ -164,6 +169,7 @@ static concptr pit_subtype_string(int type, bool nest)
 *  @param v 未使用
 *  @param a 比較対象参照ID1
 *  @param b 比較対象参照ID2
+*  TODO: to sort.c
 */
 static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -204,6 +210,7 @@ static bool ang_sort_comp_nest_mon_info(vptr u, vptr v, int a, int b)
 * @param v 未使用
 * @param a スワップ対象参照ID1
 * @param b スワップ対象参照ID2
+* TODO: to sort.c
 */
 static void ang_sort_swap_nest_mon_info(vptr u, vptr v, int a, int b)
 {
@@ -284,7 +291,7 @@ bool build_type5(void)
 
        monster_type align;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        int cur_nest_type = pick_vault_type(nest_types, d_info[p_ptr->dungeon_idx].nest);
        vault_aux_type *n_ptr;
@@ -310,7 +317,7 @@ bool build_type5(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 11);
+                       r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -345,26 +352,26 @@ bool build_type5(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       place_floor_grid(g_ptr);
+                       g_ptr->info |= (CAVE_ROOM);
                }
        }
 
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               c_ptr = &cave[y][x1 - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
+               place_outer_grid(g_ptr);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               c_ptr = &cave[y1 - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
+               place_outer_grid(g_ptr);
        }
 
 
@@ -377,18 +384,18 @@ bool build_type5(void)
        /* The inner walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               c_ptr = &cave[y][x1 - 1];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_inner_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
+               place_inner_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
+               place_inner_grid(g_ptr);
        }
 
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               c_ptr = &cave[y1 - 1][x];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_inner_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
+               place_inner_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
+               place_inner_grid(g_ptr);
        }
        for (y = y1; y <= y2; y++)
        {
@@ -428,9 +435,7 @@ bool build_type5(void)
 
        if (cheat_room)
        {
-               ang_sort_comp = ang_sort_comp_nest_mon_info;
-               ang_sort_swap = ang_sort_swap_nest_mon_info;
-               ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE);
+               ang_sort(nest_mon_info, NULL, NUM_NEST_MON_TYPE, ang_sort_comp_nest_mon_info, ang_sort_swap_nest_mon_info);
 
                /* Dump the entries (prevent multi-printing) */
                for (i = 0; i < NUM_NEST_MON_TYPE; i++)
@@ -495,7 +500,7 @@ bool build_type6(void)
 
        monster_type align;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
        vault_aux_type *n_ptr;
@@ -521,7 +526,7 @@ bool build_type6(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 11);
+                       r_idx = get_mon_num(current_floor_ptr->dun_level + 11);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -555,26 +560,26 @@ bool build_type6(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       c_ptr = &cave[y][x];
-                       place_floor_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       place_floor_grid(g_ptr);
+                       g_ptr->info |= (CAVE_ROOM);
                }
        }
 
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               c_ptr = &cave[y][x1 - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
+               place_outer_grid(g_ptr);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               c_ptr = &cave[y1 - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
+               place_outer_grid(g_ptr);
        }
 
        /* Advance to the center room */
@@ -586,17 +591,17 @@ bool build_type6(void)
        /* The inner walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               c_ptr = &cave[y][x1 - 1];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_inner_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
+               place_inner_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
+               place_inner_grid(g_ptr);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               c_ptr = &cave[y1 - 1][x];
-               place_inner_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_inner_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
+               place_inner_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
+               place_inner_grid(g_ptr);
        }
        for (y = y1; y <= y2; y++)
        {
@@ -800,7 +805,7 @@ bool build_type13(void)
 
        monster_type align;
 
-       cave_type *c_ptr;
+       grid_type *g_ptr;
 
        int cur_pit_type = pick_vault_type(pit_types, d_info[p_ptr->dungeon_idx].pit);
        vault_aux_type *n_ptr;
@@ -829,7 +834,7 @@ bool build_type13(void)
                while (attempts--)
                {
                        /* Get a (hard) monster type */
-                       r_idx = get_mon_num(dun_level + 0);
+                       r_idx = get_mon_num(current_floor_ptr->dun_level + 0);
                        r_ptr = &r_info[r_idx];
 
                        /* Decline incorrect alignment */
@@ -863,61 +868,61 @@ bool build_type13(void)
        {
                for (x = x1 - 1; x <= x2 + 1; x++)
                {
-                       c_ptr = &cave[y][x];
-                       place_inner_grid(c_ptr);
-                       c_ptr->info |= (CAVE_ROOM);
+                       g_ptr = &current_floor_ptr->grid_array[y][x];
+                       place_inner_grid(g_ptr);
+                       g_ptr->info |= (CAVE_ROOM);
                }
        }
 
        /* Place the floor area 1 */
        for (x = x1 + 3; x <= x2 - 3; x++)
        {
-               c_ptr = &cave[yval - 2][x];
-               place_floor_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[yval - 2][x];
+               place_floor_grid(g_ptr);
                add_cave_info(yval - 2, x, CAVE_ICKY);
 
-               c_ptr = &cave[yval + 2][x];
-               place_floor_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[yval + 2][x];
+               place_floor_grid(g_ptr);
                add_cave_info(yval + 2, x, CAVE_ICKY);
        }
 
        /* Place the floor area 2 */
        for (x = x1 + 5; x <= x2 - 5; x++)
        {
-               c_ptr = &cave[yval - 3][x];
-               place_floor_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[yval - 3][x];
+               place_floor_grid(g_ptr);
                add_cave_info(yval - 3, x, CAVE_ICKY);
 
-               c_ptr = &cave[yval + 3][x];
-               place_floor_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[yval + 3][x];
+               place_floor_grid(g_ptr);
                add_cave_info(yval + 3, x, CAVE_ICKY);
        }
 
        /* Corridor */
        for (x = x1; x <= x2; x++)
        {
-               c_ptr = &cave[yval][x];
-               place_floor_grid(c_ptr);
-               c_ptr = &cave[y1][x];
-               place_floor_grid(c_ptr);
-               c_ptr = &cave[y2][x];
-               place_floor_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[yval][x];
+               place_floor_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1][x];
+               place_floor_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2][x];
+               place_floor_grid(g_ptr);
        }
 
        /* Place the outer walls */
        for (y = y1 - 1; y <= y2 + 1; y++)
        {
-               c_ptr = &cave[y][x1 - 1];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y][x2 + 1];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x1 - 1];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y][x2 + 1];
+               place_outer_grid(g_ptr);
        }
        for (x = x1 - 1; x <= x2 + 1; x++)
        {
-               c_ptr = &cave[y1 - 1][x];
-               place_outer_grid(c_ptr);
-               c_ptr = &cave[y2 + 1][x];
-               place_outer_grid(c_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y1 - 1][x];
+               place_outer_grid(g_ptr);
+               g_ptr = &current_floor_ptr->grid_array[y2 + 1][x];
+               place_outer_grid(g_ptr);
        }
 
        /* Random corridor */
@@ -949,8 +954,8 @@ bool build_type13(void)
        }
 
        /* Place the wall open trap */
-       cave[yval][xval].mimic = cave[yval][xval].feat;
-       cave[yval][xval].feat = feat_trap_open;
+       current_floor_ptr->grid_array[yval][xval].mimic = current_floor_ptr->grid_array[yval][xval].feat;
+       current_floor_ptr->grid_array[yval][xval].feat = feat_trap_open;
 
        /* Sort the entries */
        for (i = 0; i < 16 - 1; i++)