OSDN Git Service

[merge](2.2.1.3) fix-gcc-warningブランチをマージ
[hengband/hengband.git] / src / hex.c
index 5b697c7..101ceb9 100644 (file)
--- a/src/hex.c
+++ b/src/hex.c
@@ -1,31 +1,39 @@
-#include "angband.h"
+/*!
+ * @file hex.c
+ * @brief 呪術の処理実装 / Hex code
+ * @date 2014/01/14
+ * @author
+ * 2014 Deskull rearranged comment for Doxygen.\n
+ * @details
+ * p_ptr-magic_num1\n
+ * 0: Flag bits of spelling spells\n
+ * 1: Flag bits of despelled spells\n
+ * 2: Revange damage\n
+ * p_ptr->magic_num2\n
+ * 0: Number of spelling spells\n
+ * 1: Type of revenge\n
+ * 2: Turn count for revenge\n
+ */
 
-/* Flag list */
-/*
-p_ptr-magic_num1
-0: Flag bits of spelling spells
-1: Flag bits of despelled spells
-2: Revange damage
-p_ptr->magic_num2
-0: Number of spelling spells
-1: Type of revenge
-2: Turn count for revenge
-*/
+#include "angband.h"
 
-#define MAX_KEEP 4
+#define MAX_KEEP 4 /*!<呪術の最大詠唱数 */
 
+/*!
+ * @brief プレイヤーが詠唱中の全呪術を停止する
+ * @return なし
+ */
 bool stop_hex_spell_all(void)
 {
        int i;
 
        for (i = 0; i < 32; i++)
        {
-               u32b spell = 1L << i;
-               if (hex_spelling(spell)) do_spell(REALM_HEX, spell, SPELL_STOP);
+               if (hex_spelling(i)) do_spell(REALM_HEX, i, SPELL_STOP);
        }
 
-       p_ptr->magic_num1[0] = 0;
-       p_ptr->magic_num2[0] = 0;
+       CASTING_HEX_FLAGS(p_ptr) = 0;
+       CASTING_HEX_NUM(p_ptr) = 0;
 
        /* Print message */
        if (p_ptr->action == ACTION_SPELL) set_action(ACTION_NONE);
@@ -37,7 +45,10 @@ bool stop_hex_spell_all(void)
        return TRUE;
 }
 
-
+/*!
+ * @brief プレイヤーが詠唱中の呪術から一つを選んで停止する
+ * @return なし
+ */
 bool stop_hex_spell(void)
 {
        int spell;
@@ -51,7 +62,7 @@ bool stop_hex_spell(void)
        if (!hex_spelling_any())
        {
 #ifdef JP
-               msg_print("¼öʸ¤ò±Ó¾§¤·¤Æ¤¤¤Þ¤»¤ó¡£");
+               msg_print("呪文を詠唱していません。");
 #else
                msg_print("You are casting no spell.");
 #endif
@@ -59,18 +70,18 @@ bool stop_hex_spell(void)
        }
 
        /* Stop all spells */
-       else if ((p_ptr->magic_num2[0] == 1) || (p_ptr->lev < 35))
+       else if ((CASTING_HEX_NUM(p_ptr) == 1) || (p_ptr->lev < 35))
        {
                return stop_hex_spell_all();
        }
        else
        {
 #ifdef JP
-               strnfmt(out_val, 78, "¤É¤Î¼öʸ¤Î±Ó¾§¤òÃæÃǤ·¤Þ¤¹¤«¡©(¼öʸ %c-%c, 'l'Á´¤Æ, ESC)",
-                       I2A(0), I2A(p_ptr->magic_num2[0] - 1));
+               strnfmt(out_val, 78, "どの呪文の詠唱を中断しますか?(呪文 %c-%c, 'l'全て, ESC)",
+                       I2A(0), I2A(CASTING_HEX_NUM(p_ptr) - 1));
 #else
                strnfmt(out_val, 78, "Which spell do you stop casting? (Spell %c-%c, 'l' to all, ESC)",
-                       I2A(0), I2A(p_ptr->magic_num2[0] - 1));
+                       I2A(0), I2A(CASTING_HEX_NUM(p_ptr) - 1));
 #endif
 
                screen_save();
@@ -79,7 +90,7 @@ bool stop_hex_spell(void)
                {
                        int n = 0;
                        Term_erase(x, y, 255);
-                       prt("     Ì¾Á°", y, x + 5);
+                       prt("     名前", y, x + 5);
                        for (spell = 0; spell < 32; spell++)
                        {
                                if (hex_spelling(spell))
@@ -91,14 +102,14 @@ bool stop_hex_spell(void)
                        }
 
                        if (!get_com(out_val, &choice, TRUE)) break;
-                       if (isupper(choice)) choice = tolower(choice);
+                       if (isupper(choice)) choice = (char)tolower(choice);
 
                        if (choice == 'l')      /* All */
                        {
                                screen_load();
                                return stop_hex_spell_all();
                        }
-                       if ((choice < I2A(0)) || (choice > I2A(p_ptr->magic_num2[0] - 1))) continue;
+                       if ((choice < I2A(0)) || (choice > I2A(CASTING_HEX_NUM(p_ptr) - 1))) continue;
                        flag = TRUE;
                }
        }
@@ -110,8 +121,8 @@ bool stop_hex_spell(void)
                int n = sp[A2I(choice)];
 
                do_spell(REALM_HEX, n, SPELL_STOP);
-               p_ptr->magic_num1[0] &= ~(1L << n);
-               p_ptr->magic_num2[0]--;
+               CASTING_HEX_FLAGS(p_ptr) &= ~(1L << n);
+               CASTING_HEX_NUM(p_ptr)--;
        }
 
        /* Redraw status */
@@ -122,11 +133,13 @@ bool stop_hex_spell(void)
 }
 
 
-/* Upkeeping hex spells
-   Called from dungeon.c */
+/*!
+ * @brief 一定時間毎に呪術で消費するMPを処理する /
+ * Upkeeping hex spells Called from dungeon.c
+ * @return なし
+ */
 void check_hex(void)
 {
-       const magic_type *s_ptr;
        int spell;
        s32b need_mana;
        u32b need_mana_frac;
@@ -134,7 +147,7 @@ void check_hex(void)
 
        /* Spells spelled by player */
        if (p_ptr->realm1 != REALM_HEX) return;
-       if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
+       if (!CASTING_HEX_FLAGS(p_ptr) && !p_ptr->magic_num1[1]) return;
 
        if (p_ptr->magic_num1[1])
        {
@@ -155,6 +168,7 @@ void check_hex(void)
        {
                if (hex_spelling(spell))
                {
+                       const magic_type *s_ptr;
                        s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
                        need_mana += mod_need_mana(s_ptr->smana, spell, REALM_HEX);
                }
@@ -164,7 +178,7 @@ void check_hex(void)
        /* Culcurates final mana cost */
        need_mana_frac = 0;
        s64b_div(&need_mana, &need_mana_frac, 0, 3); /* Divide by 3 */
-       need_mana += (p_ptr->magic_num2[0] - 1);
+       need_mana += (CASTING_HEX_NUM(p_ptr) - 1);
 
 
        /* Not enough mana */
@@ -183,7 +197,7 @@ void check_hex(void)
                if (res)
                {
 #ifdef JP
-                       msg_print("±Ó¾§¤òºÆ³«¤·¤¿¡£");
+                       msg_print("詠唱を再開した。");
 #else
                        msg_print("You restart spelling.");
 #endif
@@ -206,8 +220,12 @@ void check_hex(void)
        /* Gain experiences of spelling spells */
        for (spell = 0; spell < 32; spell++)
        {
+               const magic_type *s_ptr;
+
                if (!hex_spelling(spell)) continue;
 
+               s_ptr = &technic_info[REALM_HEX - MIN_TECHNIC][spell];
+
                if (p_ptr->spell_exp[spell] < SPELL_EXP_BEGINNER)
                        p_ptr->spell_exp[spell] += 5;
                else if(p_ptr->spell_exp[spell] < SPELL_EXP_SKILLED)
@@ -228,7 +246,10 @@ void check_hex(void)
        }
 }
 
-
+/*!
+ * @brief プレイヤーの呪術詠唱枠がすでに最大かどうかを返す
+ * @return すでに全枠を利用しているならTRUEを返す
+ */
 bool hex_spell_fully(void)
 {
        int k_max = 0;
@@ -238,33 +259,46 @@ bool hex_spell_fully(void)
        /* Paranoia */
        k_max = MIN(k_max, MAX_KEEP);
 
-       if (p_ptr->magic_num2[0] < k_max) return FALSE;
+       if (CASTING_HEX_NUM(p_ptr) < k_max) return FALSE;
 
        return TRUE;
 }
 
-void revenge_spell()
+/*!
+ * @brief 一定ゲームターン毎に復讐処理の残り期間の判定を行う
+ * @return なし
+ */
+void revenge_spell(void)
 {
        if (p_ptr->realm1 != REALM_HEX) return;
-       if (p_ptr->magic_num2[2] <= 0) return;
+       if (HEX_REVENGE_TURN(p_ptr) <= 0) return;
 
-       switch(p_ptr->magic_num2[1])
+       switch(HEX_REVENGE_TYPE(p_ptr))
        {
-       case 1: do_spell(REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
-       case 2: do_spell(REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
+               case 1: do_spell(REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
+               case 2: do_spell(REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
        }
 }
 
-void revenge_store(int dam)
+/*!
+ * @brief 復讐ダメージの追加を行う
+ * @param dam 蓄積されるダメージ量
+ * @return なし
+ */
+void revenge_store(HIT_POINT dam)
 {
        if (p_ptr->realm1 != REALM_HEX) return;
-       if (p_ptr->magic_num2[2] <= 0) return;
+       if (HEX_REVENGE_TURN(p_ptr) <= 0) return;
 
-       p_ptr->magic_num1[2] += dam;
+       HEX_REVENGE_POWER(p_ptr) += dam;
 }
 
-
-bool teleport_barrier(int m_idx)
+/*!
+ * @brief 反テレポート結界の判定
+ * @param m_idx 判定の対象となるモンスターID
+ * @return 反テレポートの効果が適用されるならTRUEを返す
+ */
+bool teleport_barrier(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -275,8 +309,12 @@ bool teleport_barrier(int m_idx)
        return TRUE;
 }
 
-
-bool magic_barrier(int m_idx)
+/*!
+ * @brief 反魔法結界の判定
+ * @param m_idx 判定の対象となるモンスターID
+ * @return 反魔法の効果が適用されるならTRUEを返す
+ */
+bool magic_barrier(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];
@@ -287,8 +325,12 @@ bool magic_barrier(int m_idx)
        return TRUE;
 }
 
-
-bool multiply_barrier(int m_idx)
+/*!
+ * @brief 反増殖結界の判定
+ * @param m_idx 判定の対象となるモンスターID
+ * @return 反増殖の効果が適用されるならTRUEを返す
+ */
+bool multiply_barrier(MONSTER_IDX m_idx)
 {
        monster_type *m_ptr = &m_list[m_idx];
        monster_race *r_ptr = &r_info[m_ptr->r_idx];