From 8e27583a8e0f0b21801ef96b0b3a393bf7d26a4e Mon Sep 17 00:00:00 2001 From: deskull Date: Sat, 24 Aug 2019 18:57:20 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20restore=5Fmana()=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/cmd/cmd-activate.c | 2 +- src/cmd/cmd-quaff.c | 2 +- src/cmd/cmd-usestaff.c | 2 +- src/spells-status.c | 26 +++++++++++++------------- src/spells-status.h | 2 +- src/wizard2.c | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/cmd/cmd-activate.c b/src/cmd/cmd-activate.c index 030b2670a..f5c548fe2 100644 --- a/src/cmd/cmd-activate.c +++ b/src/cmd/cmd-activate.c @@ -1297,7 +1297,7 @@ bool activate_artifact(player_type *user_ptr, object_type *o_ptr) case ACT_CURE_MANA_FULL: { msg_format(_("%sが青白く光った...", "The %s glows pale..."), name); - restore_mana(TRUE); + restore_mana(p_ptr, TRUE); break; } diff --git a/src/cmd/cmd-quaff.c b/src/cmd/cmd-quaff.c index 20904f8e1..58b31d72f 100644 --- a/src/cmd/cmd-quaff.c +++ b/src/cmd/cmd-quaff.c @@ -328,7 +328,7 @@ void exe_quaff_potion(player_type *creature_ptr, INVENTORY_IDX item) break; case SV_POTION_RESTORE_MANA: - ident = restore_mana(TRUE); + ident = restore_mana(creature_ptr, TRUE); break; case SV_POTION_RESTORE_EXP: diff --git a/src/cmd/cmd-usestaff.c b/src/cmd/cmd-usestaff.c index 6c77a41ff..420352e6c 100644 --- a/src/cmd/cmd-usestaff.c +++ b/src/cmd/cmd-usestaff.c @@ -179,7 +179,7 @@ int staff_effect(player_type *creature_ptr, OBJECT_SUBTYPE_VALUE sval, bool *use case SV_STAFF_THE_MAGI: { if (do_res_stat(creature_ptr, A_INT)) ident = TRUE; - ident |= restore_mana(FALSE); + ident |= restore_mana(creature_ptr, FALSE); if (set_shero(creature_ptr, 0, TRUE)) ident = TRUE; break; } diff --git a/src/spells-status.c b/src/spells-status.c index acea9baee..f67ac84df 100644 --- a/src/spells-status.c +++ b/src/spells-status.c @@ -356,36 +356,36 @@ bool_hack true_healing(HIT_POINT pow) return ident; } -bool_hack restore_mana(bool_hack magic_eater) +bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater) { bool_hack ident = FALSE; - if (p_ptr->pclass == CLASS_MAGIC_EATER && magic_eater) + if (creature_ptr->pclass == CLASS_MAGIC_EATER && magic_eater) { int i; for (i = 0; i < EATER_EXT * 2; i++) { - p_ptr->magic_num1[i] += (p_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_CHARGE / 3; - if (p_ptr->magic_num1[i] > p_ptr->magic_num2[i] * EATER_CHARGE) p_ptr->magic_num1[i] = p_ptr->magic_num2[i] * EATER_CHARGE; + creature_ptr->magic_num1[i] += (creature_ptr->magic_num2[i] < 10) ? EATER_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_CHARGE / 3; + if (creature_ptr->magic_num1[i] > creature_ptr->magic_num2[i] * EATER_CHARGE) creature_ptr->magic_num1[i] = creature_ptr->magic_num2[i] * EATER_CHARGE; } for (; i < EATER_EXT * 3; i++) { KIND_OBJECT_IDX k_idx = lookup_kind(TV_ROD, i - EATER_EXT * 2); - p_ptr->magic_num1[i] -= ((p_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : p_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval; - if (p_ptr->magic_num1[i] < 0) p_ptr->magic_num1[i] = 0; + creature_ptr->magic_num1[i] -= ((creature_ptr->magic_num2[i] < 10) ? EATER_ROD_CHARGE * 3 : creature_ptr->magic_num2[i] * EATER_ROD_CHARGE / 3)*k_info[k_idx].pval; + if (creature_ptr->magic_num1[i] < 0) creature_ptr->magic_num1[i] = 0; } msg_print(_("頭がハッキリとした。", "You feel your head clear.")); - p_ptr->window |= (PW_PLAYER); + creature_ptr->window |= (PW_PLAYER); ident = TRUE; } - else if (p_ptr->csp < p_ptr->msp) + else if (creature_ptr->csp < creature_ptr->msp) { - p_ptr->csp = p_ptr->msp; - p_ptr->csp_frac = 0; + creature_ptr->csp = creature_ptr->msp; + creature_ptr->csp_frac = 0; msg_print(_("頭がハッキリとした。", "You feel your head clear.")); - p_ptr->redraw |= (PR_MANA); - p_ptr->window |= (PW_PLAYER); - p_ptr->window |= (PW_SPELL); + creature_ptr->redraw |= (PR_MANA); + creature_ptr->window |= (PW_PLAYER); + creature_ptr->window |= (PW_SPELL); ident = TRUE; } diff --git a/src/spells-status.h b/src/spells-status.h index 3b4894262..9e4e11154 100644 --- a/src/spells-status.h +++ b/src/spells-status.h @@ -20,7 +20,7 @@ extern bool_hack cure_light_wounds(DICE_NUMBER dice, DICE_SID sides); extern bool_hack cure_serious_wounds(DICE_NUMBER dice, DICE_SID sides); extern bool_hack cure_critical_wounds(HIT_POINT pow); extern bool_hack true_healing(HIT_POINT pow); -extern bool_hack restore_mana(bool_hack magic_eater); +extern bool_hack restore_mana(player_type *creature_ptr, bool_hack magic_eater); extern bool restore_all_status(void); extern bool fishing(player_type *creature_ptr); diff --git a/src/wizard2.c b/src/wizard2.c index a0d3ac2e1..6f61a2650 100644 --- a/src/wizard2.c +++ b/src/wizard2.c @@ -1293,7 +1293,7 @@ static void wiz_create_item(void) static void do_cmd_wiz_cure_all(void) { (void)life_stream(p_ptr, FALSE, FALSE); - (void)restore_mana(TRUE); + (void)restore_mana(p_ptr, TRUE); (void)set_food(p_ptr, PY_FOOD_MAX - 1); } -- 2.11.0