OSDN Git Service

[Refactor] #38997 exe_spell() に player_type * 引数を追加. / Add player_type * argument...
authordeskull <deskull@users.sourceforge.jp>
Sun, 25 Aug 2019 12:48:03 +0000 (21:48 +0900)
committerdeskull <deskull@users.sourceforge.jp>
Sun, 25 Aug 2019 12:48:03 +0000 (21:48 +0900)
src/cmd/cmd-dump.c
src/cmd/cmd-hissatsu.c
src/cmd/cmd-spell.c
src/cmd/cmd-spell.h
src/core.c
src/player-status.c
src/realm-hex.c
src/spells-status.c
src/spells3.c

index bb51bc7..983c9a6 100644 (file)
@@ -4507,7 +4507,7 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
                        if (s_ptr->slevel >= 99) continue;
                        spell_exp = creature_ptr->spell_exp[i];
                        exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", exe_spell(creature_ptr->realm1, i, SPELL_NAME));
+                       fprintf(fff, "%-25s ", exe_spell(p_ptr, creature_ptr->realm1, i, SPELL_NAME));
                        if (creature_ptr->realm1 == REALM_HISSATSU)
                                fprintf(fff, "[--]");
                        else
@@ -4538,7 +4538,7 @@ static void do_cmd_knowledge_spell_exp(player_type *creature_ptr)
 
                        spell_exp = creature_ptr->spell_exp[i + 32];
                        exp_level = spell_exp_level(spell_exp);
-                       fprintf(fff, "%-25s ", exe_spell(creature_ptr->realm2, i, SPELL_NAME));
+                       fprintf(fff, "%-25s ", exe_spell(p_ptr, creature_ptr->realm2, i, SPELL_NAME));
                        if (exp_level >= EXP_LEVEL_EXPERT) fprintf(fff, "!");
                        else fprintf(fff, " ");
                        fprintf(fff, "%s", exp_level_str[exp_level]);
index c987718..03dec31 100644 (file)
@@ -225,7 +225,7 @@ static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
 
                                        /* Dump the spell --(-- */
                                        strcat(psi_desc, format(" %-18s%2d %3d",
-                                               exe_spell(REALM_HISSATSU, i, SPELL_NAME),
+                                               exe_spell(p_ptr, REALM_HISSATSU, i, SPELL_NAME),
                                                spell.slevel, spell.smana));
                                        prt(psi_desc, y + (line%17) + (line >= 17), x+(line/17)*30);
                                        prt("", y + (line%17) + (line >= 17) + 1, x+(line/17)*30);
@@ -280,7 +280,7 @@ static int get_hissatsu_power(player_type *creature_ptr, SPELL_IDX *sn)
                        char tmp_val[160];
 
                        /* Prompt */
-                       (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(REALM_HISSATSU, j, SPELL_NAME));
+                       (void) strnfmt(tmp_val, 78, _("%sを使いますか?", "Use %s? "), exe_spell(p_ptr, REALM_HISSATSU, j, SPELL_NAME));
 
                        /* Belay that order */
                        if (!get_check(tmp_val)) continue;
@@ -350,7 +350,7 @@ void do_cmd_hissatsu(player_type *creature_ptr)
 
        sound(SOUND_ZAP);
 
-       if (!exe_spell(REALM_HISSATSU, n, SPELL_CAST)) return;
+       if (!exe_spell(p_ptr, REALM_HISSATSU, n, SPELL_CAST)) return;
 
        take_turn(creature_ptr, 100);
 
@@ -411,7 +411,7 @@ void do_cmd_gain_hissatsu(player_type *creature_ptr)
 
                creature_ptr->spell_learned1 |= (1L << i);
                creature_ptr->spell_worked1 |= (1L << i);
-               msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(REALM_HISSATSU, i, SPELL_NAME));
+               msg_format(_("%sの技を覚えた。", "You have learned the special attack of %s."), exe_spell(p_ptr, REALM_HISSATSU, i, SPELL_NAME));
                for (j = 0; j < 64; j++)
                {
                        /* Stop at the first empty space */
index ca95c0d..c8b3dea 100644 (file)
@@ -273,23 +273,23 @@ static bool spell_okay(int spell, bool learned, bool study_pray, int use_realm)
  * @param mode 求める処理
  * @return 各領域魔法に各種テキストを求めた場合は文字列参照ポインタ、そうでない場合はNULLポインタを返す。
  */
-concptr exe_spell(REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode)
+concptr exe_spell(player_type *caster_ptr, REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode)
 {
        switch (realm)
        {
-       case REALM_LIFE:     return do_life_spell(p_ptr, spell, mode);
-       case REALM_SORCERY:  return do_sorcery_spell(p_ptr, spell, mode);
-       case REALM_NATURE:   return do_nature_spell(p_ptr, spell, mode);
-       case REALM_CHAOS:    return do_chaos_spell(p_ptr, spell, mode);
-       case REALM_DEATH:    return do_death_spell(p_ptr, spell, mode);
-       case REALM_TRUMP:    return do_trump_spell(p_ptr, spell, mode);
-       case REALM_ARCANE:   return do_arcane_spell(p_ptr, spell, mode);
-       case REALM_CRAFT:    return do_craft_spell(p_ptr, spell, mode);
-       case REALM_DAEMON:   return do_daemon_spell(p_ptr, spell, mode);
-       case REALM_CRUSADE:  return do_crusade_spell(p_ptr, spell, mode);
-       case REALM_MUSIC:    return do_music_spell(p_ptr, spell, mode);
-       case REALM_HISSATSU: return do_hissatsu_spell(p_ptr, spell, mode);
-       case REALM_HEX:      return do_hex_spell(p_ptr, spell, mode);
+       case REALM_LIFE:     return do_life_spell(caster_ptr, spell, mode);
+       case REALM_SORCERY:  return do_sorcery_spell(caster_ptr, spell, mode);
+       case REALM_NATURE:   return do_nature_spell(caster_ptr, spell, mode);
+       case REALM_CHAOS:    return do_chaos_spell(caster_ptr, spell, mode);
+       case REALM_DEATH:    return do_death_spell(caster_ptr, spell, mode);
+       case REALM_TRUMP:    return do_trump_spell(caster_ptr, spell, mode);
+       case REALM_ARCANE:   return do_arcane_spell(caster_ptr, spell, mode);
+       case REALM_CRAFT:    return do_craft_spell(caster_ptr, spell, mode);
+       case REALM_DAEMON:   return do_daemon_spell(caster_ptr, spell, mode);
+       case REALM_CRUSADE:  return do_crusade_spell(caster_ptr, spell, mode);
+       case REALM_MUSIC:    return do_music_spell(caster_ptr, spell, mode);
+       case REALM_HISSATSU: return do_hissatsu_spell(caster_ptr, spell, mode);
+       case REALM_HEX:      return do_hex_spell(caster_ptr, spell, mode);
        }
 
        return NULL;
@@ -535,11 +535,11 @@ static int get_spell(SPELL_IDX *sn, concptr prompt, OBJECT_SUBTYPE_VALUE sval, b
                        jverb(prompt, jverb_buf, JVERB_AND);
                        /* 英日切り替え機能に対応 */
                        (void)strnfmt(tmp_val, 78, "%s(MP%d, 失敗率%d%%)を%sますか? ",
-                               exe_spell(use_realm, spell, SPELL_NAME), need_mana,
+                               exe_spell(p_ptr, use_realm, spell, SPELL_NAME), need_mana,
                                spell_chance(spell, use_realm), jverb_buf);
 #else
                        (void)strnfmt(tmp_val, 78, "%^s %s (%d mana, %d%% fail)? ",
-                               prompt, exe_spell(use_realm, spell, SPELL_NAME), need_mana,
+                               prompt, exe_spell(p_ptr, use_realm, spell, SPELL_NAME), need_mana,
                                spell_chance(spell, use_realm));
 #endif
 
@@ -732,7 +732,7 @@ void do_cmd_browse(void)
                Term_erase(14, 12, 255);
                Term_erase(14, 11, 255);
 
-               roff_to_buf(exe_spell(use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
+               roff_to_buf(exe_spell(p_ptr, use_realm, spell, SPELL_DESC), 62, temp, sizeof(temp));
 
                for (j = 0, line = 11; temp[j]; j += 1 + strlen(&temp[j]))
                {
@@ -925,7 +925,7 @@ void do_cmd_study(void)
                int max_exp = (spell < 32) ? SPELL_EXP_MASTER : SPELL_EXP_EXPERT;
                int old_exp = p_ptr->spell_exp[spell];
                int new_rank = EXP_LEVEL_UNSKILLED;
-               concptr name = exe_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME);
+               concptr name = exe_spell(p_ptr, increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME);
 
                if (old_exp >= max_exp)
                {
@@ -981,16 +981,16 @@ void do_cmd_study(void)
                if (mp_ptr->spell_book == TV_MUSIC_BOOK)
                {
                        msg_format("%sを学んだ。",
-                               exe_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
+                               exe_spell(p_ptr, increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
                }
                else
                {
                        msg_format("%sの%sを学んだ。",
-                               exe_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME), p);
+                               exe_spell(p_ptr, increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME), p);
                }
 #else
                msg_format("You have learned the %s of %s.",
-                       p, exe_spell(increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
+                       p, exe_spell(p_ptr, increment ? p_ptr->realm2 : p_ptr->realm1, spell % 32, SPELL_NAME));
 #endif
        }
 
@@ -1227,7 +1227,7 @@ void do_cmd_cast(void)
                }
 
                /* Failure casting may activate some side effect */
-               exe_spell(realm, spell, SPELL_FAIL);
+               exe_spell(p_ptr, realm, spell, SPELL_FAIL);
 
 
                if ((o_ptr->tval == TV_CHAOS_BOOK) && (randint1(100) < spell))
@@ -1263,7 +1263,7 @@ void do_cmd_cast(void)
        else
        {
                /* Canceled spells cost neither a current_world_ptr->game_turn nor mana */
-               if (!exe_spell(realm, spell, SPELL_CAST)) return;
+               if (!exe_spell(p_ptr, realm, spell, SPELL_CAST)) return;
 
                if (randint1(100) < chance)
                        chg_virtue(p_ptr, V_CHANCE, 1);
index d1b3f4f..e10617e 100644 (file)
@@ -17,7 +17,7 @@ extern const u32b fake_spell_flags[4];
 #define SPELL_FAIL   4
 #define SPELL_STOP   5
 #define SPELL_CONT   6
-extern concptr exe_spell(REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode);
+extern concptr exe_spell(player_type *caster_ptr, REALM_IDX realm, SPELL_IDX spell, BIT_FLAGS mode);
 
 extern concptr info_string_dice(concptr str, DICE_NUMBER dice, DICE_SID sides, int base);
 extern concptr info_damage(DICE_NUMBER dice, DICE_SID sides, int base);
index 38fbf04..5cb5147 100644 (file)
@@ -1188,7 +1188,7 @@ static void check_music(void)
        { if (one_in_(5) && ((current_floor_ptr->dun_level + 5) > p_ptr->lev) && (current_floor_ptr->dun_level > s_ptr->slevel)) p_ptr->spell_exp[spell] += 1; }
 
        /* Do any effects of continual song */
-       exe_spell(REALM_MUSIC, spell, SPELL_CONT);
+       exe_spell(p_ptr, REALM_MUSIC, spell, SPELL_CONT);
 }
 
 /*!
index 7c8be3a..2e32daf 100644 (file)
@@ -4310,9 +4310,9 @@ static void calc_spells(player_type *creature_ptr)
                        }
 
 #ifdef JP
-                       msg_format("%sの%sを忘れてしまった。", exe_spell(which, j % 32, SPELL_NAME), p);
+                       msg_format("%sの%sを忘れてしまった。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have forgotten the %s of %s.", p, exe_spell(which, j % 32, SPELL_NAME));
+                       msg_format("You have forgotten the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
 #endif
 
 
@@ -4367,9 +4367,9 @@ static void calc_spells(player_type *creature_ptr)
                        }
 
 #ifdef JP
-                       msg_format("%sの%sを忘れてしまった。", exe_spell(which, j % 32, SPELL_NAME), p);
+                       msg_format("%sの%sを忘れてしまった。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have forgotten the %s of %s.", p, exe_spell(which, j % 32, SPELL_NAME));
+                       msg_format("You have forgotten the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
 #endif
 
 
@@ -4440,9 +4440,9 @@ static void calc_spells(player_type *creature_ptr)
                        }
 
 #ifdef JP
-                       msg_format("%sの%sを思い出した。", exe_spell(which, j % 32, SPELL_NAME), p);
+                       msg_format("%sの%sを思い出した。", exe_spell(p_ptr, which, j % 32, SPELL_NAME), p);
 #else
-                       msg_format("You have remembered the %s of %s.", p, exe_spell(which, j % 32, SPELL_NAME));
+                       msg_format("You have remembered the %s of %s.", p, exe_spell(p_ptr, which, j % 32, SPELL_NAME));
 #endif
 
 
index f1f5a5c..7a8e2c0 100644 (file)
@@ -50,7 +50,7 @@ bool stop_hex_spell_all(void)
 
        for (i = 0; i < 32; i++)
        {
-               if (hex_spelling(i)) exe_spell(REALM_HEX, i, SPELL_STOP);
+               if (hex_spelling(i)) exe_spell(p_ptr, REALM_HEX, i, SPELL_STOP);
        }
 
        CASTING_HEX_FLAGS(p_ptr) = 0;
@@ -106,7 +106,7 @@ bool stop_hex_spell(void)
                                if (hex_spelling(spell))
                                {
                                        Term_erase(x, y + n + 1, 255);
-                                       put_str(format("%c)  %s", I2A(n), exe_spell(REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
+                                       put_str(format("%c)  %s", I2A(n), exe_spell(p_ptr, REALM_HEX, spell, SPELL_NAME)), y + n + 1, x + 2);
                                        sp[n++] = spell;
                                }
                        }
@@ -130,7 +130,7 @@ bool stop_hex_spell(void)
        {
                int n = sp[A2I(choice)];
 
-               exe_spell(REALM_HEX, n, SPELL_STOP);
+               exe_spell(p_ptr, REALM_HEX, n, SPELL_STOP);
                CASTING_HEX_FLAGS(p_ptr) &= ~(1L << n);
                CASTING_HEX_NUM(p_ptr)--;
        }
@@ -238,7 +238,7 @@ void check_hex(void)
        {
                if (hex_spelling(spell))
                {
-                       exe_spell(REALM_HEX, spell, SPELL_CONT);
+                       exe_spell(p_ptr, REALM_HEX, spell, SPELL_CONT);
                }
        }
 }
@@ -267,8 +267,8 @@ void revenge_spell(void)
 
        switch(HEX_REVENGE_TYPE(p_ptr))
        {
-               case 1: exe_spell(REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
-               case 2: exe_spell(REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
+               case 1: exe_spell(p_ptr, REALM_HEX, HEX_PATIENCE, SPELL_CONT); break;
+               case 2: exe_spell(p_ptr, REALM_HEX, HEX_REVENGE, SPELL_CONT); break;
        }
 }
 
@@ -823,7 +823,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
 
                        if ((!o_ptr->k_idx) || (!object_is_cursed(o_ptr)))
                        {
-                               exe_spell(REALM_HEX, spell, SPELL_STOP);
+                               exe_spell(p_ptr, REALM_HEX, spell, SPELL_STOP);
                                CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << spell);
                                CASTING_HEX_NUM(caster_ptr)--;
                                if (!SINGING_SONG_ID(caster_ptr)) set_action(caster_ptr, ACTION_NONE);
@@ -910,7 +910,7 @@ concptr do_hex_spell(player_type *caster_ptr, SPELL_IDX spell, BIT_FLAGS mode)
 
                        if (!flag)
                        {
-                               msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(REALM_HEX, HEX_RESTORE, SPELL_NAME));
+                               msg_format(_("%sの呪文の詠唱をやめた。", "Finish casting '%^s'."), exe_spell(p_ptr, REALM_HEX, HEX_RESTORE, SPELL_NAME));
                                CASTING_HEX_FLAGS(caster_ptr) &= ~(1L << HEX_RESTORE);
                                if (cont) CASTING_HEX_NUM(caster_ptr)--;
                                if (CASTING_HEX_NUM(caster_ptr)) caster_ptr->action = ACTION_NONE;
index ba7ad88..f38910c 100644 (file)
@@ -173,7 +173,7 @@ void stop_singing(player_type *creature_ptr)
        if (creature_ptr->action == ACTION_SING) set_action(p_ptr, ACTION_NONE);
 
        /* Message text of each song or etc. */
-       exe_spell(REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
+       exe_spell(p_ptr, REALM_MUSIC, SINGING_SONG_ID(creature_ptr), SPELL_STOP);
 
        SINGING_SONG_EFFECT(creature_ptr) = MUSIC_NONE;
        SINGING_SONG_ID(creature_ptr) = 0;
index d9787e5..5e0c880 100644 (file)
@@ -2360,7 +2360,7 @@ void display_spell_list(void)
                                s_ptr = &mp_ptr->info[((j < 1) ? p_ptr->realm1 : p_ptr->realm2) - 1][i % 32];
                        }
 
-                       strcpy(name, exe_spell((j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
+                       strcpy(name, exe_spell(p_ptr, (j < 1) ? p_ptr->realm1 : p_ptr->realm2, i % 32, SPELL_NAME));
 
                        /* Illegible */
                        if (s_ptr->slevel >= 99)
@@ -2725,7 +2725,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(use_realm, spell, SPELL_INFO));
+               strcpy(info, exe_spell(p_ptr, use_realm, spell, SPELL_INFO));
 
                /* Use that info */
                comment = info;
@@ -2778,13 +2778,13 @@ 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(use_realm, spell, SPELL_NAME), /* realm, spell */
+                           exe_spell(p_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(use_realm, spell, SPELL_NAME), /* realm, spell */
+                           exe_spell(p_ptr, use_realm, spell, SPELL_NAME), /* realm, spell */
                            (max ? '!' : ' '), ryakuji,
                            s_ptr->slevel, need_mana, spell_chance(spell, use_realm), comment));
                }