OpenRA/OpenRA · error · MapGenerationException

ForestClumpiness must be >= 0

Error message

ForestClumpiness must be >= 0

What it means

Validate() checks that ForestClumpiness is >= 0. ForestClumpiness controls how tightly forest patches cluster together during generation. Negative values would produce invalid clustering behavior. The field defaults to 0 and is [FieldLoader.Require].

Source

Thrown at OpenRA.Mods.Common/Traits/World/ClassicMapGenerator.cs:329

					throw new MapGenerationException($"TerrainSmoothing must be between 0 and {MatrixUtils.MaxBinomialKernelRadius} inclusive");
				if (WaterRoughness > 0 && MinimumCoastStraight < 0)
					throw new MapGenerationException("MinimumCoastStraight must be >= 0");
				if (SmoothingThreshold < (FractionMax + 1) / 2 || SmoothingThreshold > FractionMax)
					throw new MapGenerationException($"SmoothingThreshold must be between {(FractionMax + 1) / 2} and {FractionMax} inclusive");
				if (MinimumLandSeaThickness < 1)
					throw new MapGenerationException("MinimumLandSeaThickness must be >= 1");
				if (MinimumMountainThickness < 1)
					throw new MapGenerationException("MinimumMountainThickness must be >= 1");
				if (Water < 0 || Water > FractionMax)
					throw new MapGenerationException($"Water must be between 0 and {FractionMax} inclusive");
				if (Forests < 0 || Forests > FractionMax)
					throw new MapGenerationException($"Forest must be between 0 and {FractionMax} inclusive");
				if (ForestCutout < 0)
					throw new MapGenerationException("ForestCutout must be >= 0");
				if (MaximumCutoutSpacing < 0)
					throw new MapGenerationException("TopologyAugmentationThreshold must be >= 0");
				if (ForestClumpiness < 0)
					throw new MapGenerationException("ForestClumpiness must be >= 0");
				if (Mountains < 0 || Mountains > FractionMax)
					throw new MapGenerationException($"Mountains must be between 0 and {FractionMax} inclusive");
				if (Roughness < 0 || Roughness > FractionMax)
					throw new MapGenerationException("Roughness must be between 0 and {FractionMax}");
				if (WaterRoughness < 0 || WaterRoughness > FractionMax)
					throw new MapGenerationException("WaterRoughness must be between 0 and {FractionMax}");
				if (RoughnessRadius < 1)
					throw new MapGenerationException("RoughnessRadius must be >= 1");
				if (MaximumAltitude < 0)
					throw new MapGenerationException("MaximumAltitude must be >= 0");
				if (MinimumTerrainContourSpacing < 0)
					throw new MapGenerationException("MinimumTerrainContourSpacing must be >= 0");
				if (WaterRoughness > 0 && MinimumBeachLength < 1)
					throw new MapGenerationException("MinimumBeachLength must be >= 1");
				if (WaterRoughness > 0 && MinimumCliffLength < 1)
					throw new MapGenerationException("MinimumWaterCliffLength must be >= 1");
				if (MinimumCliffLength < 1)
					throw new MapGenerationException("MinimumCliffLength must be >= 1");

View on GitHub (pinned to a520984d91)

Solutions

  1. Set ForestClumpiness to 0 or a positive integer
  2. 0 means minimal clumping; higher values create denser, more connected forest patches
  3. Ensure the YAML value is a non-negative bare integer

Example fix

# before
ForestClumpiness: -10
# after
ForestClumpiness: 0
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight check: ForestClumpiness must be >= 0
static void ValidateForestClumpiness(int clumpiness)
{
    if (clumpiness < 0)
        throw new ArgumentOutOfRangeException(nameof(clumpiness),
            "ClassicMapGenerator ForestClumpiness must be >= 0");
}

Type guard

static bool IsNonNegative(int value) => value >= 0;

Try / catch

try
{
    var param = new Parameters(map, yaml);
}
catch (MapGenerationException ex) when (ex.Message.Contains("ForestClumpiness"))
{
    Console.Error.WriteLine($"Invalid ForestClumpiness: {ex.Message}");
}

Prevention

When it happens

Trigger: The ForestClumpiness key is set to a negative number in the generator YAML.

Common situations: Negative value entered accidentally or via sign error. Mod developer experiments with negative clumpiness expecting more scattered forests.

Related errors


AI-assisted analysis of OpenRA/OpenRA@a520984d91 (2026-08-13). Data as JSON: /api/errors/320b18669c844750. Report an issue: GitHub.