OSDN Git Service

[Refactor] #37353 プレイヤーのロッド使用処理を cmd-zaprod.c/h に分離。 / Separate player's 'zap rod...
[hengband/hengband.git] / src / dungeon.c
index dc55eba..b3e6fdc 100644 (file)
  */
 
 #include "angband.h"
+#include "cmd-activate.h"
+#include "cmd-eat.h"
+#include "cmd-quaff.h"
+#include "cmd-read.h"
+#include "cmd-usestaff.h"
+#include "cmd-zaprod.h"
+#include "cmd-zapwand.h"
 
 #define TY_CURSE_CHANCE 200 /*!<太古の怨念の1ターン毎の発動確率(1/n)*/
 #define CHAINSWORD_NOISE 100 /*!<チェンソーの1ターン毎の発動確率(1/n)*/
@@ -1065,7 +1072,7 @@ static void regen_captured_monsters(void)
                        if (r_ptr->flags2 & RF2_REGENERATE) frac *= 2;
 
                        /* Hack -- Regenerate */
-                       o_ptr->xtra4 += frac;
+                       o_ptr->xtra4 += (XTRA16)frac;
 
                        /* Do not over-regenerate */
                        if (o_ptr->xtra4 > o_ptr->xtra5) o_ptr->xtra4 = o_ptr->xtra5;
@@ -1394,7 +1401,7 @@ static void check_music(void)
 
        /* Music singed by player */
        if (p_ptr->pclass != CLASS_BARD) return;
-       if (!p_ptr->magic_num1[0] && !p_ptr->magic_num1[1]) return;
+       if (!SINGING_SONG_EFFECT(p_ptr) && !INTERUPTING_SONG_EFFECT(p_ptr)) return;
 
        if (p_ptr->anti_magic)
        {
@@ -1402,7 +1409,7 @@ static void check_music(void)
                return;
        }
 
-       spell = p_ptr->magic_num2[0];
+       spell = SINGING_SONG_ID(p_ptr);
        s_ptr = &technic_info[REALM_MUSIC - MIN_TECHNIC][spell];
 
        need_mana = mod_need_mana(s_ptr->smana, spell, REALM_MUSIC);
@@ -1421,10 +1428,10 @@ static void check_music(void)
                s64b_sub(&(p_ptr->csp), &(p_ptr->csp_frac), need_mana, need_mana_frac);
 
                p_ptr->redraw |= PR_MANA;
-               if (p_ptr->magic_num1[1])
+               if (INTERUPTING_SONG_EFFECT(p_ptr))
                {
-                       p_ptr->magic_num1[0] = p_ptr->magic_num1[1];
-                       p_ptr->magic_num1[1] = 0;
+                       SINGING_SONG_EFFECT(p_ptr) = INTERUPTING_SONG_EFFECT(p_ptr);
+                       INTERUPTING_SONG_EFFECT(p_ptr) = MUSIC_NONE;
                        msg_print(_("歌を再開した。", "You restart singing."));
                        p_ptr->action = ACTION_SING;
 
@@ -1554,7 +1561,7 @@ static void process_world_aux_hp_and_sp(void)
        /* Take damage from cuts */
        if (p_ptr->cut && !IS_INVULN())
        {
-               int dam;
+               HIT_POINT dam;
 
                /* Mortal wound or Deep Gash */
                if (p_ptr->cut > 1000)
@@ -2319,7 +2326,7 @@ static void process_world_aux_mutation(void)
            !p_ptr->anti_magic && (randint1(6666) == 666))
        {
                bool pet = one_in_(6);
-               u32b mode = PM_ALLOW_GROUP;
+               BIT_FLAGS mode = PM_ALLOW_GROUP;
 
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
@@ -2430,7 +2437,7 @@ static void process_world_aux_mutation(void)
            !p_ptr->anti_magic && one_in_(7000))
        {
                bool pet = one_in_(3);
-               u32b mode = PM_ALLOW_GROUP;
+               BIT_FLAGS mode = PM_ALLOW_GROUP;
 
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
@@ -2510,7 +2517,7 @@ static void process_world_aux_mutation(void)
            !p_ptr->anti_magic && one_in_(3000))
        {
                bool pet = one_in_(5);
-               u32b mode = PM_ALLOW_GROUP;
+               BIT_FLAGS mode = PM_ALLOW_GROUP;
 
                if (pet) mode |= PM_FORCE_PET;
                else mode |= (PM_ALLOW_UNIQUE | PM_NO_PET);
@@ -2635,7 +2642,7 @@ static void process_world_aux_mutation(void)
        }
        if ((p_ptr->muta2 & MUT2_DISARM) && one_in_(10000))
        {
-               int slot = 0;
+               INVENTORY_IDX slot = 0;
                object_type *o_ptr = NULL;
 
                disturb(0, 1);
@@ -3521,7 +3528,7 @@ static void process_world(void)
                        p_ptr->energy_need = 0;
                        battle_monsters();
                }
-               else if (turn - old_turn == 150*TURNS_PER_TICK)
+               else if (turn - old_turn == 150 * TURNS_PER_TICK)
                {
                        msg_print(_("申し分けありませんが、この勝負は引き分けとさせていただきます。", "This battle have ended in a draw."));
                        p_ptr->au += kakekin;
@@ -3774,11 +3781,12 @@ static void process_world(void)
 
        /*
         * Nightmare mode activates the TY_CURSE at midnight
-        *
         * Require exact minute -- Don't activate multiple times in a minute
         */
+
        if (ironman_nightmare && (min != prev_min))
        {
+
                /* Every 15 minutes after 11:00 pm */
                if ((hour == 23) && !(min % 15))
                {
@@ -3808,11 +3816,25 @@ static void process_world(void)
                /* TY_CURSE activates at midnight! */
                if (!hour && !min)
                {
-                       int count = 0;
 
                        disturb(1, 1);
                        msg_print(_("遠くで鐘が何回も鳴り、死んだような静けさの中へ消えていった。", "A distant bell tolls many times, fading into an deathly silence."));
-                       activate_ty_curse(FALSE, &count);
+
+                       if (p_ptr->wild_mode)
+                       {
+                               /* Go into large wilderness view */
+                               p_ptr->oldpy = randint1(MAX_HGT - 2);
+                               p_ptr->oldpx = randint1(MAX_WID - 2);
+                               change_wild_mode();
+
+                               /* Give first move to monsters */
+                               p_ptr->energy_use = 100;
+
+                               /* HACk -- set the encouter flag for the wilderness generation */
+                               generate_encounter = TRUE;
+                       }
+
+                       invoking_midnight_curse = TRUE;
                }
        }
 
@@ -3874,7 +3896,7 @@ static void process_world(void)
                        if (p_ptr->food < PY_FOOD_STARVE)
                        {
                                /* Calculate damage */
-                               int dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
+                               HIT_POINT dam = (PY_FOOD_STARVE - p_ptr->food) / 10;
 
                                /* Take damage */
                                if (!IS_INVULN()) take_hit(DAMAGE_LOSELIFE, dam, _("空腹", "starvation"), -1);
@@ -4045,7 +4067,7 @@ extern void do_cmd_borg(void);
  */
 static void process_command(void)
 {
-       int old_now_message = now_message;
+       COMMAND_CODE old_now_message = now_message;
 
 #ifdef ALLOW_REPEAT /* TNB */
 
@@ -5047,6 +5069,13 @@ static void process_player(void)
                hack_mutation = FALSE;
        }
 
+       if (invoking_midnight_curse)
+       {
+               int count = 0;
+               activate_ty_curse(FALSE, &count);
+               invoking_midnight_curse = FALSE;
+       }
+
        if (p_ptr->inside_battle)
        {
                for(i = 1; i < m_max; i++)
@@ -5080,7 +5109,7 @@ static void process_player(void)
        if (resting < 0)
        {
                /* Basic resting */
-               if (resting == -1)
+               if (resting == COMMAND_ARG_REST_FULL_HEALING)
                {
                        /* Stop resting */
                        if ((p_ptr->chp == p_ptr->mhp) &&
@@ -5091,7 +5120,7 @@ static void process_player(void)
                }
 
                /* Complete resting */
-               else if (resting == -2)
+               else if (resting == COMMAND_ARG_REST_UNTIL_DONE)
                {
                        /* Stop resting */
                        if ((p_ptr->chp == p_ptr->mhp) &&
@@ -5604,9 +5633,15 @@ static void process_player(void)
 /*!
  * @brief 現在プレイヤーがいるダンジョンの全体処理 / Interact with the current dungeon level.
  * @return なし
- * @note
+ * @details
+ * <p>
+ * この関数から現在の階層を出る、プレイヤーがキャラが死ぬ、
+ * ゲームを終了するかのいずれかまでループする。
+ * </p>
+ * <p>
  * This function will not exit until the level is completed,\n
  * the user dies, or the game is terminated.\n
+ * </p>
  */
 static void dungeon(bool load_game)
 {
@@ -5616,7 +5651,7 @@ static void dungeon(bool load_game)
        base_level = dun_level;
 
        /* Reset various flags */
-       hack_mind = FALSE;
+       is_loading_now = FALSE;
 
        /* Not leaving */
        p_ptr->leaving = FALSE;
@@ -5748,8 +5783,8 @@ static void dungeon(bool load_game)
                }
        }
 
-       if ((p_ptr->pclass == CLASS_BARD) && (p_ptr->magic_num1[0] > MUSIC_DETECT))
-               p_ptr->magic_num1[0] = MUSIC_DETECT;
+       if ((p_ptr->pclass == CLASS_BARD) && (SINGING_SONG_EFFECT(p_ptr) > MUSIC_DETECT))
+               SINGING_SONG_EFFECT(p_ptr) = MUSIC_DETECT;
 
        /* Hack -- notice death or departure */
        if (!p_ptr->playing || p_ptr->is_dead) return;
@@ -5784,7 +5819,7 @@ static void dungeon(bool load_game)
        /* Reset the object generation level */
        object_level = base_level;
 
-       hack_mind = TRUE;
+       is_loading_now = TRUE;
 
        if (p_ptr->energy_need > 0 && !p_ptr->inside_battle &&
            (dun_level || p_ptr->leaving_dungeon || p_ptr->inside_arena))
@@ -5870,9 +5905,6 @@ static void dungeon(bool load_game)
                /* Hack -- Notice death or departure */
                if (!p_ptr->playing || p_ptr->is_dead) break;
 
-               /* Handle "leaving" */
-               if (p_ptr->leaving) break;
-
                /* Count game turns */
                turn++;
 
@@ -5884,6 +5916,9 @@ static void dungeon(bool load_game)
 
                prevent_turn_overflow();
 
+               /* Handle "leaving" */
+               if (p_ptr->leaving) break;
+
                if (wild_regen) wild_regen--;
        }
 
@@ -6017,7 +6052,8 @@ void extract_option_vars(void)
  */
 void determine_bounty_uniques(void)
 {
-       int          i, j, tmp;
+       int i, j;
+       MONRACE_IDX tmp;
        monster_race *r_ptr;
 
        get_mon_num_prep(NULL, NULL);