OSDN Git Service

[Refactor] #37353 spell_okay() to cmd-spell.c.
authordeskull <deskull@users.sourceforge.jp>
Tue, 5 Mar 2019 14:35:46 +0000 (23:35 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Tue, 5 Mar 2019 14:35:46 +0000 (23:35 +0900)
src/cmd-spell.c
src/externs.h
src/spells3.c

index 3975b54..39c8b39 100644 (file)
@@ -183,6 +183,60 @@ concptr info_weight(WEIGHT weight)
 }
 
 /*!
+ * @brief 魔法が利用可能かどうかを返す /
+ * Determine if a spell is "okay" for the player to cast or study
+ * The spell must be legible, not forgotten, and also, to cast,
+ * it must be known, and to study, it must not be known.
+ * @param spell 呪文ID
+ * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
+ * @param study_pray 祈りの学習判定目的ならばTRUE
+ * @param use_realm 魔法領域ID
+ * @return 失敗率(%)
+ */
+static bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
+{
+       const magic_type *s_ptr;
+
+       /* Access the spell */
+       if (!is_magic(use_realm))
+       {
+               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
+       }
+       else
+       {
+               s_ptr = &mp_ptr->info[use_realm - 1][spell];
+       }
+
+       /* Spell is illegal */
+       if (s_ptr->slevel > p_ptr->lev) return (FALSE);
+
+       /* Spell is forgotten */
+       if ((use_realm == p_ptr->realm2) ?
+               (p_ptr->spell_forgotten2 & (1L << spell)) :
+               (p_ptr->spell_forgotten1 & (1L << spell)))
+       {
+               /* Never okay */
+               return (FALSE);
+       }
+
+       if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
+       if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
+
+       /* Spell is learned */
+       if ((use_realm == p_ptr->realm2) ?
+               (p_ptr->spell_learned2 & (1L << spell)) :
+               (p_ptr->spell_learned1 & (1L << spell)))
+       {
+               /* Always true */
+               return (!study_pray);
+       }
+
+       /* Okay to study, not to cast */
+       return (!learned);
+}
+
+
+/*!
  * @brief 魔法処理のメインルーチン
  * @param realm 魔法領域のID
  * @param spell 各領域の魔法ID
index e2bfde9..050f5c8 100644 (file)
@@ -983,7 +983,6 @@ extern MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX
 extern PERCENTAGE mod_spell_chance_1(PERCENTAGE chance);
 extern PERCENTAGE mod_spell_chance_2(PERCENTAGE chance);
 extern PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX realm);
-extern bool spell_okay(int spell, bool learned, bool study_pray, int realm);
 extern void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX realm);
 extern bool polymorph_monster(POSITION y, POSITION x);
 extern bool dimension_door(void);
index 2140428..fcaf7ad 100644 (file)
@@ -3493,60 +3493,6 @@ PERCENTAGE spell_chance(SPELL_IDX spell, REALM_IDX use_realm)
 }
 
 
-/*!
- * @brief 魔法が利用可能かどうかを返す /
- * Determine if a spell is "okay" for the player to cast or study
- * The spell must be legible, not forgotten, and also, to cast,
- * it must be known, and to study, it must not be known.
- * @param spell 呪文ID
- * @param learned 使用可能な判定ならばTRUE、学習可能かどうかの判定ならばFALSE
- * @param study_pray 祈りの学習判定目的ならばTRUE
- * @param use_realm 魔法領域ID
- * @return 失敗率(%)
- */
-bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
-{
-       const magic_type *s_ptr;
-
-       /* Access the spell */
-       if (!is_magic(use_realm))
-       {
-               s_ptr = &technic_info[use_realm - MIN_TECHNIC][spell];
-       }
-       else
-       {
-               s_ptr = &mp_ptr->info[use_realm - 1][spell];
-       }
-
-       /* Spell is illegal */
-       if (s_ptr->slevel > p_ptr->lev) return (FALSE);
-
-       /* Spell is forgotten */
-       if ((use_realm == p_ptr->realm2) ?
-           (p_ptr->spell_forgotten2 & (1L << spell)) :
-           (p_ptr->spell_forgotten1 & (1L << spell)))
-       {
-               /* Never okay */
-               return (FALSE);
-       }
-
-       if (p_ptr->pclass == CLASS_SORCERER) return (TRUE);
-       if (p_ptr->pclass == CLASS_RED_MAGE) return (TRUE);
-
-       /* Spell is learned */
-       if ((use_realm == p_ptr->realm2) ?
-           (p_ptr->spell_learned2 & (1L << spell)) :
-           (p_ptr->spell_learned1 & (1L << spell)))
-       {
-               /* Always true */
-               return (!study_pray);
-       }
-
-       /* Okay to study, not to cast */
-       return (!learned);
-}
-
-
 
 /*!
  * @brief 呪文情報の表示処理 /