diff options
-rw-r--r-- | crawl-ref/source/effects.cc | 59 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/newgame.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 46 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.h | 3 |
5 files changed, 46 insertions, 90 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 40a6eb75ba..4dfe3323ee 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1102,37 +1102,29 @@ static int find_acquirement_subtype(object_class_type class_wanted, bool acquirement(object_class_type class_wanted, int agent) { int thing_created = 0; - - // Remember lava! - int type_wanted = OBJ_RANDOM; int unique = 1; while (class_wanted == OBJ_RANDOM) { mesclr(); mpr("This is a scroll of acquirement!"); - mpr( "[a|A] Weapon [b|B] Armour [c|C] Jewellery [d|D] Book" ); - mpr( "[e|E] Staff [f|F] Food [g|G] Miscellaneous [h|H] Gold" ); + mpr( "[a] Weapon [b] Armour [c] Jewellery [d] Book" ); + mpr( "[e] Staff [f] Food [g] Miscellaneous [h] Gold" ); mpr("What kind of item would you like to acquire? ", MSGCH_PROMPT); const int keyin = tolower( get_ch() ); - - if (keyin == 'a') - class_wanted = OBJ_WEAPONS; - else if (keyin == 'b') - class_wanted = OBJ_ARMOUR; - else if (keyin == 'c') - class_wanted = OBJ_JEWELLERY; - else if (keyin == 'd') - class_wanted = OBJ_BOOKS; - else if (keyin == 'e') - class_wanted = OBJ_STAVES; - else if (keyin == 'f') - class_wanted = OBJ_FOOD; - else if (keyin == 'g') - class_wanted = OBJ_MISCELLANY; - else if (keyin == 'h') - class_wanted = OBJ_GOLD; + switch ( keyin ) + { + case 'a': class_wanted = OBJ_WEAPONS; break; + case 'b': class_wanted = OBJ_ARMOUR; break; + case 'c': class_wanted = OBJ_JEWELLERY; break; + case 'd': class_wanted = OBJ_BOOKS; break; + case 'e': class_wanted = OBJ_STAVES; break; + case 'f': class_wanted = OBJ_FOOD; break; + case 'g': class_wanted = OBJ_MISCELLANY; break; + case 'h': class_wanted = OBJ_GOLD; break; + default: break; + } } if (grid_destroys_items(grd[you.x_pos][you.y_pos])) @@ -1143,11 +1135,10 @@ bool acquirement(object_class_type class_wanted, int agent) } else { - randart_properties_t proprt; for (int item_tries = 0; item_tries < 40; item_tries++) { unique = 1; - type_wanted = find_acquirement_subtype(class_wanted, unique); + int type_wanted = find_acquirement_subtype(class_wanted, unique); // BCR - unique is now used for food quantity. thing_created = items( unique, class_wanted, type_wanted, true, @@ -1170,6 +1161,7 @@ bool acquirement(object_class_type class_wanted, int agent) if ((agent == GOD_TROG || agent == GOD_OKAWARU) && is_random_artefact(doodad)) { + randart_properties_t proprt; randart_wpn_properties( doodad, proprt ); // check vs stats. positive stats will automatically fall @@ -1205,24 +1197,7 @@ bool acquirement(object_class_type class_wanted, int agent) if (thing.base_type == OBJ_BOOKS) { - if (thing.sub_type == BOOK_MINOR_MAGIC_I - || thing.sub_type == BOOK_MINOR_MAGIC_II - || thing.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 (thing.sub_type == BOOK_CONJURATIONS_I - || thing.sub_type == BOOK_CONJURATIONS_II) - { - you.had_book[ BOOK_CONJURATIONS_I ] = true; - you.had_book[ BOOK_CONJURATIONS_II ] = true; - } - else - { - you.had_book[ thing.sub_type ] = true; - } + mark_had_book(thing.sub_type); } else if (thing.base_type == OBJ_JEWELLERY) { diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 639879dc1e..12aa67ed59 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -213,7 +213,7 @@ std::string item_def::name(description_level_type descrip, } } - const bool tried = !ident && item_type_tried(*this); + const bool tried = (!ident && item_type_tried(*this)); if ( with_inscription && !(this->inscription.empty()) ) { buff << " {"; diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index cd6af24030..e732397ab1 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -86,6 +86,7 @@ #include "randart.h" #include "skills.h" #include "skills2.h" +#include "spl-book.h" #include "spl-util.h" #include "stuff.h" #include "tutorial.h" @@ -479,31 +480,8 @@ static void give_starting_food() static void mark_starting_books() { for (int i = 0; i < ENDOFPACK; i++) - { if (is_valid_item(you.inv[i]) && you.inv[i].base_type == OBJ_BOOKS) - { - const int subtype = you.inv[i].sub_type; - - you.had_book[subtype] = true; - - // one for all, all for one - if (subtype == BOOK_MINOR_MAGIC_I || - subtype == BOOK_MINOR_MAGIC_II || - subtype == 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; - } - - if (subtype == BOOK_CONJURATIONS_I || - subtype == BOOK_CONJURATIONS_II) - { - you.had_book[BOOK_CONJURATIONS_I] = true; - you.had_book[BOOK_CONJURATIONS_II] = true; - } - } - } + mark_had_book(you.inv[i].sub_type); } static void racialise_starting_equipment() 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 diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h index b3b213c461..edcb8a89f9 100644 --- a/crawl-ref/source/spl-book.h +++ b/crawl-ref/source/spl-book.h @@ -28,11 +28,12 @@ int book_rarity(unsigned char which_book); bool is_valid_spell_in_book( int splbook, int spell ); +void mark_had_book(int booktype); // updated 24may2000 {dlb} /* *********************************************************************** * called from: it_use3 - item_use - spl-book * *********************************************************************** */ -unsigned char read_book( item_def &item, read_book_action_type action ); +int read_book( item_def &item, read_book_action_type action ); // updated 24may2000 {dlb} |