From 9c825029344d1ab8e5e85987a375cbae9109e2ce Mon Sep 17 00:00:00 2001 From: zelgadis Date: Thu, 19 Jun 2008 05:05:08 +0000 Subject: For jewellery with pluses and wands, only make an ident note when the first item of the type is identified, not when the charges/pluses of any item of the type is identified. Make sure that artefacts have nothing to do with the identification level of jewellery by making versions of set_ident_type() and get_ident_type() which accept a full item_def as a parameter. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5973 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 9 +++------ crawl-ref/source/debug.cc | 2 +- crawl-ref/source/describe.cc | 3 +-- crawl-ref/source/item_use.cc | 20 +++++++++----------- crawl-ref/source/itemname.cc | 35 +++++++++++++++++++++++++++++++++-- crawl-ref/source/itemname.h | 3 +++ crawl-ref/source/itemprop.cc | 1 + crawl-ref/source/newgame.cc | 3 +-- crawl-ref/source/ouch.cc | 3 +-- crawl-ref/source/player.cc | 5 ++--- crawl-ref/source/shopping.cc | 2 +- crawl-ref/source/spells1.cc | 4 +--- crawl-ref/source/stash.cc | 2 +- 13 files changed, 58 insertions(+), 34 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 6015225761..067db5d042 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -871,8 +871,7 @@ static void _handle_wizard_command( void ) { if (is_valid_item( you.inv[i] )) { - set_ident_type( you.inv[i].base_type, you.inv[i].sub_type, - ID_KNOWN_TYPE ); + set_ident_type( you.inv[i], ID_KNOWN_TYPE ); set_ident_flags( you.inv[i], ISFLAG_IDENT_MASK ); } @@ -889,8 +888,7 @@ static void _handle_wizard_command( void ) { if (is_valid_item( you.inv[i] )) { - set_ident_type( you.inv[i].base_type, you.inv[i].sub_type, - ID_UNKNOWN_TYPE ); + set_ident_type( you.inv[i], ID_UNKNOWN_TYPE ); unset_ident_flags( you.inv[i], ISFLAG_IDENT_MASK ); } @@ -917,8 +915,7 @@ static void _handle_wizard_command( void ) if (!is_valid_item(item)) continue; - set_ident_type( item.base_type, item.sub_type, - ID_UNKNOWN_TYPE ); + set_ident_type( item, ID_UNKNOWN_TYPE ); unset_ident_flags( item, ISFLAG_IDENT_MASK ); } diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 6b51f2ae84..3315167307 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -1815,7 +1815,7 @@ static void _dump_item( const char *name, int num, const item_def &item ) mprf(" quant: %d; colour: %d; ident: 0x%08lx; ident_type: %d", item.quantity, item.colour, item.flags, - get_ident_type( item.base_type, item.sub_type ) ); + get_ident_type( item ) ); mprf(" x: %d; y: %d; link: %d", item.x, item.y, item.link ); diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index b59539e48d..06b7102088 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -1545,8 +1545,7 @@ std::string get_item_description( const item_def &item, bool verbose, << "x: " << item.x << " y: " << item.y << " link: " << item.link << " ident_type: " - << static_cast(get_ident_type(item.base_type, - item.sub_type)); + << static_cast(get_ident_type(item)); } #endif diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 8dc3e57def..b17566863b 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -2811,7 +2811,7 @@ void jewellery_wear_effects(item_def &item) } else { - set_ident_type( item.base_type, item.sub_type, ident ); + set_ident_type( item, ident ); if (ident == ID_KNOWN_TYPE) set_ident_flags( item, ISFLAG_EQ_JEWELLERY_MASK ); @@ -3484,11 +3484,11 @@ void zap_wand( int slot ) // Identify if necessary. if (!alreadyknown && (beam.obvious_effect || type_zapped == ZAP_FIREBALL)) { - set_ident_type( wand.base_type, wand.sub_type, ID_KNOWN_TYPE ); + set_ident_type( wand, ID_KNOWN_TYPE ); mpr(wand.name(DESC_INVENTORY_EQUIP).c_str()); } else - set_ident_type( wand.base_type, wand.sub_type, ID_TRIED_TYPE ); + set_ident_type( wand, ID_TRIED_TYPE ); if (item_type_known(wand) && (item_ident( wand, ISFLAG_KNOW_PLUSES ) @@ -3624,13 +3624,11 @@ void drink( int slot ) { set_ident_flags( you.inv[item_slot], ISFLAG_IDENT_MASK ); - set_ident_type( you.inv[item_slot].base_type, - you.inv[item_slot].sub_type, ID_KNOWN_TYPE ); + set_ident_type( you.inv[item_slot], ID_KNOWN_TYPE ); } else { - set_ident_type( you.inv[item_slot].base_type, - you.inv[item_slot].sub_type, ID_TRIED_TYPE ); + set_ident_type( you.inv[item_slot], ID_TRIED_TYPE ); } if (!alreadyknown && dangerous) { @@ -4128,7 +4126,7 @@ static bool scroll_modify_item(const scroll_type scroll) if ( !fully_identified(item) ) { mpr("This is a scroll of identify!"); - set_ident_type( OBJ_SCROLLS, SCR_IDENTIFY, ID_KNOWN_TYPE ); + set_ident_type( item, ID_KNOWN_TYPE ); identify(-1, item_slot); return (true); } @@ -4545,6 +4543,9 @@ void read_scroll( int slot ) break; } // end switch + set_ident_type( scroll, + (id_the_scroll) ? ID_KNOWN_TYPE : ID_TRIED_TYPE ); + // finally, destroy and identify the scroll // scrolls of immolation were already destroyed earlier if (which_scroll != SCR_PAPER && which_scroll != SCR_IMMOLATION) @@ -4555,9 +4556,6 @@ void read_scroll( int slot ) dec_inv_item_quantity( item_slot, 1 ); } - set_ident_type( OBJ_SCROLLS, which_scroll, - (id_the_scroll) ? ID_KNOWN_TYPE : ID_TRIED_TYPE ); - if (!alreadyknown && dangerous) { // Xom loves it when you read an unknown scroll and there is diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index ca737c6d78..a7ac833bcf 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -248,7 +248,7 @@ std::string item_def::name(description_level_type descrip, if (tried) { item_type_id_state_type id_type = - get_ident_type(this->base_type, this->sub_type); + get_ident_type(*this); if (id_type == ID_MON_TRIED_TYPE) tried_str = "tried by monster"; else @@ -1751,6 +1751,29 @@ id_arr& get_typeid_array() return type_ids; } +void set_ident_type( item_def &item, item_type_id_state_type setting, + bool force ) +{ + if (is_artefact(item)) + return; + + item_type_id_state_type old_setting = get_ident_type(item); + set_ident_type(item.base_type, item.sub_type, setting, force); + + if (setting == ID_KNOWN_TYPE && old_setting != ID_KNOWN_TYPE + && notes_are_active() && is_interesting_item(item) + && !(item.flags & (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET))) + { + // 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. + item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET); + } +} + void set_ident_type( object_class_type basetype, int subtype, item_type_id_state_type setting, bool force ) { @@ -1775,6 +1798,14 @@ void set_ident_type( object_class_type basetype, int subtype, } } +item_type_id_state_type get_ident_type(const item_def &item) +{ + if (is_artefact(item)) + return ID_UNKNOWN_TYPE; + + return get_ident_type(item.base_type, item.sub_type); +} + item_type_id_state_type get_ident_type(object_class_type basetype, int subtype) { const item_type_id_type idt = objtype_to_idtype(basetype); @@ -2488,7 +2519,7 @@ const std::string menu_colour_item_prefix(const item_def &item, bool temp) prefixes.push_back("identified"); else { - if (get_ident_type(item.base_type, item.sub_type) == ID_KNOWN_TYPE) + if (get_ident_type(item) == ID_KNOWN_TYPE) { // Wands are only fully identified if we know the // number of charges. diff --git a/crawl-ref/source/itemname.h b/crawl-ref/source/itemname.h index 3b4a674044..d60058faef 100644 --- a/crawl-ref/source/itemname.h +++ b/crawl-ref/source/itemname.h @@ -127,8 +127,11 @@ void init_properties(); typedef FixedArray < item_type_id_state_type, NUM_IDTYPE, 50 > id_arr; id_arr& get_typeid_array(); +item_type_id_state_type get_ident_type(const item_def &item); item_type_id_state_type get_ident_type(object_class_type basetype, int subtype); +void set_ident_type( item_def &item, item_type_id_state_type setting, + bool force = false); void set_ident_type( object_class_type basetype, int subtype, item_type_id_state_type setting, bool force = false); diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 4cfe2fd891..912153f1c7 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -582,6 +582,7 @@ void set_ident_flags( item_def &item, unsigned long flags ) } if (notes_are_active() && !(item.flags & ISFLAG_NOTED_ID) + && get_ident_type(item) != ID_KNOWN_TYPE && fully_identified(item) && is_interesting_item(item)) { // Make a note of it. diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index 1aee867768..fb4e1840f0 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -1270,8 +1270,7 @@ game_start: you.inv[i].flags |= ISFLAG_BEEN_IN_INV; // Identify all items in pack. - set_ident_type( you.inv[i].base_type, - you.inv[i].sub_type, ID_KNOWN_TYPE ); + set_ident_type( you.inv[i], ID_KNOWN_TYPE ); // link properly you.inv[i].x = -1; you.inv[i].y = -1; diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index e722c8169f..172fdc8088 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -985,8 +985,7 @@ void end_game( scorefile_entry &se ) { if (you.inv[i].base_type != 0) { - set_ident_type( you.inv[i].base_type, - you.inv[i].sub_type, ID_KNOWN_TYPE ); + set_ident_type( you.inv[i], ID_KNOWN_TYPE ); } } diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 926e99f6bb..33a97be0f4 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -5122,10 +5122,9 @@ void haste_player( int amount ) if (amu_eff) { mpr( "Your amulet glows brightly." ); - const item_def *amulet = you.slot_item(EQ_AMULET); + item_def *amulet = you.slot_item(EQ_AMULET); if (amulet && !item_type_known(*amulet)) - set_ident_type( amulet->base_type, amulet->sub_type, - ID_KNOWN_TYPE ); + set_ident_type( *amulet, ID_KNOWN_TYPE ); } if (you.duration[DUR_HASTE] == 0) diff --git a/crawl-ref/source/shopping.cc b/crawl-ref/source/shopping.cc index 7d671c6653..a169778b4a 100644 --- a/crawl-ref/source/shopping.cc +++ b/crawl-ref/source/shopping.cc @@ -349,7 +349,7 @@ static void _purchase( int shop, int item_got, int cost, bool id ) { // Identify the item and its type. // This also takes the ID note if necessary. - set_ident_type(item.base_type, item.sub_type, ID_KNOWN_TYPE); + set_ident_type(item, ID_KNOWN_TYPE); set_ident_flags(item, ISFLAG_IDENT_MASK); } diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index b90f3533cc..a6b4f48ac0 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -451,9 +451,7 @@ void identify(int power, int item_slot) continue; } - if (!is_artefact(item)) - set_ident_type( item.base_type, item.sub_type, ID_KNOWN_TYPE ); - + set_ident_type( item, ID_KNOWN_TYPE ); set_ident_flags( item, ISFLAG_IDENT_MASK ); // output identified item diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc index 1172c4abd0..5bdb3a7855 100644 --- a/crawl-ref/source/stash.cc +++ b/crawl-ref/source/stash.cc @@ -131,7 +131,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, ID_KNOWN_TYPE ); } // ---------------------------------------------------------------------- -- cgit v1.2.3-54-g00ecf