From a384dac202def374f3bbdfb82198718e92d3381b Mon Sep 17 00:00:00 2001 From: Hourier Date: Sun, 12 Jan 2020 18:31:43 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20CAN=5FTWO=5FHANDS=5FWIELDI?= =?utf8?q?NG()=20=E3=81=AE=E9=96=A2=E6=95=B0=E3=83=9E=E3=82=AF=E3=83=AD?= =?utf8?q?=E3=82=92=E6=99=AE=E9=80=9A=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AB?= =?utf8?q?=E5=A4=89=E6=9B=B4=E3=81=97=E3=80=81player=5Ftype=20*=20?= =?utf8?q?=E5=BC=95=E6=95=B0=E3=82=92=E8=BF=BD=E5=8A=A0=20/=20Changed=20ma?= =?utf8?q?cro=20function=20CAN=5FTWO=5FHANDS=5FWIELDING()=20to=20normal=20?= =?utf8?q?function=20and=20added=20player=5Ftype=20*=20argument?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd/cmd-item.c | 12 +++++++----- src/cmd/cmd-pet.c | 22 +++++++++++----------- src/cmd/cmd-pet.h | 2 +- src/files.c | 2 +- src/floor-save.c | 2 +- src/player-status.c | 12 +++++++++--- src/player-status.h | 3 +-- 7 files changed, 31 insertions(+), 24 deletions(-) diff --git a/src/cmd/cmd-item.c b/src/cmd/cmd-item.c index 35ead5e98..fe8489569 100644 --- a/src/cmd/cmd-item.c +++ b/src/cmd/cmd-item.c @@ -378,14 +378,14 @@ void do_cmd_wield(player_type *creature_ptr) switch (slot) { case INVEN_RARM: - if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) && CAN_TWO_HANDS_WIELDING()) + if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) && can_two_hands_wielding(creature_ptr)) act = STR_WIELD_ARMS; else act = (left_hander ? STR_WIELD_LARM : STR_WIELD_RARM); break; case INVEN_LARM: - if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) && CAN_TWO_HANDS_WIELDING()) + if (object_allow_two_hands_wielding(o_ptr) && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) && can_two_hands_wielding(creature_ptr)) act = STR_WIELD_ARMS; else act = (left_hander ? STR_WIELD_RARM : STR_WIELD_LARM); @@ -431,8 +431,10 @@ void do_cmd_wield(player_type *creature_ptr) calc_android_exp(creature_ptr); } + /*! * @brief 持ち替え処理 + * @param owner_ptr プレーヤーへの参照ポインタ * @param item 持ち替えを行いたい装備部位ID * @return なし */ @@ -450,7 +452,7 @@ void verify_equip_slot(player_type *owner_ptr, INVENTORY_IDX item) if (object_is_cursed(o_ptr)) { - if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING()) + if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr)) msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name); return; } @@ -460,7 +462,7 @@ void verify_equip_slot(player_type *owner_ptr, INVENTORY_IDX item) owner_ptr->total_weight += o_ptr->weight; inven_item_increase(owner_ptr, INVEN_LARM, -((int)o_ptr->number)); inven_item_optimize(owner_ptr, INVEN_LARM); - if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING()) + if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr)) msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name); else msg_format(_("%sを%sで構えた。", "You are wielding %s in your %s hand."), o_name, @@ -475,7 +477,7 @@ void verify_equip_slot(player_type *owner_ptr, INVENTORY_IDX item) if (has_melee_weapon(owner_ptr, INVEN_RARM)) { - if (object_allow_two_hands_wielding(o_ptr) && CAN_TWO_HANDS_WIELDING()) + if (object_allow_two_hands_wielding(o_ptr) && can_two_hands_wielding(owner_ptr)) msg_format(_("%sを両手で構えた。", "You are wielding %s with both hands."), o_name); return; } diff --git a/src/cmd/cmd-pet.c b/src/cmd/cmd-pet.c index 94169c2cb..29209e723 100644 --- a/src/cmd/cmd-pet.c +++ b/src/cmd/cmd-pet.c @@ -37,7 +37,7 @@ bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_r MONSTER_IDX old_riding = creature_ptr->riding; bool old_riding_ryoute = creature_ptr->riding_ryoute; bool old_old_riding_ryoute = creature_ptr->old_riding_ryoute; - bool old_pf_ryoute = (creature_ptr->pet_extra_flags & PF_RYOUTE) ? TRUE : FALSE; + bool old_pf_ryoute = (creature_ptr->pet_extra_flags & PF_TWO_HANDS) ? TRUE : FALSE; /* Hack -- prevent "icky" message */ current_world_ptr->character_xtra = TRUE; @@ -46,7 +46,7 @@ bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_r else { creature_ptr->riding = 0; - creature_ptr->pet_extra_flags &= ~(PF_RYOUTE); + creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE; } @@ -56,8 +56,8 @@ bool player_can_ride_aux(player_type *creature_ptr, grid_type *g_ptr, bool now_r p_can_enter = player_can_enter(creature_ptr, g_ptr->feat, CEM_P_CAN_ENTER_PATTERN); creature_ptr->riding = old_riding; - if (old_pf_ryoute) creature_ptr->pet_extra_flags |= (PF_RYOUTE); - else creature_ptr->pet_extra_flags &= ~(PF_RYOUTE); + if (old_pf_ryoute) creature_ptr->pet_extra_flags |= (PF_TWO_HANDS); + else creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); creature_ptr->riding_ryoute = old_riding_ryoute; creature_ptr->old_riding_ryoute = old_old_riding_ryoute; @@ -308,7 +308,7 @@ bool do_cmd_riding(player_type *creature_ptr, bool force) } creature_ptr->riding = 0; - creature_ptr->pet_extra_flags &= ~(PF_RYOUTE); + creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE; } else @@ -607,7 +607,7 @@ void do_cmd_pet(player_type *creature_ptr) (creature_ptr->hidarite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM) && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM]))) { - if (creature_ptr->pet_extra_flags & PF_RYOUTE) + if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) { power_desc[num] = _("武器を片手で持つ", "use one hand to control a riding pet"); } @@ -627,7 +627,7 @@ void do_cmd_pet(player_type *creature_ptr) case CLASS_BERSERKER: if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) { - if (creature_ptr->pet_extra_flags & PF_RYOUTE) + if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) { power_desc[num] = _("片手で格闘する", "use one hand to control a riding pet"); } @@ -640,7 +640,7 @@ void do_cmd_pet(player_type *creature_ptr) } else if ((empty_hands(creature_ptr, FALSE) != EMPTY_HAND_NONE) && !has_melee_weapon(creature_ptr, INVEN_RARM) && !has_melee_weapon(creature_ptr, INVEN_LARM)) { - if (creature_ptr->pet_extra_flags & PF_RYOUTE) + if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) { power_desc[num] = _("格闘を行わない", "use one hand to control a riding pet"); } @@ -951,8 +951,8 @@ void do_cmd_pet(player_type *creature_ptr) case PET_RYOUTE: { - if (creature_ptr->pet_extra_flags & PF_RYOUTE) creature_ptr->pet_extra_flags &= ~(PF_RYOUTE); - else creature_ptr->pet_extra_flags |= (PF_RYOUTE); + if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); + else creature_ptr->pet_extra_flags |= (PF_TWO_HANDS); creature_ptr->update |= (PU_BONUS); handle_stuff(creature_ptr); break; @@ -1069,7 +1069,7 @@ bool rakuba(player_type *creature_ptr, HIT_POINT dam, bool force) } creature_ptr->riding = 0; - creature_ptr->pet_extra_flags &= ~(PF_RYOUTE); + creature_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); creature_ptr->riding_ryoute = creature_ptr->old_riding_ryoute = FALSE; creature_ptr->update |= (PU_BONUS | PU_VIEW | PU_LITE | PU_FLOW | PU_MON_LITE | PU_MONSTERS); diff --git a/src/cmd/cmd-pet.h b/src/cmd/cmd-pet.h index e5e0025d0..2319e9935 100644 --- a/src/cmd/cmd-pet.h +++ b/src/cmd/cmd-pet.h @@ -49,5 +49,5 @@ extern int total_friends; #define PF_ATTACK_SPELL 0x0008 /*!< ペットの行動許可…攻撃魔法を使ってよい */ #define PF_SUMMON_SPELL 0x0010 /*!< ペットの行動許可…召喚魔法を使ってよい */ #define PF_BALL_SPELL 0x0020 /*!< ペットの行動許可…ボール魔法でプレイヤーを巻き込んでよい */ -#define PF_RYOUTE 0x0040 /*!< プレイヤーの騎乗フラグ…武器を片手で持つ */ +#define PF_TWO_HANDS 0x0040 /*!< プレイヤーの騎乗フラグ…武器を片手で持つ */ diff --git a/src/files.c b/src/files.c index 7562d687e..efed57e69 100644 --- a/src/files.c +++ b/src/files.c @@ -2723,7 +2723,7 @@ static void tim_player_flags(player_type *creature_ptr, BIT_FLAGS flgs[TR_FLAG_S add_flag(flgs, TR_SEE_INVIS); if (creature_ptr->tim_regen) add_flag(flgs, TR_REGEN); - if (IS_TIM_ESP()) + if (is_time_limit_esp(creature_ptr)) add_flag(flgs, TR_TELEPATHY); if (IS_FAST(creature_ptr) || creature_ptr->slow) add_flag(flgs, TR_SPEED); diff --git a/src/floor-save.c b/src/floor-save.c index 030e6a550..bf687b346 100644 --- a/src/floor-save.c +++ b/src/floor-save.c @@ -411,7 +411,7 @@ static void preserve_pet(player_type *master_ptr) if (m_ptr->parent_m_idx) { master_ptr->riding = 0; - master_ptr->pet_extra_flags &= ~(PF_RYOUTE); + master_ptr->pet_extra_flags &= ~(PF_TWO_HANDS); master_ptr->riding_ryoute = master_ptr->old_riding_ryoute = FALSE; } else diff --git a/src/player-status.c b/src/player-status.c index 53701f7c8..a00a4dd33 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -1573,7 +1573,7 @@ void calc_bonuses(player_type *creature_ptr) if (!creature_ptr->migite) default_hand = 1; } - if (CAN_TWO_HANDS_WIELDING()) + if (can_two_hands_wielding(creature_ptr)) { if (creature_ptr->migite && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM) && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) @@ -3457,7 +3457,7 @@ void calc_bonuses(player_type *creature_ptr) creature_ptr->riding_ryoute = FALSE; if (creature_ptr->ryoute || (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_NONE)) creature_ptr->riding_ryoute = TRUE; - else if (creature_ptr->pet_extra_flags & PF_RYOUTE) + else if (creature_ptr->pet_extra_flags & PF_TWO_HANDS) { switch (creature_ptr->pclass) { @@ -4945,7 +4945,7 @@ BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control) if (!creature_ptr->inventory_list[INVEN_RARM].k_idx) status |= EMPTY_HAND_RARM; if (!creature_ptr->inventory_list[INVEN_LARM].k_idx) status |= EMPTY_HAND_LARM; - if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_RYOUTE)) + if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && !(creature_ptr->pet_extra_flags & PF_TWO_HANDS)) { if (status & EMPTY_HAND_LARM) status &= ~(EMPTY_HAND_LARM); else if (status & EMPTY_HAND_RARM) status &= ~(EMPTY_HAND_RARM); @@ -5984,3 +5984,9 @@ bool is_time_limit_stealth(player_type *creature_ptr) { return creature_ptr->tim_stealth || music_singing(creature_ptr, MUSIC_STEALTH); } + + +bool can_two_hands_wielding(player_type *creature_ptr) +{ + return !creature_ptr->riding || (creature_ptr->pet_extra_flags & PF_TWO_HANDS); +} diff --git a/src/player-status.h b/src/player-status.h index cc2c912d9..8dfc9a6c9 100644 --- a/src/player-status.h +++ b/src/player-status.h @@ -813,6 +813,7 @@ extern bool is_oppose_cold(player_type *creature_ptr); extern bool is_oppose_pois(player_type *creature_ptr); extern bool is_time_limit_esp(player_type *creature_ptr); extern bool is_time_limit_stealth(player_type *creature_ptr); +extern bool can_two_hands_wielding(player_type *creature_ptr); /* * Player "food" crucial values @@ -833,6 +834,4 @@ extern bool is_time_limit_stealth(player_type *creature_ptr); #define PY_REGEN_HPBASE 1442 /* Min amount hp regen*2^16 */ #define PY_REGEN_MNBASE 524 /* Min amount mana regen*2^16 */ -#define CAN_TWO_HANDS_WIELDING() (!p_ptr->riding || (p_ptr->pet_extra_flags & PF_RYOUTE)) - extern void cheat_death(player_type *creature_ptr); -- 2.11.0