summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-01-04 13:31:34 +0100
committerAdam Borowski <kilobyte@angband.pl>2010-01-04 13:34:04 +0100
commit351147f56190d73b347c906e6ab30ddf30387a68 (patch)
treeffbf967d96fdb76ca17e5c8ee728f7400d888105
parent21e755bcfd70b2683ada62dfdb6cd67695db0f7a (diff)
downloadcrawl-ref-351147f56190d73b347c906e6ab30ddf30387a68.tar.gz
crawl-ref-351147f56190d73b347c906e6ab30ddf30387a68.zip
Track all seen weapon/armour base types and their brands, for acq purposes.
-rw-r--r--crawl-ref/source/itemprop-enum.h1
-rw-r--r--crawl-ref/source/itemprop.cc20
-rw-r--r--crawl-ref/source/itemprop.h1
-rw-r--r--crawl-ref/source/items.cc1
-rw-r--r--crawl-ref/source/main.cc6
-rw-r--r--crawl-ref/source/player.h3
-rw-r--r--crawl-ref/source/stash.cc2
-rw-r--r--crawl-ref/source/tags.cc30
-rw-r--r--crawl-ref/source/tags.h2
9 files changed, 65 insertions, 1 deletions
diff --git a/crawl-ref/source/itemprop-enum.h b/crawl-ref/source/itemprop-enum.h
index b1401d3e9c..cc807371a4 100644
--- a/crawl-ref/source/itemprop-enum.h
+++ b/crawl-ref/source/itemprop-enum.h
@@ -71,6 +71,7 @@ enum boot_type // used in pluses2
const int SP_FORBID_EGO = -1;
const int SP_FORBID_BRAND = -1;
+const int SP_UNKNOWN_BRAND = 31; // seen_weapon/armour is a 32-bit bitfield
enum brand_type // equivalent to (you.inv[].special or mitm[].special) % 30
{
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index a29eae68ff..7133545758 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -583,6 +583,14 @@ void set_ident_flags( item_def &item, unsigned long flags )
// don't note twice in those cases.
item.flags |= (ISFLAG_NOTED_ID | ISFLAG_NOTED_GET);
}
+
+ if (item.flags & ISFLAG_KNOW_TYPE && !is_artefact(item))
+ {
+ if (item.base_type == OBJ_WEAPONS)
+ you.seen_weapon[item.sub_type] |= 1 << item.special;
+ if (item.base_type == OBJ_ARMOUR)
+ you.seen_armour[item.sub_type] |= 1 << item.special;
+ }
}
void unset_ident_flags( item_def &item, unsigned long flags )
@@ -2494,3 +2502,15 @@ const char* weapon_base_name(unsigned char subtype)
{
return Weapon_prop[Weapon_index[subtype]].name;
}
+
+void seen_item(const item_def &item)
+{
+ if (!is_artefact(item))
+ {
+ // Known brands will be set in set_item_flags().
+ if (item.base_type == OBJ_WEAPONS)
+ you.seen_weapon[item.sub_type] |= 1 << SP_UNKNOWN_BRAND;
+ if (item.base_type == OBJ_ARMOUR)
+ you.seen_armour[item.sub_type] |= 1 << SP_UNKNOWN_BRAND;
+ }
+}
diff --git a/crawl-ref/source/itemprop.h b/crawl-ref/source/itemprop.h
index d1231bc9f5..e080c7ac22 100644
--- a/crawl-ref/source/itemprop.h
+++ b/crawl-ref/source/itemprop.h
@@ -166,4 +166,5 @@ equipment_type get_item_slot(const item_def& item);
std::string item_base_name(const item_def &item);
const char* weapon_base_name(unsigned char subtype);
+void seen_item(const item_def &item);
#endif
diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc
index 9bae095a87..f7aca1abb3 100644
--- a/crawl-ref/source/items.cc
+++ b/crawl-ref/source/items.cc
@@ -1460,6 +1460,7 @@ int find_free_slot(const item_def &i)
static void _got_item(item_def& item, int quant)
{
+ seen_item(item);
shopping_list.cull_identical_items(item);
if (!is_rune(item))
diff --git a/crawl-ref/source/main.cc b/crawl-ref/source/main.cc
index 9a46737ce1..7de3206765 100644
--- a/crawl-ref/source/main.cc
+++ b/crawl-ref/source/main.cc
@@ -4588,6 +4588,12 @@ static void _compile_time_asserts()
// item.special, so make sure they don't overlap.
COMPILE_CHECK((int) NUM_SPECIAL_WEAPONS < (int) UNRAND_START, c10);
+ // We have space for 32 brands in the bitfield.
+ COMPILE_CHECK((int) SP_UNKNOWN_BRAND < 8*sizeof(you.seen_weapon[0]), c11);
+ COMPILE_CHECK((int) SP_UNKNOWN_BRAND < 8*sizeof(you.seen_armour[0]), c12);
+ COMPILE_CHECK(NUM_SPECIAL_WEAPONS <= SP_UNKNOWN_BRAND, c13);
+ COMPILE_CHECK(NUM_SPECIAL_ARMOURS <= SP_UNKNOWN_BRAND, c14);
+
// Also some runtime stuff; I don't know if the order of branches[]
// needs to match the enum, but it currently does.
for (int i = 0; i < NUM_BRANCHES; ++i)
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 9a44db2e71..babd15e4ad 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -14,6 +14,7 @@
#include "species.h"
#include <vector>
+#include <stdint.h>
#ifdef USE_TILE
struct dolls_data
@@ -234,6 +235,8 @@ public:
FixedVector<bool, NUM_FIXED_BOOKS> had_book;
FixedVector<bool, NUM_SPELLS> seen_spell;
+ FixedVector<uint32_t, NUM_WEAPONS> seen_weapon;
+ FixedVector<uint32_t, NUM_ARMOURS> seen_armour;
unsigned char normal_vision; // how far the species gets to see
unsigned char current_vision; // current sight radius (cells)
diff --git a/crawl-ref/source/stash.cc b/crawl-ref/source/stash.cc
index f40dc4005e..79aebb3ce1 100644
--- a/crawl-ref/source/stash.cc
+++ b/crawl-ref/source/stash.cc
@@ -724,6 +724,8 @@ void Stash::add_item(const item_def &item, bool add_to_front)
else
items.push_back(item);
+ seen_item(item);
+
if (!_is_rottable(item))
return;
diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc
index 82a2f462ab..612f938b56 100644
--- a/crawl-ref/source/tags.cc
+++ b/crawl-ref/source/tags.cc
@@ -1176,6 +1176,14 @@ static void tag_construct_you_items(writer &th)
marshallShort(th, NUM_SPELLS);
for (j = 0; j < NUM_SPELLS; ++j)
marshallByte(th,you.seen_spell[j]);
+
+ marshallShort(th, NUM_WEAPONS);
+ for (j = 0; j < NUM_WEAPONS; ++j)
+ marshallLong(th,you.seen_weapon[j]);
+
+ marshallShort(th, NUM_ARMOURS);
+ for (j = 0; j < NUM_ARMOURS; ++j)
+ marshallLong(th,you.seen_armour[j]);
}
static void marshallPlaceInfo(writer &th, PlaceInfo place_info)
@@ -1633,8 +1641,30 @@ static void tag_read_you_items(reader &th, char minorVersion)
// how many spells?
count_s = unmarshallShort(th);
+ if (count_s > NUM_SPELLS)
+ count_s = NUM_SPELLS;
for (j = 0; j < count_s; ++j)
you.seen_spell[j] = unmarshallByte(th);
+
+#if (TAG_MAJOR_VERSION == 14)
+if (th.getMinorVersion() >= 1)
+{
+#endif
+ count_s = unmarshallShort(th);
+ if (count_s > NUM_WEAPONS)
+ count_s = NUM_WEAPONS;
+ for (j = 0; j < count_s; ++j)
+ you.seen_weapon[j] = unmarshallLong(th);
+
+ count_s = unmarshallShort(th);
+ if (count_s > NUM_ARMOURS)
+ count_s = NUM_ARMOURS;
+ for (j = 0; j < count_s; ++j)
+ you.seen_armour[j] = unmarshallLong(th);
+#if (TAG_MAJOR_VERSION == 14)
+}
+#endif
+
}
static PlaceInfo unmarshallPlaceInfo(reader &th)
diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h
index bc5045bec8..dd04e1df0e 100644
--- a/crawl-ref/source/tags.h
+++ b/crawl-ref/source/tags.h
@@ -47,7 +47,7 @@ enum tag_major_version
enum tag_minor_version
{
TAG_MINOR_RESET = 0, // Minor tags were reset
- TAG_MINOR_VERSION = 0 // Current version. (Keep equal to max.)
+ TAG_MINOR_VERSION = 1 // Current version. (Keep equal to max.)
};
struct enum_info