00001
00002
00003
00004
00005
00006
00007
00008 #ifndef MAPS_H
00009 #define MAPS_H
00010
00011 #include <vector>
00012
00013 #include "mapdef.h"
00014
00015 struct level_range;
00016 class map_def;
00017 struct map_file_place;
00018 struct vault_placement;
00019
00020 typedef std::vector<map_def> map_vector;
00021 typedef std::vector<const map_def *> mapref_vector;
00022
00023 bool map_safe_vault_place(const map_def &md,
00024 const coord_def &c,
00025 const coord_def &size);
00026
00027 map_section_type vault_main(vault_placement &vp, const map_def *vault,
00028 bool check_place = false);
00029
00030 bool resolve_subvault(map_def &vault);
00031
00032
00033
00034 void fit_region_into_map_bounds(coord_def &pos, const coord_def &size,
00035 int margin = 0);
00036
00037 const map_def *map_by_index(int index);
00038 void strip_all_maps();
00039 int map_count();
00040 int map_count_for_tag(const std::string &tag, bool check_depth = false);
00041
00042 const map_def *find_map_by_name(const std::string &name);
00043 const map_def *random_map_for_place(const level_id &place, bool minivault);
00044 const map_def *random_map_in_depth(const level_id &lid,
00045 bool want_minivault = false);
00046 const map_def *random_map_for_tag(const std::string &tag,
00047 bool check_depth = false,
00048 bool check_chance = false);
00049 mapref_vector random_chance_maps_in_depth(const level_id &place);
00050
00051 void dump_map(const map_def &map);
00052 void add_parsed_map(const map_def &md);
00053
00054 std::vector<std::string> find_map_matches(const std::string &name);
00055
00056 mapref_vector find_maps_for_tag (const std::string tag,
00057 bool check_depth = false,
00058 bool check_used = true);
00059
00060 int weight_map_vector (std::vector<map_def> maps);
00061
00062 void read_maps();
00063 void reread_maps();
00064 void sanity_check_maps();
00065 void read_map(const std::string &file);
00066 void run_map_global_preludes();
00067 void run_map_local_preludes();
00068 void reset_map_parser();
00069 std::string get_descache_path(const std::string &file,
00070 const std::string &ext);
00071
00072 typedef std::map<std::string, map_file_place> map_load_info_t;
00073
00074 extern map_load_info_t lc_loaded_maps;
00075 extern std::string lc_desfile;
00076 extern map_def lc_map;
00077 extern level_range lc_range;
00078 extern depth_ranges lc_default_depths;
00079 extern dlua_chunk lc_global_prelude;
00080 extern bool lc_run_global_prelude;
00081
00082 typedef bool (*map_place_check_t)(const map_def &, const coord_def &c,
00083 const coord_def &size);
00084
00085 typedef std::vector<coord_def> point_vector;
00086 typedef std::vector<std::string> string_vector;
00087
00088 extern map_place_check_t map_place_valid;
00089 extern point_vector map_anchor_points;
00090
00091
00092 extern string_vector map_parameters;
00093
00094 const int MAP_CACHE_VERSION = 1017;
00095
00096 class dgn_map_parameters
00097 {
00098 public:
00099 dgn_map_parameters(const std::string &astring);
00100 dgn_map_parameters(const string_vector ¶meters);
00101 private:
00102 unwind_var<string_vector> mpar;
00103 };
00104
00105 #ifdef DEBUG_DIAGNOSTICS
00106 void mg_report_random_maps(FILE *outf, const level_id &place);
00107 #endif
00108
00109 #endif