• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

変愚蛮怒のメインリポジトリです


Commit MetaInfo

Revisionb2912e8d3521ec4b39396d478c1f7ceff28f7d4c (tree)
Time2020-02-23 23:01:19
AuthorHourier <hourier@user...>
CommiterHourier

Log Message

[Refactor] #39962 display_player_various() からcalc_weapon_one_hand() を分離 / Separated calc_weapon_one_hand() from display_player_various()

Change Summary

Incremental Difference

--- a/src/view/status-first-page.c
+++ b/src/view/status-first-page.c
@@ -47,7 +47,7 @@ static void calc_shot_params(player_type *creature_ptr, object_type *o_ptr, int
4747 * @brief 武器装備に制限のあるクラスで、直接攻撃のダメージを計算する
4848 * @param creature_ptr プレーヤーへの参照ポインタ
4949 * @param hand 手 (利き手が0、反対の手が1…のはず)
50- * @param damage 最終的な直接攻撃のダメージ
50+ * @param damage 直接攻撃のダメージ
5151 * @param basedam 素手における直接攻撃のダメージ
5252 * @param o_ptr 装備中の武器への参照ポインタ
5353 * @return 利き手ならTRUE、反対の手ならFALSE
@@ -78,6 +78,30 @@ static bool calc_weapon_damage_limit(player_type *creature_ptr, int hand, int *d
7878
7979
8080 /*!
81+ * @brief 片手あたりのダメージ量を計算する
82+ * @param o_ptr 装備中の武器への参照ポインタ
83+ * @param hand 手
84+ * @param damage 直接攻撃のダメージ
85+ * @param basedam 素手における直接攻撃のダメージ
86+ * @return 素手ならFALSE、武器を持っていればTRUE
87+ */
88+static bool calc_weapon_one_hand(object_type *o_ptr, int hand, int *damage, int *basedam)
89+{
90+ if (o_ptr->k_idx == 0) return FALSE;
91+
92+ *basedam = 0;
93+ damage[hand] += *basedam;
94+ if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE))
95+ damage[hand] = 1;
96+
97+ if (damage[hand] < 0)
98+ damage[hand] = 0;
99+
100+ return TRUE;
101+}
102+
103+
104+/*!
81105 * @brief 技能ランクの表示基準を定める
82106 * Returns a "rating" of x depending on y
83107 * @param x 技能値
@@ -288,14 +312,7 @@ void display_player_various(player_type *creature_ptr, void(*display_player_one_
288312 }
289313
290314 o_ptr = &creature_ptr->inventory_list[INVEN_RARM + i];
291- if (o_ptr->k_idx == 0)
292- {
293- basedam = 0;
294- damage[i] += basedam;
295- if ((o_ptr->tval == TV_SWORD) && (o_ptr->sval == SV_POISON_NEEDLE)) damage[i] = 1;
296- if (damage[i] < 0) damage[i] = 0;
297- continue;
298- }
315+ if (calc_weapon_one_hand(o_ptr, i, damage, &basedam)) continue;
299316
300317 to_h[i] = 0;
301318 bool poison_needle = FALSE;
Show on old repository browser