From 1726fc7a8ab66c15385bdda8f0533cddeb867b58 Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move set_info into GameEditData --- lib/edit/misc.txt | 3 --- lib/mods/theme/edit/misc.txt | 3 --- src/game_edit_data.hpp | 6 ++++++ src/init1.cc | 22 ++++++--------------- src/init2.cc | 17 ++++++++++------ src/object1.cc | 46 +++++++++++++++++++++++++++++++++++--------- src/set_type_fwd.hpp | 3 --- src/variable.cc | 10 ---------- src/variable.hpp | 3 --- 9 files changed, 60 insertions(+), 53 deletions(-) delete mode 100644 src/set_type_fwd.hpp diff --git a/lib/edit/misc.txt b/lib/edit/misc.txt index 69f02bdb..8bddc2e3 100644 --- a/lib/edit/misc.txt +++ b/lib/edit/misc.txt @@ -30,9 +30,6 @@ M:F:256 # Maximum number of artifacts in a_info.txt M:A:219 -# Maximum number of sets types in set_info.txt -M:s:10 - # Maximum number of ego-items in e_info.txt M:E:200 diff --git a/lib/mods/theme/edit/misc.txt b/lib/mods/theme/edit/misc.txt index 8c5aceec..7b4b3b08 100644 --- a/lib/mods/theme/edit/misc.txt +++ b/lib/mods/theme/edit/misc.txt @@ -30,9 +30,6 @@ M:F:249 # Maximum number of artifacts in a_info.txt M:A:257 -# Maximum number of sets types in set_info.txt -M:s:17 - # Maximum number of ego-items in e_info.txt M:E:238 diff --git a/src/game_edit_data.hpp b/src/game_edit_data.hpp index 6f1ffa8f..863cabe4 100644 --- a/src/game_edit_data.hpp +++ b/src/game_edit_data.hpp @@ -8,6 +8,7 @@ #include "player_race_mod.hpp" #include "randart_gen_type.hpp" #include "randart_part_type.hpp" +#include "set_type.hpp" #include "store_action_type.hpp" #include "vault_type.hpp" @@ -40,6 +41,11 @@ struct GameEditData { */ std::vector ra_gen; + /** + * Artifact sets + */ + std::vector set_info; + /** * Building actions. */ diff --git a/src/init1.cc b/src/init1.cc index 4233b032..7d8afaa9 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -2872,12 +2872,11 @@ errr init_a_info_txt(FILE *fp) */ errr init_set_info_txt(FILE *fp) { - int i; + auto &set_info = game->edit_data.set_info; + int cur_art = 0, cur_num = 0; char buf[1024]; - char *s; - /* Current entry */ set_type *set_ptr = NULL; @@ -2905,7 +2904,7 @@ errr init_set_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); @@ -2917,19 +2916,16 @@ errr init_set_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_set_idx) return (2); - /* Save the index */ error_idx = i; /* Point at the "info" */ - set_ptr = &set_info[i]; + set_ptr = &expand_to_fit_index(set_info, i); /* Copy name */ assert(!set_ptr->name); @@ -2946,7 +2942,7 @@ errr init_set_info_txt(FILE *fp) if (buf[0] == 'D') { /* Acquire the text */ - s = buf + 2; + char const *s = buf + 2; /* Append chars to the description */ strappend(&set_ptr->desc, s); @@ -6965,12 +6961,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst max_st_idx = atoi(zz[1]); } - /* Maximum set_idx */ - else if (zz[0][0] == 's') - { - max_set_idx = atoi(zz[1]); - } - /* Maximum wilderness x size */ else if (zz[0][0] == 'X') { diff --git a/src/init2.cc b/src/init2.cc index f664ba40..6ae3d9ba 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -309,7 +309,7 @@ namespace { static void allocate() { - set_info = new set_type[max_set_idx]; + // Nothing to do } static errr parse(FILE *fp) @@ -989,15 +989,20 @@ static errr init_alloc(void) /* Init the sets in a_info */ static void init_sets_aux() { - int i, j; + auto const &set_info = game->edit_data.set_info; - for (i = 0; i < max_a_idx; i++) + for (std::size_t i = 0; i < max_a_idx; i++) + { a_info[i].set = -1; - for (i = 0; i < max_set_idx; i++) + } + + for (std::size_t i = 0; i < set_info.size(); i++) { - for (j = 0; j < set_info[i].num; j++) + auto const &set_ref = set_info[i]; + + for (std::size_t j = 0; j < set_ref.num; j++) { - a_info[set_info[i].arts[j].a_idx].set = i; + a_info[set_ref.arts[j].a_idx].set = i; } } } diff --git a/src/object1.cc b/src/object1.cc index 3e783121..0d958fc8 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -2514,6 +2514,8 @@ static cptr object_out_desc_where_found(s16b level, s16b dungeon) */ bool_ object_out_desc(object_type *o_ptr, FILE *fff, bool_ trim_down, bool_ wait_for_it) { + auto const &set_info = game->edit_data.set_info; + cptr vp[64]; byte vc[64]; int vn; @@ -6124,12 +6126,21 @@ void object_gain_level(object_type *o_ptr) */ bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent) { - set_type *s_ptr = &set_info[set_idx]; - int i; + auto &set_info = game->edit_data.set_info; + + auto s_ptr = &set_info[set_idx]; if ( -1 == a_info[a_idx].set) return (FALSE); + + int i; for (i = 0; i < s_ptr->num; i++) - if (a_idx == s_ptr->arts[i].a_idx) break; + { + if (a_idx == s_ptr->arts[i].a_idx) + { + break; + } + } + if (!s_ptr->arts[i].present) { s_ptr->num_use++; @@ -6144,17 +6155,26 @@ bool_ wield_set(s16b a_idx, s16b set_idx, bool_ silent) } return (TRUE); } + return (FALSE); } bool_ takeoff_set(s16b a_idx, s16b set_idx) { - set_type *s_ptr = &set_info[set_idx]; - int i; + auto &set_info = game->edit_data.set_info; + + auto s_ptr = &set_info[set_idx]; if ( -1 == a_info[a_idx].set) return (FALSE); + + int i; for (i = 0; i < s_ptr->num; i++) - if (a_idx == s_ptr->arts[i].a_idx) break; + { + if (a_idx == s_ptr->arts[i].a_idx) + { + break; + } + } if (s_ptr->arts[i].present) { @@ -6170,12 +6190,15 @@ bool_ takeoff_set(s16b a_idx, s16b set_idx) return (TRUE); } + return (FALSE); } void apply_set(s16b a_idx, s16b set_idx) { - set_type *s_ptr = &set_info[set_idx]; + auto const &set_info = game->edit_data.set_info; + + auto s_ptr = &set_info[set_idx]; if ( -1 == a_info[a_idx].set) { @@ -6185,7 +6208,10 @@ void apply_set(s16b a_idx, s16b set_idx) int i; for (i = 0; i < s_ptr->num; i++) { - if (a_idx == s_ptr->arts[i].a_idx) break; + if (a_idx == s_ptr->arts[i].a_idx) + { + break; + } } if (s_ptr->arts[i].present) @@ -6201,12 +6227,14 @@ 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; + if ( -1 == a_info[a_idx].set) { return; } - set_type *s_ptr = &set_info[set_idx]; + auto s_ptr = &set_info[set_idx]; int i; for (i = 0; i < s_ptr->num; i++) diff --git a/src/set_type_fwd.hpp b/src/set_type_fwd.hpp deleted file mode 100644 index 3b311808..00000000 --- a/src/set_type_fwd.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -struct set_type; diff --git a/src/variable.cc b/src/variable.cc index 621cdd4c..8356148b 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -443,11 +443,6 @@ object_kind *k_info; */ artifact_type *a_info; -/* - * The item set arrays - */ -set_type *set_info; - /* * The ego-item arrays */ @@ -654,11 +649,6 @@ u16b max_e_idx; */ u16b max_st_idx; -/* - * Item sets - */ -u16b max_set_idx = 1; - /* * Maximum number of objects in the level */ diff --git a/src/variable.hpp b/src/variable.hpp index 534f9596..a413a0f3 100644 --- a/src/variable.hpp +++ b/src/variable.hpp @@ -27,7 +27,6 @@ #include "random_artifact.hpp" #include "random_quest.hpp" #include "school_type.hpp" -#include "set_type_fwd.hpp" #include "skill_descriptor_fwd.hpp" #include "skill_modifiers_fwd.hpp" #include "skill_type_fwd.hpp" @@ -173,7 +172,6 @@ extern trap_type *t_info; extern wilderness_type_info *wf_info; extern int wildc2i[256]; extern store_info_type *st_info; -extern set_type *set_info; extern cptr DEFAULT_FEAT_TEXT; extern cptr DEFAULT_FEAT_TUNNEL; extern cptr DEFAULT_FEAT_BLOCK; @@ -197,7 +195,6 @@ extern u16b max_m_idx; extern u16b max_t_idx; extern u16b max_st_idx; extern u16b max_wf_idx; -extern u16b max_set_idx; extern int init_flags; extern bool_ ambush_flag; extern bool_ fate_flag; -- cgit v1.2.3