summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-24 16:27:58 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-24 16:27:58 +0000
commit93f5fdd067279f953af9440fa7c712985e6ecf34 (patch)
tree177f36448c1dbeedf772d627e654714c704d6b22 /crawl-ref/source/mapdef.h
parentc633d5d2b956aab18819d51236982db57ee17134 (diff)
downloadcrawl-ref-93f5fdd067279f953af9440fa7c712985e6ecf34.tar.gz
crawl-ref-93f5fdd067279f953af9440fa7c712985e6ecf34.zip
Implemented .des file caching (speeds startup a fair bit): .des files are
parsed only once (unless they're modified again). Crawl also keeps only map stubs in memory (name, place, orient, tags) and loads the map body only when it is actually selected by the dungeon builder. This probably breaks the Windows build, will be fixed soonish. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1637 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.h')
-rw-r--r--crawl-ref/source/mapdef.h21
1 files changed, 20 insertions, 1 deletions
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index bf6251597e..94bad0bc8f 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -11,6 +11,7 @@
#include <string>
#include <vector>
+#include <cstdio>
#include "luadgn.h"
#include "enum.h"
@@ -41,6 +42,9 @@ public:
bool matches(const level_id &) const;
bool matches(int depth) const;
+ void write(FILE *) const;
+ void read(FILE *);
+
bool valid() const;
int span() const;
@@ -390,6 +394,9 @@ typedef std::map<int, keyed_mapspec> keyed_specs;
typedef std::vector<level_range> depth_ranges;
+// Lua chunks cannot exceed 512K. Which is plenty!
+const int LUA_CHUNK_MAX_SIZE = 512 * 1024;
+
class map_def
{
public:
@@ -413,16 +420,25 @@ private:
// This map has been loaded from an index, and not fully realised.
bool index_only;
long cache_offset;
+ std::string file;
public:
map_def();
void init();
void reinit();
+ void load();
+
+ void write_index(FILE *) const;
+ void write_full(FILE *);
+
+ void read_index(FILE *);
+ void read_full(FILE *);
+
void set_file(const std::string &s);
std::string run_lua(bool skip_main);
void run_strip_prelude();
- void strip_lua();
+ void strip_main();
std::string validate();
@@ -463,6 +479,9 @@ public:
std::vector<std::string> get_subst_strings() const;
private:
+ void write_depth_ranges(FILE *) const;
+ void read_depth_ranges(FILE *);
+
std::string add_key_field(
const std::string &s,
std::string (keyed_mapspec::*set_field)(