summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/tilemcache.h
diff options
context:
space:
mode:
authorennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-06 03:13:34 +0000
committerennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-06 03:13:34 +0000
commita8a183dca9dfa75807dadc556e84b20aab993ce8 (patch)
treef2dcca4db96304a94b07c9282cd02a71f43f64a3 /crawl-ref/source/tilemcache.h
parent7349eedd00eabe85d7e76e457011d48522b97593 (diff)
downloadcrawl-ref-a8a183dca9dfa75807dadc556e84b20aab993ce8.tar.gz
crawl-ref-a8a183dca9dfa75807dadc556e84b20aab993ce8.zip
Tiles mcache improvements. Monsters out of sight are now shown with their last seen equipment. Player ghosts are now drawn correctly again. Denzi's new 48x32 pandemonium demon tiles are now used.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6875 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/tilemcache.h')
-rw-r--r--crawl-ref/source/tilemcache.h80
1 files changed, 80 insertions, 0 deletions
diff --git a/crawl-ref/source/tilemcache.h b/crawl-ref/source/tilemcache.h
new file mode 100644
index 0000000000..d170ae7de2
--- /dev/null
+++ b/crawl-ref/source/tilemcache.h
@@ -0,0 +1,80 @@
+/*
+ * File: tilemcache.h
+ * Summary: Monster cache support
+ * Written by: Enne Walker
+ */
+
+#ifdef USE_TILE
+#ifndef TILEMCACHE_H
+#define TILEMCACHE_H
+
+#include "AppHdr.h"
+#include "debug.h"
+#include <vector>
+
+// The monster cache is designed to hold extra information about monsters that
+// can't be contained in a single tile. This is usually for equipment,
+// doll parts, or demon parts.
+//
+// Monster cache entries for monsters that are out of sight are ref-counted
+// that they can be drawn even if that monster no longer exists. When no
+// out-of-sight tiles refer to them, they can be deleted.
+
+class tile_draw_info
+{
+public:
+ tile_draw_info() : idx(~0), ofs_x(0), ofs_y(0) {}
+
+ void set(unsigned int _idx, int _ofs_x = 0, int _ofs_y = 0)
+ { idx = _idx; _ofs_x = ofs_x; _ofs_y = ofs_y; }
+
+ unsigned int idx;
+ int ofs_x;
+ int ofs_y;
+};
+
+class mcache_entry
+{
+public:
+ mcache_entry() : m_ref_count(0) {}
+ virtual ~mcache_entry() {}
+
+ void inc_ref() { m_ref_count++; }
+ void dec_ref() { m_ref_count--; ASSERT(m_ref_count >= 0); }
+ int ref_count() { return m_ref_count; }
+
+ virtual unsigned int info(tile_draw_info *dinfo) const { return 0; }
+ virtual const dolls_data *doll() const { return NULL; }
+
+ virtual void construct(writer &th);
+
+protected:
+ mcache_entry(reader &th);
+
+ // ref count in backstore
+ int m_ref_count;
+};
+
+class mcache_manager
+{
+public:
+ ~mcache_manager();
+
+ unsigned int register_monster(const monsters *mon);
+ mcache_entry *get(unsigned int idx);
+
+ void clear_nonref();
+ void clear_all();
+
+ void read(reader &th);
+ void construct(writer &th);
+
+protected:
+ std::vector<mcache_entry*> m_entries;
+};
+
+// The global monster cache.
+extern mcache_manager mcache;
+
+#endif
+#endif