summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-book.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 12:38:44 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-07-09 12:38:44 +0000
commitbc63643a6c8bdc583694356f559f09b356d2c1c6 (patch)
treeb7b0f15bd0fcfaf3ef103c6250c099781a2f8503 /crawl-ref/source/spl-book.cc
parentbb6930c4b733afe63784e44792b47d08a7ece2d8 (diff)
downloadcrawl-ref-bc63643a6c8bdc583694356f559f09b356d2c1c6.tar.gz
crawl-ref-bc63643a6c8bdc583694356f559f09b356d2c1c6.zip
Minor refactoring.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1817 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-book.cc')
-rw-r--r--crawl-ref/source/spl-book.cc46
1 files changed, 24 insertions, 22 deletions
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 45dafb7a78..cc570e99c7 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1010,10 +1010,29 @@ static bool player_can_read_spellbook( const item_def &book )
return (true);
}
-unsigned char read_book( item_def &book, read_book_action_type action )
+
+void mark_had_book(int booktype)
{
- unsigned char key2 = 0;
+ you.had_book[booktype] = true;
+
+ if ( booktype == BOOK_MINOR_MAGIC_I
+ || booktype == BOOK_MINOR_MAGIC_II
+ || booktype == BOOK_MINOR_MAGIC_III)
+ {
+ you.had_book[BOOK_MINOR_MAGIC_I] = true;
+ you.had_book[BOOK_MINOR_MAGIC_II] = true;
+ you.had_book[BOOK_MINOR_MAGIC_III] = true;
+ }
+ else if (booktype == BOOK_CONJURATIONS_I
+ || booktype == BOOK_CONJURATIONS_II)
+ {
+ you.had_book[BOOK_CONJURATIONS_I] = true;
+ you.had_book[BOOK_CONJURATIONS_II] = true;
+ }
+}
+int read_book( item_def &book, read_book_action_type action )
+{
if (book.base_type == OBJ_BOOKS && !player_can_read_spellbook( book ))
{
mpr( "This book is beyond your current level of understanding." );
@@ -1022,27 +1041,10 @@ unsigned char read_book( item_def &book, read_book_action_type action )
}
// remember that this function is called from staff spells as well:
- key2 = spellbook_contents( book, action );
+ const int keyin = spellbook_contents( book, action );
if (book.base_type == OBJ_BOOKS)
- {
- you.had_book[ book.sub_type ] = true;
-
- if ( book.sub_type == BOOK_MINOR_MAGIC_I
- || book.sub_type == BOOK_MINOR_MAGIC_II
- || book.sub_type == BOOK_MINOR_MAGIC_III)
- {
- you.had_book[BOOK_MINOR_MAGIC_I] = true;
- you.had_book[BOOK_MINOR_MAGIC_II] = true;
- you.had_book[BOOK_MINOR_MAGIC_III] = true;
- }
- else if (book.sub_type == BOOK_CONJURATIONS_I
- || book.sub_type == BOOK_CONJURATIONS_II)
- {
- you.had_book[BOOK_CONJURATIONS_I] = true;
- you.had_book[BOOK_CONJURATIONS_II] = true;
- }
- }
+ mark_had_book(book.sub_type);
redraw_screen();
@@ -1051,7 +1053,7 @@ unsigned char read_book( item_def &book, read_book_action_type action )
set_ident_flags( book, ISFLAG_KNOW_TYPE );
- return (key2);
+ return (keyin);
} // end read_book()
// recoded to answer whether an UNDEAD_STATE is