Ejemplo n.º 1
0
bool WorldSection::parseField(const std::string key, const std::string value,
		ValidationList& validation) {
	if (key == "input_dir") {
		if (input_dir.load(key, value, validation)) {
			input_dir.setValue(BOOST_FS_ABSOLUTE(input_dir.getValue(), config_dir));
			if (!fs::is_directory(input_dir.getValue()))
				validation.error("'input_dir' must be an existing directory! '"
						+ input_dir.getValue().string() + "' does not exist!");
		}
	} else if (key == "dimension")
		dimension.load(key, value, validation);
	else if (key == "world_name")
		world_name.load(key, value, validation);

	else if (key == "default_view")
		default_view.load(key, value, validation);
	else if (key == "default_zoom")
		default_zoom.load(key, value, validation);
	else if (key == "default_rotation") {
		int rotation = stringToRotation(value, ROTATION_NAMES);
		if (rotation == -1)
			validation.error("Invalid rotation '" + value + "'!");
		default_rotation.setValue(rotation);
	}

	else if (key == "crop_min_y") {
		if (min_y.load(key, value, validation))
			world_crop.setMinY(min_y.getValue());
	} else if (key == "crop_max_y") {
		if (max_y.load(key, value, validation))
			world_crop.setMaxY(max_y.getValue());
	} else if (key == "crop_min_x") {
		if (min_x.load(key, value, validation))
			world_crop.setMinX(min_x.getValue());
	} else if (key == "crop_max_x") {
		if (max_x.load(key, value, validation))
			world_crop.setMaxX(max_x.getValue());
	} else if (key == "crop_min_z") {
		if (min_z.load(key, value, validation))
			world_crop.setMinZ(min_z.getValue());
	} else if (key == "crop_max_z") {
		if (max_z.load(key, value, validation))
			world_crop.setMaxZ(max_z.getValue());
	}

	else if (key == "crop_center_x")
		center_x.load(key, value, validation);
	else if (key == "crop_center_z")
		center_z.load(key, value, validation);
	else if (key == "crop_radius")
		radius.load(key, value, validation);

	else if (key == "crop_unpopulated_chunks")
		crop_unpopulated_chunks.load(key, value, validation);
	else if (key == "block_mask")
		block_mask.load(key, value, validation);
	else
		return false;
	return true;
}
Ejemplo n.º 2
0
void MapSection::postParse(const INIConfigSection& section,
		ValidationList& validation) {
	// parse rotations
	rotations_set.clear();
	tile_sets.clear();
	std::string str = rotations.getValue();
	std::stringstream ss;
	ss << str;
	std::string elem;
	while (ss >> elem) {
		int r = stringToRotation(elem);
		if (r != -1) {
			rotations_set.insert(r);
			tile_sets.insert(getTileSet(r));
		} else {
			validation.error("Invalid rotation '" + elem + "'!");
		}
	}

	// check if required options were specified
	if (!isGlobal()) {
		world.require(validation, "You have to specify a world ('world')!");
		texture_dir.require(validation, "You have to specify a texture directory ('texture_dir')!");
	}
}
Ejemplo n.º 3
0
void WorldSection::postParse(const INIConfigSection& section,
		ValidationList& validation) {
	if (default_zoom.isLoaded() && default_zoom.getValue() < 0)
		validation.error("The default zoom level must be bigger or equal to 0 ('default_zoom').");

	// validate the world croppping
	bool crop_rectangular = min_x.isLoaded() || max_x.isLoaded() || min_z.isLoaded() || max_z.isLoaded();
	bool crop_circular = center_x.isLoaded() || center_z.isLoaded() || radius.isLoaded();

	if (crop_rectangular && crop_circular) {
		validation.error("You can not use both world cropping types at the same time!");
	} else if (crop_rectangular) {
		if (min_x.isLoaded() && max_x.isLoaded() && min_x.getValue() > max_x.getValue())
			validation.error("min_x must be smaller than or equal to max_x!");
		if (min_z.isLoaded() && max_z.isLoaded() && min_z.getValue() > max_z.getValue())
			validation.error("min_z must be smaller than or equal to max_z!");
	} else if (crop_circular) {
		std::string message = "You have to specify crop_center_x, crop_center_z "
				"and crop_radius for circular world cropping!";
		center_x.require(validation, message)
			&& center_z.require(validation, message)
			&& radius.require(validation, message);

		world_crop.setCenter(mc::BlockPos(center_x.getValue(), center_z.getValue(), 0));
		world_crop.setRadius(radius.getValue());
	}

	if (min_y.isLoaded() && max_y.isLoaded() && min_y.getValue() > max_y.getValue())
		validation.error("min_y must be smaller than or equal to max_y!");

	world_crop.setCropUnpopulatedChunks(crop_unpopulated_chunks.getValue());
	if (block_mask.isLoaded()) {
		try {
			world_crop.loadBlockMask(block_mask.getValue());
		} catch (std::invalid_argument& exception) {
			validation.error(std::string("There is a problem parsing the block mask: ")
				+ exception.what());
		}
	}

	// check if required options were specified
	if (!isGlobal()) {
		input_dir.require(validation, "You have to specify an input directory ('input_dir')!");
	}
}
Ejemplo n.º 4
0
bool MapSection::parseField(const std::string key, const std::string value,
		ValidationList& validation) {
	if (key == "name") {
		name_long = value;
	} else if (key == "world") {
		world.load(key, value, validation);
	} else if (key == "render_view") {
		render_view.load(key, value, validation);
	} else if (key == "render_mode" || key == "rendermode") {
		render_mode.load(key, value, validation);
		if (key == "rendermode")
			validation.warning("Using the option 'rendermode' is deprecated. "
					"It's called 'render_mode' now.");
	} else if (key == "overlay") {
		overlay.load(key, value, validation);
	} else if (key == "rotations") {
		rotations.load(key, value ,validation);
	} else if (key == "texture_dir") {
		if (texture_dir.load(key, value, validation)) {
			texture_dir.setValue(BOOST_FS_ABSOLUTE(texture_dir.getValue(), config_dir));
			if (!fs::is_directory(texture_dir.getValue()))
				validation.error("'texture_dir' must be an existing directory! '"
						+ texture_dir.getValue().string() + "' does not exist!");
		}
	} else if (key == "texture_blur") {
		texture_blur.load(key, value, validation);
	} else if (key == "texture_size") {
		if (texture_size.load(key, value, validation)
				&& (texture_size.getValue() <= 0  || texture_size.getValue() > 32))
			validation.error("'texture_size' must be a number between 1 and 32!");
	} else if (key == "water_opacity") {
		if (water_opacity.load(key, value, validation)
				&& (water_opacity.getValue() < 0 || water_opacity.getValue() >= 1.0))
			validation.error("'water_opacity' must be a number between 0.0 and 1.0!");
	} else if (key == "tile_width") {
		tile_width.load(key, value, validation);
		if (tile_width.getValue() < 1)
			validation.error("'tile_width' must be a positive number!");
	} else if (key == "image_format") {
		image_format.load(key, value, validation);
	} else if (key == "png_indexed") {
		png_indexed.load(key, value, validation);
	} else if (key == "jpeg_quality") {
		if (jpeg_quality.load(key, value, validation)
				&& (jpeg_quality.getValue() < 0 || jpeg_quality.getValue() > 100))
			validation.error("'jpeg_quality' must be a number between 0 and 100!");
	} else if (key == "lighting_intensity") {
		lighting_intensity.load(key, value, validation);
	} else if (key == "lighting_water_intensity") {
		lighting_water_intensity.load(key, value, validation);
	} else if (key == "render_unknown_blocks") {
		render_unknown_blocks.load(key, value, validation);
	} else if (key == "render_leaves_transparent") {
		render_leaves_transparent.load(key, value, validation);
	} else if (key == "render_biomes") {
		render_biomes.load(key, value, validation);
	} else if (key == "use_image_mtimes") {
		use_image_mtimes.load(key, value, validation);
	} else
		return false;
	return true;
}