summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/edit/misc.txt3
-rw-r--r--lib/mods/theme/edit/misc.txt3
-rw-r--r--src/birth.cc61
-rw-r--r--src/cmd1.cc3
-rw-r--r--src/cmd2.cc16
-rw-r--r--src/cmd4.cc15
-rw-r--r--src/cmd6.cc3
-rw-r--r--src/dungeon.cc8
-rw-r--r--src/files.cc32
-rw-r--r--src/game_edit_data.hpp6
-rw-r--r--src/generate.cc40
-rw-r--r--src/init1.cc49
-rw-r--r--src/init2.cc22
-rw-r--r--src/levels.cc23
-rw-r--r--src/loadsave.cc18
-rw-r--r--src/monster2.cc8
-rw-r--r--src/object1.cc2
-rw-r--r--src/object2.cc4
-rw-r--r--src/player_type.hpp2
-rw-r--r--src/q_god.cc22
-rw-r--r--src/q_rand.cc9
-rw-r--r--src/q_thrain.cc3
-rw-r--r--src/spells1.cc3
-rw-r--r--src/spells2.cc18
-rw-r--r--src/traps.cc5
-rw-r--r--src/variable.cc10
-rw-r--r--src/variable.hpp3
-rw-r--r--src/wizard2.cc6
-rw-r--r--src/xtra1.cc4
-rw-r--r--src/xtra2.cc4
30 files changed, 274 insertions, 131 deletions
diff --git a/lib/edit/misc.txt b/lib/edit/misc.txt
index 4ad6829e..69f02bdb 100644
--- a/lib/edit/misc.txt
+++ b/lib/edit/misc.txt
@@ -36,9 +36,6 @@ M:s:10
# Maximum number of ego-items in e_info.txt
M:E:200
-# Maximum number of dungeon types in d_info.txt
-M:D:31
-
# Maximum number of trap types in tr_info.txt
M:U:176
diff --git a/lib/mods/theme/edit/misc.txt b/lib/mods/theme/edit/misc.txt
index 59b86e90..8c5aceec 100644
--- a/lib/mods/theme/edit/misc.txt
+++ b/lib/mods/theme/edit/misc.txt
@@ -36,9 +36,6 @@ M:s:17
# Maximum number of ego-items in e_info.txt
M:E:238
-# Maximum number of dungeon types in d_info.txt
-M:D:41
-
# Maximum number of trap types in tr_info.txt
M:U:176
diff --git a/src/birth.cc b/src/birth.cc
index 0d8a5e20..2106527c 100644
--- a/src/birth.cc
+++ b/src/birth.cc
@@ -719,8 +719,7 @@ static void birth_put_stats(void)
*/
static void player_wipe(void)
{
- int i, j;
-
+ auto const &d_info = game->edit_data.d_info;
/* Wipe special levels */
wipe_saved();
@@ -735,9 +734,9 @@ static void player_wipe(void)
p_ptr->lives = 0;
/* Wipe the history */
- for (i = 0; i < 4; i++)
+ for (std::size_t i = 0; i < 4; i++)
{
- for (j = 0; j < 60; j++)
+ for (std::size_t j = 0; j < 60; j++)
{
if (j < 59) history[i][j] = ' ';
else history[i][j] = '\0';
@@ -745,22 +744,22 @@ static void player_wipe(void)
}
/* Wipe the towns */
- for (i = 0; i < max_d_idx; i++)
+ for (std::size_t i = 0; i < d_info.size(); i++)
{
- for (j = 0; j < MAX_DUNGEON_DEPTH; j++)
+ for (std::size_t j = 0; j < MAX_DUNGEON_DEPTH; j++)
{
special_lvl[j][i] = 0;
}
}
/* Wipe the towns */
- for (i = max_real_towns + 1; i < max_towns; i++)
+ for (std::size_t i = max_real_towns + 1; i < max_towns; i++)
{
town_info[i].flags = 0;
}
/* Wipe the quests */
- for (i = 0; i < MAX_Q_IDX; i++)
+ for (std::size_t i = 0; i < MAX_Q_IDX; i++)
{
quest[i].status = QUEST_STATUS_UNTAKEN;
for (auto &quest_data : quest[i].data)
@@ -774,7 +773,7 @@ static void player_wipe(void)
equip_cnt = 0;
/* Clear the inventory */
- for (i = 0; i < INVEN_TOTAL; i++)
+ for (std::size_t i = 0; i < INVEN_TOTAL; i++)
{
object_wipe(&p_ptr->inventory[i]);
}
@@ -783,14 +782,14 @@ static void player_wipe(void)
init_randart();
/* Start with no artifacts made yet */
- for (i = 0; i < max_a_idx; i++)
+ for (std::size_t i = 0; i < max_a_idx; i++)
{
artifact_type *a_ptr = &a_info[i];
a_ptr->cur_num = 0;
}
/* Reset the "objects" */
- for (i = 1; i < max_k_idx; i++)
+ for (std::size_t i = 1; i < max_k_idx; i++)
{
object_kind *k_ptr = &k_info[i];
@@ -806,7 +805,7 @@ static void player_wipe(void)
/* Reset the "monsters" */
- for (i = 1; i < max_r_idx; i++)
+ for (std::size_t i = 1; i < max_r_idx; i++)
{
monster_race *r_ptr = &r_info[i];
@@ -843,7 +842,7 @@ static void player_wipe(void)
wizard = 0;
/* Clear the fate */
- for (i = 0; i < MAX_FATES; i++)
+ for (std::size_t i = 0; i < MAX_FATES; i++)
{
fates[i].fate = 0;
}
@@ -871,7 +870,7 @@ static void player_wipe(void)
doppleganger = 0;
/* Wipe the recall depths */
- for (i = 0; i < max_d_idx; i++)
+ for (std::size_t i = 0; i < d_info.size(); i++)
{
max_dlv[i] = 0;
}
@@ -883,7 +882,7 @@ static void player_wipe(void)
}
/* Wipe the known traps list */
- for (i = 0; i < max_t_idx; i++)
+ for (std::size_t i = 0; i < max_t_idx; i++)
{
t_info[i].known = 0;
t_info[i].ident = FALSE;
@@ -897,7 +896,7 @@ static void player_wipe(void)
p_ptr->allow_one_death = 0;
/* Wipe the power list */
- for (i = 0; i < POWER_MAX; i++)
+ for (std::size_t i = 0; i < POWER_MAX; i++)
{
p_ptr->powers_mod[i] = 0;
}
@@ -1496,6 +1495,7 @@ static bool_ player_birth_aux_ask()
auto &class_info = game->edit_data.class_info;
auto const &race_info = game->edit_data.race_info;
auto const &race_mod_info = game->edit_data.race_mod_info;
+ auto const &d_info = game->edit_data.d_info;
int k, n, v, sel;
@@ -3055,7 +3055,10 @@ static void init_town(int t_idx)
*/
void player_birth(void)
{
- int i, j, rtown = TOWN_RANDOM;
+ auto &d_info = game->edit_data.d_info;
+
+ /* Starting index for generated towns */
+ std::size_t rtown = TOWN_RANDOM;
/* Validate the bg[] table */
validate_bg();
@@ -3081,9 +3084,11 @@ void player_birth(void)
apply_level_abilities(1);
/* Complete the god */
- i = p_ptr->pgod;
- p_ptr->pgod = 0;
- follow_god(i, TRUE);
+ {
+ byte i = p_ptr->pgod;
+ p_ptr->pgod = 0;
+ follow_god(i, TRUE);
+ }
/* Select the default melee type */
select_default_melee();
@@ -3102,9 +3107,9 @@ void player_birth(void)
player_outfit();
/* Initialize random towns in the dungeons */
- for (i = 0; i < max_d_idx; i++)
+ for (std::size_t i = 0; i < d_info.size(); i++)
{
- dungeon_info_type *d_ptr = &d_info[i];
+ auto d_ptr = &d_info[i];
int num = 0, z;
d_ptr->t_num = 0;
@@ -3125,15 +3130,17 @@ void player_birth(void)
while (TRUE)
{
- int j;
bool_ ok = TRUE;
lev = rand_range(d_ptr->mindepth, d_ptr->maxdepth - 1);
/* Be sure it wasnt already used */
- for (j = 0; j < num; j++)
+ for (int j = 0; j < num; j++)
{
- if (d_ptr->t_level[j] == lev) ok = FALSE;
+ if (d_ptr->t_level[j] == lev)
+ {
+ ok = FALSE;
+ }
}
/* Ok found one */
@@ -3159,7 +3166,7 @@ void player_birth(void)
}
/* Init the towns */
- for (i = 1; i < max_towns; i++)
+ for (std::size_t i = 1; i < max_towns; i++)
{
/* Not destroyed ! yet .. ;) */
town_info[i].destroyed = FALSE;
@@ -3170,7 +3177,7 @@ void player_birth(void)
create_stores_stock(i);
/* Init the stores */
- for (j = 0; j < max_st_idx; j++)
+ for (std::size_t j = 0; j < max_st_idx; j++)
{
/* Initialize */
store_init(i, j);
diff --git a/src/cmd1.cc b/src/cmd1.cc
index c0283512..7d53fbef 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -16,6 +16,7 @@
#include "feature_flag.hpp"
#include "feature_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "gods.hpp"
#include "hooks.hpp"
#include "hook_move_in.hpp"
@@ -2724,6 +2725,8 @@ static bool_ easy_open_door(int y, int x)
*/
void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
{
+ auto const &d_info = game->edit_data.d_info;
+
int y, x, tmp;
cave_type *c_ptr = &cave[p_ptr->py][p_ptr->px];
diff --git a/src/cmd2.cc b/src/cmd2.cc
index eccf37f0..c581d89b 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -164,13 +164,15 @@ static bool ask_leave()
*/
void do_cmd_go_up(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
bool_ go_up = FALSE, go_up_many = FALSE, prob_traveling = FALSE;
cave_type *c_ptr;
int oldl = dun_level;
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
/* Player grid */
@@ -358,6 +360,8 @@ static bool_ between_effect(void)
*/
void do_cmd_go_down(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
cave_type *c_ptr;
bool_ go_down = FALSE, go_down_many = FALSE, prob_traveling = FALSE;
@@ -368,7 +372,7 @@ void do_cmd_go_down(void)
int old_dun = dun_level;
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
/* MUST be actived now */
@@ -513,7 +517,7 @@ void do_cmd_go_down(void)
{
if (d_info[c_ptr->special].min_plev <= p_ptr->lev)
{
- dungeon_info_type *d_ptr = &d_info[c_ptr->special];
+ auto d_ptr = &d_info[c_ptr->special];
/* Do the lua scripts refuse ? ;) */
{
@@ -649,6 +653,8 @@ static s16b chest_check(int y, int x)
*/
static void chest_death(int y, int x, s16b o_idx)
{
+ auto const &d_info = game->edit_data.d_info;
+
int number;
bool_ small;
@@ -1458,6 +1464,8 @@ static bool_ twall(int y, int x, byte feat)
*/
static bool_ do_cmd_tunnel_aux(int y, int x, int dir)
{
+ auto const &d_info = game->edit_data.d_info;
+
int skill_req = 0, skill_req_1pct = 0;
cave_type *c_ptr = &cave[y][x];
@@ -4223,6 +4231,8 @@ void do_cmd_boomerang(void)
static bool_ tport_vertically(bool_ how)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* quest? */
if (p_ptr->inside_quest)
{
diff --git a/src/cmd4.cc b/src/cmd4.cc
index 12d47324..b06947dc 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -14,6 +14,7 @@
#include "dungeon_info_type.hpp"
#include "feature_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "hooks.hpp"
#include "init1.hpp"
#include "levels.hpp"
@@ -2722,6 +2723,8 @@ static cptr do_cmd_feeling_text[11] =
*/
void do_cmd_feeling(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Verify the feeling */
if (feeling < 0) feeling = 0;
if (feeling > 10) feeling = 10;
@@ -2763,7 +2766,7 @@ void do_cmd_feeling(void)
{
/* This could be simplified with a correct p_ptr->town_num */
int i, town_level = 0;
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
/* Is it a town level ? */
for (i = 0; i < TOWN_DUNGEON; i++)
@@ -3625,10 +3628,12 @@ static void do_cmd_knowledge_objects(void)
*/
static void do_cmd_knowledge_dungeons(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
fmt::MemoryWriter w;
/* Scan all dungeons */
- for (int y = 1; y < max_d_idx; y++)
+ for (std::size_t y = 1; y < d_info.size(); y++)
{
/* The dungeon has a valid recall depth set */
if (max_dlv[y])
@@ -3651,12 +3656,14 @@ static void do_cmd_knowledge_dungeons(void)
*/
void do_cmd_knowledge_towns(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
fmt::MemoryWriter w;
/* Scan all dungeons */
- for (int i = 0; i < max_d_idx; i++)
+ for (auto const &d_ref: d_info)
{
- dungeon_info_type *d_ptr = &d_info[i];
+ auto d_ptr = &d_ref;
/* Scan all dungeon town slots */
for (int j = 0; j < TOWN_DUNGEON; j++)
diff --git a/src/cmd6.cc b/src/cmd6.cc
index 393261bf..e52d1e32 100644
--- a/src/cmd6.cc
+++ b/src/cmd6.cc
@@ -18,6 +18,7 @@
#include "dungeon_info_type.hpp"
#include "ego_item_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "hook_eat_in.hpp"
#include "hook_eat_out.hpp"
#include "hooks.hpp"
@@ -2867,6 +2868,8 @@ static object_filter_t const &item_tester_hook_readable()
*/
void do_cmd_read_scroll(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Check some conditions */
if (p_ptr->blind)
{
diff --git a/src/dungeon.cc b/src/dungeon.cc
index 6f1c8c5a..a2696236 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -1215,6 +1215,8 @@ static void process_world_gods()
*/
static void process_world(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
timer_type *t_ptr;
int x, y, i, j;
@@ -1223,7 +1225,7 @@ static void process_world(void)
bool_ cave_no_regen = FALSE;
int upkeep_factor = 0;
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
cave_type *c_ptr;
@@ -4636,6 +4638,8 @@ static void process_player(void)
*/
static void dungeon(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Reset various flags */
hack_mind = FALSE;
@@ -5054,6 +5058,8 @@ static void load_all_pref_files(void)
*/
void play_game()
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, tmp_dun;
bool_ cheat_death = FALSE;
diff --git a/src/files.cc b/src/files.cc
index cec925df..d85a7dbf 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -2325,6 +2325,7 @@ void display_player(int mode)
cptr describe_player_location()
{
auto const &wilderness = game->wilderness;
+ auto const &d_info = game->edit_data.d_info;
int i;
static char desc[80];
@@ -2563,6 +2564,8 @@ static bool_ file_character_check_stores(std::unordered_set<store_type *> *seen_
*/
errr file_character(cptr name, bool_ full)
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, j, x, y;
byte a;
char c;
@@ -2691,7 +2694,7 @@ errr file_character(cptr name, bool_ full)
fprintf(fff, "\n Always unusual rooms: OFF");
fprintf(fff, "\n\n Recall Depth:");
- for (y = 1; y < max_d_idx; y++)
+ for (y = 1; y < static_cast<int>(d_info.size()); y++)
{
if (max_dlv[y])
fprintf(fff, "\n %s: Level %d (%d')",
@@ -4011,7 +4014,9 @@ void autosave_checkpoint()
*/
static long total_points(void)
{
- s16b max_dl = 0, i, k;
+ auto const &d_info = game->edit_data.d_info;
+
+ s16b max_dl = 0;
long temp, Total = 0;
long mult = 20; /* was 100. Divided values by 5 because of an overflow error */
long comp_death = (p_ptr->companion_killed * 2 / 5);
@@ -4028,9 +4033,13 @@ static long total_points(void)
if (mult < 2) mult = 2; /* At least 10% of the original score */
/* mult is now between 2 and 40, i.e. 10% and 200% */
- for (i = 0; i < max_d_idx; i++)
+ for (std::size_t i = 0; i < d_info.size(); i++)
+ {
if (max_dlv[i] > max_dl)
+ {
max_dl = max_dlv[i];
+ }
+ }
temp = p_ptr->lev * p_ptr->lev * p_ptr->lev * p_ptr->lev + (100 * max_dl);
@@ -4042,7 +4051,7 @@ static long total_points(void)
temp += p_ptr->au / 5;
/* Completing quest increase score */
- for (i = 0; i < MAX_Q_IDX; i++)
+ for (std::size_t i = 0; i < MAX_Q_IDX; i++)
{
if (quest[i].status >= QUEST_STATUS_COMPLETED)
{
@@ -4056,7 +4065,7 @@ static long total_points(void)
/* The know objects increase the score */
/* Scan the object kinds */
- for (k = 1; k < max_k_idx; k++)
+ for (std::size_t k = 1; k < max_k_idx; k++)
{
object_kind *k_ptr = &k_info[k];
@@ -4079,7 +4088,7 @@ static long total_points(void)
}
}
- for (k = 1; k < max_r_idx; k++)
+ for (std::size_t k = 1; k < max_r_idx; k++)
{
monster_race *r_ptr = &r_info[k];
@@ -5132,13 +5141,16 @@ static void kingly(void)
*/
void wipe_saved()
{
- int d, l, od = dungeon_type, ol = dun_level;
+ auto const &d_info = game->edit_data.d_info;
+
+ int od = dungeon_type;
+ int ol = dun_level;
- for (d = 0; d < max_d_idx; d++)
+ for (std::size_t d = 0; d < d_info.size(); d++)
{
- dungeon_info_type *d_ptr = &d_info[d];
+ auto d_ptr = &d_info[d];
- for (l = d_ptr->mindepth; l <= d_ptr->maxdepth; l++)
+ for (auto l = d_ptr->mindepth; l <= d_ptr->maxdepth; l++)
{
char buf[10];
diff --git a/src/game_edit_data.hpp b/src/game_edit_data.hpp
index bfb2e418..6f1ffa8f 100644
--- a/src/game_edit_data.hpp
+++ b/src/game_edit_data.hpp
@@ -1,5 +1,6 @@
#pragma once
+#include "dungeon_info_type.hpp"
#include "hist_type.hpp"
#include "owner_type.hpp"
#include "player_class.hpp"
@@ -19,6 +20,11 @@
struct GameEditData {
/**
+ * Dungeons
+ */
+ std::vector<dungeon_info_type> d_info;
+
+ /**
* Vaults
*/
std::vector<vault_type> v_info;
diff --git a/src/generate.cc b/src/generate.cc
index 3f6d64c0..a3b3d0bd 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -430,6 +430,8 @@ static void place_up_stairs(int y, int x)
*/
static void place_down_stairs(int y, int x)
{
+ auto const &d_info = game->edit_data.d_info;
+
cave_type *c_ptr = &cave[y][x];
/*
@@ -456,7 +458,9 @@ static void place_down_stairs(int y, int x)
*/
static bool_ is_safe_floor(int y, int x)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
byte feat = cave[y][x].feat;
/* One of the legal floor types */
@@ -886,6 +890,8 @@ static void place_between(int y, int x)
*/
static void place_random_stairs(int y, int x)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Paranoia */
if (!cave_clean_bold(y, x)) return;
@@ -1022,6 +1028,8 @@ static void place_random_door(int y, int x)
*/
static void alloc_stairs(int feat, int num, int walls, int branch)
{
+ auto const &d_info = game->edit_data.d_info;
+
int y, x, i, j, cnt;
/* Place "num" stairs */
@@ -1413,6 +1421,8 @@ static void add_river(int feat1, int feat2)
*/
static void build_streamer(int feat, int chance)
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, tx, ty;
int y, x, dir;
int dummy = 0;
@@ -6126,6 +6136,8 @@ static void build_type12(int by0, int bx0)
*/
static void build_tunnel(int row1, int col1, int row2, int col2, bool_ water)
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, y, x;
int tmp_row, tmp_col;
int row_dir, col_dir;
@@ -6380,6 +6392,8 @@ static void build_tunnel(int row1, int col1, int row2, int col2, bool_ water)
*/
static int next_to_corr(int y1, int x1)
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, y, x, k = 0;
cave_type *c_ptr;
@@ -6684,8 +6698,10 @@ static void fill_level(bool_ use_floor, byte smooth);
*/
bool_ level_generate_dungeon()
{
+ auto const &d_info = game->edit_data.d_info;
+
int i, k, y, x, y1, x1, branch = get_branch();
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
int max_vault_ok = 2;
@@ -7240,7 +7256,9 @@ static void save_all_friends()
*/
static void init_feat_info(void)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
int i;
int cur_depth, max_depth;
int p1, p2;
@@ -7346,6 +7364,8 @@ static void init_feat_info(void)
static void fill_level(bool_ use_floor, byte smooth)
{
+ auto const &d_info = game->edit_data.d_info;
+
int y, x;
int step;
int shift;
@@ -7598,7 +7618,9 @@ static void supersize_grid_tile(int sy, int sx, int ty, int tx)
*/
static bool_ cave_gen(void)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
int max_vault_ok = 2;
@@ -8117,6 +8139,8 @@ static bool_ cave_gen(void)
bool_ build_special_level(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
char buf[80];
int y, x, ystart = 2, xstart = 2;
s16b level;
@@ -8178,6 +8202,8 @@ bool_ build_special_level(void)
*/
static void wipe_special_level(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
s16b level;
char buf[80];
@@ -8204,6 +8230,8 @@ static void wipe_special_level(void)
*/
static void finalise_special_level(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
s16b level;
char buf[80];
@@ -8274,7 +8302,9 @@ static void generate_grid_mana()
*/
void generate_cave(void)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
int tester_1, tester_2;
int y, x, num, i;
bool_ loaded = FALSE;
diff --git a/src/init1.cc b/src/init1.cc
index afd256a4..5fd257b0 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -5113,15 +5113,14 @@ errr grab_one_dungeon_flag(dungeon_flag_set *flags, const char *str)
*/
errr init_d_info_txt(FILE *fp)
{
- int i, j;
+ auto &d_info = game->edit_data.d_info;
+
char buf[1024];
s16b rule_num = 0;
byte r_char_number = 0;
- char *s;
-
/* Current entry */
dungeon_info_type *d_ptr = NULL;
@@ -5148,7 +5147,7 @@ errr init_d_info_txt(FILE *fp)
if (buf[0] == 'N')
{
/* Find the colon before the name */
- s = strchr(buf + 2, ':');
+ char *s = strchr(buf + 2, ':');
/* Verify that colon */
if (!s) return (1);
@@ -5160,19 +5159,16 @@ errr init_d_info_txt(FILE *fp)
if (!*s) return (1);
/* Get the index */
- i = atoi(buf + 2);
+ int i = atoi(buf + 2);
/* Verify information */
if (i < error_idx) return (4);
- /* Verify information */
- if (i >= max_d_idx) return (2);
-
/* Save the index */
error_idx = i;
/* Point at the "info" */
- d_ptr = &d_info[i];
+ d_ptr = &expand_to_fit_index(d_info, i);
/* Copy name */
assert(!d_ptr->name);
@@ -5191,14 +5187,15 @@ errr init_d_info_txt(FILE *fp)
d_ptr->fill_method = 1;
rule_num = -1;
r_char_number = 0;
- for (j = 0; j < 5; j++)
+ for (std::size_t j = 0; j < 5; j++)
{
- int k;
-
d_ptr->rules[j].mode = DUNGEON_MODE_NONE;
d_ptr->rules[j].percent = 0;
- for (k = 0; k < 5; k++) d_ptr->rules[j].r_char[k] = 0;
+ for (std::size_t k = 0; k < 5; k++)
+ {
+ d_ptr->rules[j].r_char[k] = 0;
+ }
}
/* Set default drop theme */
@@ -5223,7 +5220,7 @@ errr init_d_info_txt(FILE *fp)
d_ptr->short_name[2] = buf[4];
/* Acquire the text */
- s = buf + 6;
+ char *s = buf + 6;
/* Append to description */
strappend(&d_ptr->text, s);
@@ -5369,8 +5366,15 @@ errr init_d_info_txt(FILE *fp)
cptr tmp;
/* Find the next empty blow slot (if any) */
- for (i = 0; i < 4; i++) if ((!d_ptr->d_side[i]) &&
- (!d_ptr->d_dice[i])) break;
+ std::size_t i;
+ for (i = 0; i < 4; i++)
+ {
+ if ((!d_ptr->d_side[i]) &&
+ (!d_ptr->d_dice[i]))
+ {
+ break;
+ }
+ }
/* Oops, no more slots */
if (i == 4) return (1);
@@ -5423,7 +5427,8 @@ errr init_d_info_txt(FILE *fp)
int artif = 0, monst = 0, obj = 0;
int ix = -1, iy = -1, ox = -1, oy = -1;
int fill_method;
- s = buf + 2;
+
+ char const *s = buf + 2;
/* Read dungeon in/out coords */
if (4 == sscanf(s, "WILD_%d_%d__%d_%d", &ix, &iy, &ox, &oy))
@@ -5519,7 +5524,7 @@ errr init_d_info_txt(FILE *fp)
if (buf[0] == 'M')
{
byte r_char;
- s = buf + 2;
+ char const *s = buf + 2;
/* Read monster symbols */
if (1 == sscanf(s, "R_CHAR_%c", &r_char))
@@ -5546,7 +5551,7 @@ errr init_d_info_txt(FILE *fp)
/* Process 'S' for "Spell Flags" (multiple lines) */
if (buf[0] == 'S')
{
- s = buf + 2;
+ char const *s = buf + 2;
/* Parse this entry */
if (0 != grab_one_monster_spell_flag(&d_ptr->rules[rule_num].mspells, s))
@@ -6984,12 +6989,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst
wilderness.height(atoi(zz[1]));
}
- /* Maximum d_idx */
- else if (zz[0][0] == 'D')
- {
- max_d_idx = atoi(zz[1]);
- }
-
return (0);
}
}
diff --git a/src/init2.cc b/src/init2.cc
index f48cc44c..f664ba40 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -438,7 +438,7 @@ namespace {
static void allocate()
{
- d_info = new dungeon_info_type[max_d_idx];
+ // Nothing to do
}
static errr parse(FILE *fp)
@@ -717,7 +717,7 @@ void create_stores_stock(int t)
*/
static errr init_other(void)
{
- int i, n;
+ auto const &d_info = game->edit_data.d_info;
/*** Prepare the "dungeon" information ***/
@@ -743,27 +743,27 @@ static errr init_other(void)
km_list = new monster_type[max_m_idx];
/* Allocate and Wipe the max dungeon level */
- max_dlv = make_array<s16b>(max_d_idx);
+ max_dlv = make_array<s16b>(d_info.size());
/* Allocate and Wipe the special levels */
- for (i = 0; i < MAX_DUNGEON_DEPTH; i++)
+ for (std::size_t i = 0; i < MAX_DUNGEON_DEPTH; i++)
{
- special_lvl[i] = make_array<bool_>(max_d_idx);
+ special_lvl[i] = make_array<bool_>(d_info.size());
}
/* Allocate and wipe each line of the cave */
cave = new cave_type *[MAX_HGT];
- for (i = 0; i < MAX_HGT; i++)
+ for (std::size_t i = 0; i < MAX_HGT; i++)
{
/* Allocate one row of the cave */
cave[i] = new cave_type[MAX_WID];
}
/* Analyze the windows */
- for (n = 0; n < 8; n++)
+ for (std::size_t n = 0; n < 8; n++)
{
/* Analyze the options */
- for (i = 0; i < 32; i++)
+ for (std::size_t i = 0; i < 32; i++)
{
/* Accept */
if (window_flag_desc[i])
@@ -1007,12 +1007,12 @@ static void init_sets_aux()
*/
static void init_guardians(void)
{
- int i;
+ auto const &d_info = game->edit_data.d_info;
/* Scan dungeons */
- for (i = 0; i < max_d_idx; i++)
+ for (std::size_t i = 0; i < d_info.size(); i++)
{
- dungeon_info_type *d_ptr = &d_info[i];
+ auto d_ptr = &d_info[i];
/* Mark the guadian monster */
if (d_ptr->final_guardian)
diff --git a/src/levels.cc b/src/levels.cc
index 726ebd1a..2a1bb3ab 100644
--- a/src/levels.cc
+++ b/src/levels.cc
@@ -9,6 +9,7 @@
#include "levels.hpp"
#include "dungeon_info_type.hpp"
+#include "game.hpp"
#include "init1.hpp"
#include "util.hpp"
#include "util.h"
@@ -78,6 +79,8 @@ static bool_ get_command(const char *file, char comm, char *param)
*/
int get_branch()
{
+ auto const &d_info = game->edit_data.d_info;
+
char file[20], buf[5];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
@@ -95,6 +98,8 @@ int get_branch()
*/
int get_fbranch()
{
+ auto const &d_info = game->edit_data.d_info;
+
char file[20], buf[5];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
@@ -112,6 +117,8 @@ int get_fbranch()
*/
int get_flevel()
{
+ auto const &d_info = game->edit_data.d_info;
+
char file[20], buf[5];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
@@ -129,6 +136,8 @@ int get_flevel()
*/
bool_ get_dungeon_save(char *buf)
{
+ auto const &d_info = game->edit_data.d_info;
+
char file[20];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
@@ -144,8 +153,9 @@ bool_ get_dungeon_save(char *buf)
*/
bool_ get_dungeon_generator(char *buf)
{
- char file[20];
+ auto const &d_info = game->edit_data.d_info;
+ char file[20];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
/* Get and return the level */
@@ -159,8 +169,9 @@ bool_ get_dungeon_generator(char *buf)
*/
bool_ get_dungeon_special(char *buf)
{
- char file[20];
+ auto const &d_info = game->edit_data.d_info;
+ char file[20];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
/* Get and return the level */
@@ -174,8 +185,9 @@ bool_ get_dungeon_special(char *buf)
*/
bool_ get_dungeon_name(char *buf)
{
- char file[20];
+ auto const &d_info = game->edit_data.d_info;
+ char file[20];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
/* Get and return the level */
@@ -189,6 +201,8 @@ bool_ get_dungeon_name(char *buf)
*/
void get_level_flags()
{
+ auto const &d_info = game->edit_data.d_info;
+
char file[20];
char buf[1024], *s, *t;
@@ -226,8 +240,9 @@ void get_level_flags()
*/
bool_ get_level_desc(char *buf)
{
- char file[20];
+ auto const &d_info = game->edit_data.d_info;
+ char file[20];
sprintf(file, "dun%d.%d", dungeon_type, dun_level - d_info[dungeon_type].mindepth);
/* Get and return the level */
diff --git a/src/loadsave.cc b/src/loadsave.cc
index 5354af9a..c100418e 100644
--- a/src/loadsave.cc
+++ b/src/loadsave.cc
@@ -532,6 +532,8 @@ static void note(cptr msg)
static char loaded_game_module[80];
static bool_ do_extra(ls_flag_t flag)
{
+ auto const &d_info = game->edit_data.d_info;
+
do_string(player_name, 32, flag);
do_string(died_from, 80, flag);
@@ -543,14 +545,14 @@ static bool_ do_extra(ls_flag_t flag)
/* Handle the special levels info */
{
- byte tmp8u = max_d_idx;
+ byte tmp8u = d_info.size();
u16b tmp16u = MAX_DUNGEON_DEPTH;
do_byte(&tmp8u, flag);
if (flag == ls_flag_t::LOAD)
{
- if (tmp8u > max_d_idx)
+ if (tmp8u > d_info.size())
{
note(format("Too many dungeon types!", static_cast<int>(tmp8u)));
}
@@ -719,7 +721,7 @@ static bool_ do_extra(ls_flag_t flag)
// Max dungeon levels
{
- byte tmp8u = max_d_idx;
+ byte tmp8u = d_info.size();
do_byte(&tmp8u, flag);
@@ -729,7 +731,7 @@ static bool_ do_extra(ls_flag_t flag)
do_s16b(&tmp16s, flag);
- if ((flag == ls_flag_t::LOAD) && (i <= max_d_idx))
+ if ((flag == ls_flag_t::LOAD) && (i <= d_info.size()))
{
max_dlv[i] = tmp16s;
}
@@ -794,7 +796,7 @@ static bool_ do_extra(ls_flag_t flag)
do_s16b(&p_ptr->tim_invis, flag);
do_s16b(&p_ptr->word_recall, flag);
- do_s16b(&p_ptr->recall_dungeon, flag);
+ do_byte(&p_ptr->recall_dungeon, flag);
do_s16b(&p_ptr->see_infra, flag);
do_s16b(&p_ptr->tim_infra, flag);
do_s16b(&p_ptr->oppose_fire, flag);
@@ -2128,6 +2130,8 @@ static bool do_object_lore(ls_flag_t flag)
static bool do_towns(ls_flag_t flag)
{
+ auto &d_info = game->edit_data.d_info;
+
u16b max_towns_ldsv = max_towns;
do_u16b(&max_towns_ldsv, flag);
@@ -2172,12 +2176,12 @@ static bool do_towns(ls_flag_t flag)
if (flag == ls_flag_t::SAVE)
{
- max_towns_ldsv = max_d_idx;
+ max_towns_ldsv = d_info.size();
}
do_u16b(&max_towns_ldsv, flag);
- if ((flag == ls_flag_t::LOAD) && (max_towns_ldsv > max_d_idx))
+ if ((flag == ls_flag_t::LOAD) && (max_towns_ldsv > d_info.size()))
{
note("Too many dungeon types!");
return false;
diff --git a/src/monster2.cc b/src/monster2.cc
index 3ca14275..c2b615ee 100644
--- a/src/monster2.cc
+++ b/src/monster2.cc
@@ -838,7 +838,9 @@ errr get_mon_num_prep(void)
*/
bool_ apply_rule(monster_race *r_ptr, byte rule)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
if (d_ptr->rules[rule].mode == DUNGEON_MODE_NONE)
{
@@ -886,7 +888,9 @@ bool_ apply_rule(monster_race *r_ptr, byte rule)
bool_ restrict_monster_to_dungeon(int r_idx)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto const &d_info = game->edit_data.d_info;
+
+ auto d_ptr = &d_info[dungeon_type];
monster_race *r_ptr = &r_info[r_idx];
/* Select a random rule */
diff --git a/src/object1.cc b/src/object1.cc
index e0b4f60b..fe777d10 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -2481,6 +2481,8 @@ static void describe_device(object_type *o_ptr)
*/
static cptr object_out_desc_where_found(s16b level, s16b dungeon)
{
+ auto const &d_info = game->edit_data.d_info;
+
static char str[80];
if (dungeon == DUNGEON_WILDERNESS)
diff --git a/src/object2.cc b/src/object2.cc
index ab84a214..913bf4f6 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -4834,6 +4834,8 @@ bool_ make_object(object_type *j_ptr, bool_ good, bool_ great, obj_theme const &
*/
void place_object(int y, int x, bool_ good, bool_ great, int where)
{
+ auto const &d_info = game->edit_data.d_info;
+
s16b o_idx;
cave_type *c_ptr;
@@ -5352,6 +5354,8 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x)
*/
void acquirement(int y1, int x1, int num, bool_ great, bool_ known)
{
+ auto const &d_info = game->edit_data.d_info;
+
object_type *i_ptr;
object_type object_type_body;
diff --git a/src/player_type.hpp b/src/player_type.hpp
index 0e7aa93f..14a9466f 100644
--- a/src/player_type.hpp
+++ b/src/player_type.hpp
@@ -169,7 +169,7 @@ struct player_type
s16b immov_cntr = 0; /* Timed -- Last ``immovable'' command. */
- s16b recall_dungeon = 0; /* Recall in which dungeon */
+ byte recall_dungeon = 0; /* Recall in which dungeon */
s16b word_recall = 0; /* Word of recall counter */
s32b energy = 0; /* Current energy */
diff --git a/src/q_god.cc b/src/q_god.cc
index f5e182cc..cfd5b257 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -422,6 +422,8 @@ static void quest_god_generate_relic()
static void quest_god_set_god_dungeon_attributes_eru()
{
+ auto &d_info = game->edit_data.d_info;
+
/* The Eru temple is based on Meneltarma. */
/* W: Not too many monsters (they'll be tough though, with big
@@ -482,6 +484,8 @@ static void quest_god_set_god_dungeon_attributes_eru()
static void quest_god_set_god_dungeon_attributes_manwe()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Manwe's lost temple is high in the clouds */
/* W: Has average number of monsters. */
@@ -544,6 +548,8 @@ static void quest_god_set_god_dungeon_attributes_manwe()
static void quest_god_set_god_dungeon_attributes_tulkas()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Tulkas dungeon is quite normal, possibly a bit boring to be
* honest. Maybe I should add something radical to it. 'The
* house of Tulkas in the midmost of Valmar was a house of
@@ -589,6 +595,8 @@ static void quest_god_set_god_dungeon_attributes_tulkas()
static void quest_god_set_god_dungeon_attributes_melkor()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Melkors dungeon will be dark, fiery and stuff */
/* Many many monsters! (but prob ADJUST_LEVEL_1_2) */
@@ -642,6 +650,8 @@ static void quest_god_set_god_dungeon_attributes_melkor()
static void quest_god_set_god_dungeon_attributes_yavanna()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Yavannas dungeon will be very natural, tress and stuff. */
d_info[DUNGEON_GOD].min_m_alloc_level = 22;
@@ -693,6 +703,8 @@ static void quest_god_set_god_dungeon_attributes_yavanna()
static void quest_god_set_god_dungeon_attributes_aule()
{
+ auto &d_info = game->edit_data.d_info;
+
d_info[DUNGEON_GOD].min_m_alloc_level = 24;
d_info[DUNGEON_GOD].max_m_alloc_chance = 80;
@@ -735,6 +747,8 @@ static void quest_god_set_god_dungeon_attributes_aule()
static void quest_god_set_god_dungeon_attributes_varda()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Varda lives with Manwe, so high in the clouds */
/* W: Has average number of monsters. */
@@ -794,6 +808,8 @@ static void quest_god_set_god_dungeon_attributes_varda()
static void quest_god_set_god_dungeon_attributes_ulmo()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Ulmo dungeon is basically Tulkas, except with acquatic creatures. */
/* W: but with lots of monsters */
@@ -839,6 +855,8 @@ static void quest_god_set_god_dungeon_attributes_ulmo()
static void quest_god_set_god_dungeon_attributes_mandos()
{
+ auto &d_info = game->edit_data.d_info;
+
/* Mandos dungeon is basically Tulkas, except with undead. */
/* W: but with lots of monsters */
@@ -1093,6 +1111,8 @@ static bool_ quest_god_char_dump_hook(void *, void *in_, void *)
static void set_god_dungeon_attributes()
{
+ auto &d_info = game->edit_data.d_info;
+
/* dungeon properties altered according to which god player is worshipping, */
if (p_ptr->pgod == GOD_ERU)
{
@@ -1138,7 +1158,7 @@ static void set_god_dungeon_attributes()
/* W: All dungeons are 5 levels deep, and created at 2/3 of
* the player clvl when the quest is given */
{
- dungeon_info_type *d_ptr = &d_info[DUNGEON_GOD];
+ auto d_ptr = &d_info[DUNGEON_GOD];
d_ptr->mindepth = cquest_dun_mindepth;
d_ptr->maxdepth = cquest_dun_maxdepth;
d_ptr->min_plev = cquest_dun_minplev;
diff --git a/src/q_rand.cc b/src/q_rand.cc
index 1fed570e..9606ea7b 100644
--- a/src/q_rand.cc
+++ b/src/q_rand.cc
@@ -5,6 +5,7 @@
#include "cave_type.hpp"
#include "dungeon_flag.hpp"
#include "dungeon_info_type.hpp"
+#include "game.hpp"
#include "generate.hpp"
#include "hook_build_room1_in.hpp"
#include "hook_chardump_in.hpp"
@@ -54,6 +55,8 @@ GENERATE_MONSTER_LOOKUP_FN(get_adventurer, "Adventurer")
void initialize_random_quests(int n)
{
+ auto const &d_info = game->edit_data.d_info;
+
int step, lvl, i, k;
int old_type = dungeon_type;
@@ -81,12 +84,10 @@ void initialize_random_quests(int n)
random_quest *q_ptr = &random_quests[rl];
- int j;
-
/* Find the appropriate dungeon */
- for (j = 0; j < max_d_idx; j++)
+ for (std::size_t j = 0; j < d_info.size(); j++)
{
- dungeon_info_type *d_ptr = &d_info[j];
+ auto d_ptr = &d_info[j];
if (!(d_ptr->flags & DF_PRINCIPAL)) continue;
diff --git a/src/q_thrain.cc b/src/q_thrain.cc
index b7eb0756..2ec46cda 100644
--- a/src/q_thrain.cc
+++ b/src/q_thrain.cc
@@ -3,6 +3,7 @@
#include "cave.hpp"
#include "cave_type.hpp"
#include "dungeon_info_type.hpp"
+#include "game.hpp"
#include "generate.hpp"
#include "hook_build_room1_in.hpp"
#include "hook_move_in.hpp"
@@ -238,6 +239,8 @@ static bool_ quest_thrain_turn_hook(void *, void *, void *)
bool_ quest_thrain_init_hook()
{
+ auto const &d_info = game->edit_data.d_info;
+
if (!cquest.data[0])
{
cquest.data[0] = rand_range(d_info[DUNGEON_DOL_GULDUR].mindepth + 1, d_info[DUNGEON_DOL_GULDUR].maxdepth - 1);
diff --git a/src/spells1.cc b/src/spells1.cc
index eb3664cc..ab789a38 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -18,6 +18,7 @@
#include "files.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "gods.hpp"
#include "melee2.hpp"
#include "monster2.hpp"
@@ -6905,6 +6906,8 @@ bool_ unsafe = FALSE;
*/
static bool_ project_p(int who, int r, int y, int x, int dam, int typ, int a_rad)
{
+ auto const &d_info = game->edit_data.d_info;
+
int k = 0, do_move = 0, a = 0, b = 0, x1 = 0, y1 = 0;
/* Hack -- assume obvious */
diff --git a/src/spells2.cc b/src/spells2.cc
index 2b776c4f..2540146e 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -17,6 +17,7 @@
#include "feature_flag.hpp"
#include "feature_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "hook_identify_in.hpp"
#include "hooks.hpp"
#include "melee2.hpp"
@@ -6086,6 +6087,8 @@ static void print_dungeon_batch(std::vector<int> const &dungeon_idxs,
int start,
bool_ mode)
{
+ auto const &d_info = game->edit_data.d_info;
+
char buf[80];
int i, j;
byte attr;
@@ -6094,7 +6097,7 @@ static void print_dungeon_batch(std::vector<int> const &dungeon_idxs,
for (i = 0, j = start; i < 20 && j < static_cast<int>(dungeon_idxs.size()); i++, j++)
{
- dungeon_info_type *d_ptr = &d_info[dungeon_idxs[j]];
+ auto d_ptr = &d_info[dungeon_idxs[j]];
strnfmt(buf, 80, " %c) %-30s", I2A(i), d_ptr->name);
if (mode)
@@ -6117,11 +6120,14 @@ static void print_dungeon_batch(std::vector<int> const &dungeon_idxs,
static int find_dungeon_by_name(char const *name)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Find the index corresponding to the name */
- for (int i = 1; i < max_d_idx; i++)
+ for (std::size_t i = 1; i < d_info.size(); i++)
{
/* Skip non-initialized entries. */
- if (d_info[i].name == nullptr) {
+ if (d_info[i].name == nullptr)
+ {
continue;
}
if (iequals(name, d_info[i].name))
@@ -6135,6 +6141,8 @@ static int find_dungeon_by_name(char const *name)
static int reset_recall_aux()
{
+ auto const &d_info = game->edit_data.d_info;
+
char which;
int start = 0;
int ret;
@@ -6142,7 +6150,7 @@ static int reset_recall_aux()
// Dungeons available for recall
std::vector<int> dungeons;
- for (size_t i = 1; i < max_d_idx; i++)
+ for (size_t i = 1; i < d_info.size(); i++)
{
/* skip "blocked" dungeons */
if (d_info[i].flags & DF_NO_RECALL) continue;
@@ -6259,6 +6267,8 @@ static int reset_recall_aux()
bool_ reset_recall(bool_ no_trepas_max_depth)
{
+ auto const &d_info = game->edit_data.d_info;
+
int dun, depth, max;
/* Choose dungeon */
diff --git a/src/traps.cc b/src/traps.cc
index 5ba66cbd..067934b9 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -19,6 +19,7 @@
#include "feature_flag.hpp"
#include "feature_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "gods.hpp"
#include "monster2.hpp"
#include "monster_race.hpp"
@@ -1934,12 +1935,14 @@ void player_activate_door_trap(s16b y, s16b x)
*/
void place_trap(int y, int x)
{
+ auto const &d_info = game->edit_data.d_info;
+
s16b trap;
trap_type *t_ptr;
int cnt;
u32b flags;
cave_type *c_ptr = &cave[y][x];
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
/* No traps in town or on first level */
if (dun_level <= 1) return;
diff --git a/src/variable.cc b/src/variable.cc
index b1a8c674..621cdd4c 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -468,11 +468,6 @@ monster_race *r_info;
monster_ego *re_info;
/*
- * The dungeon types arrays
- */
-dungeon_info_type *d_info;
-
-/*
* Player abilities arrays
*/
ability_type *ab_info;
@@ -655,11 +650,6 @@ u16b max_a_idx;
u16b max_e_idx;
/*
- * Maximum number of dungeon types in d_info.txt
- */
-u16b max_d_idx;
-
-/*
* Maximum number of stores types in st_info.txt
*/
u16b max_st_idx;
diff --git a/src/variable.hpp b/src/variable.hpp
index 4f00f1da..534f9596 100644
--- a/src/variable.hpp
+++ b/src/variable.hpp
@@ -8,7 +8,6 @@
#include "cave_type_fwd.hpp"
#include "deity_type.hpp"
#include "dungeon_flag_set.hpp"
-#include "dungeon_info_type_fwd.hpp"
#include "effect_type.hpp"
#include "ego_item_type_fwd.hpp"
#include "fate.hpp"
@@ -170,7 +169,6 @@ extern artifact_type *a_info;
extern ego_item_type *e_info;
extern monster_race *r_info;
extern monster_ego *re_info;
-extern dungeon_info_type *d_info;
extern trap_type *t_info;
extern wilderness_type_info *wf_info;
extern int wildc2i[256];
@@ -194,7 +192,6 @@ extern u16b max_k_idx;
extern u16b max_f_idx;
extern u16b max_a_idx;
extern u16b max_e_idx;
-extern u16b max_d_idx;
extern u16b max_o_idx;
extern u16b max_m_idx;
extern u16b max_t_idx;
diff --git a/src/wizard2.cc b/src/wizard2.cc
index dd0d50e8..5c4ff5cd 100644
--- a/src/wizard2.cc
+++ b/src/wizard2.cc
@@ -1301,6 +1301,8 @@ void do_cmd_wiz_cure_all(void)
*/
static void do_cmd_wiz_jump(void)
{
+ auto const &d_info = game->edit_data.d_info;
+
/* Ask for level */
if (command_arg <= 0)
{
@@ -1509,6 +1511,8 @@ static void do_cmd_wiz_body(s16b bidx)
*/
void do_cmd_debug()
{
+ auto const &d_info = game->edit_data.d_info;
+
int x, y;
char cmd;
@@ -1569,7 +1573,7 @@ void do_cmd_debug()
/* Change of Dungeon type */
case 'D':
- if ((command_arg >= 0) && (command_arg < max_d_idx))
+ if ((command_arg >= 0) && (std::size_t(command_arg) < d_info.size()))
{
dungeon_type = command_arg;
dun_level = d_info[dungeon_type].mindepth;
diff --git a/src/xtra1.cc b/src/xtra1.cc
index aff76b71..6c9d0a29 100644
--- a/src/xtra1.cc
+++ b/src/xtra1.cc
@@ -539,8 +539,10 @@ static void prt_sp(void)
*/
static void prt_depth(int row, int col)
{
+ auto const &d_info = game->edit_data.d_info;
+
char depths[32];
- dungeon_info_type *d_ptr = &d_info[dungeon_type];
+ auto d_ptr = &d_info[dungeon_type];
if (p_ptr->wild_mode)
{
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 040299ff..496bcbf0 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -2400,6 +2400,8 @@ static void monster_death_gods(int m_idx, monster_type *m_ptr)
*/
void monster_death(int m_idx)
{
+ auto const &d_info = game->edit_data.d_info;
+
monster_type *m_ptr = &m_list[m_idx];
auto const r_ptr = m_ptr->race();
@@ -3886,6 +3888,8 @@ bool_ target_object(int y, int x, int mode, cptr info, bool_ *boring,
*/
static int target_set_aux(int y, int x, int mode, cptr info)
{
+ auto const &d_info = game->edit_data.d_info;
+
cave_type *c_ptr = &cave[y][x];
cptr s1, s2, s3;