From 42c0cf066213e022a8f1f0ea4230b668095c605b Mon Sep 17 00:00:00 2001 From: dshaligram Date: Tue, 18 Nov 2008 20:09:38 +0000 Subject: 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 --- crawl-ref/source/mapdef.h | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) (limited to 'crawl-ref/source/mapdef.h') 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 #include #include +#include #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_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 -- cgit v1.2.3-54-g00ecf