From 37bd983c98fe21a61cb42a450a81b6ddf4638b0c Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 21 Sep 2019 12:06:31 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38844=20max=5Fd=5Fidx=20=E3=82=92?= =?utf8?q?=20world=5Ftype=E3=80=80=E6=A7=8B=E9=80=A0=E4=BD=93=E3=81=AB?= =?utf8?q?=E5=8A=A0=E3=81=88=E3=82=8B=EF=BC=8E=20=20/=20Move=20max=5Fd=5Fi?= =?utf8?q?dx=20to=20world=5Ftype=E3=80=80structure.?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/birth.c | 2 +- src/bldg.c | 4 ++-- src/cmd/cmd-dump.c | 2 +- src/dungeon-file.c | 2 +- src/dungeon.c | 10 +++++----- src/dungeon.h | 1 - src/files.c | 2 +- src/init.c | 6 +++--- src/load.c | 2 +- src/main-win.c | 2 +- src/player-status.c | 2 +- src/rumor.c | 3 ++- src/save.c | 2 +- src/wild.c | 2 +- src/wizard2.c | 3 ++- src/world.h | 2 ++ 16 files changed, 25 insertions(+), 22 deletions(-) diff --git a/src/birth.c b/src/birth.c index c87d1d6c6..72fd1556f 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1809,7 +1809,7 @@ static void player_wipe_without_name(player_type *creature_ptr) creature_ptr->pet_extra_flags = (PF_TELEPORT | PF_ATTACK_SPELL | PF_SUMMON_SPELL); /* Wipe the recall depths */ - for (i = 0; i < max_d_idx; i++) + for (i = 0; i < current_world_ptr->max_d_idx; i++) { max_dlv[i] = 0; } diff --git a/src/bldg.c b/src/bldg.c index 18d2808c1..cdd525fa9 100644 --- a/src/bldg.c +++ b/src/bldg.c @@ -1456,7 +1456,7 @@ void update_gambling_monsters(void) bool tekitou; bool old_inside_battle = p_ptr->phase_out; - for (i = 0; i < max_d_idx; i++) + for (i = 0; i < current_world_ptr->max_d_idx; i++) if (max_dl < max_dlv[i]) max_dl = max_dlv[i]; mon_level = randint1(MIN(max_dl, 122)) + 5; @@ -4232,7 +4232,7 @@ void determine_today_mon(bool conv_old) if (!conv_old) { - for (i = 0; i < max_d_idx; i++) + for (i = 0; i < current_world_ptr->max_d_idx; i++) { if (max_dlv[i] < d_info[i].mindepth) continue; if (max_dl < max_dlv[i]) max_dl = max_dlv[i]; diff --git a/src/cmd/cmd-dump.c b/src/cmd/cmd-dump.c index 578c68029..c130efb70 100644 --- a/src/cmd/cmd-dump.c +++ b/src/cmd/cmd-dump.c @@ -6364,7 +6364,7 @@ static void do_cmd_knowledge_dungeon(void) if (fff) { - for (i = 1; i < max_d_idx; i++) + for (i = 1; i < current_world_ptr->max_d_idx; i++) { bool seiha = FALSE; diff --git a/src/dungeon-file.c b/src/dungeon-file.c index 63ab3fc44..8170d3099 100644 --- a/src/dungeon-file.c +++ b/src/dungeon-file.c @@ -4326,7 +4326,7 @@ static errr process_dungeon_file_aux(char *buf, int ymin, int xmin, int ymax, in /* Maximum d_idx */ else if (zz[0][0] == 'D') { - max_d_idx = (DUNGEON_IDX)atoi(zz[1]); + current_world_ptr->max_d_idx = (DUNGEON_IDX)atoi(zz[1]); } /* Maximum o_idx */ diff --git a/src/dungeon.c b/src/dungeon.c index 1992fe1b5..f0c9ea12b 100644 --- a/src/dungeon.c +++ b/src/dungeon.c @@ -1,5 +1,6 @@ #include "angband.h" #include "dungeon.h" +#include "world.h" /* * The dungeon arrays @@ -11,7 +12,6 @@ char *d_text; /* * Maximum number of dungeon in d_info.txt */ -DUNGEON_IDX max_d_idx; DEPTH *max_dlv; @@ -42,10 +42,10 @@ DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x) } /* Allocate the "dun" array */ - C_MAKE(dun, max_d_idx, DUNGEON_IDX); + C_MAKE(dun, current_world_ptr->max_d_idx, DUNGEON_IDX); screen_save(); - for (i = 1; i < max_d_idx; i++) + for (i = 1; i < current_world_ptr->max_d_idx; i++) { char buf[80]; bool seiha = FALSE; @@ -76,7 +76,7 @@ DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x) if ((i == ESCAPE) || !num) { /* Free the "dun" array */ - C_KILL(dun, max_d_idx, DUNGEON_IDX); + C_KILL(dun, current_world_ptr->max_d_idx, DUNGEON_IDX); screen_load(); return 0; @@ -91,7 +91,7 @@ DUNGEON_IDX choose_dungeon(concptr note, POSITION y, POSITION x) screen_load(); /* Free the "dun" array */ - C_KILL(dun, max_d_idx, DUNGEON_IDX); + C_KILL(dun, current_world_ptr->max_d_idx, DUNGEON_IDX); return select_dungeon; } diff --git a/src/dungeon.h b/src/dungeon.h index ec71f94f5..d30303e97 100644 --- a/src/dungeon.h +++ b/src/dungeon.h @@ -78,7 +78,6 @@ struct dungeon_type { }; extern DEPTH *max_dlv; -extern DUNGEON_IDX max_d_idx; extern dungeon_type *d_info; extern char *d_name; extern char *d_text; diff --git a/src/files.c b/src/files.c index de9b58879..8d87e7f66 100644 --- a/src/files.c +++ b/src/files.c @@ -4536,7 +4536,7 @@ static void dump_aux_recall(FILE *fff) int y; fprintf(fff, _("\n [帰還場所]\n\n", "\n [Recall Depth]\n\n")); - for (y = 1; y < max_d_idx; y++) + for (y = 1; y < current_world_ptr->max_d_idx; y++) { bool seiha = FALSE; diff --git a/src/init.c b/src/init.c index 0c82ceb50..b6c748197 100644 --- a/src/init.c +++ b/src/init.c @@ -778,7 +778,7 @@ static errr init_r_info(void) static errr init_d_info(void) { /* Init the header */ - init_header(&d_head, max_d_idx, sizeof(dungeon_type)); + init_header(&d_head, current_world_ptr->max_d_idx, sizeof(dungeon_type)); #ifdef ALLOW_TEMPLATES @@ -1237,7 +1237,7 @@ static errr init_other(void) } /* Allocate and Wipe the max dungeon level */ - C_MAKE(max_dlv, max_d_idx, DEPTH); + C_MAKE(max_dlv, current_world_ptr->max_d_idx, DEPTH); /* Allocate and wipe each line of the p_ptr->current_floor_ptr->grid_array */ for (i = 0; i < MAX_HGT; i++) @@ -1840,7 +1840,7 @@ void init_angband(void) if (init_d_info()) quit(_("ダンジョン初期化不能", "Cannot initialize dungeon")); { int i; - for (i = 1; i < max_d_idx; i++) + for (i = 1; i < current_world_ptr->max_d_idx; i++) if (d_info[i].final_guardian) r_info[d_info[i].final_guardian].flags7 |= RF7_GUARDIAN; } diff --git a/src/load.c b/src/load.c index 3d3674977..53b8e8f09 100644 --- a/src/load.c +++ b/src/load.c @@ -2029,7 +2029,7 @@ static void rd_extra(void) } else { - byte max = (byte)max_d_idx; + byte max = (byte)current_world_ptr->max_d_idx; rd_byte(&max); diff --git a/src/main-win.c b/src/main-win.c index 2ea21e99d..986aa58c3 100644 --- a/src/main-win.c +++ b/src/main-win.c @@ -1575,7 +1575,7 @@ static void load_music_prefs(void) } } - for (i = 0; i < max_d_idx; i++) + for (i = 0; i < current_world_ptr->max_d_idx; i++) { sprintf(key, "dungeon%03d", i); GetPrivateProfileString("Dungeon", key, "", tmp, 1024, ini_path); diff --git a/src/player-status.c b/src/player-status.c index 186ee09e8..939b42d3c 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5747,7 +5747,7 @@ long calc_score(player_type *creature_ptr) if (mult < 5) mult = 5; - for (i = 0; i < max_d_idx; i++) + for (i = 0; i < current_world_ptr->max_d_idx; i++) if (max_dlv[i] > max_dl) max_dl = max_dlv[i]; diff --git a/src/rumor.c b/src/rumor.c index db1a91a64..c2d2bdbf8 100644 --- a/src/rumor.c +++ b/src/rumor.c @@ -8,6 +8,7 @@ #include "monsterrace.h" #include "floor-town.h" #include "wild.h" +#include "world.h" /* * Display a rumor and apply its effects @@ -112,7 +113,7 @@ void display_rumor(bool ex) while (1) { - d_idx = rumor_num(zz[1], max_d_idx); + d_idx = rumor_num(zz[1], current_world_ptr->max_d_idx); d_ptr = &d_info[d_idx]; if (d_ptr->name) break; } diff --git a/src/save.c b/src/save.c index f19f2b845..9b2023476 100644 --- a/src/save.c +++ b/src/save.c @@ -714,7 +714,7 @@ static void wr_extra(void) /* Max Player and Dungeon Levels */ wr_s16b(p_ptr->max_plv); - tmp8u = (byte)max_d_idx; + tmp8u = (byte)current_world_ptr->max_d_idx; wr_byte(tmp8u); for (i = 0; i < tmp8u; i++) wr_s16b((s16b)max_dlv[i]); diff --git a/src/wild.c b/src/wild.c index f05990333..1a67d2101 100644 --- a/src/wild.c +++ b/src/wild.c @@ -907,7 +907,7 @@ errr parse_line_wilderness(char *buf, int ymin, int xmin, int ymax, int xmax, in return (PARSE_ERROR_UNDEFINED_DIRECTIVE); } - for (i = 1; i < max_d_idx; i++) + for (i = 1; i < current_world_ptr->max_d_idx; i++) { if (!d_info[i].maxdepth) continue; wilderness[d_info[i].dy][d_info[i].dx].entrance = (byte_hack)i; diff --git a/src/wizard2.c b/src/wizard2.c index 2f75bee90..7acf12b94 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -50,6 +50,7 @@ #include "objectkind.h" #include "targeting.h" #include "view-mainwindow.h" +#include "world.h" #ifdef ALLOW_WIZARD @@ -1321,7 +1322,7 @@ static void do_cmd_wiz_jump(player_type *creature_ptr) if (!get_string(ppp, tmp_val, 2)) return; tmp_dungeon_type = (DUNGEON_IDX)atoi(tmp_val); - if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND; + if (!d_info[tmp_dungeon_type].maxdepth || (tmp_dungeon_type > current_world_ptr->max_d_idx)) tmp_dungeon_type = DUNGEON_ANGBAND; /* Prompt */ sprintf(ppp, "Jump to level (0, %d-%d): ", diff --git a/src/world.h b/src/world.h index e52daf14a..ede12ad40 100644 --- a/src/world.h +++ b/src/world.h @@ -60,6 +60,8 @@ typedef struct { OBJECT_IDX max_o_idx; /*!< Maximum number of objects in the level */ MONSTER_IDX max_m_idx; /*!< Maximum number of monsters in the level */ + DUNGEON_IDX max_d_idx; + } world_type; extern bool is_daytime(void); -- 2.11.0