diff options
author | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 14:20:44 +0000 |
---|---|---|
committer | dshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573> | 2007-07-08 14:20:44 +0000 |
commit | 8fda0acad5c6c6bf377684d2c14de56ea2e77adf (patch) | |
tree | ca6f9ca80d911f17e3ac9543230bb25d1f9fe225 /crawl-ref | |
parent | cb8c16f0c7b880d19b9e6f38b8ac697d8c2f885d (diff) | |
download | crawl-ref-8fda0acad5c6c6bf377684d2c14de56ea2e77adf.tar.gz crawl-ref-8fda0acad5c6c6bf377684d2c14de56ea2e77adf.zip |
Fixed level-compiler not warning of maps with the same name consistently.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1799 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/mapdef.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/mapdef.h | 19 | ||||
-rw-r--r-- | crawl-ref/source/maps.cc | 9 | ||||
-rw-r--r-- | crawl-ref/source/maps.h | 17 | ||||
-rw-r--r-- | crawl-ref/source/util/levcomp.ypp | 23 |
5 files changed, 46 insertions, 27 deletions
diff --git a/crawl-ref/source/mapdef.cc b/crawl-ref/source/mapdef.cc index 809b278c4b..70b128a6d3 100644 --- a/crawl-ref/source/mapdef.cc +++ b/crawl-ref/source/mapdef.cc @@ -1093,6 +1093,7 @@ void map_def::init() main.clear(); validate.clear(); veto.clear(); + place_loaded_from.clear(); reinit(); } @@ -1187,6 +1188,8 @@ void map_def::write_index(FILE *outf) const end(1, false, "Map %s: can't write index - cache offset not set!", name.c_str()); writeString(outf, name); + writeString(outf, place_loaded_from.filename); + writeLong(outf, place_loaded_from.lineno); writeShort(outf, orient); writeLong(outf, chance); writeLong(outf, cache_offset); @@ -1199,6 +1202,8 @@ void map_def::write_index(FILE *outf) const void map_def::read_index(FILE *inf) { name = readString(inf); + place_loaded_from.filename = readString(inf); + place_loaded_from.lineno = readLong(inf); orient = static_cast<map_section_type>( readShort(inf) ); chance = readLong(inf); cache_offset = readLong(inf); diff --git a/crawl-ref/source/mapdef.h b/crawl-ref/source/mapdef.h index 79a9bb3a07..ddc64fe240 100644 --- a/crawl-ref/source/mapdef.h +++ b/crawl-ref/source/mapdef.h @@ -468,6 +468,23 @@ struct dlua_set_map class map_def; dungeon_feature_type map_feature(map_def *map, const coord_def &c, int rawfeat); +struct map_file_place +{ + std::string filename; + int lineno; + + map_file_place(const std::string &s = "", int line = 0) + : filename(s), lineno(line) + { + } + + void clear() + { + filename.clear(); + lineno = 0; + } +}; + class map_def { public: @@ -487,6 +504,8 @@ public: dlua_chunk prelude, main, validate, veto; + map_file_place place_loaded_from; + map_def *original; private: diff --git a/crawl-ref/source/maps.cc b/crawl-ref/source/maps.cc index 1d609e3929..73dc38c0ad 100644 --- a/crawl-ref/source/maps.cc +++ b/crawl-ref/source/maps.cc @@ -384,6 +384,7 @@ map_def lc_map; level_range lc_range; depth_ranges lc_default_depths; bool lc_run_global_prelude = true; +map_load_info_t lc_loaded_maps; std::set<std::string> map_files_read; @@ -468,8 +469,11 @@ static bool load_map_index(const std::string &base) vdefs.resize( nexist + nmaps, map_def() ); for (int i = 0; i < nmaps; ++i) { - vdefs[nexist + i].read_index(inf); - vdefs[nexist + i].set_file(base); + map_def &vdef(vdefs[nexist + i]); + vdef.read_index(inf); + vdef.set_file(base); + lc_loaded_maps[vdef.name] = vdef.place_loaded_from; + vdef.place_loaded_from.clear(); } fclose(inf); @@ -597,6 +601,7 @@ void read_maps() // Clean up cached environments. dlua.callfn("dgn_flush_map_environments", 0, 0); + lc_loaded_maps.clear(); } void add_parsed_map( const map_def &md ) diff --git a/crawl-ref/source/maps.h b/crawl-ref/source/maps.h index 5fdc288f95..dd38701b68 100644 --- a/crawl-ref/source/maps.h +++ b/crawl-ref/source/maps.h @@ -53,13 +53,16 @@ void reset_map_parser(); std::string get_descache_path(const std::string &file, const std::string &ext); -extern std::string lc_desfile; -extern map_def lc_map; -extern level_range lc_range; -extern depth_ranges lc_default_depths; -extern dlua_chunk lc_global_prelude; -extern bool lc_run_global_prelude; +typedef std::map<std::string, map_file_place> map_load_info_t; -const int MAP_CACHE_VERSION = 1004; +extern map_load_info_t lc_loaded_maps; +extern std::string lc_desfile; +extern map_def lc_map; +extern level_range lc_range; +extern depth_ranges lc_default_depths; +extern dlua_chunk lc_global_prelude; +extern bool lc_run_global_prelude; + +const int MAP_CACHE_VERSION = 1005; #endif diff --git a/crawl-ref/source/util/levcomp.ypp b/crawl-ref/source/util/levcomp.ypp index d3470e7baf..0da88b1ce1 100644 --- a/crawl-ref/source/util/levcomp.ypp +++ b/crawl-ref/source/util/levcomp.ypp @@ -15,21 +15,6 @@ 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) { if (strstr(e, lc_desfile.c_str()) == e) @@ -143,9 +128,9 @@ name : NAME STRING lc_map.name = $2; map_load_info_t::const_iterator i = - loaded_maps.find($2); + lc_loaded_maps.find($2); - if (i != loaded_maps.end()) + if (i != lc_loaded_maps.end()) { yyerror( make_stringf( @@ -155,7 +140,9 @@ name : NAME STRING i->second.lineno).c_str() ); } - loaded_maps[$2] = map_file_place(lc_desfile, yylineno); + lc_map.place_loaded_from = + map_file_place(lc_desfile, yylineno); + lc_loaded_maps[$2] = lc_map.place_loaded_from; } ; |