From 0f338eb725f33ee68843fb3bc178bfd9bc65cb22 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Thu, 12 Nov 2009 01:05:50 -0800 Subject: Add a CrawlHashTable to monster objects --- crawl-ref/source/monster.cc | 2 +- crawl-ref/source/monster.h | 3 +++ crawl-ref/source/tags.cc | 8 ++++++++ crawl-ref/source/tags.h | 3 ++- 4 files changed, 14 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index db08f3d07e..1982175f14 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -52,7 +52,7 @@ monsters::monsters() inv(NON_ITEM), spells(), attitude(ATT_HOSTILE), behaviour(BEH_WANDER), foe(MHITYOU), enchantments(), flags(0L), experience(0), number(0), colour(BLACK), foe_memory(0), shield_blocks(0), god(GOD_NO_GOD), ghost(), - seen_context("") + seen_context(""), props() { travel_path.clear(); } diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index 26b266ee37..83e9f779d1 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -60,6 +60,7 @@ public: void reset(); public: + // Possibly some of these should be moved into the hash table std::string mname; monster_type type; @@ -102,6 +103,8 @@ public: std::string seen_context; // Non-standard context for // AI_SEE_MONSTER + CrawlHashTable props; + public: mon_attitude_type temp_attitude() const; diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 4b5ab14ae8..0b99e3e2ff 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -1928,6 +1928,8 @@ static void marshall_monster(writer &th, const monsters &m) ASSERT(m.ghost.get()); marshallGhost(th, *m.ghost); } + + m.props.write(th); } static void tag_construct_level_monsters(writer &th) @@ -2246,6 +2248,12 @@ static void unmarshall_monster(reader &th, monsters &m) if (mons_is_ghost_demon(m.type)) m.set_ghost(unmarshallGhost(th, _tag_minor_version)); + if (_tag_minor_version >= TAG_MINOR_MON_PROP) + { + m.props.clear(); + m.props.read(th); + } + m.check_speed(); } diff --git a/crawl-ref/source/tags.h b/crawl-ref/source/tags.h index b843a55329..da4e1211aa 100644 --- a/crawl-ref/source/tags.h +++ b/crawl-ref/source/tags.h @@ -61,7 +61,8 @@ enum tag_minor_version TAG_MINOR_DSTRAITS = 9, // Pre-calculate demonspawn mutations TAG_MINOR_YOU_PROP = 10, // Player class has CrawlHashTable TAG_MINOR_SMALL_HASH = 11, // Reduced RAM size of CrawlHashTable - TAG_MINOR_VERSION = 11 // Current version. (Keep equal to max.) + TAG_MINOR_MON_PROP = 12, // Monster class has CrawlHashTable + TAG_MINOR_VERSION = 12 // Current version. (Keep equal to max.) }; -- cgit v1.2.3-54-g00ecf