From 8f6acb1eb68cae32770166271483b0ce58f566bf Mon Sep 17 00:00:00 2001 From: Hourier Date: Thu, 29 Apr 2021 18:12:16 +0900 Subject: [PATCH] [Refactor] #963 Separated equipment-info.cpp/h from player-status.cpp/h --- Hengband/Hengband/Hengband.vcxproj | 2 + Hengband/Hengband/Hengband.vcxproj.filters | 6 +++ src/Makefile.am | 1 + src/action/weapon-shield.cpp | 2 +- src/cmd-action/cmd-attack.cpp | 4 +- src/cmd-action/cmd-hissatsu.cpp | 4 +- src/cmd-action/cmd-mind.cpp | 2 +- src/cmd-action/cmd-pet.cpp | 10 ++-- src/cmd-item/cmd-equipment.cpp | 2 +- src/cmd-item/cmd-throw.cpp | 2 +- src/combat/attack-criticality.cpp | 2 +- src/inventory/inventory-object.cpp | 2 +- src/mind/mind-elementalist.cpp | 2 +- src/mind/mind-force-trainer.cpp | 7 ++- src/mind/mind-info.cpp | 2 +- src/mind/mind-ninja.cpp | 6 +-- src/mind/mind-power-getter.cpp | 6 +-- src/mspell/mspell-damage-calculator.cpp | 4 +- src/mutation/mutation-processor.cpp | 2 +- src/object-use/read-execution.cpp | 2 +- src/player-attack/player-attack.cpp | 10 ++-- src/player-info/alignment.cpp | 4 +- src/player-info/equipment-info.cpp | 69 ++++++++++++++++++++++++++++ src/player-info/equipment-info.h | 9 ++++ src/player-status/player-speed.cpp | 1 + src/player-status/player-stealth.cpp | 1 + src/player/patron.cpp | 2 +- src/player/permanent-resistances.cpp | 4 +- src/player/player-status-flags.cpp | 5 +- src/player/player-status.cpp | 73 +----------------------------- src/player/player-status.h | 5 -- src/racial/racial-android.cpp | 1 + src/racial/racial-switcher.cpp | 1 + src/realm/realm-hissatsu.cpp | 2 +- src/spell-realm/spells-craft.cpp | 4 +- src/view/display-player-middle.cpp | 1 + src/view/status-first-page.cpp | 2 +- 37 files changed, 144 insertions(+), 120 deletions(-) create mode 100644 src/player-info/equipment-info.cpp create mode 100644 src/player-info/equipment-info.h diff --git a/Hengband/Hengband/Hengband.vcxproj b/Hengband/Hengband/Hengband.vcxproj index afb2c0ae3..302b9a9e9 100644 --- a/Hengband/Hengband/Hengband.vcxproj +++ b/Hengband/Hengband/Hengband.vcxproj @@ -269,6 +269,7 @@ + @@ -939,6 +940,7 @@ + diff --git a/Hengband/Hengband/Hengband.vcxproj.filters b/Hengband/Hengband/Hengband.vcxproj.filters index 38198488e..bdc913625 100644 --- a/Hengband/Hengband/Hengband.vcxproj.filters +++ b/Hengband/Hengband/Hengband.vcxproj.filters @@ -2268,6 +2268,9 @@ player-info + + player-info + @@ -4884,6 +4887,9 @@ player-info + + player-info + diff --git a/src/Makefile.am b/src/Makefile.am index 688135ba1..45bf5d130 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -646,6 +646,7 @@ hengband_SOURCES = \ player-info/base-status-info.cpp player-info/base-status-info.h \ player-info/body-improvement-info.cpp player-info/body-improvement-info.h \ player-info/class-ability-info.cpp player-info/class-ability-info.h \ + player-info/equipment-info.cpp player-info/equipment-info.h \ player-info/mutation-info.cpp player-info/mutation-info.h \ player-info/alignment.cpp player-info/alignment.h \ player-info/race-ability-info.cpp player-info/race-ability-info.h \ diff --git a/src/action/weapon-shield.cpp b/src/action/weapon-shield.cpp index 3bcc3d2f8..445ab0a74 100644 --- a/src/action/weapon-shield.cpp +++ b/src/action/weapon-shield.cpp @@ -11,8 +11,8 @@ #include "object-hook/hook-checker.h" #include "object-hook/hook-weapon.h" #include "object/object-generator.h" +#include "player-info/equipment-info.h" #include "player-status/player-hand-types.h" -#include "player/player-status.h" #include "system/object-type-definition.h" #include "system/player-type-definition.h" #include "view/display-messages.h" diff --git a/src/cmd-action/cmd-attack.cpp b/src/cmd-action/cmd-attack.cpp index 5ad702e63..3936f7c4f 100644 --- a/src/cmd-action/cmd-attack.cpp +++ b/src/cmd-action/cmd-attack.cpp @@ -33,6 +33,7 @@ #include "object/item-use-flags.h" #include "player-attack/player-attack.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" @@ -179,8 +180,7 @@ bool do_cmd_attack(player_type *attacker_ptr, POSITION y, POSITION x, combat_opt update_player_turn_energy(attacker_ptr, 100, update_turn_type::ENERGY_SUBSTITUTION); - if (!can_attack_with_main_hand(attacker_ptr) && !can_attack_with_sub_hand(attacker_ptr) - && attacker_ptr->muta.has_none_of(mutation_attack_methods)) { + if (!can_attack_with_main_hand(attacker_ptr) && !can_attack_with_sub_hand(attacker_ptr) && attacker_ptr->muta.has_none_of(mutation_attack_methods)) { msg_format(_("%s攻撃できない。", "You cannot attack."), (empty_hands(attacker_ptr, FALSE) == EMPTY_HAND_NONE) ? _("両手がふさがって", "") : ""); return FALSE; } diff --git a/src/cmd-action/cmd-hissatsu.cpp b/src/cmd-action/cmd-hissatsu.cpp index b6047c20b..cda6a7eb9 100644 --- a/src/cmd-action/cmd-hissatsu.cpp +++ b/src/cmd-action/cmd-hissatsu.cpp @@ -9,8 +9,8 @@ * 2014 Deskull rearranged comment for Doxygen.\n */ -#include "cmd-action/cmd-spell.h" #include "action/action-limited.h" +#include "cmd-action/cmd-spell.h" #include "core/asking-player.h" #include "core/player-redraw-types.h" #include "core/player-update-types.h" @@ -26,9 +26,9 @@ #include "main/sound-of-music.h" #include "monster-race/monster-race-hook.h" #include "object/item-use-flags.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player/attack-defense-types.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell/spells-execution.h" #include "spell/technic-info-table.h" diff --git a/src/cmd-action/cmd-mind.cpp b/src/cmd-action/cmd-mind.cpp index 02f8b7f8a..29c61b35d 100644 --- a/src/cmd-action/cmd-mind.cpp +++ b/src/cmd-action/cmd-mind.cpp @@ -33,6 +33,7 @@ #include "mind/mind-numbers.h" #include "mind/mind-power-getter.h" #include "mind/mind-types.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player/player-class.h" #include "player/player-damage.h" @@ -48,7 +49,6 @@ #include "util/buffer-shaper.h" #include "view/display-messages.h" - /*! * @brief 職業別特殊技能の処理用構造体 */ diff --git a/src/cmd-action/cmd-pet.cpp b/src/cmd-action/cmd-pet.cpp index b9e1e9b34..00ad623b4 100644 --- a/src/cmd-action/cmd-pet.cpp +++ b/src/cmd-action/cmd-pet.cpp @@ -11,9 +11,9 @@ #include "floor/geometry.h" #include "floor/pattern-walk.h" #include "game-option/input-options.h" +#include "game-option/map-screen-options.h" #include "game-option/play-record-options.h" #include "game-option/text-display-options.h" -#include "game-option/map-screen-options.h" #include "grid/feature.h" #include "grid/grid.h" #include "inventory/inventory-slot-types.h" @@ -36,6 +36,7 @@ #include "monster/smart-learn-types.h" #include "object-hook/hook-weapon.h" #include "pet/pet-util.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" @@ -44,7 +45,6 @@ #include "player/player-move.h" #include "player/player-skill.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "status/action-setter.h" #include "system/floor-type-definition.h" @@ -417,9 +417,9 @@ void do_cmd_pet(player_type *creature_ptr) : "指定なし")); #else sprintf(target_buf, "specify a target of pet (now:%s)", - (creature_ptr->pet_t_m_idx ? ( - creature_ptr->image ? "something strange" : r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name.c_str()) - : "nothing")); + (creature_ptr->pet_t_m_idx + ? (creature_ptr->image ? "something strange" : r_info[creature_ptr->current_floor_ptr->m_list[creature_ptr->pet_t_m_idx].ap_r_idx].name.c_str()) + : "nothing")); #endif power_desc[num] = target_buf; powers[num++] = PET_TARGET; diff --git a/src/cmd-item/cmd-equipment.cpp b/src/cmd-item/cmd-equipment.cpp index 8dcbbfc5e..0d0dfb773 100644 --- a/src/cmd-item/cmd-equipment.cpp +++ b/src/cmd-item/cmd-equipment.cpp @@ -30,6 +30,7 @@ #include "object/object-mark-types.h" #include "perception/object-perception.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" @@ -83,7 +84,6 @@ void do_cmd_equip(player_type *creature_ptr) command_gap = wid - 30; } - /*! * @brief 装備するコマンドのメインルーチン / Wield or wear a single item from the pack or floor * @param creature_ptr プレーヤーへの参照ポインタ diff --git a/src/cmd-item/cmd-throw.cpp b/src/cmd-item/cmd-throw.cpp index a5ba2dbc2..27e4d1034 100644 --- a/src/cmd-item/cmd-throw.cpp +++ b/src/cmd-item/cmd-throw.cpp @@ -44,10 +44,10 @@ #include "object/object-info.h" #include "object/object-kind.h" #include "object/object-stack.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player/attack-defense-types.h" #include "player/player-status-table.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "racial/racial-android.h" #include "specific-object/torch.h" diff --git a/src/combat/attack-criticality.cpp b/src/combat/attack-criticality.cpp index fa7459fd0..490aee78e 100644 --- a/src/combat/attack-criticality.cpp +++ b/src/combat/attack-criticality.cpp @@ -5,7 +5,7 @@ #include "monster-race/race-flags1.h" #include "monster-race/race-flags7.h" #include "player-attack/player-attack-util.h" -#include "player/player-status.h" +#include "player-info/equipment-info.h" #include "sv-definition/sv-weapon-types.h" #include "system/monster-race-definition.h" #include "system/monster-type-definition.h" diff --git a/src/inventory/inventory-object.cpp b/src/inventory/inventory-object.cpp index c4916243a..8b0447fb0 100644 --- a/src/inventory/inventory-object.cpp +++ b/src/inventory/inventory-object.cpp @@ -10,7 +10,7 @@ #include "object/object-mark-types.h" #include "object/object-stack.h" #include "object/object-value.h" -#include "player/player-status.h" +#include "player-info/equipment-info.h" #include "spell-realm/spells-craft.h" #include "system/object-type-definition.h" #include "system/player-type-definition.h" diff --git a/src/mind/mind-elementalist.cpp b/src/mind/mind-elementalist.cpp index cd1dcf9f4..4b0c3da6e 100644 --- a/src/mind/mind-elementalist.cpp +++ b/src/mind/mind-elementalist.cpp @@ -37,10 +37,10 @@ #include "monster-race/race-flags7.h" #include "monster/monster-describer.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-status-base.h" #include "player/player-status-table.h" -#include "player/player-status.h" #include "racial/racial-util.h" #include "spell-kind/earthquake.h" #include "spell-kind/magic-item-recharger.h" diff --git a/src/mind/mind-force-trainer.cpp b/src/mind/mind-force-trainer.cpp index 1d8117b55..4af2c3878 100644 --- a/src/mind/mind-force-trainer.cpp +++ b/src/mind/mind-force-trainer.cpp @@ -19,8 +19,8 @@ #include "monster/monster-update.h" #include "pet/pet-util.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player/player-damage.h" -#include "player/player-status.h" #include "spell-kind/spells-launcher.h" #include "spell-kind/spells-lite.h" #include "spell/spell-types.h" @@ -42,7 +42,10 @@ * @param caster_ptr プレーヤーの参照ポインタ * @return 現在溜まっている気の量 */ -MAGIC_NUM1 get_current_ki(player_type *caster_ptr) { return caster_ptr->magic_num1[0]; } +MAGIC_NUM1 get_current_ki(player_type *caster_ptr) +{ + return caster_ptr->magic_num1[0]; +} /*! * @brief 練気術師において、気を溜める diff --git a/src/mind/mind-info.cpp b/src/mind/mind-info.cpp index 2b2745bd3..ff8ca16db 100644 --- a/src/mind/mind-info.cpp +++ b/src/mind/mind-info.cpp @@ -2,7 +2,7 @@ #include "cmd-action/cmd-spell.h" #include "mind/mind-force-trainer.h" #include "mind/mind-types.h" -#include "player/player-status.h" +#include "player-info/equipment-info.h" #include "system/player-type-definition.h" static void switch_mind_mindcrafter(player_type *caster_ptr, const PLAYER_LEVEL plev, const int power, char *p) diff --git a/src/mind/mind-ninja.cpp b/src/mind/mind-ninja.cpp index c23c251f6..29c29ef0f 100644 --- a/src/mind/mind-ninja.cpp +++ b/src/mind/mind-ninja.cpp @@ -8,9 +8,9 @@ #include "effect/effect-processor.h" #include "effect/spells-effect-util.h" #include "floor/cave.h" -#include "floor/geometry.h" #include "floor/floor-object.h" #include "floor/floor-util.h" +#include "floor/geometry.h" #include "game-option/disturbance-options.h" #include "grid/feature.h" #include "grid/grid.h" @@ -28,10 +28,10 @@ #include "object/object-generator.h" #include "object/object-kind-hook.h" #include "player-attack/player-attack-util.h" -#include "player/attack-defense-types.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" +#include "player/attack-defense-types.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "spell-kind/spells-detection.h" #include "spell-kind/spells-fetcher.h" diff --git a/src/mind/mind-power-getter.cpp b/src/mind/mind-power-getter.cpp index 922d99c5e..80301209c 100644 --- a/src/mind/mind-power-getter.cpp +++ b/src/mind/mind-power-getter.cpp @@ -1,7 +1,7 @@ #include "mind/mind-power-getter.h" #include "core/asking-player.h" -#include "core/window-redrawer.h" #include "core/stuff-handler.h" +#include "core/window-redrawer.h" #include "game-option/text-display-options.h" #include "inventory/inventory-slot-types.h" #include "io/command-repeater.h" @@ -11,12 +11,12 @@ #include "mind/mind-force-trainer.h" #include "mind/mind-info.h" #include "mind/mind-types.h" +#include "player-info/equipment-info.h" #include "player/player-class.h" -#include "player/player-status.h" +#include "player/player-status-table.h" #include "system/player-type-definition.h" #include "term/screen-processor.h" #include "util/int-char-converter.h" -#include "player/player-status-table.h" /*! * @brief 使用可能な特殊技能を選択する / diff --git a/src/mspell/mspell-damage-calculator.cpp b/src/mspell/mspell-damage-calculator.cpp index 8dab9b8df..1968fce8a 100644 --- a/src/mspell/mspell-damage-calculator.cpp +++ b/src/mspell/mspell-damage-calculator.cpp @@ -1,11 +1,11 @@ #include "mspell/mspell-damage-calculator.h" -#include "inventory/inventory-slot-types.h" #include "game-option/birth-options.h" +#include "inventory/inventory-slot-types.h" #include "monster-race/monster-race.h" #include "monster-race/race-ability-flags.h" #include "monster-race/race-flags2.h" #include "monster/monster-status.h" -#include "player/player-status.h" +#include "player-info/equipment-info.h" #include "system/floor-type-definition.h" #include "system/monster-race-definition.h" #include "system/monster-type-definition.h" diff --git a/src/mutation/mutation-processor.cpp b/src/mutation/mutation-processor.cpp index bfa17aae1..cf9f45f83 100644 --- a/src/mutation/mutation-processor.cpp +++ b/src/mutation/mutation-processor.cpp @@ -19,10 +19,10 @@ #include "object-hook/hook-checker.h" #include "object-hook/hook-enchant.h" #include "object/lite-processor.h" +#include "player-info/equipment-info.h" #include "player/digestion-processor.h" #include "player/player-damage.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "spell-kind/spells-floor.h" #include "spell-kind/spells-launcher.h" #include "spell-kind/spells-lite.h" diff --git a/src/object-use/read-execution.cpp b/src/object-use/read-execution.cpp index 159e97372..3e82166b6 100644 --- a/src/object-use/read-execution.cpp +++ b/src/object-use/read-execution.cpp @@ -25,12 +25,12 @@ #include "object/object-kind.h" #include "perception/object-perception.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player/attack-defense-types.h" #include "player/digestion-processor.h" #include "player/player-damage.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "spell-kind/magic-item-recharger.h" #include "spell-kind/spells-curse-removal.h" #include "spell-kind/spells-detection.h" diff --git a/src/player-attack/player-attack.cpp b/src/player-attack/player-attack.cpp index e87231551..7606a09b7 100644 --- a/src/player-attack/player-attack.cpp +++ b/src/player-attack/player-attack.cpp @@ -38,12 +38,12 @@ #include "player-attack/blood-sucking-processor.h" #include "player-attack/player-attack-util.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/player-damage.h" #include "player/player-skill.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "realm/realm-hex-numbers.h" #include "spell-kind/earthquake.h" #include "spell-realm/spells-hex.h" @@ -264,7 +264,7 @@ static MagicalBrandEffect select_magical_brand_effect(player_type *attacker_ptr, * @param pa_ptr プレイヤー攻撃情報への参照ポインタ * @return ダイス数 */ -static DICE_NUMBER magical_brand_extra_dice(player_attack_type* pa_ptr) +static DICE_NUMBER magical_brand_extra_dice(player_attack_type *pa_ptr) { switch (pa_ptr->magical_effect) { case MagicalBrandEffect::NONE: @@ -313,7 +313,8 @@ static bool does_equip_cause_earthquake(player_type *attacker_ptr, player_attack * @param pa_ptr 直接攻撃構造体への参照ポインタ * @return 持つならtrue、持たないならfalse */ -static bool does_weapon_has_flag(BIT_FLAGS &attacker_flags, player_attack_type *pa_ptr) { +static bool does_weapon_has_flag(BIT_FLAGS &attacker_flags, player_attack_type *pa_ptr) +{ if (!attacker_flags) return false; @@ -347,7 +348,8 @@ static void process_weapon_attack(player_type *attacker_ptr, player_attack_type auto do_impact = does_weapon_has_flag(attacker_ptr->impact, pa_ptr); if ((!(o_ptr->tval == TV_SWORD) || !(o_ptr->sval == SV_POISON_NEEDLE)) && !(pa_ptr->mode == HISSATSU_KYUSHO)) - pa_ptr->attack_damage = critical_norm(attacker_ptr, o_ptr->weight, o_ptr->to_h, pa_ptr->attack_damage, attacker_ptr->to_h[pa_ptr->hand], pa_ptr->mode, do_impact); + pa_ptr->attack_damage + = critical_norm(attacker_ptr, o_ptr->weight, o_ptr->to_h, pa_ptr->attack_damage, attacker_ptr->to_h[pa_ptr->hand], pa_ptr->mode, do_impact); pa_ptr->drain_result = pa_ptr->attack_damage; process_vorpal_attack(attacker_ptr, pa_ptr, vorpal_cut, vorpal_chance); diff --git a/src/player-info/alignment.cpp b/src/player-info/alignment.cpp index c36b16c56..ed3447602 100644 --- a/src/player-info/alignment.cpp +++ b/src/player-info/alignment.cpp @@ -2,13 +2,13 @@ #include "artifact/fixed-art-types.h" #include "game-option/text-display-options.h" #include "inventory/inventory-slot-types.h" -#include "monster/monster-info.h" #include "monster-race/monster-race.h" #include "monster-race/race-flags3.h" +#include "monster/monster-info.h" #include "monster/monster-status.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player/player-race.h" -#include "player/player-status.h" // todo has_melee_weapon()が相互依存している。後で消す #include "system/floor-type-definition.h" #include "system/monster-race-definition.h" #include "system/monster-type-definition.h" diff --git a/src/player-info/equipment-info.cpp b/src/player-info/equipment-info.cpp new file mode 100644 index 000000000..ce7d67e84 --- /dev/null +++ b/src/player-info/equipment-info.cpp @@ -0,0 +1,69 @@ +#include "player-info/equipment-info.h" +#include "inventory/inventory-slot-types.h" +#include "object-hook/hook-weapon.h" +#include "pet/pet-util.h" +#include "player-status/player-hand-types.h" +#include "system/object-type-definition.h" +#include "system/player-type-definition.h" +#include "util/bit-flags-calculator.h" + +/*! + * @brief プレイヤーが現在右手/左手に武器を持っているか判定する / + * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND) + * @return 持っているならばTRUE + */ +bool has_melee_weapon(player_type *creature_ptr, int slot) +{ + return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot])); +} + +/*! + * @brief プレイヤーの現在開いている手の状態を返す + * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。 + * @return 開いている手のビットフラグ + */ +BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control) +{ + BIT_FLAGS16 status = EMPTY_HAND_NONE; + if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) + status |= EMPTY_HAND_MAIN; + if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) + status |= EMPTY_HAND_SUB; + + if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) { + if (any_bits(status, EMPTY_HAND_SUB)) + reset_bits(status, EMPTY_HAND_SUB); + else if (any_bits(status, EMPTY_HAND_MAIN)) + reset_bits(status, EMPTY_HAND_MAIN); + } + + return status; +} + +bool can_two_hands_wielding(player_type *creature_ptr) +{ + return !creature_ptr->riding || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS); +} + +/*! + * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。 + * @return ペナルティが適用されるならばTRUE。 + */ +bool heavy_armor(player_type *creature_ptr) +{ + if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA)) + return FALSE; + + WEIGHT monk_arm_wgt = 0; + if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD) + monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight; + if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD) + monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight; + monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight; + monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight; + monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight; + monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight; + monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight; + + return (monk_arm_wgt > (100 + (creature_ptr->lev * 4))); +} diff --git a/src/player-info/equipment-info.h b/src/player-info/equipment-info.h new file mode 100644 index 000000000..ec1188377 --- /dev/null +++ b/src/player-info/equipment-info.h @@ -0,0 +1,9 @@ +#pragma once + +#include "system/angband.h" + +struct player_type; +bool has_melee_weapon(player_type *creature_ptr, int i); +BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control); +bool can_two_hands_wielding(player_type *creature_ptr); +bool heavy_armor(player_type *creature_ptr); diff --git a/src/player-status/player-speed.cpp b/src/player-status/player-speed.cpp index dc662f45a..670718a41 100644 --- a/src/player-status/player-speed.cpp +++ b/src/player-status/player-speed.cpp @@ -9,6 +9,7 @@ #include "mutation/mutation-flag-types.h" #include "object-enchant/tr-types.h" #include "object/object-flags.h" +#include "player-info/equipment-info.h" #include "player/attack-defense-types.h" #include "player/digestion-processor.h" #include "player/player-race.h" diff --git a/src/player-status/player-stealth.cpp b/src/player-status/player-stealth.cpp index a06adc900..19f7644e5 100644 --- a/src/player-status/player-stealth.cpp +++ b/src/player-status/player-stealth.cpp @@ -1,6 +1,7 @@ #include "player-status/player-stealth.h" #include "mind/mind-ninja.h" #include "mutation/mutation-flag-types.h" +#include "player-info/equipment-info.h" #include "player/mimic-info-table.h" #include "player/player-class.h" #include "player/player-personality.h" diff --git a/src/player/patron.cpp b/src/player/patron.cpp index 0e4d32b70..106b25d5a 100644 --- a/src/player/patron.cpp +++ b/src/player/patron.cpp @@ -13,10 +13,10 @@ #include "mutation/mutation-investor-remover.h" #include "object-enchant/object-curse.h" #include "object/object-kind-hook.h" +#include "player-info/equipment-info.h" #include "player/player-class.h" #include "player/player-damage.h" #include "player/player-race-types.h" -#include "player/player-status.h" #include "spell-kind/spells-floor.h" #include "spell-kind/spells-genocide.h" #include "spell-kind/spells-launcher.h" diff --git a/src/player/permanent-resistances.cpp b/src/player/permanent-resistances.cpp index 199dcdc1d..e558002cc 100644 --- a/src/player/permanent-resistances.cpp +++ b/src/player/permanent-resistances.cpp @@ -3,11 +3,11 @@ #include "mind/mind-elementalist.h" #include "mutation/mutation-flag-types.h" #include "object-enchant/tr-types.h" +#include "player-info/equipment-info.h" #include "player/player-personality-types.h" #include "player/player-race-types.h" #include "player/player-race.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "system/object-type-definition.h" #include "system/player-type-definition.h" @@ -161,7 +161,7 @@ static void add_mutation_flags(player_type *creature_ptr, BIT_FLAGS *flags) if (creature_ptr->muta.has(MUTA::FLESH_ROT)) remove_flag(flags, TR_REGEN); - if (creature_ptr->muta.has_any_of({MUTA::XTRA_FAT, MUTA::XTRA_LEGS, MUTA::SHORT_LEG})) + if (creature_ptr->muta.has_any_of({ MUTA::XTRA_FAT, MUTA::XTRA_LEGS, MUTA::SHORT_LEG })) add_flag(flags, TR_SPEED); if (creature_ptr->muta.has(MUTA::ELEC_TOUC)) add_flag(flags, TR_SH_ELEC); diff --git a/src/player/player-status-flags.cpp b/src/player/player-status-flags.cpp index c6ca72ab5..5c4602561 100644 --- a/src/player/player-status-flags.cpp +++ b/src/player/player-status-flags.cpp @@ -13,11 +13,12 @@ #include "object-hook/hook-checker.h" #include "object-hook/hook-weapon.h" #include "object/object-flags.h" +#include "player-info/equipment-info.h" #include "player-status/player-basic-statistics.h" -#include "player-status/player-speed.h" -#include "player-status/player-stealth.h" #include "player-status/player-hand-types.h" #include "player-status/player-infravision.h" +#include "player-status/player-speed.h" +#include "player-status/player-stealth.h" #include "player/attack-defense-types.h" #include "player/digestion-processor.h" #include "player/mimic-info-table.h" diff --git a/src/player/player-status.cpp b/src/player/player-status.cpp index ddaa55d85..862f5395f 100644 --- a/src/player/player-status.cpp +++ b/src/player/player-status.cpp @@ -57,6 +57,7 @@ #include "pet/pet-util.h" #include "player-info/alignment.h" #include "player-info/avatar.h" +#include "player-info/equipment-info.h" #include "player-status/player-basic-statistics.h" #include "player-status/player-hand-types.h" #include "player-status/player-infravision.h" @@ -138,8 +139,6 @@ static s16b calc_to_damage_misc(player_type *creature_ptr); static s16b calc_to_hit_misc(player_type *creature_ptr); static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_IDX slot); -static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot); - static player_hand main_attack_hand(player_type *creature_ptr); /*** Player information ***/ @@ -386,7 +385,7 @@ static void update_bonuses(player_type *creature_ptr) creature_ptr->heavy_wield[i] = is_heavy_wield(creature_ptr, i); creature_ptr->num_blow[i] = calc_num_blow(creature_ptr, i); creature_ptr->to_dd[i] = calc_to_weapon_dice_num(creature_ptr, INVEN_MAIN_HAND + i); - creature_ptr->to_ds[i] = calc_to_weapon_dice_side(creature_ptr, INVEN_MAIN_HAND + i); + creature_ptr->to_ds[i] = 0; } creature_ptr->pspeed = PlayerSpeed(creature_ptr).get_value(); @@ -2515,13 +2514,6 @@ static DICE_NUMBER calc_to_weapon_dice_num(player_type *creature_ptr, INVENTORY_ return dn; } -static DICE_NUMBER calc_to_weapon_dice_side(player_type *creature_ptr, INVENTORY_IDX slot) -{ - (void)creature_ptr; // unused - (void)slot; // unused - return 0; -} - /*! * @brief プレイヤーの所持重量制限を計算する / * Computes current weight limit. @@ -2536,62 +2528,6 @@ WEIGHT calc_weight_limit(player_type *creature_ptr) } /*! - * @brief プレイヤーが現在右手/左手に武器を持っているか判定する / - * @param i 判定する手のID(右手:INVEN_MAIN_HAND 左手:INVEN_SUB_HAND) - * @return 持っているならばTRUE - */ -bool has_melee_weapon(player_type *creature_ptr, int slot) -{ - return ((creature_ptr->inventory_list[slot].k_idx) && object_is_melee_weapon(&creature_ptr->inventory_list[slot])); -} - -/*! - * @brief プレイヤーの現在開いている手の状態を返す - * @param riding_control 乗馬中により片手を必要としている状態ならばTRUEを返す。 - * @return 開いている手のビットフラグ - */ -BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control) -{ - BIT_FLAGS16 status = EMPTY_HAND_NONE; - if (!creature_ptr->inventory_list[INVEN_MAIN_HAND].k_idx) - status |= EMPTY_HAND_MAIN; - if (!creature_ptr->inventory_list[INVEN_SUB_HAND].k_idx) - status |= EMPTY_HAND_SUB; - - if (riding_control && (status != EMPTY_HAND_NONE) && creature_ptr->riding && none_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS)) { - if (any_bits(status, EMPTY_HAND_SUB)) - reset_bits(status, EMPTY_HAND_SUB); - else if (any_bits(status, EMPTY_HAND_MAIN)) - reset_bits(status, EMPTY_HAND_MAIN); - } - - return status; -} - -/*! - * @brief プレイヤーが防具重量制限のある職業時にペナルティを受ける状態にあるかどうかを返す。 - * @return ペナルティが適用されるならばTRUE。 - */ -bool heavy_armor(player_type *creature_ptr) -{ - if ((creature_ptr->pclass != CLASS_MONK) && (creature_ptr->pclass != CLASS_FORCETRAINER) && (creature_ptr->pclass != CLASS_NINJA)) - return FALSE; - - WEIGHT monk_arm_wgt = 0; - if (creature_ptr->inventory_list[INVEN_MAIN_HAND].tval > TV_SWORD) - monk_arm_wgt += creature_ptr->inventory_list[INVEN_MAIN_HAND].weight; - if (creature_ptr->inventory_list[INVEN_SUB_HAND].tval > TV_SWORD) - monk_arm_wgt += creature_ptr->inventory_list[INVEN_SUB_HAND].weight; - monk_arm_wgt += creature_ptr->inventory_list[INVEN_BODY].weight; - monk_arm_wgt += creature_ptr->inventory_list[INVEN_HEAD].weight; - monk_arm_wgt += creature_ptr->inventory_list[INVEN_OUTER].weight; - monk_arm_wgt += creature_ptr->inventory_list[INVEN_ARMS].weight; - monk_arm_wgt += creature_ptr->inventory_list[INVEN_FEET].weight; - - return (monk_arm_wgt > (100 + (creature_ptr->lev * 4))); -} - -/*! * @brief update のフラグに応じた更新をまとめて行う / Handle "update" * @return なし * @details 更新処理の対象はプレイヤーの能力修正/光源寿命/HP/MP/魔法の学習状態、他多数の外界の状態判定。 @@ -3064,11 +3000,6 @@ 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 || any_bits(creature_ptr->pet_extra_flags, PF_TWO_HANDS); -} - /*! * @brief 口を使う継続的な処理を中断する * @param caster_ptr プレーヤーへの参照ポインタ diff --git a/src/player/player-status.h b/src/player/player-status.h index 234759089..d834fe89c 100644 --- a/src/player/player-status.h +++ b/src/player/player-status.h @@ -18,11 +18,7 @@ WEIGHT calc_inventory_weight(player_type *creature_ptr); s16b calc_num_fire(player_type *creature_ptr, object_type *o_ptr); WEIGHT calc_weight_limit(player_type *creature_ptr); -bool has_melee_weapon(player_type *creature_ptr, int i); - -bool heavy_armor(player_type *creature_ptr); void update_creature(player_type *creature_ptr); -BIT_FLAGS16 empty_hands(player_type *creature_ptr, bool riding_control); bool player_has_no_spellbooks(player_type *creature_ptr); bool player_place(player_type *creature_ptr, POSITION y, POSITION x); @@ -36,7 +32,6 @@ long calc_score(player_type *creature_ptr); bool is_blessed(player_type *creature_ptr); bool is_time_limit_esp(player_type *creature_ptr); bool is_time_limit_stealth(player_type *creature_ptr); -bool can_two_hands_wielding(player_type *creature_ptr); bool is_fast(player_type *creature_ptr); bool is_invuln(player_type *creature_ptr); bool is_hero(player_type *creature_ptr); diff --git a/src/racial/racial-android.cpp b/src/racial/racial-android.cpp index 74f045bf3..be01f41a0 100644 --- a/src/racial/racial-android.cpp +++ b/src/racial/racial-android.cpp @@ -8,6 +8,7 @@ #include "object/object-kind.h" #include "object/object-value-calc.h" #include "object/object-value.h" +#include "player-info/equipment-info.h" #include "player/player-status.h" #include "spell-kind/spells-launcher.h" #include "spell/spell-types.h" diff --git a/src/racial/racial-switcher.cpp b/src/racial/racial-switcher.cpp index 24eeb883a..b370c10f6 100644 --- a/src/racial/racial-switcher.cpp +++ b/src/racial/racial-switcher.cpp @@ -46,6 +46,7 @@ #include "mind/stances-table.h" #include "mutation/mutation-flag-types.h" #include "object/item-tester-hooker.h" +#include "player-info/equipment-info.h" #include "player-status/player-energy.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" diff --git a/src/realm/realm-hissatsu.cpp b/src/realm/realm-hissatsu.cpp index 4361bb84a..bcbc4487b 100644 --- a/src/realm/realm-hissatsu.cpp +++ b/src/realm/realm-hissatsu.cpp @@ -30,9 +30,9 @@ #include "monster/monster-update.h" #include "object-enchant/tr-types.h" #include "object/object-flags.h" +#include "player-info/equipment-info.h" #include "player/player-damage.h" #include "player/player-move.h" -#include "player/player-status.h" #include "spell-kind/earthquake.h" #include "spell-kind/spells-detection.h" #include "spell-kind/spells-launcher.h" diff --git a/src/spell-realm/spells-craft.cpp b/src/spell-realm/spells-craft.cpp index 4f75160c2..3e2436d90 100644 --- a/src/spell-realm/spells-craft.cpp +++ b/src/spell-realm/spells-craft.cpp @@ -14,9 +14,9 @@ #include "object-hook/hook-enchant.h" #include "object/item-use-flags.h" #include "object/object-flags.h" -#include "player/attack-defense-types.h" #include "player-info/avatar.h" -#include "player/player-status.h" +#include "player-info/equipment-info.h" +#include "player/attack-defense-types.h" #include "player/special-defense-types.h" #include "racial/racial-android.h" #include "spell/spells-object.h" diff --git a/src/view/display-player-middle.cpp b/src/view/display-player-middle.cpp index 8df29688f..c5abde538 100644 --- a/src/view/display-player-middle.cpp +++ b/src/view/display-player-middle.cpp @@ -9,6 +9,7 @@ #include "perception/object-perception.h" #include "player-status/player-hand-types.h" #include "player/attack-defense-types.h" +#include "player-info/equipment-info.h" #include "player/player-race-types.h" #include "player/player-skill.h" #include "player/player-status-flags.h" diff --git a/src/view/status-first-page.cpp b/src/view/status-first-page.cpp index 404c4fe93..5888295d9 100644 --- a/src/view/status-first-page.cpp +++ b/src/view/status-first-page.cpp @@ -17,9 +17,9 @@ #include "object-enchant/tr-types.h" #include "object/object-flags.h" #include "perception/object-perception.h" +#include "player-info/equipment-info.h" #include "player-status/player-hand-types.h" #include "player/player-status-flags.h" -#include "player/player-status.h" #include "player/special-defense-types.h" #include "sv-definition/sv-weapon-types.h" #include "system/object-type-definition.h" -- 2.11.0