summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/util/levcomp.ypp
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-20 14:15:49 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-02-20 14:15:49 +0000
commit2245a9af95475ef1bd76045fab6856ecf31823f6 (patch)
tree4c23f4cc2f56dfaa3d4c272b3cf12bdc95c80857 /crawl-ref/source/util/levcomp.ypp
parentfa27b5e7cb607e9718e2ebd43af84940ff977aa2 (diff)
downloadcrawl-ref-2245a9af95475ef1bd76045fab6856ecf31823f6.tar.gz
crawl-ref-2245a9af95475ef1bd76045fab6856ecf31823f6.zip
Level compiler now croaks if two maps have the same name.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@957 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/util/levcomp.ypp')
-rw-r--r--crawl-ref/source/util/levcomp.ypp31
1 files changed, 31 insertions, 0 deletions
diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp
index 658e6736cf..4adbdfb486 100644
--- a/crawl-ref/source/util/levcomp.ypp
+++ b/crawl-ref/source/util/levcomp.ypp
@@ -4,11 +4,27 @@
#include "libutil.h"
#include "levcomp.h"
#include "stuff.h"
+#include <map>
int yylex();
extern int yylineno;
+struct map_file_place
+{
+ std::string filename;
+ int lineno;
+
+ map_file_place(const std::string &s = "", int line = 0)
+ : filename(s), lineno(line)
+ {
+ }
+};
+
+typedef std::map<std::string, map_file_place> map_load_info_t;
+
+static map_load_info_t loaded_maps;
+
void yyerror(const char *e)
{
fprintf(stderr, "%s:%d: %s\n", lc_desfile.c_str(), yylineno, e);
@@ -114,6 +130,21 @@ name : NAME STRING
lc_map.init();
lc_map.depth = lc_default_depth;
lc_map.name = $2;
+
+ map_load_info_t::const_iterator i =
+ loaded_maps.find($2);
+
+ if (i != loaded_maps.end())
+ {
+ yyerror(
+ make_stringf(
+ "Map named '%s' already loaded at %s:%d",
+ $2,
+ i->second.filename.c_str(),
+ i->second.lineno).c_str() );
+ }
+
+ loaded_maps[$2] = map_file_place(lc_desfile, yylineno);
}
;