OSDN Git Service

[Refactor] プレイヤーがダンジョンに居るかの判定をis_in_dungeon()関数に置換. / Replaced determining if a playe...
authordeskull <deskull@users.sourceforge.jp>
Tue, 9 Mar 2021 10:59:39 +0000 (19:59 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 9 Mar 2021 10:59:39 +0000 (19:59 +0900)
17 files changed:
src/action/action-limited.cpp
src/cmd-action/cmd-move.cpp
src/cmd-building/cmd-store.cpp
src/cmd-io/cmd-dump.cpp
src/core/hp-mp-processor.cpp
src/core/player-processor.cpp
src/floor/floor-leaver.cpp
src/grid/grid.cpp
src/io/write-diary.cpp
src/load/player-info-loader.cpp
src/monster-race/monster-race-hook.cpp
src/mutation/mutation-processor.cpp
src/player/player-damage.cpp
src/player/player-status.cpp
src/player/player-status.h
src/spell-kind/spells-world.cpp
src/wizard/wizard-special-process.cpp

index afbb7e6..83c51b4 100644 (file)
@@ -15,7 +15,7 @@
  */
 bool cmd_limit_cast(player_type *creature_ptr)
 {
-    if (creature_ptr->current_floor_ptr->dun_level && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC)) {
+    if (is_in_dungeon(creature_ptr) && (d_info[creature_ptr->dungeon_idx].flags1 & DF1_NO_MAGIC)) {
         msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
         msg_print(NULL);
         return TRUE;
index df50518..638d9f5 100644 (file)
@@ -104,7 +104,7 @@ void do_cmd_go_up(player_type *creature_ptr)
         return;
     }
 
-    if (!creature_ptr->current_floor_ptr->dun_level)
+    if (!is_in_dungeon(creature_ptr))
         go_up = TRUE;
     else
         go_up = confirm_leave_level(creature_ptr, FALSE);
@@ -216,7 +216,7 @@ void do_cmd_go_down(player_type *creature_ptr)
     }
 
     DUNGEON_IDX target_dungeon = 0;
-    if (!creature_ptr->current_floor_ptr->dun_level) {
+    if (!is_in_dungeon(creature_ptr)) {
         target_dungeon = has_flag(f_ptr->flags, FF_ENTRANCE) ? g_ptr->special : DUNGEON_ANGBAND;
         if (ironman_downward && (target_dungeon != DUNGEON_ANGBAND)) {
             msg_print(_("ダンジョンの入口は塞がれている!", "The entrance of this dungeon is closed!"));
@@ -245,7 +245,7 @@ void do_cmd_go_down(player_type *creature_ptr)
     else
         down_num += 1;
 
-    if (!creature_ptr->current_floor_ptr->dun_level) {
+    if (!is_in_dungeon(creature_ptr)) {
         creature_ptr->enter_dungeon = TRUE;
         down_num = d_info[creature_ptr->dungeon_idx].mindepth;
     }
index efb2624..71558a5 100644 (file)
@@ -76,7 +76,7 @@ void do_cmd_store(player_type *player_ptr)
     old_town_num = player_ptr->town_num;
     if ((which == STORE_HOME) || (which == STORE_MUSEUM))
         player_ptr->town_num = 1;
-    if (player_ptr->current_floor_ptr->dun_level)
+    if (is_in_dungeon(player_ptr))
         player_ptr->town_num = NO_TOWN;
     inner_town_num = player_ptr->town_num;
 
index d563e50..3d4d5ad 100644 (file)
@@ -221,7 +221,7 @@ void do_cmd_feeling(player_type *creature_ptr)
         return;
     }
 
-    if (!creature_ptr->current_floor_ptr->dun_level) {
+    if (!is_in_dungeon(creature_ptr)) {
         msg_print(_("典型的な荒野のようだ。", "Looks like a typical wilderness."));
         return;
     }
index 08c7387..17fb98f 100644 (file)
@@ -70,7 +70,7 @@ void process_player_hp_mp(player_type *creature_ptr)
     }
 
     if (is_specific_player_race(creature_ptr, RACE_VAMPIRE) || (creature_ptr->mimic_form == MIMIC_VAMPIRE)) {
-        if (!creature_ptr->current_floor_ptr->dun_level && !has_resist_lite(creature_ptr) && !is_invuln(creature_ptr) && is_daytime()) {
+        if (!is_in_dungeon(creature_ptr) && !has_resist_lite(creature_ptr) && !is_invuln(creature_ptr) && is_daytime()) {
             if ((creature_ptr->current_floor_ptr->grid_array[creature_ptr->y][creature_ptr->x].info & (CAVE_GLOW | CAVE_MNDK)) == CAVE_GLOW) {
                 msg_print(_("日光があなたのアンデッドの肉体を焼き焦がした!", "The sun's rays scorch your undead flesh!"));
                 take_hit(creature_ptr, DAMAGE_NOESCAPE, 1, _("日光", "sunlight"), -1);
index 7613dbf..c094f0c 100644 (file)
@@ -59,7 +59,7 @@ static void process_fishing(player_type *creature_ptr)
         bool success = FALSE;
         get_mon_num_prep(creature_ptr, monster_is_fishing_target, NULL);
         r_idx = get_mon_num(creature_ptr, 0,
-            creature_ptr->current_floor_ptr->dun_level ? creature_ptr->current_floor_ptr->dun_level
+            is_in_dungeon(creature_ptr) ? creature_ptr->current_floor_ptr->dun_level
                                                        : wilderness[creature_ptr->wilderness_y][creature_ptr->wilderness_x].level,
             0);
         msg_print(NULL);
index 2527f53..e970577 100644 (file)
@@ -307,7 +307,7 @@ static void jump_floors(player_type *creature_ptr)
         move_num += SGN(move_num);
 
     if (creature_ptr->change_floor_mode & CFM_DOWN) {
-        if (!creature_ptr->current_floor_ptr->dun_level)
+        if (!is_in_dungeon(creature_ptr))
             move_num = d_info[creature_ptr->dungeon_idx].mindepth;
     } else if (creature_ptr->change_floor_mode & CFM_UP) {
         if (creature_ptr->current_floor_ptr->dun_level + move_num < d_info[creature_ptr->dungeon_idx].mindepth)
@@ -319,7 +319,7 @@ static void jump_floors(player_type *creature_ptr)
 
 static void exit_to_wilderness(player_type *creature_ptr)
 {
-    if ((creature_ptr->current_floor_ptr->dun_level != 0) || (creature_ptr->dungeon_idx == 0))
+    if (is_in_dungeon(creature_ptr) || (creature_ptr->dungeon_idx == 0))
         return;
 
     creature_ptr->leaving_dungeon = TRUE;
index a03e621..dc3f426 100644 (file)
@@ -208,7 +208,7 @@ bool new_player_spot(player_type *creature_ptr)
         /* Must be a "naked" floor grid */
         if (g_ptr->m_idx)
             continue;
-        if (creature_ptr->current_floor_ptr->dun_level) {
+        if (is_in_dungeon(creature_ptr)) {
             f_ptr = &f_info[g_ptr->feat];
 
             if (max_attempts > 5000) /* Rule 1 */
index a1daf85..2fa3b48 100644 (file)
@@ -362,7 +362,7 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note)
        }
        case DIARY_WIZ_TELE:
        {
-               concptr to = !creature_ptr->current_floor_ptr->dun_level
+        concptr to = !is_in_dungeon(creature_ptr)
                        ? _("地上", "the surface")
                        : format(_("%d階(%s)", "level %d of %s"), creature_ptr->current_floor_ptr->dun_level, d_name + d_info[creature_ptr->dungeon_idx].name);
                fprintf(fff, _(" %2d:%02d %20s %sへとウィザード・テレポートで移動した。\n",
@@ -371,7 +371,7 @@ errr exe_write_diary(player_type *creature_ptr, int type, int num, concptr note)
        }
        case DIARY_PAT_TELE:
        {
-               concptr to = !creature_ptr->current_floor_ptr->dun_level
+               concptr to = !is_in_dungeon(creature_ptr)
                        ? _("地上", "the surface")
                        : format(_("%d階(%s)", "level %d of %s"), creature_ptr->current_floor_ptr->dun_level, d_name + d_info[creature_ptr->dungeon_idx].name);
                fprintf(fff, _(" %2d:%02d %20s %sへとパターンの力で移動した。\n",
index f09574e..0126ff2 100644 (file)
@@ -248,7 +248,7 @@ static void rd_arena(player_type *creature_ptr)
     creature_ptr->oldpx = (POSITION)tmp16s;
     rd_s16b(&tmp16s);
     creature_ptr->oldpy = (POSITION)tmp16s;
-    if (z_older_than(10, 3, 13) && !creature_ptr->current_floor_ptr->dun_level && !creature_ptr->current_floor_ptr->inside_arena) {
+    if (z_older_than(10, 3, 13) && !is_in_dungeon(creature_ptr) && !creature_ptr->current_floor_ptr->inside_arena) {
         creature_ptr->oldpy = 33;
         creature_ptr->oldpx = 131;
     }
index b9b1bd5..00ed481 100644 (file)
@@ -127,7 +127,7 @@ bool mon_hook_quest(player_type *player_ptr, MONRACE_IDX r_idx)
  */
 bool mon_hook_dungeon(player_type *player_ptr, MONRACE_IDX r_idx)
 {
-    if (!player_ptr->current_floor_ptr->dun_level && !player_ptr->current_floor_ptr->inside_quest)
+    if (!is_in_dungeon(player_ptr) && !player_ptr->current_floor_ptr->inside_quest)
         return TRUE;
 
     monster_race *r_ptr = &r_info[r_idx];
index 38fa369..950dc38 100644 (file)
@@ -237,7 +237,7 @@ void process_world_aux_mutation(player_type *creature_ptr)
         msg_print(_("突然ほとんど孤独になった気がする。", "You suddenly feel almost lonely."));
 
         banish_monsters(creature_ptr, 100);
-        if (!creature_ptr->current_floor_ptr->dun_level && creature_ptr->town_num) {
+        if (!is_in_dungeon(creature_ptr) && creature_ptr->town_num) {
             int n;
             do {
                 n = randint0(MAX_STORES);
index 391cf84..a736b0c 100644 (file)
@@ -395,7 +395,7 @@ int take_hit(player_type *creature_ptr, int damage_type, HIT_POINT damage, concp
 
                 if (creature_ptr->current_floor_ptr->inside_arena)
                     strcpy(buf, _("アリーナ", "in the Arena"));
-                else if (!creature_ptr->current_floor_ptr->dun_level)
+                else if (!is_in_dungeon(creature_ptr))
                     strcpy(buf, _("地上", "on the surface"));
                 else if (q_idx && (is_fixed_quest_idx(q_idx) && !((q_idx == QUEST_OBERON) || (q_idx == QUEST_SERPENT))))
                     strcpy(buf, _("クエスト", "in a quest"));
index 520fb31..ec05ccc 100644 (file)
@@ -4469,3 +4469,12 @@ static player_hand main_attack_hand(player_type *creature_ptr)
     }
     return PLAYER_HAND_MAIN;
 }
+
+/*!
+ * @brief プレイヤーが現在ダンジョンに潜っているかどうかを返す。
+ * @memo 現在はdun_levelが0でないかそうでないかに限るが可読性を高めるため。
+ */
+bool is_in_dungeon(player_type *creature_ptr)
+{
+    return creature_ptr->current_floor_ptr->dun_level > 0;
+}
index 27f826e..10875d0 100644 (file)
@@ -511,6 +511,7 @@ bool is_invuln(player_type *creature_ptr);
 bool is_hero(player_type *creature_ptr);
 bool is_shero(player_type *creature_ptr);
 bool is_echizen(player_type *creature_ptr);
+bool is_in_dungeon(player_type *creature_ptr);
 
 /*
  * Player "food" crucial values
index a17c958..2e51e10 100644 (file)
@@ -108,7 +108,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
             msg_format("%^s sink%s through the floor.", m_name, (m_idx <= 0) ? "" : "s");
 #endif
         if (m_idx <= 0) {
-            if (!creature_ptr->current_floor_ptr->dun_level) {
+            if (!is_in_dungeon(creature_ptr)) {
                 creature_ptr->dungeon_idx = ironman_downward ? DUNGEON_ANGBAND : creature_ptr->recall_dungeon;
                 creature_ptr->oldpy = creature_ptr->y;
                 creature_ptr->oldpx = creature_ptr->x;
@@ -120,7 +120,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
             if (autosave_l)
                 do_cmd_save_game(creature_ptr, TRUE);
 
-            if (!creature_ptr->current_floor_ptr->dun_level) {
+            if (!is_in_dungeon(creature_ptr)) {
                 creature_ptr->current_floor_ptr->dun_level = d_info[creature_ptr->dungeon_idx].mindepth;
                 prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
             } else {
@@ -354,7 +354,7 @@ bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
         return TRUE;
     }
 
-    bool is_special_floor = creature_ptr->current_floor_ptr->dun_level > 0;
+    bool is_special_floor = is_in_dungeon(creature_ptr);
     is_special_floor &= max_dlv[creature_ptr->dungeon_idx] > creature_ptr->current_floor_ptr->dun_level;
     is_special_floor &= !creature_ptr->current_floor_ptr->inside_quest;
     is_special_floor &= !creature_ptr->word_recall;
@@ -373,7 +373,7 @@ bool recall_player(player_type *creature_ptr, TIME_EFFECT turns)
         return TRUE;
     }
 
-    if (!creature_ptr->current_floor_ptr->dun_level) {
+    if (!is_in_dungeon(creature_ptr)) {
         DUNGEON_IDX select_dungeon;
         select_dungeon = choose_dungeon(_("に帰還", "recall"), 2, 14);
         if (!select_dungeon)
index d5ea4af..390ebdc 100644 (file)
@@ -406,7 +406,7 @@ void wiz_jump_to_dungeon(player_type *creature_ptr)
 
     creature_ptr->current_floor_ptr->dun_level = command_arg;
     prepare_change_floor_mode(creature_ptr, CFM_RAND_PLACE);
-    if (!creature_ptr->current_floor_ptr->dun_level)
+    if (!is_in_dungeon(creature_ptr))
         creature_ptr->dungeon_idx = 0;
 
     creature_ptr->current_floor_ptr->inside_arena = FALSE;