diff options
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 71 |
1 files changed, 37 insertions, 34 deletions
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 79a6c369cf..a58e66ff1f 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -661,7 +661,7 @@ static int _get_dist_to_nearest_monster() } // Returns false if spell failed, and true otherwise. -bool cast_a_spell(bool check_range) +bool cast_a_spell(bool check_range, spell_type spell) { if (!you.spell_no) { @@ -686,52 +686,55 @@ bool cast_a_spell(bool check_range) const int minRange = _get_dist_to_nearest_monster(); - int keyin = 0; - - while (true) + if (spell == SPELL_NO_SPELL) { - if (keyin == 0) + int keyin = 0; + + while (true) { - mpr("Cast which spell? (? or * to list) ", MSGCH_PROMPT); + if (keyin == 0) + { + mpr("Cast which spell? (? or * to list) ", MSGCH_PROMPT); - keyin = get_ch(); - } + keyin = get_ch(); + } - if (keyin == '?' || keyin == '*') - { - keyin = list_spells(true, false, minRange); - if (!keyin) - keyin = ESCAPE; + if (keyin == '?' || keyin == '*') + { + keyin = list_spells(true, false, minRange); + if (!keyin) + keyin = ESCAPE; - if (!crawl_state.doing_prev_cmd_again) - redraw_screen(); + if (!crawl_state.doing_prev_cmd_again) + redraw_screen(); - if (isalpha(keyin) || keyin == ESCAPE) - break; + if (isalpha(keyin) || keyin == ESCAPE) + break; + else + mesclr(); + + keyin = 0; + } else - mesclr(); + break; + } - keyin = 0; + if (keyin == ESCAPE) + { + canned_msg( MSG_OK ); + return (false); } - else - break; - } - if (keyin == ESCAPE) - { - canned_msg( MSG_OK ); - return (false); - } + if (!isalpha(keyin)) + { + mpr("You don't know that spell."); + crawl_state.zero_turns_taken(); + return (false); + } - if (!isalpha(keyin)) - { - mpr("You don't know that spell."); - crawl_state.zero_turns_taken(); - return (false); + spell = get_spell_by_letter( keyin ); } - const spell_type spell = get_spell_by_letter( keyin ); - if (spell == SPELL_NO_SPELL) { mpr("You don't know that spell."); |