Example #1
0
gamemap::gamemap(const config& cfg, const config& level):
		tiles_(1),
		terrainList_(),
		tcodeToTerrain_(),
		villages_(),
		borderCache_(),
		terrainFrequencyCache_(),
		w_(-1),
		h_(-1),
		total_width_(0),
		total_height_(0),
		border_size_(gamemap::SINGLE_TILE_BORDER),
		usage_(IS_MAP)
{
	DBG_G << "loading map: '" << level.debug() << "'\n";
	const config::const_child_itors &terrains = cfg.child_range("terrain_type");
	create_terrain_maps(terrains, terrainList_, tcodeToTerrain_);

	const config& map_child = level.child_or_empty("map");

	if (map_child.empty()) {
		const std::string& map_data = level["map_data"];
		if (!map_data.empty()) {
			read(map_data);
		} else {
			w_ = 0;
			h_ = 0;
			total_width_ = 0;
			total_height_ = 0;
		}
	} else {
		read(map_child["data"], true, map_child["border_size"], map_child["usage"]);
	}
}
Example #2
0
gamemap::gamemap(const config& cfg, const std::string& data):
		tiles_(1),
		terrainList_(),
		tcodeToTerrain_(),
		villages_(),
		borderCache_(),
		terrainFrequencyCache_(),
		w_(-1),
		h_(-1),
		total_width_(0),
		total_height_(0),
		border_size_(NO_BORDER),
		usage_(IS_MAP)
{
	DBG_G << "loading map: '" << data << "'\n";
	const config::const_child_itors &terrains = cfg.child_range("terrain_type");
	create_terrain_maps(terrains, terrainList_, tcodeToTerrain_);

	read(data);
}