diff options
-rw-r--r-- | crawl-ref/source/abl-show.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 22 | ||||
-rw-r--r-- | crawl-ref/source/notes.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/notes.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/shopping.cc | 33 | ||||
-rw-r--r-- | crawl-ref/source/stash.cc | 109 |
10 files changed, 110 insertions, 89 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index e05e686682..d61ab5bcc2 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1747,9 +1747,10 @@ static bool _do_ability(const ability_def& abil) if (you.magic_points) set_mp(random2(you.magic_points), false); + bool note_status = notes_are_active(); activate_notes(false); // this banishment shouldn't be noted banished(DNGN_ENTER_ABYSS); - activate_notes(true); + activate_notes(note_status); break; } case ABIL_NEMELEX_DRAW_ONE: diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index 8509d1bea6..7bc319bff2 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1812,10 +1812,10 @@ bool recharge_wand(int item_slot) item_def &wand = you.inv[ item_slot ]; if (wand.base_type == OBJ_WEAPONS - && get_weapon_brand( wand ) == SPWPN_ELECTROCUTION) + && get_weapon_brand(wand) == SPWPN_ELECTROCUTION) { // might fail because of already high enchantment - if ( enchant_weapon( ENCHANT_TO_DAM, false, wand )) + if (enchant_weapon( ENCHANT_TO_DAM, false, wand )) { you.wield_change = true; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index c83392ec3a..596ef98904 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -504,7 +504,6 @@ void wield_effects(int item_wield_2, bool showMsgs) { if (item.sub_type == STAFF_POWER) { - // inc_max_mp(13); calc_mp(); set_ident_flags( item, ISFLAG_EQ_WEAPON_MASK ); mpr("You feel your mana capacity increase."); @@ -4444,7 +4443,7 @@ void read_scroll( int slot ) // scrolls of immolation were already destroyed earlier if (which_scroll != SCR_PAPER && which_scroll != SCR_IMMOLATION) { - if ( id_the_scroll ) + if (id_the_scroll) set_ident_flags( scroll, ISFLAG_KNOW_TYPE ); // for notes dec_inv_item_quantity( item_slot, 1 ); diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 14a8c72474..f299dbc8d1 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -2128,15 +2128,18 @@ static char retlet( int sed ) bool is_interesting_item( const item_def& item ) { if (fully_identified(item) - && (is_random_artefact(item) || - is_unrandom_artefact(item) || - is_fixed_artefact(item))) + && (is_random_artefact(item) + || is_unrandom_artefact(item) + || is_fixed_artefact(item))) + { return (true); + } const std::string iname = item.name(DESC_PLAIN); for (unsigned i = 0; i < Options.note_items.size(); ++i) if (Options.note_items[i].matches(iname)) return (true); + return (false); } diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index e7617661fc..c8004d4424 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -574,11 +574,12 @@ void set_ident_flags( item_def &item, unsigned long flags ) if (notes_are_active() && !(item.flags & ISFLAG_NOTED_ID) && fully_identified(item) && is_interesting_item(item)) { - // make a note of it + // Make a note of it. take_note(Note(NOTE_ID_ITEM, 0, 0, item.name(DESC_NOCAP_A).c_str(), origin_desc(item).c_str())); - // sometimes (e.g. shops) you can ID an item before you get it; - // don't note twice in those cases + + // Sometimes (e.g. shops) you can ID an item before you get it; + // don't note twice in those cases. item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET); } } diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index eabb7fab8b..7652cff35d 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -970,7 +970,7 @@ static void check_note_item(item_def &item) // If it's already fully identified when picked up, don't take // further notes. - if ( fully_identified(item) ) + if (fully_identified(item)) item.flags |= ISFLAG_NOTED_ID; } } @@ -1448,8 +1448,13 @@ static void _got_item(item_def& item, int quant) } item.flags |= ISFLAG_BEEN_IN_INV; - take_note(Note(NOTE_FOUND_ORB_OR_RUNE, 0, 0, - item.name(DESC_NOCAP_A).c_str())); + if (!(item.flags & ISFLAG_NOTED_GET)) + { + take_note(Note(NOTE_GET_ITEM, 0, 0, + item.name(DESC_NOCAP_A).c_str())); + // Don't take another note. + item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET); + } } // Returns quantity of items moved into player's inventory and -1 if @@ -1610,8 +1615,12 @@ int move_item_to_player( int obj, int quant_got, bool quiet ) && you.char_direction == GDT_DESCENDING) { // Take a note! - take_note(Note(NOTE_FOUND_ORB_OR_RUNE, 0, 0, - item.name(DESC_NOCAP_A).c_str())); + if (!(item.flags & ISFLAG_NOTED_GET)) + { + take_note(Note(NOTE_GET_ITEM, 0, 0, + item.name(DESC_NOCAP_A).c_str())); + item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET); + } if (!quiet) mpr("Now all you have to do is get back out of the dungeon!"); @@ -2409,9 +2418,12 @@ item_def find_item_type(object_class_type base_type, std::string name) { if (!max_subtype[i]) continue; + if (find_subtype_by_name(item, static_cast<object_class_type>(i), max_subtype[i], name)) + { break; + } } } else diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc index 3b269070dd..957b8cb52f 100644 --- a/crawl-ref/source/notes.cc +++ b/crawl-ref/source/notes.cc @@ -119,7 +119,6 @@ static bool _is_noteworthy( const Note& note ) || note.type == NOTE_POLY_MONSTER || note.type == NOTE_USER_NOTE || note.type == NOTE_MESSAGE - || note.type == NOTE_FOUND_ORB_OR_RUNE || note.type == NOTE_LOSE_GOD || note.type == NOTE_PENANCE || note.type == NOTE_MOLLIFY_GOD @@ -341,9 +340,6 @@ std::string Note::describe( bool when, bool where, bool what ) const case NOTE_DEATH: result << name; break; - case NOTE_FOUND_ORB_OR_RUNE: - result << "Found " << name; - break; case NOTE_USER_NOTE: result << Options.user_note_prefix << name; break; @@ -432,12 +428,12 @@ bool notes_active = false; bool notes_are_active() { - return notes_active; + return (notes_active); } void take_note( const Note& note, bool force ) { - if ( notes_active && (force || _is_noteworthy(note)) ) + if (notes_active && (force || _is_noteworthy(note))) { note_list.push_back( note ); note.check_milestone(); diff --git a/crawl-ref/source/notes.h b/crawl-ref/source/notes.h index b9bbbe2253..7e8366bb3a 100644 --- a/crawl-ref/source/notes.h +++ b/crawl-ref/source/notes.h @@ -46,7 +46,6 @@ enum NOTE_TYPES NOTE_PENANCE, /* needs: god id */ NOTE_MOLLIFY_GOD, /* needs: god id */ NOTE_DEATH, /* needs: death cause */ - NOTE_FOUND_ORB_OR_RUNE, /* needs: item name (string) */ NOTE_NUM_TYPES }; diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 631cace5ca..fb9c1975c6 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -154,12 +154,13 @@ static int _shop_get_item_value(const item_def& item, int greed, bool id) static std::string _shop_print_stock( const std::vector<int>& stock, const shop_struct& shop ) { - ShopInfo &si = StashTrack.get_shop(shop.x, shop.y); + ShopInfo &si = StashTrack.get_shop(shop.x, shop.y); const bool id = shoptype_identifies_stock(shop.type); std::string purchasable; for (unsigned int i = 0; i < stock.size(); ++i) { - const int gp_value = _shop_get_item_value(mitm[stock[i]], shop.greed, id); + const int gp_value = _shop_get_item_value(mitm[stock[i]], shop.greed, + id); const bool can_afford = (you.gold >= gp_value); cgotoxy(1, i+1, GOTO_CRT); @@ -200,7 +201,7 @@ static void _in_a_shop( int shopidx ) std::vector<int> stock = _shop_get_stock(shopidx); clrscr(); - if ( stock.empty() ) + if (stock.empty()) { _shop_print("I'm sorry, my shop is empty now.", 1); _shop_more(); @@ -248,7 +249,7 @@ static void _in_a_shop( int shopidx ) bool is_ok = true; ft = get_ch(); - if ( !isalpha(ft) ) + if (!isalpha(ft)) { is_ok = false; } @@ -259,7 +260,7 @@ static void _in_a_shop( int shopidx ) is_ok = false; } - if ( !is_ok ) + if (!is_ok) { _shop_print("Huh?", 1); _shop_more(); @@ -275,16 +276,18 @@ static void _in_a_shop( int shopidx ) // noted when you buy it. item_def& item = mitm[stock[ft]]; const unsigned long old_flags = item.flags; - if ( id_stock ) + if (id_stock) + { item.flags |= (ISFLAG_IDENT_MASK | ISFLAG_NOTED_ID | ISFLAG_NOTED_GET); + } describe_item(item); - if ( id_stock ) + if (id_stock) item.flags = old_flags; } else if (ft == '?' || ft == '*') invent(-1, false); - else if ( !isalpha(ft) ) + else if (!isalpha(ft)) { _shop_print("Huh?", 1); _shop_more(); @@ -323,10 +326,9 @@ static void _in_a_shop( int shopidx ) bool shoptype_identifies_stock(shop_type type) { - return - type != SHOP_WEAPON_ANTIQUE && - type != SHOP_ARMOUR_ANTIQUE && - type != SHOP_GENERAL_ANTIQUE; + return (type != SHOP_WEAPON_ANTIQUE + && type != SHOP_ARMOUR_ANTIQUE + && type != SHOP_GENERAL_ANTIQUE); } static void _purchase( int shop, int item_got, int cost, bool id ) @@ -353,15 +355,16 @@ static void _purchase( int shop, int item_got, int cost, bool id ) if (num < quant) { snprintf( info, INFO_SIZE, "I'll put %s outside for you.", - (quant == 1) ? "it" : - (num > 0) ? "the rest" : "these" ); + (quant == 1) ? "it" : + (num > 0) ? "the rest" + : "these" ); _shop_print(info, 1); _shop_more(); move_item_to_grid( &item_got, env.shop[shop].x, env.shop[shop].y ); } -} // end purchase() +} // This probably still needs some work. Rings used to be the only // artefacts which had a change in price, and that value corresponds diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 314dd4fe19..ecc2fc9fe1 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -80,19 +80,17 @@ std::string stash_annotate_item(const char *s, bool exclusive = false) { std::string text = userdef_annotate_item(s, item, exclusive); - if ((item->base_type == OBJ_BOOKS - && item_type_known(*item) - && item->sub_type != BOOK_MANUAL - && item->sub_type != BOOK_DESTRUCTION) + if (item->base_type == OBJ_BOOKS + && item_type_known(*item) + && item->sub_type != BOOK_MANUAL + && item->sub_type != BOOK_DESTRUCTION || count_staff_spells(*item, true) > 1) { formatted_string fs; item_def dup = *item; - spellbook_contents( dup, - item->base_type == OBJ_BOOKS? - RBOOK_READ_SPELL - : RBOOK_USE_STAFF, - &fs ); + spellbook_contents(dup, item->base_type == OBJ_BOOKS ? RBOOK_READ_SPELL + : RBOOK_USE_STAFF, + &fs); text += EOL; text += fs.tostring(2, -2); } @@ -132,9 +130,7 @@ static void fully_identify_item(item_def *item) set_ident_flags( *item, ISFLAG_IDENT_MASK ); if (item->base_type != OBJ_WEAPONS) - set_ident_type( item->base_type, - item->sub_type, - ID_KNOWN_TYPE ); + set_ident_type( item->base_type, item->sub_type, ID_KNOWN_TYPE ); } // ---------------------------------------------------------------------- @@ -241,12 +237,19 @@ bool Stash::is_boring_feature(dungeon_feature_type feat) switch (feat) { // Discard spammy dungeon features. - case DNGN_SHALLOW_WATER: case DNGN_DEEP_WATER: - case DNGN_LAVA: case DNGN_OPEN_DOOR: case DNGN_STONE_STAIRS_DOWN_I: - case DNGN_STONE_STAIRS_DOWN_II: case DNGN_STONE_STAIRS_DOWN_III: - case DNGN_STONE_STAIRS_UP_I: case DNGN_STONE_STAIRS_UP_II: - case DNGN_STONE_STAIRS_UP_III: case DNGN_ESCAPE_HATCH_DOWN: - case DNGN_ESCAPE_HATCH_UP: case DNGN_ENTER_SHOP: + case DNGN_SHALLOW_WATER: + case DNGN_DEEP_WATER: + case DNGN_LAVA: + case DNGN_OPEN_DOOR: + case DNGN_STONE_STAIRS_DOWN_I: + case DNGN_STONE_STAIRS_DOWN_II: + case DNGN_STONE_STAIRS_DOWN_III: + case DNGN_STONE_STAIRS_UP_I: + case DNGN_STONE_STAIRS_UP_II: + case DNGN_STONE_STAIRS_UP_III: + case DNGN_ESCAPE_HATCH_DOWN: + case DNGN_ESCAPE_HATCH_UP: + case DNGN_ENTER_SHOP: case DNGN_UNDISCOVERED_TRAP: return (true); default: @@ -490,15 +493,14 @@ bool Stash::matches_search(const std::string &prefix, const base_pattern &search, stash_search_result &res) const { - if (!enabled || (items.empty() && feat == DNGN_FLOOR)) + if (!enabled || items.empty() && feat == DNGN_FLOOR) return false; for (unsigned i = 0; i < items.size(); ++i) { const item_def &item = items[i]; - std::string s = stash_item_name(item); - std::string ann = stash_annotate_item( - STASH_LUA_SEARCH_ANNOTATE, &item); + std::string s = stash_item_name(item); + std::string ann = stash_annotate_item(STASH_LUA_SEARCH_ANNOTATE, &item); if (search.matches(prefix + " " + ann + s)) { if (!res.count++) @@ -542,14 +544,16 @@ bool Stash::matches_search(const std::string &prefix, return !!res.matches; } -void Stash::write(std::ostream &os, - int refx, int refy, - std::string place, - bool identify) +void Stash::write(std::ostream &os, int refx, int refy, + std::string place, bool identify) const { + bool note_status = notes_are_active(); activate_notes(false); - if (!enabled || (items.size() == 0 && verified)) return; + + if (!enabled || (items.size() == 0 && verified)) + return; + os << "(" << ((int) x - refx) << ", " << ((int) y - refy) << (place.length()? ", " + place : "") << ")" @@ -566,8 +570,7 @@ void Stash::write(std::ostream &os, std::string s = stash_item_name(item); strncpy(buf, s.c_str(), sizeof buf); - std::string ann = userdef_annotate_item( - STASH_LUA_DUMP_ANNOTATE, &item); + std::string ann = userdef_annotate_item(STASH_LUA_DUMP_ANNOTATE, &item); if (!ann.empty()) { @@ -577,7 +580,7 @@ void Stash::write(std::ostream &os, os << " " << buf << (!ann.empty()? ann : std::string()) - << (!verified && (items.size() > 1 || i)? " (still there?)" : "") + << (!verified && (items.size() > 1 || i) ? " (still there?)" : "") << std::endl; if (is_dumpable_artefact(item, false)) @@ -591,10 +594,11 @@ void Stash::write(std::ostream &os, // If string is not-empty, pad out to a neat indent if (desc.length()) { - // Walk backwards and prepend indenting spaces to \n characters + // Walk backwards and prepend indenting spaces to \n characters. for (int j = desc.length() - 1; j >= 0; --j) if (desc[j] == '\n') desc.insert(j + 1, " "); + os << " " << desc << std::endl; } } @@ -602,7 +606,8 @@ void Stash::write(std::ostream &os, if (items.size() <= 1 && !verified) os << " (unseen)" << std::endl; - activate_notes(true); + + activate_notes(note_status); } void Stash::save(writer& outf) const @@ -634,13 +639,10 @@ void Stash::load(reader& inf) x = unmarshallByte(inf); y = unmarshallByte(inf); - feat = - static_cast<dungeon_feature_type>( - static_cast<unsigned char>( unmarshallByte(inf) )); - trap = - static_cast<trap_type>( - static_cast<unsigned char>( unmarshallByte(inf) )); - + feat = static_cast<dungeon_feature_type>( + static_cast<unsigned char>( unmarshallByte(inf) )); + trap = static_cast<trap_type>( + static_cast<unsigned char>( unmarshallByte(inf) )); unsigned char flags = unmarshallByte(inf); verified = (flags & 1) != 0; @@ -699,7 +701,7 @@ std::string ShopInfo::shop_item_name(const shop_item &si) const snprintf(shopitem, sizeof shopitem, "%s (%u gold)", itemname.c_str(), si.price); - if ( oldflags != si.item.flags ) + if (oldflags != si.item.flags) const_cast<shop_item&>(si).item.flags = oldflags; return shopitem; @@ -725,7 +727,7 @@ std::string ShopInfo::shop_item_desc(const shop_item &si) const desc.insert(i + 1, " "); } - if ( oldflags != si.item.flags ) + if (oldflags != si.item.flags) const_cast<shop_item&>(si).item.flags = oldflags; return desc; @@ -808,13 +810,16 @@ bool ShopInfo::matches_search(const std::string &prefix, if (items.empty() && visited) return false; + bool note_status = notes_are_active(); + activate_notes(false); + bool match = false; for (unsigned i = 0; i < items.size(); ++i) { std::string sname = shop_item_name(items[i]); - std::string ann = stash_annotate_item( - STASH_LUA_SEARCH_ANNOTATE, &items[i].item, true); + std::string ann = stash_annotate_item( STASH_LUA_SEARCH_ANNOTATE, + &items[i].item, true ); bool thismatch = false; if (search.matches(prefix + " " + ann + sname)) @@ -853,11 +858,13 @@ bool ShopInfo::matches_search(const std::string &prefix, res.pos.pos.y = y; } - return match || res.matches; + activate_notes(note_status); + return (match || res.matches); } void ShopInfo::write(std::ostream &os, bool identify) const { + bool note_status = notes_are_active(); activate_notes(false); os << "[Shop] " << name << std::endl; if (items.size() > 0) @@ -879,7 +886,8 @@ void ShopInfo::write(std::ostream &os, bool identify) const os << " (Shop is empty)" << std::endl; else os << " (Shop contents are unknown)" << std::endl; - activate_notes(true); + + activate_notes(note_status); } void ShopInfo::save(writer& outf) const @@ -964,10 +972,9 @@ const Stash *LevelStashes::find_stash(int x, int y) const const ShopInfo *LevelStashes::find_shop(int x, int y) const { for (unsigned i = 0; i < m_shops.size(); ++i) - { if (m_shops[i].isAt(x, y)) return (&m_shops[i]); - } + return (NULL); } @@ -1123,13 +1130,13 @@ void LevelStashes::get_matching_stashes( void LevelStashes::write(std::ostream &os, bool identify) const { - if (visible_stash_count() == 0) return ; + if (visible_stash_count() == 0) + return; + os << level_name() << std::endl; for (unsigned i = 0; i < m_shops.size(); ++i) - { m_shops[i].write(os, identify); - } if (m_stashes.size()) { @@ -1137,7 +1144,7 @@ void LevelStashes::write(std::ostream &os, bool identify) const int refx = s.getX(), refy = s.getY(); std::string levname = short_level_name(); for (stashes_t::const_iterator iter = m_stashes.begin(); - iter != m_stashes.end(); iter++) + iter != m_stashes.end(); iter++) { iter->second.write(os, refx, refy, levname, identify); } |