summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/delay.cc19
-rw-r--r--crawl-ref/source/delay.h1
-rw-r--r--crawl-ref/source/spl-book.cc9
-rw-r--r--crawl-ref/source/tilereg.cc3
4 files changed, 29 insertions, 3 deletions
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index 9244f4e5da..c8a73876fb 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -301,6 +301,9 @@ void start_delay( delay_type type, int turns, int parm1, int parm2 )
ASSERT(!crawl_state.arena);
ASSERT(!crawl_state.is_repeating_cmd() || type == DELAY_MACRO);
+ if (type == DELAY_MEMORISE && already_learning_spell(parm1))
+ return;
+
_interrupts_blocked = 0; // Just to be safe
delay_queue_item delay;
@@ -701,6 +704,22 @@ bool player_stair_delay()
|| delay.type == DELAY_DESCENDING_STAIRS);
}
+bool already_learning_spell(int spell)
+{
+ if (!you_are_delayed())
+ return (false);
+
+ for (unsigned int i = 0; i < you.delay_queue.size(); ++i)
+ {
+ if (you.delay_queue[i].type != DELAY_MEMORISE)
+ continue;
+
+ if (you.delay_queue[i].parm1 == spell)
+ return (true);
+ }
+ return (false);
+}
+
// Check whether there are monsters who might be influenced by Recite.
// Returns 0, if no monsters found
// Returns 1, if eligible audience found
diff --git a/crawl-ref/source/delay.h b/crawl-ref/source/delay.h
index 03749a14fb..6d6d53d8db 100644
--- a/crawl-ref/source/delay.h
+++ b/crawl-ref/source/delay.h
@@ -78,6 +78,7 @@ bool is_run_delay(int delay);
bool is_being_butchered(const item_def &item, bool just_first = true);
bool is_vampire_feeding();
bool player_stair_delay();
+bool already_learning_spell(int spell);
void stop_butcher_delay();
void maybe_clear_weapon_swap();
void handle_interrupted_swap(bool swap_if_safe = false,
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index e204e24dfd..123ff8debe 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1707,6 +1707,9 @@ static bool _learn_spell_checks(spell_type specspell)
if (!can_learn_spell())
return (false);
+ if (already_learning_spell((int) specspell))
+ return (false);
+
if (you_cannot_memorise(specspell))
{
mprf("You cannot memorise that spell because you are a %s.",
@@ -1767,6 +1770,8 @@ bool learn_spell(spell_type specspell, int book, bool is_safest_book)
"attempt fails. Attempt to memorise anyway?",
fakebook.name(DESC_NOCAP_THE).c_str());
+ // Deactivate choice from tile inventory.
+ mouse_control mc(MOUSE_MODE_MORE);
if (!yesno(prompt.c_str(), false, 'n'))
{
canned_msg( MSG_OK );
@@ -1797,6 +1802,8 @@ bool learn_spell(spell_type specspell, int book, bool is_safest_book)
spell_levels_required(specspell) > 1 ? "s" : "",
player_spell_levels() - spell_levels_required(specspell));
+ // Deactivate choice from tile inventory.
+ mouse_control mc(MOUSE_MODE_MORE);
if (!yesno(info, true, 'n', false))
{
canned_msg( MSG_OK );
@@ -1854,7 +1861,7 @@ bool learn_spell(spell_type specspell, int book, bool is_safest_book)
did_god_conduct( DID_SPELL_CASTING, 2 + random2(5) );
return (true);
-} // end which_spell()
+}
int count_staff_spells(const item_def &item, bool need_id)
{
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index b5892abc37..85711f10c4 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1864,8 +1864,7 @@ int InventoryRegion::handle_spells_mouse(MouseEvent &event, int item_idx)
tiles.set_need_redraw();
if (!learn_spell(spell, m_items[item_idx].special))
flush_input_buffer( FLUSH_ON_FAILURE );
-
-// if (!can_learn_spell(true) || !has_spells_to_memorise())
+ else if (!can_learn_spell(true) || !has_spells_to_memorise())
{
// Jump back to spells list. (Really, this should only happen
// if there aren't any other spells to memorise, but this