OSDN Git Service

[Refactor] #40514 calc_base_ac() を帰り値持ちに仕様変更. / calc_base_ac() was changed specificat...
authordeskull <deskull@users.sourceforge.jp>
Sat, 15 Aug 2020 15:28:15 +0000 (00:28 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sat, 15 Aug 2020 15:28:15 +0000 (00:28 +0900)
src/player/player-status.c

index 8f7da9a..4464948 100644 (file)
@@ -122,7 +122,7 @@ static s16b calc_dexterity_addition(player_type *creature_ptr);
 static s16b calc_constitution_addition(player_type *creature_ptr);
 static s16b calc_charisma_addition(player_type *creature_ptr);
 static s16b calc_to_magic_chance(player_type *creature_ptr);
-static void calc_base_ac(player_type *creature_ptr);
+static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr);
 static void calc_base_ac_display(player_type *creature_ptr);
 static void calc_to_ac(player_type *creature_ptr);
 static void calc_to_ac_display(player_type *creature_ptr);
@@ -456,7 +456,7 @@ void calc_bonuses(player_type *creature_ptr)
     creature_ptr->stat_add[A_CON] = calc_constitution_addition(creature_ptr);
     creature_ptr->stat_add[A_CHR] = calc_charisma_addition(creature_ptr);
     creature_ptr->to_m_chance = calc_to_magic_chance(creature_ptr);
-    calc_base_ac(creature_ptr);
+    creature_ptr->ac = calc_base_ac(creature_ptr);
     calc_to_ac(creature_ptr);
     calc_base_ac_display(creature_ptr);
     calc_to_ac_display(creature_ptr);
@@ -2366,23 +2366,26 @@ static s16b calc_to_magic_chance(player_type *creature_ptr)
     return chance;
 }
 
-static void calc_base_ac(player_type *creature_ptr)
+static ARMOUR_CLASS calc_base_ac(player_type *creature_ptr)
 {
-    creature_ptr->ac = 0;
+    ARMOUR_CLASS ac = 0;
     if (creature_ptr->yoiyami)
-        return;
+        return 0;
 
     for (int i = INVEN_RARM; i < INVEN_TOTAL; i++) {
         object_type *o_ptr;
         o_ptr = &creature_ptr->inventory_list[i];
         if (!o_ptr->k_idx)
             continue;
-        creature_ptr->ac += o_ptr->ac;
+        ac += o_ptr->ac;
     }
+
     if (object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_RARM])
         || object_is_armour(creature_ptr, &creature_ptr->inventory_list[INVEN_LARM])) {
-        creature_ptr->ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
+        ac += creature_ptr->skill_exp[GINOU_SHIELD] * (1 + creature_ptr->lev / 22) / 2000;
     }
+
+       return ac;
 }
 
 static void calc_to_ac(player_type *creature_ptr)