From a59025b069d3d08cfa7c5ccd21d3b0ae116da71c Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 18 Feb 2008 15:51:08 +0000 Subject: First batch of Paul's patches: 1896018: cycle ammo with '(' 1895278: no (v)iewing of unreadable books 1895075: cancel Ely's abilities without cost Fix 1894920: fix overly long dungeon overview Also fix 1884145: weapon swap ignoring {!w} git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3441 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/describe.cc | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'crawl-ref/source/describe.cc') diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index 829a04fe43..00edf93c78 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1621,6 +1621,10 @@ std::string get_item_description( const item_def &item, bool verbose, break; case OBJ_BOOKS: + if (! player_can_read_spellbook( item )) + description << "This book is beyond your current level of understanding.$$"; + break; + case OBJ_SCROLLS: case OBJ_POTIONS: case OBJ_ORBS: @@ -1686,7 +1690,8 @@ void describe_feature_wide(int x, int y) getch(); } -static void show_item_description(const item_def &item) +// Return true if spells can be shown to player +static bool show_item_description(const item_def &item) { clrscr(); @@ -1697,6 +1702,8 @@ static void show_item_description(const item_def &item) if (item.has_spells()) { + if (item.base_type == OBJ_BOOKS && !player_can_read_spellbook( item )) + return false; formatted_string fs; item_def dup = item; spellbook_contents( dup, @@ -1705,7 +1712,10 @@ static void show_item_description(const item_def &item) : RBOOK_USE_STAFF, &fs ); fs.display(2, -2); + return true; } + + return false; } static bool describe_spells(const item_def &item) @@ -1739,8 +1749,9 @@ void describe_item( item_def &item, bool allow_inscribe ) { for (;;) { - show_item_description(item); - if (item.has_spells()) + const bool spells_shown = show_item_description(item); + + if (spells_shown) { cgotoxy(1, wherey()); textcolor(LIGHTGREY); -- cgit v1.2.3-54-g00ecf