From 4e04a0338e4ae8b56fc9eef462c5bcf52422908f Mon Sep 17 00:00:00 2001 From: deskull Date: Sun, 10 Nov 2019 23:59:44 +0900 Subject: [PATCH] =?utf8?q?[Refactor]=20#38997=20print=5Fspells()=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=20/=20Add=20player=5Ftype=20*=20argu?= =?utf8?q?ment=20to=20print=5Fspells().?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- src/cmd/cmd-spell.c | 6 +++--- src/object2.c | 2 +- src/spells.h | 2 +- src/spells3.c | 45 +++++++++++++++++++++++---------------------- 4 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/cmd/cmd-spell.c b/src/cmd/cmd-spell.c index d99e09882..7fc9edcc5 100644 --- a/src/cmd/cmd-spell.c +++ b/src/cmd/cmd-spell.c @@ -439,7 +439,7 @@ static int get_spell(player_type *caster_ptr, SPELL_IDX *sn, concptr prompt, OBJ } if (menu_line > num) menu_line -= num; /* Display a list of spells */ - print_spells(menu_line, spells, num, 1, 15, use_realm); + print_spells(caster_ptr, menu_line, spells, num, 1, 15, use_realm); if (ask) continue; } else @@ -454,7 +454,7 @@ static int get_spell(player_type *caster_ptr, SPELL_IDX *sn, concptr prompt, OBJ screen_save(); /* Display a list of spells */ - print_spells(menu_line, spells, num, 1, 15, use_realm); + print_spells(caster_ptr, menu_line, spells, num, 1, 15, use_realm); } /* Hide the list */ @@ -712,7 +712,7 @@ void do_cmd_browse(player_type *caster_ptr) if (spell == -1) break; /* Display a list of spells */ - print_spells(0, spells, num, 1, 15, use_realm); + print_spells(caster_ptr, 0, spells, num, 1, 15, use_realm); /* Notify that there's nothing to see, and wait. */ if (use_realm == REALM_HISSATSU) diff --git a/src/object2.c b/src/object2.c index d10ab90e0..ac9461394 100644 --- a/src/object2.c +++ b/src/object2.c @@ -5796,7 +5796,7 @@ void display_koff(KIND_OBJECT_IDX k_idx) } /* Print spells */ - print_spells(0, spells, num, 2, 0, use_realm); + print_spells(p_ptr, 0, spells, num, 2, 0, use_realm); } } diff --git a/src/spells.h b/src/spells.h index 5f54cc8c3..8abef3b8b 100644 --- a/src/spells.h +++ b/src/spells.h @@ -315,7 +315,7 @@ extern MANA_POINT mod_need_mana(MANA_POINT need_mana, SPELL_IDX spell, REALM_IDX extern PERCENTAGE mod_spell_chance_1(PERCENTAGE chance); extern PERCENTAGE mod_spell_chance_2(PERCENTAGE chance); extern PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX realm); -extern void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX realm); +extern void print_spells(player_type* caster_ptr, SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX realm); extern bool polymorph_monster(player_type *caster_ptr, POSITION y, POSITION x); extern bool dimension_door(void); extern bool mirror_tunnel(void); diff --git a/src/spells3.c b/src/spells3.c index e135d9704..06cbba50c 100644 --- a/src/spells3.c +++ b/src/spells3.c @@ -2631,6 +2631,7 @@ PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_ * @brief 呪文情報の表示処理 / * Print a list of spells (for browsing or casting or viewing) * @param target_spell 呪文ID + * @param caster_ptr 術者の参照ポインタ * @param spells 表示するスペルID配列の参照ポインタ * @param num 表示するスペルの数(spellsの要素数) * @param y 表示メッセージ左上Y座標 @@ -2638,7 +2639,7 @@ PERCENTAGE spell_chance(player_type *caster_ptr, SPELL_IDX spell, REALM_IDX use_ * @param use_realm 魔法領域ID * @return なし */ -void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm) +void print_spells(player_type* caster_ptr, SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y, TERM_LEN x, REALM_IDX use_realm) { int i; SPELL_IDX spell; @@ -2666,9 +2667,9 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y put_str(_("名前", "Name"), y, x + 5); put_str(buf, y, x + 29); - if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) increment = 0; - else if (use_realm == p_ptr->realm1) increment = 0; - else if (use_realm == p_ptr->realm2) increment = 32; + if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE)) increment = 0; + else if (use_realm == caster_ptr->realm1) increment = 0; + else if (use_realm == caster_ptr->realm2) increment = 32; /* Dump the spells */ for (i = 0; i < num; i++) @@ -2700,7 +2701,7 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y if (!increment && (exp_level == EXP_LEVEL_MASTER)) max = TRUE; else if ((increment == 32) && (exp_level >= EXP_LEVEL_EXPERT)) max = TRUE; else if (s_ptr->slevel >= 99) max = TRUE; - else if ((p_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE; + else if ((caster_ptr->pclass == CLASS_RED_MAGE) && (exp_level >= EXP_LEVEL_SKILLED)) max = TRUE; strncpy(ryakuji, exp_level_str[exp_level], 4); ryakuji[3] = ']'; @@ -2726,7 +2727,7 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y /* XXX XXX Could label spells above the players level */ /* Get extra info */ - strcpy(info, exe_spell(p_ptr, use_realm, spell, SPELL_INFO)); + strcpy(info, exe_spell(caster_ptr, use_realm, spell, SPELL_INFO)); /* Use that info */ comment = info; @@ -2735,41 +2736,41 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y line_attr = TERM_WHITE; /* Analyze the spell */ - if ((p_ptr->pclass == CLASS_SORCERER) || (p_ptr->pclass == CLASS_RED_MAGE)) + if ((caster_ptr->pclass == CLASS_SORCERER) || (caster_ptr->pclass == CLASS_RED_MAGE)) { - if (s_ptr->slevel > p_ptr->max_plv) + if (s_ptr->slevel > caster_ptr->max_plv) { comment = _("未知", "unknown"); line_attr = TERM_L_BLUE; } - else if (s_ptr->slevel > p_ptr->lev) + else if (s_ptr->slevel > caster_ptr->lev) { comment = _("忘却", "forgotten"); line_attr = TERM_YELLOW; } } - else if ((use_realm != p_ptr->realm1) && (use_realm != p_ptr->realm2)) + else if ((use_realm != caster_ptr->realm1) && (use_realm != caster_ptr->realm2)) { comment = _("未知", "unknown"); line_attr = TERM_L_BLUE; } - else if ((use_realm == p_ptr->realm1) ? - ((p_ptr->spell_forgotten1 & (1L << spell))) : - ((p_ptr->spell_forgotten2 & (1L << spell)))) + else if ((use_realm == caster_ptr->realm1) ? + ((caster_ptr->spell_forgotten1 & (1L << spell))) : + ((caster_ptr->spell_forgotten2 & (1L << spell)))) { comment = _("忘却", "forgotten"); line_attr = TERM_YELLOW; } - else if (!((use_realm == p_ptr->realm1) ? - (p_ptr->spell_learned1 & (1L << spell)) : - (p_ptr->spell_learned2 & (1L << spell)))) + else if (!((use_realm == caster_ptr->realm1) ? + (caster_ptr->spell_learned1 & (1L << spell)) : + (caster_ptr->spell_learned2 & (1L << spell)))) { comment = _("未知", "unknown"); line_attr = TERM_L_BLUE; } - else if (!((use_realm == p_ptr->realm1) ? - (p_ptr->spell_worked1 & (1L << spell)) : - (p_ptr->spell_worked2 & (1L << spell)))) + else if (!((use_realm == caster_ptr->realm1) ? + (caster_ptr->spell_worked1 & (1L << spell)) : + (caster_ptr->spell_worked2 & (1L << spell)))) { comment = _("未経験", "untried"); line_attr = TERM_L_GREEN; @@ -2779,15 +2780,15 @@ void print_spells(SPELL_IDX target_spell, SPELL_IDX *spells, int num, TERM_LEN y if (use_realm == REALM_HISSATSU) { strcat(out_val, format("%-25s %2d %4d", - exe_spell(p_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */ + exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */ s_ptr->slevel, need_mana)); } else { strcat(out_val, format("%-25s%c%-4s %2d %4d %3d%% %s", - exe_spell(p_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */ + exe_spell(caster_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */ (max ? '!' : ' '), ryakuji, - s_ptr->slevel, need_mana, spell_chance(p_ptr, spell, use_realm), comment)); + s_ptr->slevel, need_mana, spell_chance(caster_ptr, spell, use_realm), comment)); } c_prt(line_attr, out_val, y + i + 1, x); } -- 2.11.0