• R/O
  • HTTP
  • SSH
  • HTTPS

hengband: Commit

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


Commit MetaInfo

Revisione8789aa0badf1e7d55a63830d491f907004c1c9e (tree)
Time2019-02-04 02:10:44
AuthorDeskull <deskull@user...>
CommiterDeskull

Log Message

[Refactor] #37353 do_cmd_rerate() を roll_hitdice() に改名して spells-status.c に移動。 / Rename do_cmd_rerate() to roll_hitdice() and move to spells-status.c.

Change Summary

Incremental Difference

--- a/src/birth.c
+++ b/src/birth.c
@@ -19,6 +19,7 @@
1919 #include "quest.h"
2020 #include "player-status.h"
2121 #include "spells.h"
22+#include "spells-status.h"
2223
2324 /*!
2425 * オートローラーの内容を描画する間隔 /
@@ -1200,7 +1201,7 @@ static void get_extra(bool roll_hitdie)
12001201 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
12011202
12021203 /* Roll for hit point unless quick-start */
1203- if (roll_hitdie) do_cmd_rerate(SPOP_NO_UPDATE);
1204+ if (roll_hitdie) roll_hitdice(SPOP_NO_UPDATE);
12041205
12051206 /* Initial hitpoints */
12061207 p_ptr->mhp = p_ptr->player_hp[0];
--- a/src/cmd-quaff.c
+++ b/src/cmd-quaff.c
@@ -452,7 +452,7 @@ void do_cmd_quaff_potion_aux(INVENTORY_IDX item)
452452 break;
453453
454454 case SV_POTION_NEW_LIFE:
455- do_cmd_rerate(0L);
455+ roll_hitdice(0L);
456456 get_max_stats();
457457 p_ptr->update |= PU_BONUS;
458458 lose_all_mutations();
--- a/src/effects.c
+++ b/src/effects.c
@@ -3687,7 +3687,7 @@ void change_race(CHARACTER_IDX new_race, concptr effect_msg)
36873687 else
36883688 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
36893689
3690- do_cmd_rerate(0L);
3690+ roll_hitdice(0L);
36913691
36923692 /* The experience level may be modified */
36933693 check_experience();
@@ -3817,7 +3817,7 @@ void do_poly_self(void)
38173817 power -= 10;
38183818
38193819 get_max_stats();
3820- do_cmd_rerate(0L);
3820+ roll_hitdice(0L);
38213821 }
38223822
38233823 while ((power > randint0(15)) && one_in_(3))
--- a/src/externs.h
+++ b/src/externs.h
@@ -1428,7 +1428,6 @@ extern void spoil_random_artifact(concptr fname);
14281428
14291429 /* wizard2.c */
14301430 extern void strip_name(char *buf, KIND_OBJECT_IDX k_idx);
1431-extern void do_cmd_rerate(SPOP_FLAGS options);
14321431 extern void cheat_death(player_type *creature_ptr);
14331432
14341433
--- a/src/load.c
+++ b/src/load.c
@@ -48,6 +48,7 @@
4848 #include "store.h"
4949 #include "artifact.h"
5050 #include "avatar.h"
51+#include "spells-status.h"
5152
5253
5354 /*
@@ -3791,22 +3792,22 @@ static errr rd_savefile_new_aux(void)
37913792 if(z_older_than(10, 2, 2) && (p_ptr->pclass == CLASS_BEASTMASTER) && !p_ptr->is_dead)
37923793 {
37933794 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3794- do_cmd_rerate(0L);
3795+ roll_hitdice(0L);
37953796 }
37963797 if(z_older_than(10, 3, 2) && (p_ptr->pclass == CLASS_ARCHER) && !p_ptr->is_dead)
37973798 {
37983799 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3799- do_cmd_rerate(0L);
3800+ roll_hitdice(0L);
38003801 }
38013802 if(z_older_than(10, 2, 6) && (p_ptr->pclass == CLASS_SORCERER) && !p_ptr->is_dead)
38023803 {
38033804 p_ptr->hitdie = rp_ptr->r_mhp/2 + cp_ptr->c_mhp + ap_ptr->a_mhp;
3804- do_cmd_rerate(0L);
3805+ roll_hitdice(0L);
38053806 }
38063807 if(z_older_than(10, 4, 7) && (p_ptr->pclass == CLASS_BLUE_MAGE) && !p_ptr->is_dead)
38073808 {
38083809 p_ptr->hitdie = rp_ptr->r_mhp + cp_ptr->c_mhp + ap_ptr->a_mhp;
3809- do_cmd_rerate(0L);
3810+ roll_hitdice(0L);
38103811 }
38113812
38123813 /* Important -- Initialize the magic */
--- a/src/spells-status.c
+++ b/src/spells-status.c
@@ -2,6 +2,7 @@
22 #include "avatar.h"
33 #include "spells-status.h"
44 #include "projection.h"
5+#include "spells.h"
56
67 /*!
78 * @brief モンスター回復処理
@@ -185,3 +186,67 @@ bool time_walk(player_type *creature_ptr)
185186 handle_stuff();
186187 return TRUE;
187188 }
189+
190+/*!
191+ * @brief プレイヤーのヒットダイスを振る / Role Hitpoints
192+ * @param options スペル共通オプション
193+ * @return なし
194+ */
195+void roll_hitdice(SPOP_FLAGS options)
196+{
197+ PERCENTAGE percent;
198+
199+ /* Minimum hitpoints at highest level */
200+ HIT_POINT min_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 3 / 8;
201+
202+ /* Maximum hitpoints at highest level */
203+ HIT_POINT max_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 5 / 8;
204+
205+ int i;
206+
207+ /* Rerate */
208+ while (1)
209+ {
210+ /* Pre-calculate level 1 hitdice */
211+ p_ptr->player_hp[0] = (HIT_POINT)p_ptr->hitdie;
212+
213+ for (i = 1; i < 4; i++)
214+ {
215+ p_ptr->player_hp[0] += randint1(p_ptr->hitdie);
216+ }
217+
218+ /* Roll the hitpoint values */
219+ for (i = 1; i < PY_MAX_LEVEL; i++)
220+ {
221+ p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + randint1(p_ptr->hitdie);
222+ }
223+
224+ /* Require "valid" hitpoints at highest level */
225+ if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
226+ (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
227+ }
228+
229+ percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
230+ (2 * p_ptr->hitdie + ((PY_MAX_LEVEL - 1 + 3) * (p_ptr->hitdie + 1))));
231+
232+ /* Update and redraw hitpoints */
233+ p_ptr->update |= (PU_HP);
234+ p_ptr->redraw |= (PR_HP);
235+ p_ptr->window |= (PW_PLAYER);
236+
237+ if (!(options & SPOP_NO_UPDATE)) handle_stuff();
238+
239+ if (options & SPOP_DISPLAY_MES)
240+ {
241+ if (options & SPOP_DEBUG)
242+ {
243+ msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
244+ p_ptr->knowledge |= KNOW_HPRATE;
245+ }
246+ else
247+ {
248+ msg_print(_("体力ランクが変わった。", "Life rate is changed."));
249+ p_ptr->knowledge &= ~(KNOW_HPRATE);
250+ }
251+ }
252+}
--- a/src/spells-status.h
+++ b/src/spells-status.h
@@ -12,4 +12,5 @@ extern bool poly_monster(DIRECTION dir, int power);
1212 extern bool clone_monster(DIRECTION dir);
1313 extern void stop_singing(void);
1414 extern bool time_walk(player_type *creature_ptr);
15+extern void roll_hitdice(SPOP_FLAGS options);
1516
--- a/src/spells2.c
+++ b/src/spells2.c
@@ -4622,7 +4622,7 @@ void cast_shuffle(void)
46224622 else if (die < 111)
46234623 {
46244624 msg_print(_("《審判》だ。", "It's the Judgement."));
4625- do_cmd_rerate(0L);
4625+ roll_hitdice(0L);
46264626 lose_all_mutations();
46274627 }
46284628 else if (die < 120)
--- a/src/wizard2.c
+++ b/src/wizard2.c
@@ -22,71 +22,7 @@
2222 #include "spells.h"
2323 #include "spells-object.h"
2424 #include "spells-summon.h"
25-
26-/*!
27- * @brief プレイヤーのヒットダイスを振り直す / Hack -- Rerate Hitpoints
28- * @param options スペル共通オプション
29- * @return なし
30- */
31-void do_cmd_rerate(SPOP_FLAGS options)
32-{
33- PERCENTAGE percent;
34-
35- /* Minimum hitpoints at highest level */
36- HIT_POINT min_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 3 / 8;
37-
38- /* Maximum hitpoints at highest level */
39- HIT_POINT max_value = p_ptr->hitdie + ((PY_MAX_LEVEL + 2) * (p_ptr->hitdie + 1)) * 5 / 8;
40-
41- int i;
42-
43- /* Rerate */
44- while (1)
45- {
46- /* Pre-calculate level 1 hitdice */
47- p_ptr->player_hp[0] = (HIT_POINT)p_ptr->hitdie;
48-
49- for (i = 1; i < 4; i++)
50- {
51- p_ptr->player_hp[0] += randint1(p_ptr->hitdie);
52- }
53-
54- /* Roll the hitpoint values */
55- for (i = 1; i < PY_MAX_LEVEL; i++)
56- {
57- p_ptr->player_hp[i] = p_ptr->player_hp[i - 1] + randint1(p_ptr->hitdie);
58- }
59-
60- /* Require "valid" hitpoints at highest level */
61- if ((p_ptr->player_hp[PY_MAX_LEVEL - 1] >= min_value) &&
62- (p_ptr->player_hp[PY_MAX_LEVEL - 1] <= max_value)) break;
63- }
64-
65- percent = (int)(((long)p_ptr->player_hp[PY_MAX_LEVEL - 1] * 200L) /
66- (2 * p_ptr->hitdie + ((PY_MAX_LEVEL - 1+3) * (p_ptr->hitdie + 1))));
67-
68- /* Update and redraw hitpoints */
69- p_ptr->update |= (PU_HP);
70- p_ptr->redraw |= (PR_HP);
71- p_ptr->window |= (PW_PLAYER);
72-
73- if(!(options & SPOP_NO_UPDATE)) handle_stuff();
74-
75- if (options & SPOP_DISPLAY_MES)
76- {
77- if (options & SPOP_DEBUG)
78- {
79- msg_format(_("現在の体力ランクは %d/100 です。", "Your life rate is %d/100 now."), percent);
80- p_ptr->knowledge |= KNOW_HPRATE;
81- }
82- else
83- {
84- msg_print(_("体力ランクが変わった。", "Life rate is changed."));
85- p_ptr->knowledge &= ~(KNOW_HPRATE);
86- }
87- }
88-}
89-
25+#include "spells-status.h"
9026
9127 #ifdef ALLOW_WIZARD
9228
@@ -1895,7 +1831,7 @@ void do_cmd_debug(void)
18951831
18961832 /* Hitpoint rerating */
18971833 case 'h':
1898- do_cmd_rerate(SPOP_DISPLAY_MES | SPOP_DEBUG);
1834+ roll_hitdice(SPOP_DISPLAY_MES | SPOP_DEBUG);
18991835 break;
19001836
19011837 case 'H':
Show on old repository browser