summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-14 20:23:08 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2009-09-14 20:23:08 +0000
commit94530c7cbe5031fa9e512a0f9ae41dac41821559 (patch)
treef8948a643e7694290e1f152913a2d0d57dd38567 /crawl-ref
parent33bfc8a3d44515f59a0f2ad840ac03fe55606bab (diff)
downloadcrawl-ref-94530c7cbe5031fa9e512a0f9ae41dac41821559.tar.gz
crawl-ref-94530c7cbe5031fa9e512a0f9ae41dac41821559.zip
Jump from the memorisation display back to spells if you cannot memorise
any further spells. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10677 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/spl-book.cc17
-rw-r--r--crawl-ref/source/spl-book.h3
-rw-r--r--crawl-ref/source/tilereg.cc5
3 files changed, 17 insertions, 8 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 123ff8debe..ecb318b264 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1301,7 +1301,8 @@ static bool _get_mem_list(spell_list &mem_spells,
spells_to_books &book_hash,
unsigned int &num_unreadable,
unsigned int &num_race,
- bool just_check = false)
+ bool just_check = false,
+ spell_type current_spell = SPELL_NO_SPELL)
{
bool book_errors = false;
unsigned int num_books = 0;
@@ -1396,7 +1397,7 @@ static bool _get_mem_list(spell_list &mem_spells,
{
const spell_type spell = i->first;
- if (player_knows_spell(spell))
+ if (spell == current_spell || player_knows_spell(spell))
num_known++;
else if (you_cannot_memorise(spell))
num_race++;
@@ -1404,9 +1405,13 @@ static bool _get_mem_list(spell_list &mem_spells,
{
mem_spells.push_back(spell);
+ int avail_slots = player_spell_levels();
+ if (current_spell != SPELL_NO_SPELL)
+ avail_slots -= spell_levels_required(current_spell);
+
if (spell_difficulty(spell) > you.experience_level)
num_low_xl++;
- else if (player_spell_levels() < spell_levels_required(spell))
+ else if (avail_slots < spell_levels_required(spell))
num_low_levels++;
else
{
@@ -1475,7 +1480,9 @@ static bool _get_mem_list(spell_list &mem_spells,
return (false);
}
-bool has_spells_to_memorise(bool silent)
+// If current_spell is a valid spell, returns whether you'll be able to
+// memorise any further spells once this one is committed to memory.
+bool has_spells_to_memorise(bool silent, int current_spell)
{
spell_list mem_spells;
spells_to_books book_hash;
@@ -1483,7 +1490,7 @@ bool has_spells_to_memorise(bool silent)
unsigned int num_race;
return _get_mem_list(mem_spells, book_hash, num_unreadable, num_race,
- silent);
+ silent, (spell_type) current_spell);
}
static bool _sort_mem_spells(spell_type a, spell_type b)
diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h
index b73b890baf..e8373e4e49 100644
--- a/crawl-ref/source/spl-book.h
+++ b/crawl-ref/source/spl-book.h
@@ -64,7 +64,8 @@ int staff_spell( int zap_device_2 );
bool is_memorised(spell_type spell);
bool you_cannot_memorise(spell_type spell);
-bool has_spells_to_memorise(bool silent = true);
+bool has_spells_to_memorise(bool silent = true,
+ int current_spell = SPELL_NO_SPELL);
std::vector<spell_type> get_mem_spell_list(std::vector<int> &books);
int spellbook_contents( item_def &book, read_book_action_type action,
diff --git a/crawl-ref/source/tilereg.cc b/crawl-ref/source/tilereg.cc
index 85711f10c4..3c8136bc11 100644
--- a/crawl-ref/source/tilereg.cc
+++ b/crawl-ref/source/tilereg.cc
@@ -1864,7 +1864,8 @@ 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 );
- else if (!can_learn_spell(true) || !has_spells_to_memorise())
+ else if (!can_learn_spell(true)
+ || !has_spells_to_memorise(true, spell))
{
// Jump back to spells list. (Really, this should only happen
// if there aren't any other spells to memorise, but this
@@ -2056,7 +2057,7 @@ bool InventoryRegion::update_tip_text(std::string& tip)
bool display_actions = (m_items[item_idx].key == 0
&& mouse_control::current_mode() == MOUSE_MODE_COMMAND);
- if (display_actions && Options.tile_display != TDSP_INVENT)
+ if (Options.tile_display != TDSP_INVENT)
{
if (m_items[item_idx].idx == NUM_SPELLS)
{