OSDN Git Service

[Refactor] #38997 spells.h にあったTELE_LEVEL_IS_INEFF() の関数マクロを普通の関数に変換しspells3.cに配置...
authorHourier <hourier@users.sourceforge.jp>
Thu, 9 Jan 2020 12:43:47 +0000 (21:43 +0900)
committerHourier <hourier@users.sourceforge.jp>
Thu, 9 Jan 2020 12:43:47 +0000 (21:43 +0900)
src/mspells1.c
src/mspells2.c
src/player-inventory.c
src/spells.h
src/spells3.c

index 6af5db3..a3a5da2 100644 (file)
@@ -1565,7 +1565,7 @@ bool make_attack_spell(MONSTER_IDX m_idx, player_type *target_ptr)
                }
 
                /* Hack -- decline "teleport level" in some case */
-               if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF(0))
+               if ((f6 & RF6_TELE_LEVEL) && is_teleport_level_ineffective(target_ptr, 0))
                {
                        f6 &= ~(RF6_TELE_LEVEL);
                }
index 156f44b..2a1fb67 100644 (file)
@@ -644,7 +644,7 @@ bool monst_spell_monst(player_type *target_ptr, MONSTER_IDX m_idx)
                }
 
                /* Hack -- decline "teleport level" in some case */
-               if ((f6 & RF6_TELE_LEVEL) && TELE_LEVEL_IS_INEFF((target_idx == target_ptr->riding) ? 0 : target_idx))
+               if ((f6 & RF6_TELE_LEVEL) && is_teleport_level_ineffective(target_ptr, (target_idx == target_ptr->riding) ? 0 : target_idx))
                {
                        f6 &= ~(RF6_TELE_LEVEL);
                }
index cad6a0a..00735d5 100644 (file)
@@ -28,6 +28,7 @@ bool is_ring_slot(int i)
 
 /*!
  * @brief 選択アルファベットラベルからプレイヤーの装備オブジェクトIDを返す /
+ * @param player_ptr プレーヤーへの参照ポインタ
  * Convert a label into the index of a item in the "equip"
  * @return 対応するID。該当スロットにオブジェクトが存在しなかった場合-1を返す / Return "-1" if the label does not indicate a real item
  */
index 17ae8ac..afa12c9 100644 (file)
@@ -327,11 +327,5 @@ extern bool detonation(player_type *creature_ptr);
 extern void blood_curse_to_enemy(player_type *caster_ptr, MONSTER_IDX m_idx);
 extern bool fire_crimson(player_type *shooter_ptr);
 extern bool tele_town(player_type *caster_ptr);
+extern bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx);
 extern int project_length;
-
-/* Is "teleport level" ineffective to this target? */
-#define TELE_LEVEL_IS_INEFF(TARGET) \
-       (p_ptr->current_floor_ptr->inside_arena || p_ptr->phase_out || \
-        (p_ptr->current_floor_ptr->inside_quest && !random_quest_number(p_ptr->current_floor_ptr->dun_level)) || \
-        (((TARGET) <= 0) && (quest_number(p_ptr->current_floor_ptr->dun_level) || (p_ptr->current_floor_ptr->dun_level >= d_info[p_ptr->dungeon_idx].maxdepth)) && \
-         (p_ptr->current_floor_ptr->dun_level >= 1) && ironman_downward))
index e9786f9..ef6745b 100644 (file)
@@ -616,7 +616,7 @@ void teleport_level(player_type *creature_ptr, MONSTER_IDX m_idx)
        }
 
        /* No effect in some case */
-       if (TELE_LEVEL_IS_INEFF(m_idx))
+       if (is_teleport_level_ineffective(creature_ptr, m_idx))
        {
                if (see_m) msg_print(_("効果がなかった。", "There is no effect."));
                return;
@@ -3500,6 +3500,25 @@ bool tele_town(player_type *caster_ptr)
 }
 
 
+/*!
+* todo 変数名が実態と合っているかどうかは要確認
+* テレポート・レベルが効かないモンスターであるかどうかを判定する
+* @param caster_ptr プレーヤーへの参照ポインタ
+* @param idx テレポート・レベル対象のモンスター
+*/
+bool is_teleport_level_ineffective(player_type *caster_ptr, MONSTER_IDX idx)
+{
+       floor_type *floor_ptr = caster_ptr->current_floor_ptr;
+       bool is_special_floor = floor_ptr->inside_arena || caster_ptr->phase_out ||
+               (floor_ptr->inside_quest && !random_quest_number(floor_ptr->dun_level));
+       bool is_invalid_floor = idx <= 0;
+       is_invalid_floor &= quest_number(floor_ptr->dun_level) || (floor_ptr->dun_level >= d_info[caster_ptr->dungeon_idx].maxdepth);
+       is_invalid_floor &= caster_ptr->current_floor_ptr->dun_level >= 1;
+       is_invalid_floor &= ironman_downward;
+       return is_special_floor || is_invalid_floor;
+}
+
+
 static bool update_player(player_type *caster_ptr)
 {
        caster_ptr->update |= PU_COMBINE | PU_REORDER;