OSDN Git Service

[Fix] #37353 VC++のC4100警告修正。 / Fix C4100 VC++ warning .
[hengband/hengband.git] / src / cmd2.c
index cba6e7f..0092d06 100644 (file)
 #include "object-hook.h"
 #include "projection.h"
 #include "spells-summon.h"
+#include "spells-status.h"
 #include "monster-status.h"
 #include "quest.h"
 #include "artifact.h"
 #include "avatar.h"
 #include "player-status.h"
+#include "realm-hex.h"
 
 /*!
  * @brief フロア脱出時に出戻りが不可能だった場合に警告を加える処理
@@ -52,6 +54,65 @@ bool confirm_leave_level(bool down_stair)
 }
 
 /*!
+ * @brief 魔法系コマンドが制限されているかを返す。
+ * @return 魔法系コマンドを使用可能ならFALSE、不可能ならば理由をメッセージ表示してTRUEを返す。
+ */
+bool cmd_limit_cast(player_type *creature_ptr)
+{
+       if (dun_level && (d_info[dungeon_type].flags1 & DF1_NO_MAGIC))
+       {
+               msg_print(_("ダンジョンが魔法を吸収した!", "The dungeon absorbs all attempted magic!"));
+               msg_print(NULL);
+               return TRUE;
+       }
+       else if (creature_ptr->anti_magic)
+       {
+               msg_print(_("反魔法バリアが魔法を邪魔した!", "An anti-magic shell disrupts your magic!"));
+               return TRUE;
+       }
+       else if (creature_ptr->shero)
+       {
+               msg_format(_("狂戦士化していて頭が回らない!", "You cannot think directly!"));
+               return TRUE;
+       }
+       else
+               return FALSE;
+}
+
+bool cmd_limit_confused(player_type *creature_ptr)
+{
+       if (creature_ptr->confused)
+       {
+               msg_print(_("混乱していてできない!", "You are too confused!"));
+               return TRUE;
+       }
+       return FALSE;
+}
+
+bool cmd_limit_arena(player_type *creature_ptr)
+{
+       if (creature_ptr->inside_arena)
+       {
+               msg_print(_("アリーナが魔法を吸収した!", "The arena absorbs all attempted magic!"));
+               msg_print(NULL);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+bool cmd_limit_time_walk(player_type *creature_ptr)
+{
+       if (world_player)
+       {
+               if (flush_failure) flush();
+               msg_print(_("止まった時の中ではうまく働かないようだ。", "It shows no reaction."));
+               sound(SOUND_FAIL);
+               return TRUE;
+       }
+       return FALSE;
+}
+
+/*!
  * @brief 階段を使って階層を昇る処理 / Go up one level
  * @return なし
  */
@@ -117,8 +178,7 @@ void do_cmd_go_up(void)
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
                
-               /* Hack -- take a turn */
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
 
                /* End the command */
                return;
@@ -136,8 +196,7 @@ void do_cmd_go_up(void)
        /* Cancel the command */
        if (!go_up) return;
 
-       /* Hack -- take a turn */
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);
 
        if (autosave_l) do_cmd_save_game(TRUE);
 
@@ -267,13 +326,10 @@ void do_cmd_go_down(void)
 
                /* Leaving */
                p_ptr->leaving = TRUE;
-
                p_ptr->oldpx = 0;
                p_ptr->oldpy = 0;
                
-               
-        /* Hack -- take a turn */
-        p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
        }
 
        else
@@ -308,8 +364,7 @@ void do_cmd_go_down(void)
                        prepare_change_floor_mode(CFM_FIRST_FLOOR);
                }
 
-               /* Hack -- take a turn */
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);
 
                if (autosave_l) do_cmd_save_game(TRUE);
 
@@ -391,7 +446,7 @@ void do_cmd_search(void)
                /* Cancel the arg */
                command_arg = 0;
        }
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Search */
        search();
@@ -449,7 +504,7 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Attempt to unlock it */
        if (o_ptr->pval > 0)
@@ -502,18 +557,6 @@ static bool do_cmd_open_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
 }
 
 /*!
- * @brief 地形は開くものであって、かつ開かれているかを返す /
- * Attempt to open the given chest at the given location
- * @param feat 地形ID
- * @return 開いた地形である場合TRUEを返す /  Return TRUE if the given feature is an open door
- */
-static bool is_open(IDX feat)
-{
-       return have_flag(f_info[feat].flags, FF_CLOSE) && (feat != feat_state(feat, FF_CLOSE));
-}
-
-
-/*!
  * @brief プレイヤーの周辺9マスに該当する地形がいくつあるかを返す /
  * Attempt to open the given chest at the given location
  * @param y 該当する地形の中から1つのY座標を返す参照ポインタ
@@ -663,7 +706,7 @@ static bool do_cmd_open_aux(POSITION y, POSITION x)
        feature_type *f_ptr = &f_info[c_ptr->feat];
        bool more = FALSE;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -812,7 +855,7 @@ void do_cmd_open(void)
                /* Monster in the way */
                else if (c_ptr->m_idx && p_ptr->riding != c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
                        py_attack(y, x, 0);
                }
@@ -855,7 +898,7 @@ static bool do_cmd_close_aux(POSITION y, POSITION x)
        FEAT_IDX old_feat = c_ptr->feat;
        bool more = FALSE;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Seeing true feature code (ignore mimic) */
 
@@ -954,7 +997,7 @@ void do_cmd_close(void)
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1028,7 +1071,7 @@ static bool do_cmd_tunnel_aux(POSITION y, POSITION x)
        /* Verify legality */
        if (!do_cmd_tunnel_test(y, x)) return (FALSE);
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Get grid */
        c_ptr = &cave[y][x];
@@ -1199,7 +1242,7 @@ void do_cmd_tunnel(void)
                /* A monster is in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1329,7 +1372,7 @@ static bool do_cmd_disarm_chest(POSITION y, POSITION x, OBJECT_IDX o_idx)
        bool more = FALSE;
        object_type *o_ptr = &o_list[o_idx];
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Get the "disarm" factor */
        i = p_ptr->skill_dis;
@@ -1424,7 +1467,7 @@ bool do_cmd_disarm_aux(POSITION y, POSITION x, DIRECTION dir)
        int i = p_ptr->skill_dis;
        int j;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Penalize some conditions */
        if (p_ptr->blind || no_lite()) i = i / 10;
@@ -1607,7 +1650,7 @@ static bool do_cmd_bash_aux(POSITION y, POSITION x, DIRECTION dir)
 
        concptr name = f_name + f_info[get_feat_mimic(c_ptr)].name;
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        msg_format(_("%sに体当たりをした!", "You smash into the %s!"), name);
 
@@ -1730,7 +1773,7 @@ void do_cmd_bash(void)
                /* Monster in the way */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1805,7 +1848,7 @@ void do_cmd_alter(void)
                feat = get_feat_mimic(c_ptr);
                f_ptr = &f_info[feat];
 
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);;
 
                if (c_ptr->m_idx)
                {
@@ -1941,7 +1984,7 @@ void do_cmd_spike(void)
                /* Is a monster in the way? */
                else if (c_ptr->m_idx)
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        msg_print(_("モンスターが立ちふさがっている!", "There is a monster in the way!"));
 
@@ -1952,7 +1995,7 @@ void do_cmd_spike(void)
                /* Go for it */
                else
                {
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        /* Successful jamming */
                        msg_format(_("%sにくさびを打ち込んだ。", "You jam the %s with a spike."), f_name + f_info[feat].name);
@@ -1995,7 +2038,7 @@ void do_cmd_walk(bool pickup)
        /* Get a "repeated" direction */
        if (get_rep_dir(&dir, FALSE))
        {
-               p_ptr->energy_use = 100;
+               take_turn(p_ptr, 100);;
 
                if ((dir != 5) && (p_ptr->special_defense & KATA_MUSOU))
                {
@@ -2030,7 +2073,7 @@ void do_cmd_walk(bool pickup)
                        change_wild_mode();
 
                        /* Give first move to monsters */
-                       p_ptr->energy_use = 100;
+                       take_turn(p_ptr, 100);;
 
                        /* HACk -- set the encouter flag for the wilderness generation */
                        generate_encounter = TRUE;
@@ -2050,13 +2093,7 @@ void do_cmd_walk(bool pickup)
 void do_cmd_run(void)
 {
        DIRECTION dir;
-
-       /* Hack -- no running when confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて走れない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        if (p_ptr->special_defense & KATA_MUSOU)
        {
@@ -2097,7 +2134,7 @@ void do_cmd_stay(bool pickup)
                command_arg = 0;
        }
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        if (pickup) mpe_mode |= MPE_DO_PICKUP;
        (void)move_player_effect(p_ptr->y, p_ptr->x, mpe_mode);
@@ -2164,7 +2201,7 @@ void do_cmd_rest(void)
        if (p_ptr->special_defense & NINJA_S_STEALTH) set_superstealth(FALSE);
 
        /* Take a turn (?) */
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* The sin of sloth */
        if (command_arg > 100) chg_virtue(V_DILIGENCE, -1);
@@ -2470,7 +2507,7 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                p_ptr->redraw |= (PR_EQUIPPY);
        }
 
-       p_ptr->energy_use = 100;
+       take_turn(p_ptr, 100);;
 
        /* Rogue and Ninja gets bonus */
        if ((p_ptr->pclass == CLASS_ROGUE) || (p_ptr->pclass == CLASS_NINJA))
@@ -2492,7 +2529,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
 
        if (shuriken) chance *= 2;
 
-       /* Save the old location */
        prev_y = y;
        prev_x = x;
 
@@ -2536,7 +2572,6 @@ bool do_cmd_throw(int mult, bool boomerang, OBJECT_IDX shuriken)
                        Term_xtra(TERM_XTRA_DELAY, msec);
                }
 
-               /* Save the old location */
                prev_y = y;
                prev_x = x;