OSDN Git Service

[Refactor] #40514 have_two_handed_weapons() を calc_bonuses() から分離. / Separated have_t...
authordeskull <deskull@users.sourceforge.jp>
Mon, 10 Aug 2020 14:33:53 +0000 (23:33 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Mon, 10 Aug 2020 14:33:53 +0000 (23:33 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index 2348dcc..ae97878 100644 (file)
@@ -8,6 +8,7 @@
 #include "object-enchant/object-ego.h"
 #include "object-enchant/tr-types.h"
 #include "object-enchant/trc-types.h"
+#include "object-hook/hook-weapon.h"
 #include "object-hook/hook-checker.h"
 #include "object/object-flags.h"
 #include "player/player-class.h"
@@ -2073,3 +2074,26 @@ void have_left_hand_weapon(player_type *creature_ptr)
         creature_ptr->left_hand_weapon = TRUE;
     }
 }
+
+void have_two_handed_weapons(player_type *creature_ptr)
+{ 
+       creature_ptr->two_handed_weapon = FALSE;
+    if (can_two_hands_wielding(creature_ptr)) {
+        if (creature_ptr->right_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
+            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
+            creature_ptr->two_handed_weapon = TRUE;
+        } else if (creature_ptr->left_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
+            && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
+            creature_ptr->two_handed_weapon = TRUE;
+        } else {
+            switch (creature_ptr->pclass) {
+            case CLASS_MONK:
+            case CLASS_FORCETRAINER:
+            case CLASS_BERSERKER:
+                if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
+                    creature_ptr->two_handed_weapon = TRUE;
+                }
+            }
+        }
+    }
+}
index ce6871e..2e3aec9 100644 (file)
@@ -73,5 +73,6 @@ void have_immune_fire(player_type *creature_ptr);
 void have_immune_cold(player_type *creature_ptr);
 void have_right_hand_weapon(player_type *creature_ptr);
 void have_left_hand_weapon(player_type *creature_ptr);
+void have_two_handed_weapons(player_type *creature_ptr);
 
 
index bc7c531..d49b79d 100644 (file)
@@ -556,14 +556,6 @@ static void delayed_visual_update(player_type *player_ptr)
 }
 
 /*!
- * @brief プレイヤー構造体の全ステータスを初期化する
- */
-static void clear_creature_bonuses(player_type *creature_ptr)
-{
-    creature_ptr->two_handed_weapon = FALSE;
-}
-
-/*!
  * @brief 射撃武器がプレイヤーにとって重すぎるかどうかの判定 /
  * @param o_ptr 判定する射撃武器のアイテム情報参照ポインタ
  * @return 重すぎるならばTRUE
@@ -628,10 +620,9 @@ void calc_bonuses(player_type *creature_ptr)
     ARMOUR_CLASS old_dis_ac = creature_ptr->dis_ac;
     ARMOUR_CLASS old_dis_to_a = creature_ptr->dis_to_a;
 
-    clear_creature_bonuses(creature_ptr);
-
        have_right_hand_weapon(creature_ptr);
     have_left_hand_weapon(creature_ptr);
+    have_two_handed_weapons(creature_ptr);
 
     if (has_melee_weapon(creature_ptr, INVEN_LARM)) {
         if (!creature_ptr->right_hand_weapon)
@@ -641,20 +632,9 @@ void calc_bonuses(player_type *creature_ptr)
     if (can_two_hands_wielding(creature_ptr)) {
         if (creature_ptr->right_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_LARM)
             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_RARM])) {
-            creature_ptr->two_handed_weapon = TRUE;
         } else if (creature_ptr->left_hand_weapon && (empty_hands(creature_ptr, FALSE) == EMPTY_HAND_RARM)
             && object_allow_two_hands_wielding(&creature_ptr->inventory_list[INVEN_LARM])) {
-            creature_ptr->two_handed_weapon = TRUE;
         } else {
-            switch (creature_ptr->pclass) {
-            case CLASS_MONK:
-            case CLASS_FORCETRAINER:
-            case CLASS_BERSERKER:
-                if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
-                    creature_ptr->two_handed_weapon = TRUE;
-                }
-            }
-
             default_hand = 1;
         }
     }