summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBardur Arantsson <bardur@scientician.net>2016-10-05 18:45:08 +0200
committerBardur Arantsson <bardur@scientician.net>2016-10-05 18:49:38 +0200
commitb9fca0267b1d6a32d57e1fb4387f52c19d1c3fa6 (patch)
treed8c7c6c1df4b2ead1ca4cf200b771245bcd7d3ca
parent0c2f30b56c221a826ba64f0ec864c29d0f717644 (diff)
Move f_info into GameEditData
-rw-r--r--lib/edit/misc.txt3
-rw-r--r--lib/mods/theme/edit/misc.txt3
-rw-r--r--src/cave.cc65
-rw-r--r--src/cmd1.cc15
-rw-r--r--src/cmd2.cc15
-rw-r--r--src/cmd4.cc13
-rw-r--r--src/dungeon.cc21
-rw-r--r--src/feature_type_fwd.hpp3
-rw-r--r--src/files.cc16
-rw-r--r--src/game_edit_data.hpp6
-rw-r--r--src/gen_evol.cc3
-rw-r--r--src/generate.cc16
-rw-r--r--src/init1.cc22
-rw-r--r--src/init2.cc2
-rw-r--r--src/melee2.cc2
-rw-r--r--src/object1.cc10
-rw-r--r--src/object2.cc2
-rw-r--r--src/powers.cc3
-rw-r--r--src/q_dragons.cc3
-rw-r--r--src/q_evil.cc3
-rw-r--r--src/q_fireprof.cc3
-rw-r--r--src/q_god.cc2
-rw-r--r--src/q_haunted.cc3
-rw-r--r--src/q_wolves.cc3
-rw-r--r--src/spells1.cc2
-rw-r--r--src/spells2.cc24
-rw-r--r--src/spells3.cc3
-rw-r--r--src/traps.cc9
-rw-r--r--src/variable.cc10
-rw-r--r--src/variable.hpp3
-rw-r--r--src/wild.cc4
-rw-r--r--src/xtra2.cc3
32 files changed, 185 insertions, 110 deletions
diff --git a/lib/edit/misc.txt b/lib/edit/misc.txt
index 02e286b4..fb7fdbd6 100644
--- a/lib/edit/misc.txt
+++ b/lib/edit/misc.txt
@@ -15,9 +15,6 @@ M:Y:66
# Maximum number of items in k_info.txt
M:K:819
-# Maximum number of terrain features in f_info.txt
-M:F:256
-
# Maximum number of artifacts in a_info.txt
M:A:219
diff --git a/lib/mods/theme/edit/misc.txt b/lib/mods/theme/edit/misc.txt
index 19077acb..47587f9e 100644
--- a/lib/mods/theme/edit/misc.txt
+++ b/lib/mods/theme/edit/misc.txt
@@ -15,9 +15,6 @@ M:Y:66
# Maximum number of items in k_info.txt
M:K:886
-# Maximum number of terrain features in f_info.txt
-M:F:249
-
# Maximum number of artifacts in a_info.txt
M:A:257
diff --git a/src/cave.cc b/src/cave.cc
index 08482dcc..515a66d3 100644
--- a/src/cave.cc
+++ b/src/cave.cc
@@ -70,15 +70,15 @@ int distance(int y1, int x1, int y2, int x2)
*/
static bool_ is_wall(cave_type *c_ptr)
{
- byte feat;
-
+ auto const &f_info = game->edit_data.f_info;
/* Handle feature mimics */
- if (c_ptr->mimic) feat = c_ptr->mimic;
- else feat = c_ptr->feat;
+ byte const feat = c_ptr->mimic
+ ? c_ptr->mimic
+ : c_ptr->feat;
/* Paranoia */
- if (feat >= max_f_idx) return FALSE;
+ if (feat >= f_info.size()) return FALSE;
/* Vanilla floors and doors aren't considered to be walls */
if (feat < FEAT_SECRET) return FALSE;
@@ -850,6 +850,7 @@ static void map_info(int y, int x, byte *ap, char *cp)
{
auto const &st_info = game->edit_data.st_info;
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
byte a;
@@ -867,20 +868,13 @@ static void map_info(int y, int x, byte *ap, char *cp)
auto info = c_ptr->info;
/* Feature code */
- auto feat = c_ptr->feat;
-
- /* Apply "mimic" field */
- if (c_ptr->mimic)
- {
- feat = c_ptr->mimic;
- }
- else
- {
- feat = f_info[feat].mimic;
- }
+ auto const feat = c_ptr->mimic
+ ? c_ptr->mimic
+ : f_info[c_ptr->feat].mimic
+ ;
/* Access floor */
- feature_type *f_ptr = &f_info[feat];
+ auto f_ptr = &f_info[feat];
/**** Layer 1 -- Terrain feature ****/
@@ -1286,6 +1280,7 @@ void map_info_default(int y, int x, byte *ap, char *cp)
{
auto const &st_info = game->edit_data.st_info;
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
byte a;
@@ -1306,17 +1301,9 @@ void map_info_default(int y, int x, byte *ap, char *cp)
auto info = c_ptr->info;
/* Feature code */
- auto feat = c_ptr->feat;
-
- /* Apply "mimic" field */
- if (c_ptr->mimic)
- {
- feat = c_ptr->mimic;
- }
- else
- {
- feat = f_info[feat].mimic;
- }
+ auto const feat = c_ptr->mimic
+ ? c_ptr->mimic
+ : f_info[c_ptr->feat].mimic;
/* Access floor */
feature_type const *f_ptr = &f_info[feat];
@@ -2001,9 +1988,9 @@ static byte priority_table[][2] =
*/
static byte priority(byte a, char c)
{
- int i, p0, p1;
+ auto const &f_info = game->edit_data.f_info;
- feature_type *f_ptr;
+ int i, p0, p1;
/* Scan the table */
for (i = 0; TRUE; i++)
@@ -2018,7 +2005,7 @@ static byte priority(byte a, char c)
p0 = priority_table[i][0];
/* Access the feature */
- f_ptr = &f_info[p0];
+ auto f_ptr = &f_info[p0];
/* Check character and attribute, accept matches */
if ((f_ptr->x_char == c) && (f_ptr->x_attr == a)) return (p1);
@@ -3566,6 +3553,8 @@ void forget_mon_lite(void)
*/
void update_mon_lite(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, y, x, d;
int fy, fx;
@@ -4590,6 +4579,8 @@ bool cave_floor_bold(int y, int x)
*/
bool cave_floor_grid(cave_type const *c)
{
+ auto const &f_info = game->edit_data.f_info;
+
return (f_info[c->feat].flags & FF_FLOOR) && (c->feat != FEAT_MON_TRAP);
}
@@ -4609,6 +4600,8 @@ bool cave_plain_floor_bold(int y, int x)
*/
bool cave_plain_floor_grid(cave_type const *c)
{
+ auto const &f_info = game->edit_data.f_info;
+
return
(f_info[c->feat].flags & FF_FLOOR) &&
!(f_info[c->feat].flags & FF_REMEMBER);
@@ -4635,6 +4628,8 @@ bool cave_sight_bold(int y, int x)
bool cave_sight_grid(cave_type const *c)
{
+ auto const &f_info = game->edit_data.f_info;
+
return !(f_info[c->feat].flags & FF_NO_VISION);
}
@@ -4649,6 +4644,8 @@ bool cave_sight_grid(cave_type const *c)
*/
bool cave_clean_bold(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
return
(f_info[cave[y][x].feat].flags & FF_FLOOR) &&
(cave[y][x].feat != FEAT_MON_TRAP) &&
@@ -4681,6 +4678,8 @@ bool cave_empty_bold(int y, int x)
*/
bool cave_naked_bold(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
return
(f_info[cave[y][x].feat].flags & FF_FLOOR) &&
(cave[y][x].feat != FEAT_MON_TRAP) &&
@@ -4691,6 +4690,8 @@ bool cave_naked_bold(int y, int x)
bool cave_naked_bold2(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
return
(f_info[cave[y][x].feat].flags & FF_FLOOR) &&
(cave[y][x].feat != FEAT_MON_TRAP) &&
@@ -4709,6 +4710,8 @@ bool cave_perma_bold(int y, int x)
bool cave_perma_grid(cave_type const *c)
{
+ auto const &f_info = game->edit_data.f_info;
+
return bool(f_info[c->feat].flags & FF_PERMANENT);
}
diff --git a/src/cmd1.cc b/src/cmd1.cc
index 87ef7a6c..726916c4 100644
--- a/src/cmd1.cc
+++ b/src/cmd1.cc
@@ -2543,6 +2543,7 @@ void py_attack(int y, int x, int max_blow)
bool_ player_can_enter(byte feature)
{
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
bool_ pass_wall;
@@ -2737,6 +2738,7 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
{
auto const &d_info = game->edit_data.d_info;
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
int y, x, tmp;
@@ -3020,11 +3022,10 @@ void move_player_aux(int dir, int do_pickup, int run, bool_ disarm)
/* Wall (or secret door) */
else
{
- int feat;
-
- if (c_ptr->mimic) feat = c_ptr->mimic;
- else
- feat = f_info[c_ptr->feat].mimic;
+ int const feat = c_ptr->mimic
+ ? c_ptr->mimic
+ : f_info[c_ptr->feat].mimic
+ ;
msg_format("You feel %s.", f_info[feat].block);
c_ptr->info |= (CAVE_MARK);
@@ -3271,6 +3272,8 @@ void move_player(int dir, int do_pickup, bool_ disarm)
*/
static int see_obstacle_grid(cave_type *c_ptr)
{
+ auto const &f_info = game->edit_data.f_info;
+
/*
* Hack -- Avoid hitting detected traps, because we cannot rely on
* the CAVE_MARK check below, and traps can be set to nearly
@@ -3630,6 +3633,8 @@ static void run_init(int dir)
*/
static bool_ run_test(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
int prev_dir, new_dir, check_dir = 0;
int row, col;
diff --git a/src/cmd2.cc b/src/cmd2.cc
index 9afcb7b4..8b409f6b 100644
--- a/src/cmd2.cc
+++ b/src/cmd2.cc
@@ -1394,6 +1394,8 @@ void do_cmd_close(void)
*/
static bool_ do_cmd_tunnel_test(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
/* Must have knowledge(execpt on "forget" levels) */
if (!(cave[y][x].info & (CAVE_MARK)))
{
@@ -1475,11 +1477,12 @@ 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;
+ auto const &f_info = game->edit_data.f_info;
int skill_req = 0, skill_req_1pct = 0;
cave_type *c_ptr = &cave[y][x];
- feature_type *f_ptr = &f_info[c_ptr->feat];
+ auto f_ptr = &f_info[c_ptr->feat];
bool_ more = FALSE;
@@ -1920,9 +1923,9 @@ static bool_ do_cmd_disarm_chest(int y, int x, s16b o_idx)
*/
static bool_ do_cmd_disarm_aux(int y, int x, int dir, int do_pickup)
{
- int i, j, power;
+ auto const &f_info = game->edit_data.f_info;
- cave_type *c_ptr;
+ int i, j, power;
cptr name;
@@ -1933,7 +1936,7 @@ static bool_ do_cmd_disarm_aux(int y, int x, int dir, int do_pickup)
energy_use = 100;
/* Get grid and contents */
- c_ptr = &cave[y][x];
+ auto c_ptr = &cave[y][x];
/* Access trap name */
if (t_info[c_ptr->t_idx].ident)
@@ -2353,6 +2356,8 @@ void do_cmd_bash(void)
*/
void do_cmd_alter(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
int y, x, dir;
cave_type *c_ptr;
@@ -2890,6 +2895,8 @@ void do_cmd_stay(int pickup)
*/
void do_cmd_rest(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
/* Can't rest on a Void Jumpgate -- too dangerous */
if (cave[p_ptr->py][p_ptr->px].feat == FEAT_BETWEEN)
{
diff --git a/src/cmd4.cc b/src/cmd4.cc
index 85ed490d..e030d452 100644
--- a/src/cmd4.cc
+++ b/src/cmd4.cc
@@ -2015,6 +2015,7 @@ void do_cmd_macros(void)
void do_cmd_visuals(void)
{
auto &r_info = game->edit_data.r_info;
+ auto &f_info = game->edit_data.f_info;
int i;
@@ -2219,9 +2220,9 @@ void do_cmd_visuals(void)
fprintf(fff, "# Feature attr/char definitions\n\n");
/* Dump features */
- for (i = 0; i < max_f_idx; i++)
+ for (std::size_t f_idx = 0; f_idx < f_info.size(); f_idx++)
{
- feature_type *f_ptr = &f_info[i];
+ auto f_ptr = &f_info[f_idx];
/* Skip non-entries */
if (!f_ptr->name) continue;
@@ -2230,7 +2231,7 @@ void do_cmd_visuals(void)
fprintf(fff, "# %s\n", f_ptr->name);
/* Dump the feature attr/char info */
- fprintf(fff, "F:%d:0x%02X:0x%02X\n\n", i,
+ fprintf(fff, "F:%zu:0x%02X:0x%02X\n\n", f_idx,
(byte)(f_ptr->x_attr), (byte)(f_ptr->x_char));
}
@@ -2365,7 +2366,7 @@ void do_cmd_visuals(void)
/* Hack -- query until done */
while (1)
{
- feature_type *f_ptr = &f_info[f];
+ auto f_ptr = &f_info[f];
byte da = f_ptr->d_attr;
char dc = f_ptr->d_char;
@@ -2400,8 +2401,8 @@ void do_cmd_visuals(void)
if (i == ESCAPE) break;
/* Analyze */
- if (i == 'n') f = (f + max_f_idx + 1) % max_f_idx;
- if (i == 'N') f = (f + max_f_idx - 1) % max_f_idx;
+ if (i == 'n') f = (f + f_info.size() + 1) % f_info.size();
+ if (i == 'N') f = (f + f_info.size() - 1) % f_info.size();
if (i == 'a') f_info[f].x_attr = (ca + 1);
if (i == 'A') f_info[f].x_attr = (ca - 1);
if (i == 'c') f_info[f].x_char = (cc + 1);
diff --git a/src/dungeon.cc b/src/dungeon.cc
index c044021f..96ac89cb 100644
--- a/src/dungeon.cc
+++ b/src/dungeon.cc
@@ -898,9 +898,11 @@ static void check_music()
*/
static void apply_effect(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
cave_type *c_ptr = &cave[y][x];
- feature_type *f_ptr = &f_info[c_ptr->feat];
+ auto f_ptr = &f_info[c_ptr->feat];
if (f_ptr->d_frequency[0] != 0)
@@ -1219,6 +1221,7 @@ static void process_world(void)
{
auto const &d_info = game->edit_data.d_info;
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
timer_type *t_ptr;
@@ -4186,6 +4189,8 @@ static void process_command(void)
*/
static void process_player(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, j;
int speed_use;
@@ -4530,17 +4535,9 @@ static void process_player(void)
for (i = panel_col_min; i <= panel_col_max; i++)
{
cave_type *c_ptr = &cave[j][i];
- feature_type *f_ptr;
-
- /* Apply terrain feature mimics */
- if (c_ptr->mimic)
- {
- f_ptr = &f_info[c_ptr->mimic];
- }
- else
- {
- f_ptr = &f_info[f_info[c_ptr->feat].mimic];
- }
+ auto f_ptr = c_ptr->mimic
+ ? &f_info[c_ptr->mimic]
+ : &f_info[f_info[c_ptr->feat].mimic];
/* Skip normal features */
if (!(f_ptr->flags & FF_ATTR_MULTI))
diff --git a/src/feature_type_fwd.hpp b/src/feature_type_fwd.hpp
deleted file mode 100644
index 168ec6c7..00000000
--- a/src/feature_type_fwd.hpp
+++ /dev/null
@@ -1,3 +0,0 @@
-#pragma once
-
-struct feature_type;
diff --git a/src/files.cc b/src/files.cc
index cfd80362..42d1bed3 100644
--- a/src/files.cc
+++ b/src/files.cc
@@ -220,6 +220,7 @@ errr process_pref_file_aux(char *buf)
auto &st_info = game->edit_data.st_info;
auto &re_info = game->edit_data.re_info;
auto &r_info = game->edit_data.r_info;
+ auto &f_info = game->edit_data.f_info;
int i, j, n1, n2;
@@ -377,13 +378,18 @@ errr process_pref_file_aux(char *buf)
{
if (tokenize(buf + 2, 3, zz, ':', '/') == 3)
{
- feature_type *f_ptr;
- i = (huge)strtol(zz[0], NULL, 0);
+ std::size_t f_idx = strtoul(zz[0], NULL, 0);
n1 = strtol(zz[1], NULL, 0);
n2 = strtol(zz[2], NULL, 0);
- if (i >= max_f_idx) return (1);
- f_ptr = &f_info[i];
- if (n1) f_ptr->x_attr = n1;
+
+ if (f_idx >= f_info.size()) return (1);
+
+ auto f_ptr = &f_info[f_idx];
+
+ if (n1)
+ {
+ f_ptr->x_attr = n1;
+ }
if (n2)
{
f_ptr->x_char = n2;
diff --git a/src/game_edit_data.hpp b/src/game_edit_data.hpp
index 16a97da7..6adb3804 100644
--- a/src/game_edit_data.hpp
+++ b/src/game_edit_data.hpp
@@ -2,6 +2,7 @@
#include "ability_type.hpp"
#include "dungeon_info_type.hpp"
+#include "feature_type.hpp"
#include "hist_type.hpp"
#include "monster_ego.hpp"
#include "monster_race.hpp"
@@ -102,6 +103,11 @@ struct GameEditData {
*/
std::vector<monster_ego> re_info;
+ /*
+ * Terrain features
+ */
+ std::vector<feature_type> f_info;
+
/**
* Wilderness features
*/
diff --git a/src/gen_evol.cc b/src/gen_evol.cc
index 889e7a01..7dca5b9a 100644
--- a/src/gen_evol.cc
+++ b/src/gen_evol.cc
@@ -12,6 +12,7 @@
#include "cave_type.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "generate.hpp"
#include "levels.hpp"
#include "player_type.hpp"
@@ -23,6 +24,8 @@
*/
void evolve_level(bool_ noise)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, j;
int cw = 0, cf = 0;
diff --git a/src/generate.cc b/src/generate.cc
index 9bd01010..6612a888 100644
--- a/src/generate.cc
+++ b/src/generate.cc
@@ -478,6 +478,8 @@ static bool_ is_safe_floor(int y, int x)
*/
void place_new_way(int *y, int *x)
{
+ auto const &f_info = game->edit_data.f_info;
+
int xx, yy;
int x0, x1, x2;
int y0, y1, y2;
@@ -784,7 +786,9 @@ bool_ new_player_spot(int branch)
*/
static int next_to_walls(int y, int x)
{
- int k = 0;
+ auto const &f_info = game->edit_data.f_info;
+
+ int k = 0;
if (f_info[cave[y + 1][x].feat].flags & FF_WALL) k++;
if (f_info[cave[y - 1][x].feat].flags & FF_WALL) k++;
@@ -1506,6 +1510,8 @@ static void build_streamer(int feat, int chance)
*/
static void build_streamer2(int feat, int killwall)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, j, mid, tx, ty;
int y, x, dir;
int poolchance;
@@ -1723,6 +1729,8 @@ static void destroy_level(void)
*/
static bool_ get_is_floor(int x, int y)
{
+ auto const &f_info = game->edit_data.f_info;
+
/* Out of bounds */
if (!in_bounds(y, x)) return (FALSE);
@@ -4298,6 +4306,8 @@ static void fill_hack(int y0, int x0, int y, int x, int xsize, int ysize,
bool_ generate_fracave(int y0, int x0, int xsize, int ysize,
int cutoff, bool_ light, bool_ room)
{
+ auto const &f_info = game->edit_data.f_info;
+
int x, y, i, amount, xhsize, yhsize;
cave_type *c_ptr;
@@ -6467,6 +6477,8 @@ static int next_to_corr(int y1, int x1)
*/
static bool_ possible_doorway(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
/* Count the adjacent corridors */
if (next_to_corr(y, x) >= 2)
{
@@ -6495,6 +6507,8 @@ static bool_ possible_doorway(int y, int x)
*/
static void try_doors(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
bool_ dir_ok[4];
int i, k, n;
int yy, xx;
diff --git a/src/init1.cc b/src/init1.cc
index 3dcee907..d2fef6a9 100644
--- a/src/init1.cc
+++ b/src/init1.cc
@@ -2056,9 +2056,9 @@ static int grab_one_feature_flag(cptr what, feature_flag_set *flags)
*/
errr init_f_info_txt(FILE *fp)
{
- int i;
+ auto &f_info = game->edit_data.f_info;
+
char buf[1024];
- char *s;
/* Current entry */
feature_type *f_ptr = NULL;
@@ -2085,7 +2085,7 @@ errr init_f_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);
@@ -2097,19 +2097,16 @@ errr init_f_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_f_idx) return (2);
-
/* Save the index */
error_idx = i;
/* Point at the "info" */
- f_ptr = &f_info[i];
+ f_ptr = &expand_to_fit_index(f_info, i);
/* Copy name */
assert(!f_ptr->name);
@@ -2133,7 +2130,7 @@ errr init_f_info_txt(FILE *fp)
if (buf[0] == 'D')
{
/* Acquire the text */
- s = buf + 4;
+ const char *s = buf + 4;
switch (buf[2])
{
@@ -2226,6 +2223,7 @@ errr init_f_info_txt(FILE *fp)
{
int side, dice, freq, type;
cptr tmp;
+ int i;
/* Find the next empty blow slot (if any) */
for (i = 0; i < 4; i++) if ((!f_ptr->d_side[i]) &&
@@ -6785,12 +6783,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst
max_k_idx = atoi(zz[1]);
}
- /* Maximum f_idx */
- else if (zz[0][0] == 'F')
- {
- max_f_idx = atoi(zz[1]);
- }
-
/* Maximum a_idx */
else if (zz[0][0] == 'A')
{
diff --git a/src/init2.cc b/src/init2.cc
index 79b5a0a3..950badc3 100644
--- a/src/init2.cc
+++ b/src/init2.cc
@@ -277,7 +277,7 @@ namespace {
static void allocate()
{
- f_info = new feature_type[max_f_idx];
+ // Nothing to do
}
static errr parse(FILE *fp)
diff --git a/src/melee2.cc b/src/melee2.cc
index d1fc3767..415fd478 100644
--- a/src/melee2.cc
+++ b/src/melee2.cc
@@ -5254,6 +5254,8 @@ static bool_ player_invis(monster_type * m_ptr)
*/
static void process_monster(int m_idx, bool_ is_frien)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, d, oy, ox, ny, nx;
int mm[8];
diff --git a/src/object1.cc b/src/object1.cc
index 466488fe..c10a52f9 100644
--- a/src/object1.cc
+++ b/src/object1.cc
@@ -637,17 +637,15 @@ void reset_visuals(void)
auto &race_mod_info = game->edit_data.race_mod_info;
auto &re_info = game->edit_data.re_info;
auto &r_info = game->edit_data.r_info;
+ auto &f_info = game->edit_data.f_info;
int i;
/* Extract some info about terrain features */
- for (i = 0; i < max_f_idx; i++)
+ for (auto &f_ref: f_info)
{
- feature_type *f_ptr = &f_info[i];
-
- /* Assume we will use the underlying values */
- f_ptr->x_attr = f_ptr->d_attr;
- f_ptr->x_char = f_ptr->d_char;
+ f_ref.x_attr = f_ref.d_attr;
+ f_ref.x_char = f_ref.d_char;
}
/* Extract default attr/char code for stores */
diff --git a/src/object2.cc b/src/object2.cc
index eb0a66e8..901bb854 100644
--- a/src/object2.cc
+++ b/src/object2.cc
@@ -5078,6 +5078,8 @@ void place_gold(int y, int x)
*/
s16b drop_near(object_type *j_ptr, int chance, int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, k, d, s;
int bs, bn;
diff --git a/src/powers.cc b/src/powers.cc
index 0c01a0e6..88292e21 100644
--- a/src/powers.cc
+++ b/src/powers.cc
@@ -17,6 +17,7 @@
#include "feature_flag.hpp"
#include "feature_type.hpp"
#include "files.hpp"
+#include "game.hpp"
#include "hooks.hpp"
#include "mimic.hpp"
#include "monster2.hpp"
@@ -129,6 +130,8 @@ static bool_ power_chance(power_type *x_ptr)
static void power_activate(int power)
{
+ auto const &f_info = game->edit_data.f_info;
+
s16b plev = p_ptr->lev;
char ch = 0;
int amber_power = 0;
diff --git a/src/q_dragons.cc b/src/q_dragons.cc
index 2c3faa69..1ed5a97b 100644
--- a/src/q_dragons.cc
+++ b/src/q_dragons.cc
@@ -5,6 +5,7 @@
#include "dungeon_flag.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "hook_quest_finish_in.hpp"
#include "hooks.hpp"
#include "init1.hpp"
@@ -20,6 +21,8 @@
static bool_ quest_dragons_gen_hook(void *, void *, void *)
{
+ auto const &f_info = game->edit_data.f_info;
+
int x, y, i;
int xstart = 2;
int ystart = 2;
diff --git a/src/q_evil.cc b/src/q_evil.cc
index cadaa171..21d608e7 100644
--- a/src/q_evil.cc
+++ b/src/q_evil.cc
@@ -5,6 +5,7 @@
#include "dungeon_flag.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "hook_quest_finish_in.hpp"
#include "hooks.hpp"
#include "init1.hpp"
@@ -20,6 +21,8 @@
static bool_ quest_evil_gen_hook(void *, void *, void *)
{
+ auto const &f_info = game->edit_data.f_info;
+
int x, y, i;
int xstart = 2;
int ystart = 2;
diff --git a/src/q_fireprof.cc b/src/q_fireprof.cc
index 207f306f..03190889 100644
--- a/src/q_fireprof.cc
+++ b/src/q_fireprof.cc
@@ -4,6 +4,7 @@
#include "dungeon_flag.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "hook_get_in.hpp"
#include "hooks.hpp"
#include "lua_bind.hpp"
@@ -470,6 +471,8 @@ std::string quest_fireproof_describe()
static bool_ fireproof_gen_hook(void *, void *, void *)
{
+ auto const &f_info = game->edit_data.f_info;
+
fireproof_settings const *settings = fireproof_get_settings();
/* Only if player doing this quest */
diff --git a/src/q_god.cc b/src/q_god.cc
index 38b911b7..79a25232 100644
--- a/src/q_god.cc
+++ b/src/q_god.cc
@@ -361,6 +361,8 @@ static void quest_god_place_rand_dung()
static void quest_god_generate_relic()
{
+ auto const &f_info = game->edit_data.f_info;
+
int tries = 1000, x = -1, y = -1;
object_type relic;
diff --git a/src/q_haunted.cc b/src/q_haunted.cc
index 902778fc..df90435c 100644
--- a/src/q_haunted.cc
+++ b/src/q_haunted.cc
@@ -5,6 +5,7 @@
#include "dungeon_flag.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "hook_quest_finish_in.hpp"
#include "hooks.hpp"
#include "init1.hpp"
@@ -21,6 +22,8 @@
static bool_ quest_haunted_gen_hook(void *, void *, void *)
{
+ auto const &f_info = game->edit_data.f_info;
+
int x, y, i, m_idx;
int xstart = 2;
int ystart = 2;
diff --git a/src/q_wolves.cc b/src/q_wolves.cc
index 3d83f414..637003dc 100644
--- a/src/q_wolves.cc
+++ b/src/q_wolves.cc
@@ -5,6 +5,7 @@
#include "dungeon_flag.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "hook_quest_finish_in.hpp"
#include "hooks.hpp"
#include "init1.hpp"
@@ -21,6 +22,8 @@
static bool_ quest_wolves_gen_hook(void *, void *, void *)
{
+ auto const &f_info = game->edit_data.f_info;
+
int x, y, i;
int xstart = 2;
int ystart = 2;
diff --git a/src/spells1.cc b/src/spells1.cc
index ed10c525..c11be30b 100644
--- a/src/spells1.cc
+++ b/src/spells1.cc
@@ -2906,6 +2906,7 @@ static int project_m_y;
static bool_ project_f(int who, int r, int y, int x, int dam, int typ)
{
cave_type *c_ptr = &cave[y][x];
+ auto const &f_info = game->edit_data.f_info;
bool_ obvious = FALSE;
@@ -6913,6 +6914,7 @@ 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;
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
int k = 0, do_move = 0, a = 0, b = 0, x1 = 0, y1 = 0;
diff --git a/src/spells2.cc b/src/spells2.cc
index 1cd03430..f918a970 100644
--- a/src/spells2.cc
+++ b/src/spells2.cc
@@ -97,6 +97,8 @@ void grow_things(s16b type, int rad)
*/
void grow_trees(int rad)
{
+ auto const &f_info = game->edit_data.f_info;
+
int a, i, j;
for (a = 0; a < rad * rad + 11; a++)
@@ -119,6 +121,8 @@ void grow_trees(int rad)
*/
void grow_grass(int rad)
{
+ auto const &f_info = game->edit_data.f_info;
+
int a, i, j;
for (a = 0; a < rad * rad + 11; a++)
@@ -5457,6 +5461,8 @@ bool_ trap_creation(void)
bool_ wall_stone(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
cave_type *c_ptr = &cave[y][x];
int flg = PROJECT_GRID | PROJECT_ITEM;
auto const featflags = f_info[c_ptr->feat].flags;
@@ -5993,7 +5999,14 @@ bool_ heal_insanity(int val)
*/
bool_ passwall(int dir, bool_ safe)
{
- int x = p_ptr->px, y = p_ptr->py, ox = p_ptr->px, oy = p_ptr->py, lx = p_ptr->px, ly = p_ptr->py;
+ auto const &f_info = game->edit_data.f_info;
+
+ int x = p_ptr->px;
+ int y = p_ptr->py;
+ int ox = p_ptr->px;
+ int oy = p_ptr->py;
+ int lx = p_ptr->px;
+ int ly = p_ptr->py;
cave_type *c_ptr;
bool_ ok = FALSE;
@@ -6305,6 +6318,8 @@ bool_ reset_recall(bool_ no_trepas_max_depth)
*/
void create_between_gate(int dist, int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
int ii, ij, plev = get_skill(SKILL_CONVEYANCE);
if (dungeon_flags & DF_NO_TELEPORT)
@@ -6408,6 +6423,8 @@ static int rotate_dir(int dir, int mov)
void geomancy_random_wall(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
#define TABLE_SIZE 4
cave_type *c_ptr = &cave[y][x];
int feat = -1;
@@ -6422,7 +6439,8 @@ void geomancy_random_wall(int y, int x)
};
/* Do not destroy permanent things */
- if (f_info[c_ptr->feat].flags & FF_PERMANENT) {
+ if (f_info[c_ptr->feat].flags & FF_PERMANENT)
+ {
return;
}
@@ -6437,6 +6455,8 @@ void geomancy_random_wall(int y, int x)
void geomancy_random_floor(int y, int x, bool_ kill_wall)
{
+ auto const &f_info = game->edit_data.f_info;
+
#define TABLE_SIZE 9
cave_type *c_ptr = &cave[y][x];
int feat = -1;
diff --git a/src/spells3.cc b/src/spells3.cc
index 68b3a2f0..276cfeec 100644
--- a/src/spells3.cc
+++ b/src/spells3.cc
@@ -5,6 +5,7 @@
#include "cmd5.hpp"
#include "feature_flag.hpp"
#include "feature_type.hpp"
+#include "game.hpp"
#include "lua_bind.hpp"
#include "mimic.hpp"
#include "monster2.hpp"
@@ -2726,6 +2727,8 @@ const char *mind_stun_info()
casting_result tempo_magelock()
{
+ auto const &f_info = game->edit_data.f_info;
+
if (get_level_s(MAGELOCK, 50) >= 30)
{
int x,y;
diff --git a/src/traps.cc b/src/traps.cc
index 0f6c1f5d..f5abe202 100644
--- a/src/traps.cc
+++ b/src/traps.cc
@@ -104,6 +104,8 @@ bool_ do_player_trap_call_out(void)
static bool_ do_trap_teleport_away(object_type *i_ptr, s16b y, s16b x)
{
+ auto const &f_info = game->edit_data.f_info;
+
bool_ ident = FALSE;
char o_name[80];
@@ -166,6 +168,8 @@ static bool_ do_trap_teleport_away(object_type *i_ptr, s16b y, s16b x)
*/
static bool_ player_handle_trap_of_walls(void)
{
+ auto const &f_info = game->edit_data.f_info;
+
bool_ ident;
s16b dx, dy, cx, cy;
@@ -1899,6 +1903,8 @@ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item)
void player_activate_door_trap(s16b y, s16b x)
{
+ auto const &f_info = game->edit_data.f_info;
+
cave_type *c_ptr;
bool_ ident = FALSE;
@@ -1936,6 +1942,7 @@ 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;
+ auto const &f_info = game->edit_data.f_info;
s16b trap;
trap_type *t_ptr;
@@ -2055,6 +2062,8 @@ void place_trap_object(object_type *o_ptr)
/* Dangerous trap placing function */
void wiz_place_trap(int y, int x, int idx)
{
+ auto const &f_info = game->edit_data.f_info;
+
cave_type *c_ptr = &cave[y][x];
/* Dangerous enough as it is... */
diff --git a/src/variable.cc b/src/variable.cc
index a58191d5..f8be6224 100644
--- a/src/variable.cc
+++ b/src/variable.cc
@@ -429,11 +429,6 @@ player_spec const *spp_ptr;
/*
- * The terrain feature arrays
- */
-feature_type *f_info;
-
-/*
* The object kind arrays
*/
object_kind *k_info;
@@ -579,11 +574,6 @@ s32b get_level_use_stick = -1;
u16b max_k_idx;
/*
- * Maximum number of terrain features in f_info.txt
- */
-u16b max_f_idx;
-
-/*
* Maximum number of artifacts in a_info.txt
*/
u16b max_a_idx;
diff --git a/src/variable.hpp b/src/variable.hpp
index 70c381b9..9daaf3d9 100644
--- a/src/variable.hpp
+++ b/src/variable.hpp
@@ -10,7 +10,6 @@
#include "effect_type.hpp"
#include "ego_item_type_fwd.hpp"
#include "fate.hpp"
-#include "feature_type_fwd.hpp"
#include "monster_type_fwd.hpp"
#include "object_kind_fwd.hpp"
#include "object_type_fwd.hpp"
@@ -152,7 +151,6 @@ extern player_class const *cp_ptr;
extern player_spec const *spp_ptr;
extern char player_name[32];
extern char player_base[32];
-extern feature_type *f_info;
extern object_kind *k_info;
extern artifact_type *a_info;
extern ego_item_type *e_info;
@@ -169,7 +167,6 @@ extern bool_ (*get_mon_num_hook)(int r_idx);
extern bool_ (*get_mon_num2_hook)(int r_idx);
extern bool_ (*get_obj_num_hook)(int k_idx);
extern u16b max_k_idx;
-extern u16b max_f_idx;
extern u16b max_a_idx;
extern u16b max_e_idx;
extern u16b max_o_idx;
diff --git a/src/wild.cc b/src/wild.cc
index 101e06f5..fd9ed6fd 100644
--- a/src/wild.cc
+++ b/src/wild.cc
@@ -376,6 +376,8 @@ namespace {
*/
void wilderness_gen()
{
+ auto const &f_info = game->edit_data.f_info;
+
int i, y, x, hack_floor;
bool_ daytime;
int xstart = 0;
@@ -942,6 +944,8 @@ static std::vector<std::size_t> get_shops()
/* Generate town borders */
static void set_border(int y, int x)
{
+ auto const &f_info = game->edit_data.f_info;
+
cave_type *c_ptr;
/* Paranoia */
diff --git a/src/xtra2.cc b/src/xtra2.cc
index 482526ef..af25e906 100644
--- a/src/xtra2.cc
+++ b/src/xtra2.cc
@@ -2403,6 +2403,7 @@ 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;
+ auto const &f_info = game->edit_data.f_info;
monster_type *m_ptr = &m_list[m_idx];
@@ -3737,6 +3738,7 @@ static s16b target_pick(point p, int dy, int dx, std::vector<point> const &point
static bool_ target_set_accept(int y, int x)
{
auto const &r_info = game->edit_data.r_info;
+ auto const &f_info = game->edit_data.f_info;
/* Player grid is always interesting */
if ((y == p_ptr->py) && (x == p_ptr->px)) return (TRUE);
@@ -3897,6 +3899,7 @@ static int target_set_aux(int y, int x, int mode, cptr info)
auto const &d_info = game->edit_data.d_info;
auto const &st_info = game->edit_data.st_info;
auto const &wf_info = game->edit_data.wf_info;
+ auto const &f_info = game->edit_data.f_info;
cave_type *c_ptr = &cave[y][x];