Exemplo n.º 1
0
fs::path findExecutableMapcrafterDir(fs::path executable) {
	std::string filename = BOOST_FS_FILENAME(executable);
	if ((filename == "testconfig" || filename == "mapcrafter_markers") &&
			BOOST_FS_FILENAME(executable.parent_path()) == "tools")
		return executable.parent_path().parent_path();
	return executable.parent_path();
}
Exemplo n.º 2
0
bool World::readRegions(const std::string& path) {
	fs::path region_dir(path);
	if(!fs::exists(region_dir))
		return false;
	std::string ending = ".mca";
	for(fs::directory_iterator it(region_dir); it != fs::directory_iterator(); ++it) {
		std::string region_file = (*it).path().string();
		std::string filename = BOOST_FS_FILENAME((*it).path());

		if(!std::equal(ending.rbegin(), ending.rend(), filename.rbegin()))
			continue;
		int x = 0;
		int z = 0;
		if(sscanf(filename.c_str(), "r.%d.%d.mca", &x, &z) != 2)
			continue;
		RegionPos pos(x, z);
		// check if we should not crop this region
		if (!worldcrop.isRegionContained(pos))
			continue;
		if (rotation)
			pos.rotate(rotation);
		available_regions.insert(pos);
		region_files[pos] = it->path().string();
	}
	return true;
}
Exemplo n.º 3
0
RegionPos RegionPos::byFilename(const std::string& filename) {
	std::string name = BOOST_FS_FILENAME(fs::path(filename));

	int x, z;
	if (sscanf(name.c_str(), "r.%d.%d.mca", &x, &z) != 2)
		throw std::runtime_error("Invalid filename " + name + "!");
	return RegionPos(x, z);
}