OSDN Git Service

[Refactor] #40514 calc_to_damage() と calc_to_damage_display() を整理. / Refactor calc_to...
authordeskull <deskull@users.sourceforge.jp>
Thu, 20 Aug 2020 15:34:18 +0000 (00:34 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Thu, 20 Aug 2020 15:34:18 +0000 (00:34 +0900)
src/player/player-status.c

index d25e926..af3fe88 100644 (file)
@@ -3017,7 +3017,6 @@ static void calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot)
     }
 
     // 武器以外の装備による修正
-    int default_hand = get_default_hand(creature_ptr);
     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         int bonus_to_d;
         o_ptr = &creature_ptr->inventory_list[i];
@@ -3044,9 +3043,8 @@ static void calc_to_damage(player_type *creature_ptr, INVENTORY_IDX slot)
             creature_ptr->to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
             creature_ptr->to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
             continue;
-        }
-
-        creature_ptr->to_d[default_hand] += (s16b)bonus_to_d;
+        } else if (id == get_default_hand(creature_ptr))
+                       creature_ptr->to_d[id] += (s16b)bonus_to_d;
     }
 
        if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
@@ -3104,7 +3102,6 @@ static void calc_to_damage_display(player_type *creature_ptr, INVENTORY_IDX slot
     }
 
     // 武器以外の装備による修正
-    int default_hand = get_default_hand(creature_ptr);
     for (inventory_slot_type i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         int bonus_to_d;
         o_ptr = &creature_ptr->inventory_list[i];
@@ -3129,17 +3126,14 @@ static void calc_to_damage_display(player_type *creature_ptr, INVENTORY_IDX slot
         if (have_right_hand_weapon(creature_ptr) && have_left_hand_weapon(creature_ptr)) {
             if (!object_is_known(o_ptr))
                 continue;
-
             creature_ptr->dis_to_d[0] += (bonus_to_d > 0) ? (bonus_to_d + 1) / 2 : bonus_to_d;
             creature_ptr->dis_to_d[1] += (bonus_to_d > 0) ? bonus_to_d / 2 : bonus_to_d;
             continue;
+        } else if (id == get_default_hand(creature_ptr)) {
+            if(object_is_known(o_ptr)) creature_ptr->to_d[id] += (s16b)bonus_to_d;
         }
-
-        if (!object_is_known(o_ptr))
-            continue;
-
-        creature_ptr->dis_to_d[default_hand] += (s16b)bonus_to_d;
-    }
+                               
+       }
 
        if (is_martial_arts_mode(creature_ptr) && (!heavy_armor(creature_ptr) || creature_ptr->pclass != CLASS_BERSERKER)) {
         creature_ptr->dis_to_d[id] += (creature_ptr->lev / 6);