From 57bb453a15034c67d04496360b306a5f3bfd0bf2 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move a_info into GameEditData --- src/artifact_type_fwd.hpp | 3 --- src/birth.cc | 6 +++--- src/cmd3.cc | 2 ++ src/cmd4.cc | 14 ++++++-------- src/cmd6.cc | 2 ++ src/game_edit_data.hpp | 6 ++++++ src/generate.cc | 6 ++++-- src/init1.cc | 19 ++++++------------- src/init2.cc | 13 ++++++++----- src/loadsave.cc | 13 ++++++++----- src/monster2.cc | 2 ++ src/object1.cc | 27 +++++++++++++++++++++------ src/object2.cc | 23 +++++++++++++++++------ src/q_one.cc | 3 +++ src/q_rand.cc | 1 + src/q_troll.cc | 3 +++ src/traps.cc | 2 ++ src/variable.cc | 10 ---------- src/variable.hpp | 3 --- src/wizard2.cc | 12 +++++++++--- src/xtra1.cc | 13 +++++++++---- src/xtra2.cc | 3 ++- 22 files changed, 114 insertions(+), 72 deletions(-) delete mode 100644 src/artifact_type_fwd.hpp (limited to 'src') diff --git a/src/artifact_type_fwd.hpp b/src/artifact_type_fwd.hpp deleted file mode 100644 index f3862d5a..00000000 --- a/src/artifact_type_fwd.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -struct artifact_type; diff --git a/src/birth.cc b/src/birth.cc index 65f6389e..63560757 100644 --- a/src/birth.cc +++ b/src/birth.cc @@ -722,6 +722,7 @@ static void player_wipe(void) auto const &d_info = game->edit_data.d_info; auto &r_info = game->edit_data.r_info; auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; /* Wipe special levels */ wipe_saved(); @@ -784,10 +785,9 @@ static void player_wipe(void) init_randart(); /* Start with no artifacts made yet */ - for (std::size_t i = 0; i < max_a_idx; i++) + for (auto &a_ref: a_info) { - artifact_type *a_ptr = &a_info[i]; - a_ptr->cur_num = 0; + a_ref.cur_num = 0; } /* Reset the "objects" */ diff --git a/src/cmd3.cc b/src/cmd3.cc index 0010a6ea..259efd67 100644 --- a/src/cmd3.cc +++ b/src/cmd3.cc @@ -206,6 +206,8 @@ bool_ is_slot_ok(int slot) */ void do_cmd_wield(void) { + auto const &a_info = game->edit_data.a_info; + int item, slot, num = 1; object_type forge; diff --git a/src/cmd4.cc b/src/cmd4.cc index 4ebb73d0..26794840 100644 --- a/src/cmd4.cc +++ b/src/cmd4.cc @@ -3025,19 +3025,17 @@ void do_cmd_save_screen(void) void do_cmd_knowledge_artifacts(void) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; int i, z, x, y; char base_name[80]; /* Scan the artifacts */ - std::unique_ptr okay(new bool_[max_a_idx]); - for (std::size_t k = 0; k < max_a_idx; k++) + std::vector okay(a_info.size(), FALSE); + for (std::size_t k = 0; k < a_info.size(); k++) { - artifact_type *a_ptr = &a_info[k]; - - /* Default */ - okay[k] = FALSE; + auto a_ptr = &a_info[k]; /* Skip "empty" artifacts */ if (!a_ptr->name) continue; @@ -3163,9 +3161,9 @@ void do_cmd_knowledge_artifacts(void) fmt::MemoryWriter w; /* Scan the artifacts */ - for (std::size_t k = 0; k < max_a_idx; k++) + for (std::size_t k = 0; k < a_info.size(); k++) { - artifact_type *a_ptr = &a_info[k]; + auto a_ptr = &a_info[k]; /* List "dead" ones */ if (!okay[k]) continue; diff --git a/src/cmd6.cc b/src/cmd6.cc index 56dd5cab..93df49ad 100644 --- a/src/cmd6.cc +++ b/src/cmd6.cc @@ -4851,6 +4851,7 @@ static void activate_valaroma() void do_cmd_activate(void) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; int item, lev, chance; @@ -5075,6 +5076,7 @@ void do_cmd_activate(void) const char *activation_aux(object_type * o_ptr, bool_ doit, int item) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; int plev = get_skill(SKILL_DEVICE); diff --git a/src/game_edit_data.hpp b/src/game_edit_data.hpp index 59a74182..6a6fea9c 100644 --- a/src/game_edit_data.hpp +++ b/src/game_edit_data.hpp @@ -1,6 +1,7 @@ #pragma once #include "ability_type.hpp" +#include "artifact_type.hpp" #include "dungeon_info_type.hpp" #include "feature_type.hpp" #include "hist_type.hpp" @@ -49,6 +50,11 @@ struct GameEditData { */ std::vector ra_gen; + /** + * Artifacts + */ + std::vector a_info; + /** * Artifact sets */ diff --git a/src/generate.cc b/src/generate.cc index fb59afe2..856b593f 100644 --- a/src/generate.cc +++ b/src/generate.cc @@ -7671,6 +7671,7 @@ static bool_ cave_gen(void) { auto const &d_info = game->edit_data.d_info; auto const &r_info = game->edit_data.r_info; + auto const &a_info = game->edit_data.a_info; auto &k_info = game->edit_data.k_info; auto d_ptr = &d_info[dungeon_type]; @@ -7924,7 +7925,7 @@ static bool_ cave_gen(void) /* Grant a normal artefact */ else if (a_info[fates[i].a_idx].cur_num == 0) { - artifact_type *a_ptr = &a_info[fates[i].a_idx]; + auto a_ptr = &a_info[fates[i].a_idx]; s16b I_kind; /* Get local object */ @@ -8041,7 +8042,7 @@ static bool_ cave_gen(void) if (m_idx && d_ptr->final_artifact && (a_info[d_ptr->final_artifact].cur_num == 0)) { - artifact_type *a_ptr = &a_info[d_ptr->final_artifact]; + auto a_ptr = &a_info[d_ptr->final_artifact]; object_type *q_ptr, forge, *o_ptr; int I_kind, o_idx; @@ -8358,6 +8359,7 @@ static void generate_grid_mana() void generate_cave(void) { auto const &d_info = game->edit_data.d_info; + auto &a_info = game->edit_data.a_info; auto d_ptr = &d_info[dungeon_type]; int tester_1, tester_2; diff --git a/src/init1.cc b/src/init1.cc index 89149c8f..3912db12 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -2627,6 +2627,8 @@ errr init_k_info_txt(FILE *fp) */ errr init_a_info_txt(FILE *fp) { + auto &a_info = game->edit_data.a_info; + int i; char buf[1024]; char *s; @@ -2675,14 +2677,11 @@ errr init_a_info_txt(FILE *fp) /* Verify information */ if (i < error_idx) return (4); - /* Verify information */ - if (i >= max_a_idx) return (2); - /* Save the index */ error_idx = i; /* Point at the "info" */ - a_ptr = &a_info[i]; + a_ptr = &expand_to_fit_index(a_info, i); /* Copy name */ assert(!a_ptr->name); @@ -6169,6 +6168,7 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst { auto &wilderness = game->wilderness; auto &wf_info = game->edit_data.wf_info; + auto &a_info = game->edit_data.a_info; int i; @@ -6557,11 +6557,10 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst { int I_kind = 0; - artifact_type *a_ptr = &a_info[artifact_index]; - - object_type forge; + auto a_ptr = &a_info[artifact_index]; /* Get local object */ + object_type forge; object_type *q_ptr = &forge; a_allow_special[artifact_index] = TRUE; @@ -6776,12 +6775,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst max_real_towns = atoi(zz[1]); } - /* Maximum a_idx */ - else if (zz[0][0] == 'A') - { - max_a_idx = atoi(zz[1]); - } - /* Maximum e_idx */ else if (zz[0][0] == 'E') { diff --git a/src/init2.cc b/src/init2.cc index 73863842..8181f2d1 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -325,7 +325,7 @@ namespace { static void allocate() { - a_info = new artifact_type[max_a_idx]; + // Nothing to do } static errr parse(FILE *fp) @@ -724,13 +724,14 @@ static errr init_other(void) auto const &d_info = game->edit_data.d_info; auto const &r_info = game->edit_data.r_info; auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; /*** Prepare the "dungeon" information ***/ /* Allocate and Wipe the special gene flags */ m_allow_special = make_array(r_info.size()); k_allow_special = make_array(k_info.size()); - a_allow_special = make_array(max_a_idx); + a_allow_special = make_array(a_info.size()); /*** Prepare "vinfo" array ***/ @@ -993,10 +994,11 @@ static errr init_alloc(void) static void init_sets_aux() { auto const &set_info = game->edit_data.set_info; + auto &a_info = game->edit_data.a_info; - for (std::size_t i = 0; i < max_a_idx; i++) + for (auto &a_ref: a_info) { - a_info[i].set = -1; + a_ref.set = -1; } for (std::size_t i = 0; i < set_info.size(); i++) @@ -1018,6 +1020,7 @@ static void init_guardians(void) auto const &d_info = game->edit_data.d_info; auto &r_info = game->edit_data.r_info; auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; /* Scan dungeons */ for (std::size_t i = 0; i < d_info.size(); i++) @@ -1034,7 +1037,7 @@ static void init_guardians(void) /* Mark the final artifact */ if (d_ptr->final_artifact) { - artifact_type *a_ptr = &a_info[d_ptr->final_artifact]; + auto a_ptr = &a_info[d_ptr->final_artifact]; a_ptr->flags |= TR_SPECIAL_GENE; } diff --git a/src/loadsave.cc b/src/loadsave.cc index 1329827f..c58279a2 100644 --- a/src/loadsave.cc +++ b/src/loadsave.cc @@ -1057,6 +1057,7 @@ static bool_ wearable_p(object_type *o_ptr) static void do_item(object_type *o_ptr, ls_flag_t flag) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; byte old_dd; byte old_ds; @@ -1181,10 +1182,8 @@ static void do_item(object_type *o_ptr, ls_flag_t flag) /* Paranoia */ if (o_ptr->name1) { - artifact_type *a_ptr; - /* Obtain the artifact info */ - a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; /* Verify that artifact */ if (!a_ptr->name) o_ptr->name1 = 0; @@ -1852,6 +1851,8 @@ static void do_options(ls_flag_t flag) */ static bool_ do_inventory(ls_flag_t flag) { + auto const &a_info = game->edit_data.a_info; + if (flag == ls_flag_t::LOAD) { int slot = 0; @@ -2322,16 +2323,18 @@ static bool do_randarts(ls_flag_t flag) static bool do_artifacts(ls_flag_t flag) { + auto &a_info = game->edit_data.a_info; + u16b n_artifacts; if (flag == ls_flag_t::SAVE) { - n_artifacts = max_a_idx; + n_artifacts = a_info.size(); } do_u16b(&n_artifacts, flag); - if ((flag == ls_flag_t::LOAD) && (n_artifacts > max_a_idx)) + if ((flag == ls_flag_t::LOAD) && (n_artifacts > a_info.size())) { note("Too many artifacts!"); return false; diff --git a/src/monster2.cc b/src/monster2.cc index 17b5ab9a..9b82130e 100644 --- a/src/monster2.cc +++ b/src/monster2.cc @@ -431,6 +431,7 @@ static cptr funny_comments[MAX_COMMENT] = void delete_monster_idx(int i) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; /* Get location */ monster_type *m_ptr = &m_list[i]; @@ -1890,6 +1891,7 @@ void update_monsters(bool_ full) void monster_carry(monster_type *m_ptr, int m_idx, object_type *q_ptr) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; object_type *o_ptr; diff --git a/src/object1.cc b/src/object1.cc index 42c3f9ff..8795bdbd 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -801,6 +801,7 @@ bool_ object_flags_no_set = FALSE; object_flag_set object_flags(object_type const *o_ptr) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; auto k_ptr = &k_info[o_ptr->k_idx]; @@ -810,7 +811,7 @@ object_flag_set object_flags(object_type const *o_ptr) /* Artifact */ if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; f = a_ptr->flags; @@ -833,6 +834,7 @@ object_flag_set object_flags(object_type const *o_ptr) int object_power(object_type *o_ptr) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; auto k_ptr = &k_info[o_ptr->k_idx]; int power = -1; @@ -858,9 +860,12 @@ int object_power(object_type *o_ptr) /* Artifact */ if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; - if (power == -1) power = a_ptr->power; + if (power == -1) + { + power = a_ptr->power; + } } return (power); @@ -874,6 +879,7 @@ int object_power(object_type *o_ptr) object_flag_set object_flags_known(object_type const *o_ptr) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; auto k_ptr = &k_info[o_ptr->k_idx]; @@ -892,7 +898,7 @@ object_flag_set object_flags_known(object_type const *o_ptr) /* Artifact */ if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; /* Need full knowledge or spoilers */ if ((o_ptr->ident & IDENT_MENTAL)) @@ -1021,6 +1027,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode) { auto const &r_info = game->edit_data.r_info; auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; static auto const TR_PVAL_MASK = compute_pval_mask(); bool_ hack_name = FALSE; @@ -1686,7 +1693,7 @@ static std::string object_desc_aux(object_type const *o_ptr, int pref, int mode) /* Grab any artifact name */ else if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; /* Unique corpses don't require another name */ if (o_ptr->tval != TV_CORPSE) @@ -2144,6 +2151,7 @@ void object_desc_store(char *buf, object_type *o_ptr, int pref, int mode) cptr item_activation(object_type *o_ptr, byte num) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; /* Needed hacks */ static char rspell[2][80]; @@ -2517,6 +2525,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait auto const &set_info = game->edit_data.set_info; auto const &st_info = game->edit_data.st_info; auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; cptr vp[64]; byte vc[64]; @@ -2569,7 +2578,7 @@ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait if (o_ptr->name1 && (!trim_down)) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; text_out_c(TERM_YELLOW, a_ptr->text); text_out("\n"); @@ -4065,6 +4074,8 @@ void display_equip(void) /* Get the color of the letter idx */ byte get_item_letter_color(object_type const *o_ptr) { + auto const &a_info = game->edit_data.a_info; + byte color = TERM_WHITE; /* Must have knowlegde */ @@ -6129,6 +6140,7 @@ void object_gain_level(object_type *o_ptr) bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent) { auto &set_info = game->edit_data.set_info; + auto const &a_info = game->edit_data.a_info; auto s_ptr = &set_info[set_idx]; @@ -6164,6 +6176,7 @@ bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent) bool_ takeoff_set(s16b a_idx, s16b set_idx) { auto &set_info = game->edit_data.set_info; + auto const &a_info = game->edit_data.a_info; auto s_ptr = &set_info[set_idx]; @@ -6199,6 +6212,7 @@ bool_ takeoff_set(s16b a_idx, s16b set_idx) void apply_set(s16b a_idx, s16b set_idx) { auto const &set_info = game->edit_data.set_info; + auto const &a_info = game->edit_data.a_info; auto s_ptr = &set_info[set_idx]; @@ -6230,6 +6244,7 @@ void apply_set(s16b a_idx, s16b set_idx) static void apply_flags_set(s16b a_idx, s16b set_idx, object_flag_set *f) { auto const &set_info = game->edit_data.set_info; + auto const &a_info = game->edit_data.a_info; if ( -1 == a_info[a_idx].set) { diff --git a/src/object2.cc b/src/object2.cc index e812340b..7134308f 100644 --- a/src/object2.cc +++ b/src/object2.cc @@ -380,6 +380,7 @@ void compact_objects(int size) void wipe_o_list(void) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; int i; @@ -1090,6 +1091,7 @@ s32b object_value_real(object_type const *o_ptr) { auto const &r_info = game->edit_data.r_info; auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; s32b value; @@ -1118,7 +1120,7 @@ s32b object_value_real(object_type const *o_ptr) /* Artifact */ else if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; /* Hack -- "worthless" artifacts */ if (!a_ptr->cost) return (0L); @@ -2136,6 +2138,8 @@ static void random_artifact_power(object_type *o_ptr) void random_artifact_resistance(object_type * o_ptr) { + auto const &a_info = game->edit_data.a_info; + auto const art_flags = a_info[o_ptr->name1].flags; // Check flags of the 'protype' artifact @@ -2193,14 +2197,15 @@ void random_artifact_resistance(object_type * o_ptr) static bool_ make_artifact_special(object_type *o_ptr) { auto const &k_info = game->edit_data.k_info; + auto const &a_info = game->edit_data.a_info; /* No artifacts in the town */ if (!dun_level) return (FALSE); /* Check the artifact list (just the "specials") */ - for (int i = 0; i < max_a_idx; i++) + for (std::size_t i = 0; i < a_info.size(); i++) { - artifact_type *a_ptr = &a_info[i]; + auto a_ptr = &a_info[i]; /* Skip "empty" artifacts */ if (!a_ptr->name) continue; @@ -2273,6 +2278,7 @@ static bool_ make_artifact_special(object_type *o_ptr) */ static bool_ make_artifact(object_type *o_ptr) { + auto const &a_info = game->edit_data.a_info; auto const &k_info = game->edit_data.k_info; /* No artifacts in the town */ @@ -2282,9 +2288,9 @@ static bool_ make_artifact(object_type *o_ptr) if (o_ptr->number != 1) return (FALSE); /* Check the artifact list (skip the "specials") */ - for (int i = 0; i < max_a_idx; i++) + for (std::size_t i = 0; i < a_info.size(); i++) { - artifact_type *a_ptr = &a_info[i]; + auto a_ptr = &a_info[i]; /* Skip "empty" items */ if (!a_ptr->name) continue; @@ -3964,6 +3970,7 @@ void add_random_ego_flag(object_type *o_ptr, ego_flag_set const &fego, bool_ *li void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ great, boost::optional force_power) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; int i, rolls; auto k_ptr = &k_info[o_ptr->k_idx]; @@ -4102,7 +4109,7 @@ void apply_magic(object_type *o_ptr, int lev, bool_ okay, bool_ good, bool_ grea /* Hack -- analyze artifacts */ if (o_ptr->name1) { - artifact_type *a_ptr = &a_info[o_ptr->name1]; + auto a_ptr = &a_info[o_ptr->name1]; /* Hack -- Mark the artifact as "created" */ a_ptr->cur_num = 1; @@ -4885,6 +4892,7 @@ void place_object(int y, int x, bool_ good, bool_ great, int where) { auto const &d_info = game->edit_data.d_info; auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; s16b o_idx; @@ -5120,6 +5128,7 @@ s16b drop_near(object_type *j_ptr, int chance, int y, int x) { auto const &f_info = game->edit_data.f_info; auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; int i, k, d, s; @@ -5550,6 +5559,8 @@ void inven_item_increase(int item, int num) */ bool_ inven_item_optimize(int item) { + auto const &a_info = game->edit_data.a_info; + object_type *o_ptr = &p_ptr->inventory[item]; /* Only optimize real items */ diff --git a/src/q_one.cc b/src/q_one.cc index 0c2753a0..e982501c 100644 --- a/src/q_one.cc +++ b/src/q_one.cc @@ -3,6 +3,7 @@ #include "artifact_type.hpp" #include "cave.hpp" #include "cave_type.hpp" +#include "game.hpp" #include "gods.hpp" #include "hook_calculate_hp_in.hpp" #include "hook_calculate_hp_out.hpp" @@ -232,6 +233,8 @@ static bool_ quest_one_identify_hook(void *, void *in_, void *) static bool_ quest_one_death_hook(void *, void *in_, void *) { + auto const &a_info = game->edit_data.a_info; + struct hook_monster_death_in *in = static_cast(in_); s32b m_idx = in->m_idx; s32b r_idx = m_list[m_idx].r_idx; diff --git a/src/q_rand.cc b/src/q_rand.cc index 7a1faa87..7f0b2503 100644 --- a/src/q_rand.cc +++ b/src/q_rand.cc @@ -219,6 +219,7 @@ bool_ is_randhero(int level) static void do_get_new_obj(int y, int x) { auto &k_info = game->edit_data.k_info; + auto &a_info = game->edit_data.a_info; object_type *q_ptr[3], forge[3]; int res, i; diff --git a/src/q_troll.cc b/src/q_troll.cc index 626897f0..dfb5a867 100644 --- a/src/q_troll.cc +++ b/src/q_troll.cc @@ -3,6 +3,7 @@ #include "artifact_type.hpp" #include "cave.hpp" #include "cave_type.hpp" +#include "game.hpp" #include "hook_monster_death_in.hpp" #include "hook_quest_finish_in.hpp" #include "hooks.hpp" @@ -27,6 +28,8 @@ GENERATE_MONSTER_LOOKUP_FN(get_forest_troll, "Forest troll") static bool_ quest_troll_gen_hook(void *, void *, void *) { + auto &a_info = game->edit_data.a_info; + int x, y; int xstart = 2; int ystart = 2; diff --git a/src/traps.cc b/src/traps.cc index 0f80f8d6..ccc84aea 100644 --- a/src/traps.cc +++ b/src/traps.cc @@ -475,6 +475,8 @@ static bool_ player_handle_breath_trap(s16b rad, s16b type, u16b trap) */ bool_ player_activate_trap_type(s16b y, s16b x, object_type *i_ptr, s16b item) { + auto const &a_info = game->edit_data.a_info; + bool_ ident = FALSE; s16b trap; diff --git a/src/variable.cc b/src/variable.cc index 4275f21f..542ba16d 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -428,11 +428,6 @@ player_class const *cp_ptr; player_spec const *spp_ptr; -/* - * The artifact arrays - */ -artifact_type *a_info; - /* * The ego-item arrays */ @@ -563,11 +558,6 @@ bool_ (*get_obj_num_hook)(int k_idx); s32b get_level_max_stick = -1; s32b get_level_use_stick = -1; -/* - * Maximum number of artifacts in a_info.txt - */ -u16b max_a_idx; - /* * Maximum number of ego-items in e_info.txt */ diff --git a/src/variable.hpp b/src/variable.hpp index 430a1a46..829f0f2b 100644 --- a/src/variable.hpp +++ b/src/variable.hpp @@ -2,7 +2,6 @@ #include "angband.h" #include "alloc_entry_fwd.hpp" -#include "artifact_type_fwd.hpp" #include "birther.hpp" #include "cave_type_fwd.hpp" #include "deity_type.hpp" @@ -150,7 +149,6 @@ extern player_class const *cp_ptr; extern player_spec const *spp_ptr; extern char player_name[32]; extern char player_base[32]; -extern artifact_type *a_info; extern ego_item_type *e_info; extern trap_type *t_info; extern int wildc2i[256]; @@ -164,7 +162,6 @@ extern char *ANGBAND_DIR_DNGN; 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_a_idx; extern u16b max_e_idx; extern u16b max_o_idx; extern u16b max_m_idx; diff --git a/src/wizard2.cc b/src/wizard2.cc index 6665102e..e3e93918 100644 --- a/src/wizard2.cc +++ b/src/wizard2.cc @@ -150,20 +150,24 @@ void do_cmd_rerate(void) */ static void wiz_create_named_art() { + auto const &a_info = game->edit_data.a_info; + object_type forge; object_type *q_ptr; int i, a_idx; cptr p = "Number of the artifact: "; char out_val[80] = ""; - artifact_type *a_ptr; if (!get_string(p, out_val, 4)) return; a_idx = atoi(out_val); /* Return if out-of-bounds */ - if ((a_idx <= 0) || (a_idx >= max_a_idx)) return; + if ((a_idx <= 0) || (a_idx >= static_cast(a_info.size()))) + { + return; + } - a_ptr = &a_info[a_idx]; + auto a_ptr = &a_info[a_idx]; /* Get local object */ q_ptr = &forge; @@ -821,6 +825,8 @@ static void wiz_reroll_item(object_type *o_ptr) */ static void wiz_statistics(object_type *o_ptr) { + auto &a_info = game->edit_data.a_info; + long i, matches, better, worse, other; char ch; diff --git a/src/xtra1.cc b/src/xtra1.cc index 27bdce71..c64b26ac 100644 --- a/src/xtra1.cc +++ b/src/xtra1.cc @@ -2820,6 +2820,7 @@ void calc_bonuses(bool_ silent) auto const &s_descriptors = game->edit_data.s_descriptors; auto const &r_info = game->edit_data.r_info; auto &s_info = game->s_info; + auto const &a_info = game->edit_data.a_info; static bool_ monk_notify_aux = FALSE; int i, j, hold; @@ -4384,15 +4385,17 @@ bool_ monk_heavy_armor(void) static int get_artifact_idx(int level) { + auto const &a_info = game->edit_data.a_info; + int count = 0, i; while (count < 1000) { - artifact_type *a_ptr; count++; - i = randint(max_a_idx - 1); - a_ptr = &a_info[i]; + i = rand_int(a_info.size()); + + auto a_ptr = &a_info[i]; if (!a_ptr->tval) continue; /* It is found/lost */ @@ -4561,6 +4564,8 @@ void gain_fate(byte fate) std::string fate_desc(int fate) { + auto const &a_info = game->edit_data.a_info; + fmt::MemoryWriter w; if (fates[fate].serious) @@ -4590,7 +4595,7 @@ std::string fate_desc(int fate) { object_type *q_ptr, forge; char o_name[80]; - artifact_type *a_ptr = &a_info[fates[fate].a_idx]; + auto a_ptr = &a_info[fates[fate].a_idx]; int I_kind; /* Failed artefact allocation XXX XXX XXX */ diff --git a/src/xtra2.cc b/src/xtra2.cc index bb757b4f..25333356 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -2404,6 +2404,7 @@ void monster_death(int m_idx) { auto const &d_info = game->edit_data.d_info; auto const &f_info = game->edit_data.f_info; + auto &a_info = game->edit_data.a_info; monster_type *m_ptr = &m_list[m_idx]; @@ -2715,7 +2716,7 @@ void monster_death(int m_idx) { if (a_info[a_idx].cur_num == 0) { - artifact_type *a_ptr = &a_info[a_idx]; + auto a_ptr = &a_info[a_idx]; /* Get local object */ q_ptr = &forge; -- cgit v1.2.3