summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapmark.cc
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-12 06:09:15 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2007-11-12 06:09:15 +0000
commit3a38986e4358d3a989cef881386ecc654b36fa1c (patch)
treec0590eb69702ab13c945dfc9444a83117cb72ad6 /crawl-ref/source/mapmark.cc
parent53ad48697e85f87bb7686d2e030fc3716994406d (diff)
downloadcrawl-ref-3a38986e4358d3a989cef881386ecc654b36fa1c.tar.gz
crawl-ref-3a38986e4358d3a989cef881386ecc654b36fa1c.zip
Lua map markers can now be generated in C code from
map_lua_marker::parse_marker() by prefixing the Lua string with "lua_mapless:" rather than "lua:". Fog machines can be created and placed from within C code via place_fog_machine(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2843 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapmark.cc')
-rw-r--r--crawl-ref/source/mapmark.cc37
1 files changed, 28 insertions, 9 deletions
diff --git a/crawl-ref/source/mapmark.cc b/crawl-ref/source/mapmark.cc
index a427749e9b..77a3db7aa1 100644
--- a/crawl-ref/source/mapmark.cc
+++ b/crawl-ref/source/mapmark.cc
@@ -161,14 +161,24 @@ map_lua_marker::map_lua_marker()
{
}
-map_lua_marker::map_lua_marker(const std::string &s, const std::string &)
+map_lua_marker::map_lua_marker(const std::string &s, const std::string &,
+ bool mapdef_marker)
: map_marker(MAT_LUA_MARKER, coord_def()), initialised(false)
{
lua_stack_cleaner clean(dlua);
- if (dlua.loadstring(("return " + s).c_str(), "lua_marker"))
- mprf(MSGCH_WARN, "lua_marker load error: %s", dlua.error.c_str());
- if (!dlua.callfn("dgn_run_map", 1, 1))
- mprf(MSGCH_WARN, "lua_marker exec error: %s", dlua.error.c_str());
+ if (mapdef_marker)
+ {
+ if (dlua.loadstring(("return " + s).c_str(), "lua_marker"))
+ mprf(MSGCH_WARN, "lua_marker load error: %s", dlua.error.c_str());
+ if (!dlua.callfn("dgn_run_map", 1, 1))
+ mprf(MSGCH_WARN, "lua_marker exec error: %s", dlua.error.c_str());
+ }
+ else
+ {
+ if (dlua.execstring(("return " + s).c_str(), "lua_marker_mapless", 1))
+ mprf(MSGCH_WARN, "lua_marker_mapless exec error: %s",
+ dlua.error.c_str());
+ }
check_register_table();
}
@@ -369,11 +379,20 @@ std::string map_lua_marker::property(const std::string &pname) const
map_marker *map_lua_marker::parse(
const std::string &s, const std::string &ctx) throw (std::string)
{
- if (s.find("lua:") != 0)
+ std::string raw = s;
+ bool mapdef_marker = true;
+
+ if (s.find("lua:") == 0)
+ strip_tag(raw, "lua:", true);
+ else if (s.find("lua_mapless:") == 0)
+ {
+ strip_tag(raw, "lua_mapless:", true);
+ mapdef_marker = false;
+ }
+ else
return (NULL);
- std::string raw = s;
- strip_tag(raw, "lua:", true);
- map_lua_marker *mark = new map_lua_marker(raw, ctx);
+
+ map_lua_marker *mark = new map_lua_marker(raw, ctx, mapdef_marker);
if (!mark->initialised)
{
delete mark;