diff options
Diffstat (limited to 'crawl-ref/source/spl-book.cc')
-rw-r--r-- | crawl-ref/source/spl-book.cc | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index a1c83caa89..6023dece43 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1485,6 +1485,16 @@ bool has_spells_to_memorise() return _get_mem_list(mem_spells, book_hash, num_unreadable, num_race, true); } +static bool _sort_mem_spells(spell_type a, spell_type b) +{ + if (spell_fail(a) != spell_fail(b)) + return (spell_fail(a) < spell_fail(b)); + if (spell_difficulty(a) != spell_difficulty(b)) + return (spell_difficulty(a) < spell_difficulty(b)); + + return (stricmp(spell_title(a), spell_title(b)) < 0); +} + std::vector<spell_type> get_mem_spell_list() { std::vector<spell_type> spells; @@ -1497,22 +1507,14 @@ std::vector<spell_type> get_mem_spell_list() if (!_get_mem_list(mem_spells, book_hash, num_unreadable, num_race)) return (spells); + std::sort(mem_spells.begin(), mem_spells.end(), _sort_mem_spells); + for (unsigned int i = 0; i < mem_spells.size(); i++) spells.push_back(mem_spells[i]); return (spells); } -static bool _sort_mem_spells(spell_type a, spell_type b) -{ - if (spell_fail(a) != spell_fail(b)) - return (spell_fail(a) < spell_fail(b)); - if (spell_difficulty(a) != spell_difficulty(b)) - return (spell_difficulty(a) < spell_difficulty(b)); - - return (stricmp(spell_title(a), spell_title(b)) < 0); -} - static spell_type _choose_mem_spell(spell_list &spells, spells_to_books &book_hash, unsigned long num_unreadable, |