summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.h
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-18 20:09:38 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-11-18 20:09:38 +0000
commit42c0cf066213e022a8f1f0ea4230b668095c605b (patch)
tree792728ce498a6c6160a9cba6cd49f86ed3c4d887 /crawl-ref/source/mapdef.h
parent82cc08db3375be0e6ab3b871f7dde5916ed67c30 (diff)
downloadcrawl-ref-42c0cf066213e022a8f1f0ea4230b668095c605b.tar.gz
crawl-ref-42c0cf066213e022a8f1f0ea4230b668095c605b.zip
Lua marker code is now converted into an anonymous function in the same scope as the rest of the map Lua code so that locals defined in the map Lua are visible to the marker code.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7479 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.h')
-rw-r--r--crawl-ref/source/mapdef.h24
1 files changed, 22 insertions, 2 deletions
diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h
index 775f2e82b2..83098d2b5a 100644
--- a/crawl-ref/source/mapdef.h
+++ b/crawl-ref/source/mapdef.h
@@ -15,6 +15,7 @@
#include <string>
#include <vector>
#include <cstdio>
+#include <memory>
#include "luadgn.h"
#include "enum.h"
@@ -202,15 +203,25 @@ class shuffle_spec : public map_transformer
class map_marker_spec : public map_transformer
{
- public:
+public:
int key;
std::string marker;
+ // Special handling for Lua markers:
+ std::auto_ptr<lua_datum> lua_fn;
+
map_marker_spec(int _key, const std::string &mark)
- : key(_key), marker(mark) { }
+ : key(_key), marker(mark), lua_fn() { }
+
+ map_marker_spec(int _key, const lua_datum &fn)
+ : key(_key), marker(), lua_fn(new lua_datum(fn)) { }
+
std::string apply_transform(map_lines &map);
transform_type type() const;
std::string describe() const;
+
+private:
+ map_marker *create_marker();
};
class map_def;
@@ -266,6 +277,8 @@ public:
void add_marker(map_marker *marker);
std::string add_feature_marker(const std::string &desc);
+ std::string add_lua_marker(const std::string &key,
+ const lua_datum &fn);
void apply_markers(const coord_def &pos);
void apply_colours(const coord_def &pos);
@@ -742,6 +755,13 @@ private:
std::string escape_string(std::string in, const std::string &toesc,
const std::string &escapewith);
+
+std::string mapdef_split_key_item(const std::string &s,
+ std::string *key,
+ int *separator,
+ std::string *arg,
+ int key_max_len = 1);
+
const char *map_section_name(int msect);
#endif