From 51d62e860115df9be4f5749d1cce2fb842029ecb Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 18 Aug 2019 17:47:05 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20=E3=82=A6=E3=82=A3?= =?utf8?q?=E3=82=B6=E3=83=BC=E3=83=89=E3=83=A2=E3=83=BC=E3=83=89=E3=83=95?= =?utf8?q?=E3=83=A9=E3=82=B0=20=E3=82=92=20player=5Ftype=E3=80=80=E6=A7=8B?= =?utf8?q?=E9=80=A0=E4=BD=93=E3=81=8B=E3=82=89=E3=80=80world=5Ftype=20?= =?utf8?q?=E6=A7=8B=E9=80=A0=E4=BD=93=E3=81=B8=E7=A7=BB=E5=8B=95=EF=BC=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/artifact.c | 3 ++- src/birth.c | 2 +- src/cmd/cmd-dump.c | 26 +++++++++++++------------- src/cmd/cmd-gameoption.c | 4 ++-- src/combat/melee1.c | 2 +- src/core.c | 10 +++++----- src/files.c | 2 +- src/load.c | 2 +- src/monster-status.c | 2 +- src/monster1.c | 4 ++-- src/object2.c | 8 ++++---- src/player-move.c | 2 +- src/player-status.c | 2 +- src/player-status.h | 2 -- src/realm-hex.c | 5 +++-- src/save.c | 2 +- src/spells3.c | 6 +++--- src/targeting.c | 5 +++-- src/view-mainwindow.c | 6 +++--- src/world.h | 4 +++- 20 files changed, 51 insertions(+), 48 deletions(-) diff --git a/src/artifact.c b/src/artifact.c index ed46d9c69..35bf1df3d 100644 --- a/src/artifact.c +++ b/src/artifact.c @@ -33,6 +33,7 @@ #include "view-mainwindow.h" #include "player-class.h" #include "player-personality.h" +#include "world.h" /* * The artifact arrays @@ -1700,7 +1701,7 @@ bool become_random_artifact(object_type *o_ptr, bool a_scroll) random_slay(o_ptr); break; default: - if (p_ptr->wizard) msg_print("Switch error in become_random_artifact!"); + if (current_world_ptr->wizard) msg_print("Switch error in become_random_artifact!"); powers++; } }; diff --git a/src/birth.c b/src/birth.c index 2ec22885f..b623ed459 100644 --- a/src/birth.c +++ b/src/birth.c @@ -1799,7 +1799,7 @@ static void player_wipe_without_name(player_type *creature_ptr) /* Assume no cheating */ creature_ptr->noscore = 0; - creature_ptr->wizard = FALSE; + current_world_ptr->wizard = FALSE; /* Not waiting to report score */ creature_ptr->wait_report_score = FALSE; diff --git a/src/cmd/cmd-dump.c b/src/cmd/cmd-dump.c index 6a206852e..eb06ab49c 100644 --- a/src/cmd/cmd-dump.c +++ b/src/cmd/cmd-dump.c @@ -3427,7 +3427,7 @@ static KIND_OBJECT_IDX collect_objects(int grp_cur, KIND_OBJECT_IDX object_idx[] } else { - if (!p_ptr->wizard) + if (!current_world_ptr->wizard) { /* Skip non-flavoured objects */ if (!k_ptr->flavor) continue; @@ -5202,9 +5202,9 @@ static void display_monster_list(int col, int row, int per_page, s16b mon_idx[], /* Hack -- visual_list mode */ if (per_page == 1) { - c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 56 : 61); + c_prt(attr, format("%02x/%02x", r_ptr->x_attr, r_ptr->x_char), row + i, (current_world_ptr->wizard || visual_only) ? 56 : 61); } - if (p_ptr->wizard || visual_only) + if (current_world_ptr->wizard || visual_only) { c_prt(attr, format("%d", r_idx), row + i, 62); } @@ -5328,7 +5328,7 @@ static void do_cmd_knowledge_monsters(bool *need_redraw, bool visual_only, IDX d prt(format(_("%s - モンスター", "%s - monsters"), !visual_only ? _("知識", "Knowledge") : _("表示", "Visuals")), 2, 0); if (direct_r_idx < 0) prt(_("グループ", "Group"), 4, 0); prt(_("名前", "Name"), 4, max + 3); - if (p_ptr->wizard || visual_only) prt("Idx", 4, 62); + if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 62); prt(_("文字", "Sym"), 4, 67); if (!visual_only) prt(_("殺害数", "Kills"), 4, 72); @@ -5534,9 +5534,9 @@ static void display_object_list(int col, int row, int per_page, IDX object_idx[] /* Hack -- visual_list mode */ if (per_page == 1) { - c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (p_ptr->wizard || visual_only) ? 64 : 68); + c_prt(attr, format("%02x/%02x", flavor_k_ptr->x_attr, flavor_k_ptr->x_char), row + i, (current_world_ptr->wizard || visual_only) ? 64 : 68); } - if (p_ptr->wizard || visual_only) + if (current_world_ptr->wizard || visual_only) { c_prt(attr, format("%d", k_idx), row + i, 70); } @@ -5698,13 +5698,13 @@ static void do_cmd_knowledge_objects(bool *need_redraw, bool visual_only, IDX di prt(format("%s - アイテム", !visual_only ? "知識" : "表示"), 2, 0); if (direct_k_idx < 0) prt("グループ", 4, 0); prt("名前", 4, max + 3); - if (p_ptr->wizard || visual_only) prt("Idx", 4, 70); + if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 70); prt("文字", 4, 74); #else prt(format("%s - objects", !visual_only ? "Knowledge" : "Visuals"), 2, 0); if (direct_k_idx < 0) prt("Group", 4, 0); prt("Name", 4, max + 3); - if (p_ptr->wizard || visual_only) prt("Idx", 4, 70); + if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 70); prt("Sym", 4, 75); #endif @@ -5908,9 +5908,9 @@ static void display_feature_list(int col, int row, int per_page, FEAT_IDX *feat_ /* Display lighting level */ c_prt(attr, format("(%s)", lighting_level_str[lighting_level]), row_i, col + 1 + strlen(f_name + f_ptr->name)); - c_prt(attr, format("%02x/%02x", f_ptr->x_attr[lighting_level], f_ptr->x_char[lighting_level]), row_i, f_idx_col - ((p_ptr->wizard || visual_only) ? 6 : 2)); + c_prt(attr, format("%02x/%02x", f_ptr->x_attr[lighting_level], f_ptr->x_char[lighting_level]), row_i, f_idx_col - ((current_world_ptr->wizard || visual_only) ? 6 : 2)); } - if (p_ptr->wizard || visual_only) + if (current_world_ptr->wizard || visual_only) { c_prt(attr, format("%d", f_idx), row_i, f_idx_col); } @@ -6048,12 +6048,12 @@ static void do_cmd_knowledge_features(bool *need_redraw, bool visual_only, IDX d prt(_("名前", "Name"), 4, max + 3); if (use_bigtile) { - if (p_ptr->wizard || visual_only) prt("Idx", 4, 62); + if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 62); prt(_("文字 ( l/ d)", "Sym ( l/ d)"), 4, 66); } else { - if (p_ptr->wizard || visual_only) prt("Idx", 4, 64); + if (current_world_ptr->wizard || visual_only) prt("Idx", 4, 64); prt(_("文字 (l/d)", "Sym (l/d)"), 4, 68); } @@ -6774,7 +6774,7 @@ static void do_cmd_knowledge_quests(void) do_cmd_knowledge_quests_completed(fff, quest_num); fputc('\n', fff); do_cmd_knowledge_quests_failed(fff, quest_num); - if (p_ptr->wizard) + if (current_world_ptr->wizard) { fputc('\n', fff); do_cmd_knowledge_quests_wiz_random(fff); diff --git a/src/cmd/cmd-gameoption.c b/src/cmd/cmd-gameoption.c index 49ea5c743..9b10cf605 100644 --- a/src/cmd/cmd-gameoption.c +++ b/src/cmd/cmd-gameoption.c @@ -1307,7 +1307,7 @@ void do_cmd_options(void) case 'b': { /* Spawn */ - do_cmd_options_aux(OPT_PAGE_BIRTH, (!p_ptr->wizard || !allow_debug_opts) ? + do_cmd_options_aux(OPT_PAGE_BIRTH, (!current_world_ptr->wizard || !allow_debug_opts) ? _("初期オプション(参照のみ)", "Birth Options(browse only)") : _("初期オプション((*)はスコアに影響)", "Birth Options((*)s effect score)")); break; @@ -1476,7 +1476,7 @@ void do_cmd_options_aux(int page, concptr info) int opt[24]; char buf[80]; bool browse_only = (page == OPT_PAGE_BIRTH) && current_world_ptr->character_generated && - (!p_ptr->wizard || !allow_debug_opts); + (!current_world_ptr->wizard || !allow_debug_opts); /* Lookup the options */ diff --git a/src/combat/melee1.c b/src/combat/melee1.c index 48ab90b30..703e533ad 100644 --- a/src/combat/melee1.c +++ b/src/combat/melee1.c @@ -1543,7 +1543,7 @@ static void py_attack_aux(POSITION y, POSITION x, bool *fear, bool *mdeath, s16b { old_ptr = ma_ptr; - if (p_ptr->wizard && cheat_xtra) + if (current_world_ptr->wizard && cheat_xtra) { msg_print(_("攻撃を再選択しました。", "Attack re-selected.")); } diff --git a/src/core.c b/src/core.c index cd221008b..b81ce8908 100644 --- a/src/core.c +++ b/src/core.c @@ -3532,14 +3532,14 @@ static void process_command(void) /*** Wizard Commands ***/ case KTRL('W'): { - if (p_ptr->wizard) + if (current_world_ptr->wizard) { - p_ptr->wizard = FALSE; + current_world_ptr->wizard = FALSE; msg_print(_("ウィザードモード解除。", "Wizard mode off.")); } else if (enter_wizard_mode()) { - p_ptr->wizard = TRUE; + current_world_ptr->wizard = TRUE; msg_print(_("ウィザードモード突入。", "Wizard mode on.")); } p_ptr->update |= (PU_MONSTERS); @@ -5479,7 +5479,7 @@ void play_game(bool new_game) { if (enter_wizard_mode()) { - p_ptr->wizard = TRUE; + current_world_ptr->wizard = TRUE; if (p_ptr->is_dead || !p_ptr->y || !p_ptr->x) { @@ -5661,7 +5661,7 @@ void play_game(bool new_game) else { /* Mega-Hack -- Allow player to cheat death */ - if ((p_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? "))) + if ((current_world_ptr->wizard || cheat_live) && !get_check(_("死にますか? ", "Die? "))) { cheat_death(p_ptr); } diff --git a/src/files.c b/src/files.c index a30d73955..2b9ed19a6 100644 --- a/src/files.c +++ b/src/files.c @@ -645,7 +645,7 @@ errr process_pref_file_command(char *buf) int ob = option_info[i].o_bit; if ((p_ptr->playing || current_world_ptr->character_xtra) && - (OPT_PAGE_BIRTH == option_info[i].o_page) && !p_ptr->wizard) + (OPT_PAGE_BIRTH == option_info[i].o_page) && !current_world_ptr->wizard) { msg_format(_("初期オプションは変更できません! '%s'", "Birth options can not changed! '%s'"), buf); msg_print(NULL); diff --git a/src/load.c b/src/load.c index 7d1738d89..e88136bee 100644 --- a/src/load.c +++ b/src/load.c @@ -1541,7 +1541,7 @@ static void rd_options(void) rd_u16b(&c); - if (c & 0x0002) p_ptr->wizard = TRUE; + if (c & 0x0002) current_world_ptr->wizard = TRUE; cheat_peek = (c & 0x0100) ? TRUE : FALSE; cheat_hear = (c & 0x0200) ? TRUE : FALSE; diff --git a/src/monster-status.c b/src/monster-status.c index be8c6719a..e5c8fcb3d 100644 --- a/src/monster-status.c +++ b/src/monster-status.c @@ -1034,7 +1034,7 @@ bool mon_take_hit(MONSTER_IDX m_idx, HIT_POINT dam, bool *fear, concptr note) if (m_ptr->dealt_damage > m_ptr->max_maxhp * 100) m_ptr->dealt_damage = m_ptr->max_maxhp * 100; - if (p_ptr->wizard) + if (current_world_ptr->wizard) { msg_format(_("合計%d/%dのダメージを与えた。", "You do %d (out of %d) damage."), m_ptr->dealt_damage, m_ptr->maxhp); } diff --git a/src/monster1.c b/src/monster1.c index 0f46a4df8..c1cdfe45e 100644 --- a/src/monster1.c +++ b/src/monster1.c @@ -2041,7 +2041,7 @@ void roff_top(MONRACE_IDX r_idx) Term_addstr(-1, TERM_WHITE, "'):"); /* Wizards get extra info */ - if (p_ptr->wizard) + if (current_world_ptr->wizard) { char buf[16]; @@ -2972,7 +2972,7 @@ void monster_death(MONSTER_IDX m_idx, bool drop_item) chance = r_ptr->artifact_percent[i]; } - if ((a_idx > 0) && ((randint0(100) < chance) || p_ptr->wizard)) + if ((a_idx > 0) && ((randint0(100) < chance) || current_world_ptr->wizard)) { artifact_type *a_ptr = &a_info[a_idx]; diff --git a/src/object2.c b/src/object2.c index 5b08b825b..4542b79d4 100644 --- a/src/object2.c +++ b/src/object2.c @@ -4605,7 +4605,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION #else msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(破損)", "(breakage)")); + if (current_world_ptr->wizard) msg_print(_("(破損)", "(breakage)")); /* Failure */ return (0); @@ -4704,7 +4704,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); + if (current_world_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); /* Failure */ return (0); @@ -4753,7 +4753,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); + if (current_world_ptr->wizard) msg_print(_("(床スペースがない)", "(no floor space)")); /* Mega-Hack -- preserve artifacts */ if (preserve_mode) @@ -4826,7 +4826,7 @@ OBJECT_IDX drop_near(object_type *j_ptr, PERCENTAGE chance, POSITION y, POSITION msg_format("The %s disappear%s.", o_name, (plural ? "" : "s")); #endif - if (p_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)")); + if (current_world_ptr->wizard) msg_print(_("(アイテムが多過ぎる)", "(too many objects)")); /* Hack -- Preserve artifacts */ if (object_is_fixed_artifact(j_ptr)) diff --git a/src/player-move.c b/src/player-move.c index 8ab9373b4..6060dc69c 100644 --- a/src/player-move.c +++ b/src/player-move.c @@ -573,7 +573,7 @@ bool pattern_seq(player_type *creature_ptr, POSITION c_y, POSITION c_x, POSITION ok_move = PATTERN_TILE_1; break; default: - if (creature_ptr->wizard) + if (current_world_ptr->wizard) msg_format(_("おかしなパターン歩行、%d。", "Funny Pattern walking, %d."), pattern_type_cur); return TRUE; /* Goof-up */ diff --git a/src/player-status.c b/src/player-status.c index 47649efc6..ef873eed1 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5266,7 +5266,7 @@ void sanity_blast(player_type *creature_ptr, monster_type *m_ptr, bool necro) /* Demon characters are unaffected */ if (PRACE_IS_(creature_ptr, RACE_IMP) || PRACE_IS_(creature_ptr, RACE_DEMON) || (mimic_info[creature_ptr->mimic_form].MIMIC_FLAGS & MIMIC_IS_DEMON)) return; - if (creature_ptr->wizard) return; + if (current_world_ptr->wizard) return; /* Undead characters are 50% likely to be unaffected */ if (PRACE_IS_(creature_ptr, RACE_SKELETON) || PRACE_IS_(creature_ptr, RACE_ZOMBIE) diff --git a/src/player-status.h b/src/player-status.h index 1f3df00d0..24ffbb293 100644 --- a/src/player-status.h +++ b/src/player-status.h @@ -430,8 +430,6 @@ struct player_type bool reset_concent; /* Concentration reset flag */ - bool wizard; /* Player is in wizard mode */ - MONSTER_IDX riding; /* Riding on a monster of this index */ #define KNOW_STAT 0x01 diff --git a/src/realm-hex.c b/src/realm-hex.c index 7bd99c7c0..f1f5a5c79 100644 --- a/src/realm-hex.c +++ b/src/realm-hex.c @@ -36,6 +36,7 @@ #include "targeting.h" #include "realm-song.h" #include "view-mainwindow.h" +#include "world.h" #define MAX_KEEP 4 /*!<呪術の最大詠唱数 */ @@ -543,7 +544,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) project(0, rad, caster_ptr->y, caster_ptr->x, power, GF_HELL_FIRE, (PROJECT_STOP | PROJECT_GRID | PROJECT_ITEM | PROJECT_KILL), -1); } - if (caster_ptr->wizard) + if (current_world_ptr->wizard) { msg_format(_("%d点のダメージを返した。", "You return %d damages."), power); } @@ -1101,7 +1102,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode) fire_ball(GF_HELL_FIRE, dir, power, 1); - if (caster_ptr->wizard) + if (current_world_ptr->wizard) { msg_format(_("%d点のダメージを返した。", "You return %d damages."), power); } diff --git a/src/save.c b/src/save.c index 84fff1484..44ad47a26 100644 --- a/src/save.c +++ b/src/save.c @@ -484,7 +484,7 @@ static void wr_options(void) c = 0; - if (p_ptr->wizard) c |= 0x0002; + if (current_world_ptr->wizard) c |= 0x0002; if (cheat_sight) c |= 0x0040; if (cheat_turn) c |= 0x0080; diff --git a/src/spells3.c b/src/spells3.c index 84b46715d..d9787e516 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -514,7 +514,7 @@ void teleport_player_to(POSITION ny, POSITION nx, BIT_FLAGS mode) } /* Accept any grid when wizard mode */ - if (p_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!current_floor_ptr->grid_array[y][x].m_idx || (current_floor_ptr->grid_array[y][x].m_idx == p_ptr->riding))) break; + if (current_world_ptr->wizard && !(mode & TELEPORT_PASSIVE) && (!current_floor_ptr->grid_array[y][x].m_idx || (current_floor_ptr->grid_array[y][x].m_idx == p_ptr->riding))) break; /* Accept teleportable floor grids */ if (cave_player_teleportable_bold(y, x, mode)) break; @@ -654,7 +654,7 @@ void teleport_level(MONSTER_IDX m_idx) if (randint0(100) < 50) go_up = TRUE; else go_up = FALSE; - if ((m_idx <= 0) && p_ptr->wizard) + if ((m_idx <= 0) && current_world_ptr->wizard) { if (get_check("Force to go up? ")) go_up = TRUE; else if (get_check("Force to go down? ")) go_up = FALSE; @@ -2652,7 +2652,7 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y char buf[256]; bool max = FALSE; - if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && p_ptr->wizard) + if (((use_realm <= REALM_NONE) || (use_realm > MAX_REALM)) && current_world_ptr->wizard) msg_print(_("警告! print_spell が領域なしに呼ばれた", "Warning! print_spells called with null realm")); /* Title the list */ diff --git a/src/targeting.c b/src/targeting.c index 7e0a7a83d..1460e6779 100644 --- a/src/targeting.c +++ b/src/targeting.c @@ -39,6 +39,7 @@ #include "quest.h" #include "dungeon.h" #include "spells.h" +#include "world.h" /*! * @brief コンソール上におけるマップ表示の左上位置を返す / @@ -465,7 +466,7 @@ static void evaluate_monster_exp(char *buf, monster_type *m_ptr) } else if (!ap_r_ptr->r_tkills || (m_ptr->mflag2 & MFLAG2_KAGE)) { - if (!p_ptr->wizard) + if (!current_world_ptr->wizard) { sprintf(buf,"??"); return; @@ -974,7 +975,7 @@ static char target_set_aux(POSITION y, POSITION x, BIT_FLAGS mode, concptr info) #endif /* Display a message */ - if (p_ptr->wizard) + if (current_world_ptr->wizard) { char f_idx_str[32]; if (g_ptr->mimic) sprintf(f_idx_str, "%d/%d", g_ptr->feat, g_ptr->mimic); diff --git a/src/view-mainwindow.c b/src/view-mainwindow.c index d907ed9f0..962b5d7dd 100644 --- a/src/view-mainwindow.c +++ b/src/view-mainwindow.c @@ -745,7 +745,7 @@ static void prt_title(void) concptr p = ""; GAME_TEXT str[14]; - if (p_ptr->wizard) + if (current_world_ptr->wizard) { p = _("[ウィザード]", "[=-WIZARD-=]"); } @@ -1011,7 +1011,7 @@ static void prt_depth(void) */ static void prt_hunger(void) { - if(p_ptr->wizard && p_ptr->inside_arena) return; + if(current_world_ptr->wizard && p_ptr->inside_arena) return; /* Fainting / Starving */ if (p_ptr->food < PY_FOOD_FAINT) @@ -1392,7 +1392,7 @@ static void health_redraw(bool riding) m_ptr = ¤t_floor_ptr->m_list[health_who]; - if (p_ptr->wizard && p_ptr->phase_out) + if (current_world_ptr->wizard && p_ptr->phase_out) { row = ROW_INFO - 2; col = COL_INFO + 2; diff --git a/src/world.h b/src/world.h index 1d4b485ef..c3c93ba2e 100644 --- a/src/world.h +++ b/src/world.h @@ -55,9 +55,11 @@ typedef struct { bool creating_savefile; /* New savefile is currently created */ + bool wizard; /* This world under wizard mode */ + } world_type; extern bool is_daytime(void); extern void extract_day_hour_min(int *day, int *hour, int *min); -extern world_type *current_world_ptr; \ No newline at end of file +extern world_type *current_world_ptr; -- 2.11.0