summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/mapdef.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-24 19:38:20 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-24 19:38:20 +0000
commit29e85c811ddbf45cc8cb830012abefce8a92009a (patch)
tree0a1ef24f6ffc42389b48dd1f5a665ee9159b1561 /crawl-ref/source/mapdef.cc
parent7a6a09598a661b45bb3d96f48281ea7520370590 (diff)
downloadcrawl-ref-29e85c811ddbf45cc8cb830012abefce8a92009a.tar.gz
crawl-ref-29e85c811ddbf45cc8cb830012abefce8a92009a.zip
Hackily rewrite Lua chunk errors to reflect line numbers from the original
.des file so that level-designers can find the lines that are causing the problem. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1641 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/mapdef.cc')
-rw-r--r--crawl-ref/source/mapdef.cc27
1 files changed, 12 insertions, 15 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc
index 8a4c40ff39..5323c421a0 100644
--- a/crawl-ref/source/mapdef.cc
+++ b/crawl-ref/source/mapdef.cc
@@ -813,7 +813,7 @@ std::vector<std::string> map_lines::get_subst_strings() const
map_def::map_def()
: name(), tags(), place(), depths(), orient(), chance(),
- map(), mons(), items(), keyspecs(), prelude(), main(),
+ map(), mons(), items(), keyspecs(), prelude("dlprelude"), main("dlmain"),
index_only(false), cache_offset(0L)
{
init();
@@ -937,18 +937,6 @@ void map_def::set_file(const std::string &s)
file = get_base_filename(s);
}
-void map_def::run_strip_prelude()
-{
- run_lua(false);
- prelude.clear();
-}
-
-void map_def::strip_main()
-{
- main.clear();
- index_only = true;
-}
-
std::string map_def::run_lua(bool run_main)
{
dlua.callfn("dgn_set_map", "m", this);
@@ -970,14 +958,23 @@ std::string map_def::run_lua(bool run_main)
}
if (!dlua.callfn("dgn_run_map", 2, 0))
- return (dlua.error);
-
+ return rewrite_chunk_errors(dlua.error);
+
// Clear the map setting.
dlua.callfn("dgn_set_map", 0, 0);
return (dlua.error);
}
+std::string map_def::rewrite_chunk_errors(const std::string &s) const
+{
+ std::string res = s;
+ if (prelude.rewrite_chunk_errors(res))
+ return (res);
+ main.rewrite_chunk_errors(res);
+ return (res);
+}
+
std::string map_def::validate()
{
std::string err = run_lua(true);