diff options
Diffstat (limited to 'crawl-ref/source/util/levcomp.ypp')
-rw-r--r-- | crawl-ref/source/util/levcomp.ypp | 31 |
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); } ; |