From 5ddcbbf1cdce68e565376819efedd519892512ad Mon Sep 17 00:00:00 2001 From: Bardur Arantsson Date: Wed, 5 Oct 2016 18:45:08 +0200 Subject: Move wf_info into GameEditData --- src/cmd2.cc | 2 ++ src/dungeon.cc | 2 ++ src/files.cc | 30 +++++++++++++++--------------- src/game_edit_data.hpp | 6 ++++++ src/init1.cc | 22 +++++++--------------- src/init2.cc | 2 +- src/monster1.cc | 2 ++ src/object1.cc | 1 + src/q_god.cc | 1 + src/variable.cc | 6 ------ src/variable.hpp | 3 --- src/wild.cc | 4 ++++ src/wilderness_type_info_fwd.hpp | 3 --- src/wizard2.cc | 2 ++ src/xtra1.cc | 1 + src/xtra2.cc | 1 + 16 files changed, 45 insertions(+), 43 deletions(-) delete mode 100644 src/wilderness_type_info_fwd.hpp (limited to 'src') diff --git a/src/cmd2.cc b/src/cmd2.cc index dd5f302a..641e2738 100644 --- a/src/cmd2.cc +++ b/src/cmd2.cc @@ -2523,6 +2523,8 @@ void do_cmd_spike(void) static void do_cmd_walk_jump(int pickup, bool_ disarm) { + auto const &wf_info = game->edit_data.wf_info; + int dir; bool_ more = FALSE; diff --git a/src/dungeon.cc b/src/dungeon.cc index a2696236..d3554e50 100644 --- a/src/dungeon.cc +++ b/src/dungeon.cc @@ -3222,6 +3222,8 @@ static bool_ enter_debug_mode(void) */ static void process_command(void) { + auto const &wf_info = game->edit_data.wf_info; + char error_m[80]; /* Handle repeating the last command */ diff --git a/src/files.cc b/src/files.cc index 6a046b10..f897b515 100644 --- a/src/files.cc +++ b/src/files.cc @@ -2340,6 +2340,7 @@ std::string describe_player_location() { auto const &wilderness = game->wilderness; auto const &d_info = game->edit_data.d_info; + auto const &wf_info = game->edit_data.wf_info; std::string desc; @@ -2370,13 +2371,11 @@ std::string describe_player_location() */ int landmark = 0, lwx = 0, lwy = 0; int l_dist = -1; - int i; - for (i = 0; i < max_wf_idx; i++) + for (std::size_t i = 0; i < wf_info.size(); i++) { int wx = wf_info[i].wild_x; int wy = wf_info[i].wild_y; - int dist; /* Skip if not a landmark */ if (!wf_info[i].entrance) continue; @@ -2384,7 +2383,7 @@ std::string describe_player_location() /* Skip if we haven't seen it */ if (!wilderness(wx, wy).known) continue; - dist = distance(wy, wx, pwy, pwx); + int dist = distance(wy, wx, pwy, pwx); if (dist < l_dist || l_dist < 0) { landmark = i; @@ -2525,7 +2524,7 @@ void file_character_print_item(FILE *fff, char label, object_type *obj, bool_ fu * * Prints out one "store" (for Home and Mathom-house) */ -static void file_character_print_store(FILE *fff, wilderness_type_info *place, std::size_t store, bool_ full) +static void file_character_print_store(FILE *fff, wilderness_type_info const *place, std::size_t store, bool_ full) { auto const &st_info = game->edit_data.st_info; @@ -2555,7 +2554,7 @@ static void file_character_print_store(FILE *fff, wilderness_type_info *place, s * was not already there. XXX This is an ugly workaround for the double Gondolin * problem. */ -static bool_ file_character_check_stores(std::unordered_set *seen_stores, wilderness_type_info *place, int store) +static bool_ file_character_check_stores(std::unordered_set *seen_stores, wilderness_type_info const *place, int store) { town_type *town = &town_info[place->entrance]; store_type *st_ptr = &town->store[store]; @@ -2580,8 +2579,9 @@ static bool_ file_character_check_stores(std::unordered_set *seen_ errr file_character(cptr name, bool_ full) { auto const &d_info = game->edit_data.d_info; + auto const &wf_info = game->edit_data.wf_info; - int i, j, x, y; + int i, x, y; byte a; char c; int fd = -1; @@ -2874,12 +2874,12 @@ errr file_character(cptr name, bool_ full) /* Print all homes in the different towns */ { std::unordered_set seen_stores; - for (j = 0; j < max_wf_idx; j++) + for (auto const &wf_ref: wf_info) { - if (wf_info[j].feat == FEAT_TOWN && - file_character_check_stores(&seen_stores, &wf_info[j], 7)) + if (wf_ref.feat == FEAT_TOWN && + file_character_check_stores(&seen_stores, &wf_ref, 7)) { - file_character_print_store(fff, &wf_info[j], 7, full); + file_character_print_store(fff, &wf_ref, 7, full); } } } @@ -2887,12 +2887,12 @@ errr file_character(cptr name, bool_ full) /* Print all Mathom-houses in the different towns */ { std::unordered_set seen_stores; - for (j = 0; j < max_wf_idx; j++) + for (auto const &wf_ref: wf_info) { - if (wf_info[j].feat == FEAT_TOWN && - file_character_check_stores(&seen_stores, &wf_info[j], 57)) + if (wf_ref.feat == FEAT_TOWN && + file_character_check_stores(&seen_stores, &wf_ref, 57)) { - file_character_print_store(fff, &wf_info[j], 57, full); + file_character_print_store(fff, &wf_ref, 57, full); } } } diff --git a/src/game_edit_data.hpp b/src/game_edit_data.hpp index 85da3997..8b118397 100644 --- a/src/game_edit_data.hpp +++ b/src/game_edit_data.hpp @@ -15,6 +15,7 @@ #include "store_action_type.hpp" #include "store_info_type.hpp" #include "vault_type.hpp" +#include "wilderness_type_info.hpp" #include @@ -95,6 +96,11 @@ struct GameEditData { */ std::vector re_info; + /** + * Wilderness features + */ + std::vector wf_info; + /** * Base skills for all characters. */ diff --git a/src/init1.cc b/src/init1.cc index 62211893..17024337 100644 --- a/src/init1.cc +++ b/src/init1.cc @@ -6000,9 +6000,9 @@ errr init_ow_info_txt(FILE *fp) */ errr init_wf_info_txt(FILE *fp) { - int i; + auto &wf_info = game->edit_data.wf_info; + char buf[1024]; - char *s; /* Current entry */ wilderness_type_info *wf_ptr = NULL; @@ -6029,7 +6029,7 @@ errr init_wf_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); @@ -6041,19 +6041,16 @@ errr init_wf_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_wf_idx) return (2); - /* Save the index */ error_idx = i; /* Point at the "info" */ - wf_ptr = &wf_info[i]; + wf_ptr = &expand_to_fit_index(wf_info, i); /* Copy the name */ assert(!wf_ptr->name); @@ -6070,7 +6067,7 @@ errr init_wf_info_txt(FILE *fp) if (buf[0] == 'D') { /* Acquire the text */ - s = buf + 2; + char *s = buf + 2; /* Copy description */ assert(!wf_ptr->text); @@ -6177,6 +6174,7 @@ static dungeon_grid letter[255]; static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalstart, int ymax, int xmax, bool_ full) { auto &wilderness = game->wilderness; + auto &wf_info = game->edit_data.wf_info; int i; @@ -6832,12 +6830,6 @@ static errr process_dungeon_file_aux(char *buf, int *yval, int *xval, int xvalst max_t_idx = atoi(zz[1]); } - /* Maximum wf_idx */ - else if (zz[0][0] == 'W') - { - max_wf_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 d574deca..da011da7 100644 --- a/src/init2.cc +++ b/src/init2.cc @@ -501,7 +501,7 @@ namespace { static void allocate() { - wf_info = new wilderness_type_info[max_wf_idx]; + // Nothing to do } static errr parse(FILE *fp) diff --git a/src/monster1.cc b/src/monster1.cc index 2060b7af..2f874259 100644 --- a/src/monster1.cc +++ b/src/monster1.cc @@ -1536,6 +1536,8 @@ static bool_ monster_lava(int r_idx) void set_mon_num_hook(void) { + auto const &wf_info = game->edit_data.wf_info; + if (!dun_level) { auto const &wilderness = game->wilderness; diff --git a/src/object1.cc b/src/object1.cc index c98e2ed5..8be0655a 100644 --- a/src/object1.cc +++ b/src/object1.cc @@ -2480,6 +2480,7 @@ 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; + auto const &wf_info = game->edit_data.wf_info; static char str[80]; diff --git a/src/q_god.cc b/src/q_god.cc index 1cb4c0f5..38b911b7 100644 --- a/src/q_god.cc +++ b/src/q_god.cc @@ -294,6 +294,7 @@ std::string quest_god_describe() static void quest_god_place_rand_dung() { auto &wilderness = game->wilderness; + auto const &wf_info = game->edit_data.wf_info; int x = -1, y = -1, tries; diff --git a/src/variable.cc b/src/variable.cc index 35aeff7f..1f861563 100644 --- a/src/variable.cc +++ b/src/variable.cc @@ -460,7 +460,6 @@ monster_race *r_info; /* * The wilderness features arrays */ -wilderness_type_info *wf_info; int wildc2i[256]; /* @@ -619,11 +618,6 @@ u16b max_m_idx; */ u16b max_t_idx; -/* - * Maximum number of wilderness features in wf_info.txt - */ -u16b max_wf_idx; - /* * Flags for initialization */ diff --git a/src/variable.hpp b/src/variable.hpp index a1cc5266..1813b762 100644 --- a/src/variable.hpp +++ b/src/variable.hpp @@ -30,7 +30,6 @@ #include "timer_type_fwd.hpp" #include "town_type_fwd.hpp" #include "trap_type_fwd.hpp" -#include "wilderness_type_info_fwd.hpp" #include "seed.hpp" extern int max_macrotrigger; @@ -160,7 +159,6 @@ extern artifact_type *a_info; extern ego_item_type *e_info; extern monster_race *r_info; extern trap_type *t_info; -extern wilderness_type_info *wf_info; extern int wildc2i[256]; extern cptr DEFAULT_FEAT_TEXT; extern cptr DEFAULT_FEAT_TUNNEL; @@ -180,7 +178,6 @@ extern u16b max_e_idx; extern u16b max_o_idx; extern u16b max_m_idx; extern u16b max_t_idx; -extern u16b max_wf_idx; extern int init_flags; extern bool_ ambush_flag; extern bool_ fate_flag; diff --git a/src/wild.cc b/src/wild.cc index 01b36f87..5627629a 100644 --- a/src/wild.cc +++ b/src/wild.cc @@ -157,6 +157,8 @@ static void plasma_recursive(int x1, int y1, int x2, int y2, static int generate_area(int y, int x, bool_ border, bool_ corner) { auto const &wilderness = game->wilderness; + auto const &wf_info = game->edit_data.wf_info; + int road, entrance; int x1, y1; int hack_floor = 0; @@ -577,6 +579,8 @@ void wilderness_gen() void wilderness_gen_small() { auto const &wilderness = game->wilderness; + auto const &wf_info = game->edit_data.wf_info; + int xstart = 0; int ystart = 0; diff --git a/src/wilderness_type_info_fwd.hpp b/src/wilderness_type_info_fwd.hpp deleted file mode 100644 index a206c9e3..00000000 --- a/src/wilderness_type_info_fwd.hpp +++ /dev/null @@ -1,3 +0,0 @@ -#pragma once - -struct wilderness_type_info; diff --git a/src/wizard2.cc b/src/wizard2.cc index 046fd80c..b2713636 100644 --- a/src/wizard2.cc +++ b/src/wizard2.cc @@ -82,6 +82,8 @@ static void wiz_align_monster(int status) */ static void teleport_player_town(int town) { + auto const &wf_info = game->edit_data.wf_info; + autosave_checkpoint(); /* Change town */ diff --git a/src/xtra1.cc b/src/xtra1.cc index 65767d76..2829b2f6 100644 --- a/src/xtra1.cc +++ b/src/xtra1.cc @@ -540,6 +540,7 @@ static void prt_sp(void) static void prt_depth(int row, int col) { auto const &d_info = game->edit_data.d_info; + auto const &wf_info = game->edit_data.wf_info; char depths[32]; auto d_ptr = &d_info[dungeon_type]; diff --git a/src/xtra2.cc b/src/xtra2.cc index 14cc9bc9..d9d9746f 100644 --- a/src/xtra2.cc +++ b/src/xtra2.cc @@ -3892,6 +3892,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; cave_type *c_ptr = &cave[y][x]; -- cgit v1.2.3