OSDN Git Service

[Refactor] #37353 混乱時のコマンド制限処理を cmd_limit_confused() に統合。 / Integrate command limitat...
authorDeskull <deskull@users.sourceforge.jp>
Wed, 30 Jan 2019 14:57:23 +0000 (23:57 +0900)
committerDeskull <deskull@users.sourceforge.jp>
Wed, 30 Jan 2019 14:57:23 +0000 (23:57 +0900)
14 files changed:
src/cmd-item.c
src/cmd-magiceat.c
src/cmd-pet.c
src/cmd-read.c
src/cmd-spell.c
src/cmd2.c
src/externs.h
src/hissatsu.c
src/mane.c
src/mind.c
src/mspells3.c
src/object2.c
src/racial.c
src/snipe.c

index 82f0521..da76e92 100644 (file)
@@ -1743,11 +1743,7 @@ void do_cmd_use(void)
                                msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));
                                return;
                        }
-                       if (p_ptr->confused)
-                       {
-                               msg_print(_("混乱していて読めない!", "You are too confused!"));
-                               return;
-                       }
+                       if (cmd_limit_confused(p_ptr)) return;
 
                  do_cmd_read_scroll_aux(item, TRUE);
                  break;
index 6aff382..9a3f3c7 100644 (file)
@@ -512,12 +512,7 @@ bool do_cmd_magic_eater(bool only_browse, bool powerful)
        OBJECT_SUBTYPE_VALUE sval;
        bool use_charge = TRUE;
 
-       /* Not when confused */
-       if (!only_browse && p_ptr->confused)
-       {
-               msg_print(_("混乱していて唱えられない!", "You are too confused!"));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        item = select_magic_eater(only_browse);
        if (item == -1)
index c9bb312..945827e 100644 (file)
@@ -345,11 +345,7 @@ bool do_riding(bool force)
        }
        else
        {
-               if (p_ptr->confused)
-               {
-                       msg_print(_("混乱していて乗れない!", "You are too confused!"));
-                       return FALSE;
-               }
+               if (cmd_limit_confused(p_ptr)) return FALSE;
 
                m_ptr = &m_list[c_ptr->m_idx];
 
index 87dfce4..025b506 100644 (file)
@@ -631,12 +631,7 @@ void do_cmd_read_scroll(void)
                msg_print(_("明かりがないので、暗くて読めない。", "You have no light to read by."));\r
                return;\r
        }\r
-       if (p_ptr->confused)\r
-       {\r
-               msg_print(_("混乱していて読めない。", "You are too confused!"));\r
-               return;\r
-       }\r
-\r
+       if (cmd_limit_confused(p_ptr)) return;\r
 \r
        /* Restrict choices to scrolls */\r
        item_tester_hook = item_tester_hook_readable;\r
index cf642b5..38ff3c8 100644 (file)
@@ -739,11 +739,7 @@ void do_cmd_study(void)
                return;\r
        }\r
 \r
-       if (p_ptr->confused)\r
-       {\r
-               msg_print(_("混乱していて読めない!", "You are too confused!"));\r
-               return;\r
-       }\r
+       if (cmd_limit_confused(p_ptr)) return;\r
 \r
        if (!(p_ptr->new_spells))\r
        {\r
@@ -1002,13 +998,7 @@ void do_cmd_cast(void)
                return;\r
        }\r
 \r
-       /* Not when confused */\r
-       if (p_ptr->confused)\r
-       {\r
-               msg_print(_("混乱していて唱えられない!", "You are too confused!"));\r
-               flush();\r
-               return;\r
-       }\r
+       if (cmd_limit_confused(p_ptr)) return;\r
 \r
        /* Hex */\r
        if (p_ptr->realm1 == REALM_HEX)\r
index 8a193f0..b8a2597 100644 (file)
@@ -53,6 +53,17 @@ bool confirm_leave_level(bool down_stair)
        return FALSE;
 }
 
+
+bool cmd_limit_confused(player_type *creature_ptr)
+{
+       if (p_ptr->confused)
+       {
+               msg_print(_("混乱していてできない!", "You are too confused!"));
+               return TRUE;
+       }
+       return FALSE;
+}
+
 bool cmd_limit_arena(player_type *creature_ptr)
 {
        if (p_ptr->inside_arena)
@@ -2063,13 +2074,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)
        {
index 1ee9598..3507b80 100644 (file)
@@ -544,6 +544,7 @@ extern void travel_step(void);
 /* cmd2.c */
 extern bool cmd_limit_arena(player_type *creature_ptr);
 extern bool cmd_limit_time_walk(player_type *creature_ptr);
+extern bool cmd_limit_confused(player_type *creature_ptr);
 extern void forget_travel_flow(void);
 extern bool confirm_leave_level(bool down_stair);
 extern void do_cmd_go_up(void);
index ca0d6f4..8d76b1a 100644 (file)
@@ -313,12 +313,7 @@ void do_cmd_hissatsu(void)
        SPELL_IDX       n = 0;
        magic_type      spell;
 
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
        if (!has_melee_weapon(INVEN_RARM) && !has_melee_weapon(INVEN_LARM))
        {
                if (flush_failure) flush();
@@ -395,11 +390,7 @@ void do_cmd_gain_hissatsu(void)
                return;
        }
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて読めない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        if (!(p_ptr->new_spells))
        {
index 8b27f5d..fbffdd3 100644 (file)
@@ -934,13 +934,7 @@ bool do_cmd_mane(bool baigaesi)
        monster_power   spell;
        bool            cast;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return TRUE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        if (!p_ptr->mane_num)
        {
index 941dfff..4ea7ba2 100644 (file)
@@ -1762,12 +1762,7 @@ void do_cmd_mind(void)
        concptr            p;
        bool            on_mirror = FALSE;
 
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        /* get power */
        if (!get_mind_power(&n, FALSE)) return;
index 293da9b..c31fcc6 100644 (file)
@@ -1403,13 +1403,7 @@ bool do_cmd_cast_learned(void)
        bool cast;
        MANA_POINT need_mana;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて唱えられない!", "You are too confused!"));
-               return TRUE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        /* get power */
        if (!get_learned_power(&n)) return FALSE;
@@ -1521,8 +1515,7 @@ bool do_cmd_cast_learned(void)
        p_ptr->energy_use = 100;
 
        p_ptr->redraw |= (PR_MANA);
-       p_ptr->window |= (PW_PLAYER);
-       p_ptr->window |= (PW_SPELL);
+       p_ptr->window |= (PW_PLAYER | PW_SPELL);
 
        return TRUE;
 }
index 99232bb..690c8da 100644 (file)
@@ -8357,11 +8357,7 @@ void do_cmd_kaji(bool only_browse)
 
        if (!only_browse)
        {
-               if (p_ptr->confused)
-               {
-                       msg_print(_("混乱していて作業できない!", "You are too confused!"));
-                       return;
-               }
+               if (cmd_limit_confused(p_ptr)) return;
                if (p_ptr->blind)
                {
                        msg_print(_("目が見えなくて作業できない!", "You are blind!"));
index 10c693d..ef6bca7 100644 (file)
@@ -61,11 +61,7 @@ static bool choose_kamae(void)
        int i;
        char buf[80];
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて構えられない!", "Too confused."));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
        screen_save();
        prt(_(" a) 構えをとく", " a) No form"), 2, 20);
 
@@ -152,11 +148,7 @@ static bool choose_kata(void)
        int i;
        char buf[80];
 
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて構えられない!", "Too confused."));
-               return FALSE;
-       }
+       if (cmd_limit_confused(p_ptr)) return FALSE;
 
        if (p_ptr->stun)
        {
@@ -345,15 +337,13 @@ static int racial_aux(power_desc_type *pd_ptr)
                                         "You need to attain level %d to use this power."), min_level);
 
                p_ptr->energy_use = 0;
-               return 0;
+               return FALSE;
        }
 
-       /* Too confused */
-       else if (p_ptr->confused)
+       if (cmd_limit_confused(p_ptr))
        {
-               msg_print(_("混乱していてその能力は使えない。", "You are too confused to use this power."));
                p_ptr->energy_use = 0;
-               return 0;
+               return FALSE;
        }
 
        /* Risk death? */
@@ -362,7 +352,7 @@ static int racial_aux(power_desc_type *pd_ptr)
                if (!get_check(_("本当に今の衰弱した状態でこの能力を使いますか?", "Really use the power in your weakened state? ")))
                {
                        p_ptr->energy_use = 0;
-                       return 0;
+                       return FALSE;
                }
        }
 
@@ -868,9 +858,8 @@ void do_cmd_racial_power(void)
 
        num = 0;
 
-       if (p_ptr->confused)
+       if (cmd_limit_confused(p_ptr))
        {
-               msg_print(_("混乱していて特殊能力を使えません!", "You are too confused to use any powers!"));
                p_ptr->energy_use = 0;
                return;
        }
index a6d4d57..1c533cb 100644 (file)
@@ -542,13 +542,7 @@ void do_cmd_snipe(void)
        COMMAND_CODE n = 0;
        bool            cast;
 
-
-       /* not if confused */
-       if (p_ptr->confused)
-       {
-               msg_print(_("混乱していて集中できない!", "You are too confused!"));
-               return;
-       }
+       if (cmd_limit_confused(p_ptr)) return;
 
        /* not if hullucinated */
        if (p_ptr->image)