From b15ecfa8769ac4094409e6ab2a0063451ec8ef56 Mon Sep 17 00:00:00 2001 From: Deskull Date: Wed, 30 Jan 2019 23:57:23 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#37353=20=E6=B7=B7=E4=B9=B1?= =?utf8?q?=E6=99=82=E3=81=AE=E3=82=B3=E3=83=9E=E3=83=B3=E3=83=89=E5=88=B6?= =?utf8?q?=E9=99=90=E5=87=A6=E7=90=86=E3=82=92=20cmd=5Flimit=5Fconfused()?= =?utf8?q?=20=E3=81=AB=E7=B5=B1=E5=90=88=E3=80=82=20/=20Integrate=20comman?= =?utf8?q?d=20limitation=20on=20confusion=20to=20cmd=5Flimit=5Fconfused().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd-item.c | 6 +----- src/cmd-magiceat.c | 7 +------ src/cmd-pet.c | 6 +----- src/cmd-read.c | 7 +------ src/cmd-spell.c | 14 ++------------ src/cmd2.c | 19 ++++++++++++------- src/externs.h | 1 + src/hissatsu.c | 13 ++----------- src/mane.c | 8 +------- src/mind.c | 7 +------ src/mspells3.c | 11 ++--------- src/object2.c | 6 +----- src/racial.c | 25 +++++++------------------ src/snipe.c | 8 +------- 14 files changed, 34 insertions(+), 104 deletions(-) diff --git a/src/cmd-item.c b/src/cmd-item.c index 82f052106..da76e927b 100644 --- a/src/cmd-item.c +++ b/src/cmd-item.c @@ -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; diff --git a/src/cmd-magiceat.c b/src/cmd-magiceat.c index 6aff38222..9a3f3c762 100644 --- a/src/cmd-magiceat.c +++ b/src/cmd-magiceat.c @@ -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) diff --git a/src/cmd-pet.c b/src/cmd-pet.c index c9bb3121f..945827ef6 100644 --- a/src/cmd-pet.c +++ b/src/cmd-pet.c @@ -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]; diff --git a/src/cmd-read.c b/src/cmd-read.c index 87dfce437..025b5061f 100644 --- a/src/cmd-read.c +++ b/src/cmd-read.c @@ -631,12 +631,7 @@ void do_cmd_read_scroll(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; /* Restrict choices to scrolls */ item_tester_hook = item_tester_hook_readable; diff --git a/src/cmd-spell.c b/src/cmd-spell.c index cf642b512..38ff3c8cd 100644 --- a/src/cmd-spell.c +++ b/src/cmd-spell.c @@ -739,11 +739,7 @@ void do_cmd_study(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)) { @@ -1002,13 +998,7 @@ void do_cmd_cast(void) return; } - /* Not when confused */ - if (p_ptr->confused) - { - msg_print(_("混乱していて唱えられない!", "You are too confused!")); - flush(); - return; - } + if (cmd_limit_confused(p_ptr)) return; /* Hex */ if (p_ptr->realm1 == REALM_HEX) diff --git a/src/cmd2.c b/src/cmd2.c index 8a193f034..b8a2597e2 100644 --- a/src/cmd2.c +++ b/src/cmd2.c @@ -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) { diff --git a/src/externs.h b/src/externs.h index 1ee9598b9..3507b80d3 100644 --- a/src/externs.h +++ b/src/externs.h @@ -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); diff --git a/src/hissatsu.c b/src/hissatsu.c index ca0d6f423..8d76b1a46 100644 --- a/src/hissatsu.c +++ b/src/hissatsu.c @@ -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)) { diff --git a/src/mane.c b/src/mane.c index 8b27f5d51..fbffdd349 100644 --- a/src/mane.c +++ b/src/mane.c @@ -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) { diff --git a/src/mind.c b/src/mind.c index 941dfff12..4ea7ba290 100644 --- a/src/mind.c +++ b/src/mind.c @@ -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; diff --git a/src/mspells3.c b/src/mspells3.c index 293da9bba..c31fcc6f0 100644 --- a/src/mspells3.c +++ b/src/mspells3.c @@ -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; } diff --git a/src/object2.c b/src/object2.c index 99232bb74..690c8da5d 100644 --- a/src/object2.c +++ b/src/object2.c @@ -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!")); diff --git a/src/racial.c b/src/racial.c index 10c693d96..ef6bca7ce 100644 --- a/src/racial.c +++ b/src/racial.c @@ -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; } diff --git a/src/snipe.c b/src/snipe.c index a6d4d57e9..1c533cb29 100644 --- a/src/snipe.c +++ b/src/snipe.c @@ -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) -- 2.11.0