OSDN Git Service

[Refactor] #40514 is_icky_wield_weapon() を calc_bonuses() から分離. / Separated is_icky_w...
authordeskull <deskull@users.sourceforge.jp>
Wed, 12 Aug 2020 07:34:22 +0000 (16:34 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Wed, 12 Aug 2020 07:34:22 +0000 (16:34 +0900)
src/player/player-status-flags.c
src/player/player-status-flags.h
src/player/player-status.c

index ba6d183..2f02eff 100644 (file)
@@ -8,13 +8,15 @@
 #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-hook/hook-weapon.h"
 #include "object/object-flags.h"
 #include "player/player-class.h"
 #include "player/player-race-types.h"
 #include "player/player-race.h"
+#include "player/player-skill.h"
 #include "player/player-status.h"
+#include "player/player-status-flags.h"
 #include "player/special-defense-types.h"
 #include "realm/realm-hex-numbers.h"
 #include "realm/realm-song-numbers.h"
@@ -23,6 +25,7 @@
 #include "system/floor-type-definition.h"
 #include "system/monster-type-definition.h"
 #include "system/object-type-definition.h"
+#include "sv-definition/sv-weapon-types.h"
 #include "util/bit-flags-calculator.h"
 #include "util/quarks.h"
 #include "util/string-processor.h"
@@ -63,7 +66,7 @@ void have_pass_wall(player_type *creature_ptr)
         creature_ptr->pass_wall = TRUE;
     }
 
-       if (creature_ptr->riding) {
+    if (creature_ptr->riding) {
         monster_type *riding_m_ptr = &creature_ptr->current_floor_ptr->m_list[creature_ptr->riding];
         monster_race *riding_r_ptr = &r_info[riding_m_ptr->r_idx];
         if (!(riding_r_ptr->flags2 & RF2_PASS_WALL))
@@ -1948,7 +1951,7 @@ void have_resist_fear(player_type *creature_ptr)
         creature_ptr->resist_fear = TRUE;
     }
 
-       if (is_hero(creature_ptr) || creature_ptr->shero) {
+    if (is_hero(creature_ptr) || creature_ptr->shero) {
         creature_ptr->resist_fear = TRUE;
     }
 
@@ -2053,22 +2056,21 @@ void have_immune_cold(player_type *creature_ptr)
 
 void have_right_hand_weapon(player_type *creature_ptr)
 {
-       creature_ptr->right_hand_weapon = FALSE;
+    creature_ptr->right_hand_weapon = FALSE;
     if (has_melee_weapon(creature_ptr, INVEN_RARM))
         creature_ptr->right_hand_weapon = TRUE;
 
     if (can_two_hands_wielding(creature_ptr)) {
         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->right_hand_weapon = TRUE;
-                }
-                break;
+        case CLASS_MONK:
+        case CLASS_FORCETRAINER:
+        case CLASS_BERSERKER:
+            if (empty_hands(creature_ptr, FALSE) == (EMPTY_HAND_RARM | EMPTY_HAND_LARM)) {
+                creature_ptr->right_hand_weapon = TRUE;
+            }
+            break;
         }
     }
-
 }
 
 void have_left_hand_weapon(player_type *creature_ptr)
@@ -2080,8 +2082,8 @@ void have_left_hand_weapon(player_type *creature_ptr)
 }
 
 void have_two_handed_weapons(player_type *creature_ptr)
-{ 
-       creature_ptr->two_handed_weapon = FALSE;
+{
+    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])) {
@@ -2108,18 +2110,18 @@ void have_lite(player_type *creature_ptr)
     if (creature_ptr->pclass == CLASS_NINJA)
         return;
 
-       if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
-               creature_ptr->lite = TRUE;
+    if (creature_ptr->mimic_form == MIMIC_VAMPIRE) {
+        creature_ptr->lite = TRUE;
     }
 
     if (!creature_ptr->mimic_form && creature_ptr->prace == RACE_VAMPIRE)
         creature_ptr->lite = TRUE;
 
-       if (creature_ptr->sh_fire)
+    if (creature_ptr->sh_fire)
         creature_ptr->lite = TRUE;
 
     if (creature_ptr->ult_res || (creature_ptr->special_defense & KATA_MUSOU)) {
-               creature_ptr->lite = TRUE;
+        creature_ptr->lite = TRUE;
     }
 }
 
@@ -2133,3 +2135,39 @@ bool is_disable_two_handed_bonus(player_type *creature_ptr, int i)
     }
     return FALSE;
 }
+
+void is_icky_wield_weapon(player_type* creature_ptr, int i)
+{
+
+       object_type *o_ptr;
+    BIT_FLAGS flgs[TR_FLAG_SIZE];
+    o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
+    object_flags(creature_ptr, o_ptr, flgs);
+
+       creature_ptr->icky_wield[i] = FALSE;
+    if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
+        creature_ptr->icky_wield[i] = TRUE;
+    } else if (creature_ptr->pclass == CLASS_SORCERER) {
+        if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
+            creature_ptr->icky_wield[i] = TRUE;
+        }
+    }
+    if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
+        creature_ptr->icky_wield[i] = TRUE;
+    }
+}
+
+bool is_not_ninja_weapon(player_type *creature_ptr, int i)
+{
+    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
+    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+    return creature_ptr->pclass == CLASS_NINJA
+        && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
+}
+
+bool is_not_monk_weapon(player_type *creature_ptr, int i)
+{
+    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
+    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
+    return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
+}
index 146eab4..4c15981 100644 (file)
@@ -76,5 +76,8 @@ void have_left_hand_weapon(player_type *creature_ptr);
 void have_two_handed_weapons(player_type *creature_ptr);
 void have_lite(player_type *creature_ptr);
 bool is_disable_two_handed_bonus(player_type *creature_ptr, int i);
+bool is_not_ninja_weapon(player_type *creature_ptr, int i);
+bool is_not_monk_weapon(player_type *creature_ptr, int i);
+void is_icky_wield_weapon(player_type *creature_ptr, int i);
 
 
index 3bca9c7..46e0f10 100644 (file)
@@ -99,8 +99,6 @@
 #include "world/world.h"
 
 static bool is_martial_arts_mode(player_type *creature_ptr);
-static bool is_not_ninja_weapon(player_type *creature_ptr, int i);
-static bool is_not_monk_weapon(player_type *creature_ptr, int i);
 
 static void calc_intra_vision(player_type *creature_ptr);
 static void calc_stealth(player_type *creature_ptr);
@@ -783,19 +781,8 @@ void calc_bonuses(player_type *creature_ptr)
     }
 
     for (int i = 0; i < 2; i++) {
-        o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
-        object_flags(creature_ptr, o_ptr, flgs);
-
+        is_icky_wield_weapon(creature_ptr, i);
         calc_num_blow(creature_ptr, i);
-
-        if ((creature_ptr->pclass == CLASS_PRIEST) && (!(have_flag(flgs, TR_BLESSED))) && ((o_ptr->tval == TV_SWORD) || (o_ptr->tval == TV_POLEARM))) {
-            creature_ptr->icky_wield[i] = TRUE;
-        } else if (creature_ptr->pclass == CLASS_SORCERER) {
-            if (!((o_ptr->tval == TV_HAFTED) && ((o_ptr->sval == SV_WIZSTAFF) || (o_ptr->sval == SV_NAMAKE_HAMMER)))) {
-                creature_ptr->icky_wield[i] = TRUE;
-            }
-        }
-
         calc_to_weapon_dice_num(creature_ptr, INVEN_RARM + i);
         calc_to_weapon_dice_side(creature_ptr, INVEN_RARM + i);
 
@@ -803,10 +790,6 @@ void calc_bonuses(player_type *creature_ptr)
             && !have_flag(flgs, TR_RIDING)) {
             creature_ptr->riding_wield[i] = TRUE;
         }
-
-        if (is_not_monk_weapon(creature_ptr, i) || is_not_ninja_weapon(creature_ptr, i)) {
-            creature_ptr->icky_wield[i] = TRUE;
-        }
     }
 
     calc_riding_weapon_penalty(creature_ptr);
@@ -1892,21 +1875,6 @@ static bool is_martial_arts_mode(player_type *creature_ptr)
         && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM) && !creature_ptr->left_hand_weapon;
 }
 
-static bool is_not_ninja_weapon(player_type *creature_ptr, int i)
-{
-    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
-    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
-    return creature_ptr->pclass == CLASS_NINJA
-        && !((s_info[CLASS_NINJA].w_max[tval][sval] > WEAPON_EXP_BEGINNER) && (creature_ptr->inventory_list[INVEN_LARM - i].tval != TV_SHIELD));
-}
-
-static bool is_not_monk_weapon(player_type *creature_ptr, int i)
-{
-    tval_type tval = creature_ptr->inventory_list[INVEN_RARM + i].tval - TV_WEAPON_BEGIN;
-    OBJECT_SUBTYPE_VALUE sval = creature_ptr->inventory_list[INVEN_RARM + i].sval;
-    return (creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER) && (!s_info[creature_ptr->pclass].w_max[tval][sval]);
-}
-
 static void calc_num_blow(player_type *creature_ptr, int i)
 {
     object_type *o_ptr;
@@ -1915,7 +1883,6 @@ static void calc_num_blow(player_type *creature_ptr, int i)
     o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
     object_flags(creature_ptr, o_ptr, flgs);
     creature_ptr->heavy_wield[i] = FALSE;
-    creature_ptr->icky_wield[i] = FALSE;
     creature_ptr->riding_wield[i] = FALSE;
     if (!has_melee_weapon(creature_ptr, INVEN_RARM + i)) {
         creature_ptr->num_blow[i] = 1;