From 3f40ffc6ae0d47299c917d660a40ae46bc6fa007 Mon Sep 17 00:00:00 2001 From: deskull Date: Fri, 12 Jul 2019 00:06:45 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20check=5Fexperience()=20?= =?utf8?q?=E3=81=AB=20player=5Ftype=20*=20=E5=BC=95=E6=95=B0=E3=82=92?= =?utf8?q?=E8=BF=BD=E5=8A=A0=EF=BC=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/core.c | 2 +- src/player-effects.c | 10 +++--- src/player-status.c | 100 +++++++++++++++++++++++++-------------------------- src/player-status.h | 2 +- src/realm-hex.c | 2 +- src/spells2.c | 2 +- src/wizard2.c | 2 +- 7 files changed, 60 insertions(+), 60 deletions(-) diff --git a/src/core.c b/src/core.c index a5b199c7a..3472fbc01 100644 --- a/src/core.c +++ b/src/core.c @@ -2662,7 +2662,7 @@ static void process_world_aux_curse(void) if (p_ptr->exp < 0) p_ptr->exp = 0; p_ptr->max_exp -= (p_ptr->lev + 1) / 2; if (p_ptr->max_exp < 0) p_ptr->max_exp = 0; - check_experience(); + check_experience(p_ptr); } /* Add light curse (Later) */ if ((p_ptr->cursed & TRC_ADD_L_CURSE) && one_in_(2000)) diff --git a/src/player-effects.c b/src/player-effects.c index eaecde146..5e38749cb 100644 --- a/src/player-effects.c +++ b/src/player-effects.c @@ -3625,7 +3625,7 @@ bool restore_level(player_type *creature_ptr) creature_ptr->exp = creature_ptr->max_exp; /* Check the experience */ - check_experience(); + check_experience(p_ptr); /* Did something */ return (TRUE); @@ -3753,7 +3753,7 @@ void change_race(player_type *creature_ptr, CHARACTER_IDX new_race, concptr effe roll_hitdice(creature_ptr, 0L); /* The experience level may be modified */ - check_experience(); + check_experience(p_ptr); creature_ptr->redraw |= (PR_BASIC); @@ -3922,7 +3922,7 @@ void gain_exp_64(player_type *creature_ptr, s32b amount, u32b amount_frac) creature_ptr->max_exp += amount / 5; } - check_experience(); + check_experience(p_ptr); } @@ -4024,7 +4024,7 @@ void calc_android_exp(player_type *creature_ptr) if (i == INVEN_BODY) total_exp += exp / 32; } creature_ptr->exp = creature_ptr->max_exp = total_exp; - check_experience(); + check_experience(p_ptr); } @@ -4038,7 +4038,7 @@ void lose_exp(player_type *creature_ptr, s32b amount) creature_ptr->exp -= amount; - check_experience(); + check_experience(p_ptr); } diff --git a/src/player-status.c b/src/player-status.c index 11b9e4037..7f01681cd 100644 --- a/src/player-status.c +++ b/src/player-status.c @@ -5479,91 +5479,91 @@ void sanity_blast(monster_type *m_ptr, bool necro) * Advance experience levels and print experience * @return なし */ -void check_experience(void) +void check_experience(player_type *creature_ptr) { bool level_reward = FALSE; bool level_mutation = FALSE; bool level_inc_stat = FALSE; - bool android = (p_ptr->prace == RACE_ANDROID ? TRUE : FALSE); - PLAYER_LEVEL old_lev = p_ptr->lev; + bool android = (creature_ptr->prace == RACE_ANDROID ? TRUE : FALSE); + PLAYER_LEVEL old_lev = creature_ptr->lev; /* Hack -- lower limit */ - if (p_ptr->exp < 0) p_ptr->exp = 0; - if (p_ptr->max_exp < 0) p_ptr->max_exp = 0; - if (p_ptr->max_max_exp < 0) p_ptr->max_max_exp = 0; + if (creature_ptr->exp < 0) creature_ptr->exp = 0; + if (creature_ptr->max_exp < 0) creature_ptr->max_exp = 0; + if (creature_ptr->max_max_exp < 0) creature_ptr->max_max_exp = 0; /* Hack -- upper limit */ - if (p_ptr->exp > PY_MAX_EXP) p_ptr->exp = PY_MAX_EXP; - if (p_ptr->max_exp > PY_MAX_EXP) p_ptr->max_exp = PY_MAX_EXP; - if (p_ptr->max_max_exp > PY_MAX_EXP) p_ptr->max_max_exp = PY_MAX_EXP; + if (creature_ptr->exp > PY_MAX_EXP) creature_ptr->exp = PY_MAX_EXP; + if (creature_ptr->max_exp > PY_MAX_EXP) creature_ptr->max_exp = PY_MAX_EXP; + if (creature_ptr->max_max_exp > PY_MAX_EXP) creature_ptr->max_max_exp = PY_MAX_EXP; /* Hack -- maintain "max" experience */ - if (p_ptr->exp > p_ptr->max_exp) p_ptr->max_exp = p_ptr->exp; + if (creature_ptr->exp > creature_ptr->max_exp) creature_ptr->max_exp = creature_ptr->exp; /* Hack -- maintain "max max" experience */ - if (p_ptr->max_exp > p_ptr->max_max_exp) p_ptr->max_max_exp = p_ptr->max_exp; + if (creature_ptr->max_exp > creature_ptr->max_max_exp) creature_ptr->max_max_exp = creature_ptr->max_exp; /* Redraw experience */ - p_ptr->redraw |= (PR_EXP); + creature_ptr->redraw |= (PR_EXP); handle_stuff(); /* Lose levels while possible */ - while ((p_ptr->lev > 1) && - (p_ptr->exp < ((android ? player_exp_a : player_exp)[p_ptr->lev - 2] * p_ptr->expfact / 100L))) + while ((creature_ptr->lev > 1) && + (creature_ptr->exp < ((android ? player_exp_a : player_exp)[creature_ptr->lev - 2] * creature_ptr->expfact / 100L))) { /* Lose a level */ - p_ptr->lev--; - p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); - p_ptr->redraw |= (PR_LEV | PR_TITLE); - p_ptr->window |= (PW_PLAYER); + creature_ptr->lev--; + creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); + creature_ptr->redraw |= (PR_LEV | PR_TITLE); + creature_ptr->window |= (PW_PLAYER); handle_stuff(); } /* Gain levels while possible */ - while ((p_ptr->lev < PY_MAX_LEVEL) && - (p_ptr->exp >= ((android ? player_exp_a : player_exp)[p_ptr->lev - 1] * p_ptr->expfact / 100L))) + while ((creature_ptr->lev < PY_MAX_LEVEL) && + (creature_ptr->exp >= ((android ? player_exp_a : player_exp)[creature_ptr->lev - 1] * creature_ptr->expfact / 100L))) { /* Gain a level */ - p_ptr->lev++; + creature_ptr->lev++; /* Save the highest level */ - if (p_ptr->lev > p_ptr->max_plv) + if (creature_ptr->lev > creature_ptr->max_plv) { - p_ptr->max_plv = p_ptr->lev; + creature_ptr->max_plv = creature_ptr->lev; - if ((p_ptr->pclass == CLASS_CHAOS_WARRIOR) || - (p_ptr->muta2 & MUT2_CHAOS_GIFT)) + if ((creature_ptr->pclass == CLASS_CHAOS_WARRIOR) || + (creature_ptr->muta2 & MUT2_CHAOS_GIFT)) { level_reward = TRUE; } - if (p_ptr->prace == RACE_BEASTMAN) + if (creature_ptr->prace == RACE_BEASTMAN) { if (one_in_(5)) level_mutation = TRUE; } level_inc_stat = TRUE; - do_cmd_write_nikki(NIKKI_LEVELUP, p_ptr->lev, NULL); + do_cmd_write_nikki(NIKKI_LEVELUP, creature_ptr->lev, NULL); } sound(SOUND_LEVEL); - msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), p_ptr->lev); + msg_format(_("レベル %d にようこそ。", "Welcome to level %d."), creature_ptr->lev); - p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); - p_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP); - p_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN); + creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); + creature_ptr->redraw |= (PR_LEV | PR_TITLE | PR_EXP); + creature_ptr->window |= (PW_PLAYER | PW_SPELL | PW_INVEN); /* HPとMPの上昇量を表示 */ - p_ptr->level_up_message = TRUE; + creature_ptr->level_up_message = TRUE; handle_stuff(); - p_ptr->level_up_message = FALSE; + creature_ptr->level_up_message = FALSE; if (level_inc_stat) { - if (!(p_ptr->max_plv % 10)) + if (!(creature_ptr->max_plv % 10)) { int choice; screen_save(); @@ -5572,17 +5572,17 @@ void check_experience(void) int n; char tmp[32]; - cnv_stat(p_ptr->stat_max[0], tmp); + cnv_stat(creature_ptr->stat_max[0], tmp); prt(format(_(" a) 腕力 (現在値 %s)", " a) Str (cur %s)"), tmp), 2, 14); - cnv_stat(p_ptr->stat_max[1], tmp); + cnv_stat(creature_ptr->stat_max[1], tmp); prt(format(_(" b) 知能 (現在値 %s)", " a) Int (cur %s)"), tmp), 3, 14); - cnv_stat(p_ptr->stat_max[2], tmp); + cnv_stat(creature_ptr->stat_max[2], tmp); prt(format(_(" c) 賢さ (現在値 %s)", " a) Wis (cur %s)"), tmp), 4, 14); - cnv_stat(p_ptr->stat_max[3], tmp); + cnv_stat(creature_ptr->stat_max[3], tmp); prt(format(_(" d) 器用 (現在値 %s)", " a) Dex (cur %s)"), tmp), 5, 14); - cnv_stat(p_ptr->stat_max[4], tmp); + cnv_stat(creature_ptr->stat_max[4], tmp); prt(format(_(" e) 耐久 (現在値 %s)", " a) Con (cur %s)"), tmp), 6, 14); - cnv_stat(p_ptr->stat_max[5], tmp); + cnv_stat(creature_ptr->stat_max[5], tmp); prt(format(_(" f) 魅力 (現在値 %s)", " a) Chr (cur %s)"), tmp), 7, 14); prt("", 8, 14); @@ -5598,38 +5598,38 @@ void check_experience(void) prt("", n + 2, 14); if (get_check(_("よろしいですか?", "Are you sure? "))) break; } - do_inc_stat(p_ptr, choice - 'a'); + do_inc_stat(creature_ptr, choice - 'a'); screen_load(); } - else if (!(p_ptr->max_plv % 2)) - do_inc_stat(p_ptr, randint0(6)); + else if (!(creature_ptr->max_plv % 2)) + do_inc_stat(creature_ptr, randint0(6)); } if (level_mutation) { msg_print(_("あなたは変わった気がする...", "You feel different...")); - (void)gain_mutation(p_ptr, 0); + (void)gain_mutation(creature_ptr, 0); level_mutation = FALSE; } /* - * 報酬でレベルが上ると再帰的に check_experience() が + * 報酬でレベルが上ると再帰的に check_experience(creature_ptr) が * 呼ばれるので順番を最後にする。 */ if (level_reward) { - gain_level_reward(p_ptr, 0); + gain_level_reward(creature_ptr, 0); level_reward = FALSE; } - p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); - p_ptr->redraw |= (PR_LEV | PR_TITLE); - p_ptr->window |= (PW_PLAYER | PW_SPELL); + creature_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS); + creature_ptr->redraw |= (PR_LEV | PR_TITLE); + creature_ptr->window |= (PW_PLAYER | PW_SPELL); handle_stuff(); } /* Load an autopick preference file */ - if (old_lev != p_ptr->lev) autopick_load_pref(FALSE); + if (old_lev != creature_ptr->lev) autopick_load_pref(FALSE); } /*! diff --git a/src/player-status.h b/src/player-status.h index 5d147cab3..73557306d 100644 --- a/src/player-status.h +++ b/src/player-status.h @@ -747,7 +747,7 @@ extern void free_turn(player_type *creature_ptr); extern bool player_place(player_type *creature_ptr, POSITION y, POSITION x); extern void sanity_blast(monster_type *m_ptr, bool necro); -extern void check_experience(void); +extern void check_experience(player_type *creature_ptr); extern void wreck_the_pattern(player_type *creature_ptr); extern void cnv_stat(int val, char *out_val); extern s16b modify_stat_value(int value, int amount); diff --git a/src/realm-hex.c b/src/realm-hex.c index b240dfa45..3833298a7 100644 --- a/src/realm-hex.c +++ b/src/realm-hex.c @@ -885,7 +885,7 @@ concptr do_hex_spell(SPELL_IDX spell, BIT_FLAGS mode) p_ptr->exp += r; /* Check the experience */ - check_experience(); + check_experience(p_ptr); flag = TRUE; } diff --git a/src/spells2.c b/src/spells2.c index d6039ee1a..786277d4a 100644 --- a/src/spells2.c +++ b/src/spells2.c @@ -3153,7 +3153,7 @@ void ring_of_power(DIRECTION dir) /* Lose some experience (permanently) */ p_ptr->exp -= (p_ptr->exp / 4); p_ptr->max_exp -= (p_ptr->exp / 4); - check_experience(); + check_experience(p_ptr); break; } diff --git a/src/wizard2.c b/src/wizard2.c index 2d97a92d6..dcb4596df 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -387,7 +387,7 @@ static void do_cmd_wiz_change_aux(void) p_ptr->exp = tmp_long; /* Update */ - check_experience(); + check_experience(p_ptr); } } -- 2.11.0