OSDN Git Service

[Refactor] #39962 display_player_various() からcalc_two_hands() を分離 / Separated calc_tw...
authorHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 14:28:28 +0000 (23:28 +0900)
committerHourier <hourier@users.sourceforge.jp>
Sun, 23 Feb 2020 14:28:28 +0000 (23:28 +0900)
src/view/status-first-page.c

index 05cbff3..0796cac 100644 (file)
@@ -233,6 +233,54 @@ static concptr likert(int x, int y)
 
 
 /*!
+ * @brief \8b|\81{\97¼\8eè\82Ì\95\90\8aí\82»\82ê\82¼\82ê\82É\82Â\82¢\82Ä\83_\83\81\81[\83W\82ð\8cv\8eZ\82·\82é
+ * @param creature_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
+ * @param damage \92¼\90Ú\8dU\8c\82\82Ì\83_\83\81\81[\83W
+ * @param to_h \96½\92\86\95â\90³
+ * @return \82È\82µ
+ */
+static void calc_two_hands(player_type *creature_ptr, int *damage, int *to_h)
+{
+       object_type *o_ptr;
+       o_ptr = &creature_ptr->inventory_list[INVEN_BOW];
+       BIT_FLAGS flgs[TR_FLAG_SIZE];
+       for (int i = 0; i < 2; i++)
+       {
+               int basedam;
+               damage[i] = creature_ptr->dis_to_d[i] * 100;
+               if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))
+               {
+                       if (!calc_weapon_damage_limit(creature_ptr, i, damage, &basedam, o_ptr))
+                               break;
+
+                       continue;
+               }
+
+               o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
+               if (calc_weapon_one_hand(o_ptr, i, damage, &basedam)) continue;
+
+               to_h[i] = 0;
+               bool poison_needle = FALSE;
+               if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) poison_needle = TRUE;
+               if (object_is_known(o_ptr))
+               {
+                       damage[i] += o_ptr->to_d * 100;
+                       to_h[i] += o_ptr->to_h;
+               }
+
+               basedam = ((o_ptr->dd + creature_ptr->to_dd[i]) * (o_ptr->ds + creature_ptr->to_ds[i] + 1)) * 50;
+               object_flags_known(o_ptr, flgs);
+
+               basedam = calc_expect_crit(creature_ptr, o_ptr->weight, to_h[i], basedam, creature_ptr->dis_to_h[i], poison_needle);
+               basedam = strengthen_basedam(creature_ptr, o_ptr, basedam, flgs);
+               damage[i] += basedam;
+               if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[i] = 1;
+               if (damage[i] < 0) damage[i] = 0;
+       }
+}
+
+
+/*!
  * @brief \83L\83\83\83\89\8aî\96{\8fî\95ñ\8by\82Ñ\8bZ\94\\92l\82ð\83\81\83C\83\93\83E\83B\83\93\83h\83E\82É\95\\8e¦\82·\82é
  * @param creature_ptr \83v\83\8c\81[\83\84\81[\82Ö\82Ì\8eQ\8fÆ\83|\83C\83\93\83^
  * @param xthb \95\90\8aí\93\99\82ð\8aÜ\82ß\82½\8dÅ\8fI\96½\92\86\97¦
@@ -331,40 +379,6 @@ void display_player_various(player_type *creature_ptr, void(*display_player_one_
 
        int damage[2];
        int to_h[2];
-       BIT_FLAGS flgs[TR_FLAG_SIZE];
-       for (int i = 0; i < 2; i++)
-       {
-               int basedam;
-               damage[i] = creature_ptr->dis_to_d[i] * 100;
-               if (((creature_ptr->pclass == CLASS_MONK) || (creature_ptr->pclass == CLASS_FORCETRAINER)) && (empty_hands(creature_ptr, TRUE) & EMPTY_HAND_RARM))
-               {
-                       if (!calc_weapon_damage_limit(creature_ptr, i, damage, &basedam, o_ptr))
-                               break;
-
-                       continue;
-               }
-
-               o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
-               if (calc_weapon_one_hand(o_ptr, i, damage, &basedam)) continue;
-
-               to_h[i] = 0;
-               bool poison_needle = FALSE;
-               if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) poison_needle = TRUE;
-               if (object_is_known(o_ptr))
-               {
-                       damage[i] += o_ptr->to_d * 100;
-                       to_h[i] += o_ptr->to_h;
-               }
-
-               basedam = ((o_ptr->dd + creature_ptr->to_dd[i]) * (o_ptr->ds + creature_ptr->to_ds[i] + 1)) * 50;
-               object_flags_known(o_ptr, flgs);
-
-               basedam = calc_expect_crit(creature_ptr, o_ptr->weight, to_h[i], basedam, creature_ptr->dis_to_h[i], poison_needle);
-               basedam = strengthen_basedam(creature_ptr, o_ptr, basedam, flgs);
-               damage[i] += basedam;
-               if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[i] = 1;
-               if (damage[i] < 0) damage[i] = 0;
-       }
-
+       calc_two_hands(creature_ptr, damage, to_h);
        display_first_page(creature_ptr, xthb, damage, shots, shot_frac, display_player_one_line);
 }