OpenRA/OpenRA · error · MapGenerationException

OreUniformity must be >= 0

Error message

OreUniformity must be >= 0

What it means

Thrown when OreUniformity is negative. OreUniformity controls how uniformly ore is spread (higher = more even distribution, lower = patchier); negative values break the resource-generation weighting. Zero is permitted.

Source

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

					throw new MapGenerationException("MaximumResourceSpawnsPerExpansion must be >= 1");
				if (MinimumBuildings < 0)
					throw new MapGenerationException("MinimumBuildings must be >= 0");
				if (MaximumBuildings < 0)
					throw new MapGenerationException("MaximumBuildings must be >= 0");
				if (MinimumBuildings > MaximumBuildings)
					throw new MapGenerationException("MinimumBuildings must be <= maximumBuildings");
				if (CivilianBuildings < 0 || CivilianBuildings > FractionMax)
					throw new MapGenerationException($"CivilianBuildings must be between 0 and {FractionMax} inclusive");
				if (CivilianBuildingDensity < 0 || CivilianBuildingDensity > FractionMax)
					throw new MapGenerationException($"CivilianBuildingDensity must be between 0 and {FractionMax} inclusive");
				if (MinimumCivilianBuildingDensity < 0 || MinimumCivilianBuildingDensity > FractionMax)
					throw new MapGenerationException($"MinimumCivilianBuildingDensity must be between 0 and {FractionMax} inclusive");
				if (CivilianBuildingDensityRadius < 0)
					throw new MapGenerationException("CivilianBuildingDensityRadius must be >= 0");
				if (ResourcesPerPlayer < 0)
					throw new MapGenerationException("ResourcesPerPlayer must be >= 0");
				if (OreUniformity < 0)
					throw new MapGenerationException("OreUniformity must be >= 0");
				if (OreClumpiness < 0)
					throw new MapGenerationException("OreClumpiness must be >= 0");
				foreach (var kv in BuildingWeights)
					if (kv.Value < 0)
						throw new MapGenerationException("BuildingWeights.* must be >= 0");
				foreach (var kv in ResourceSpawnWeights)
					if (kv.Value < 0)
						throw new MapGenerationException("ResourceSpawnWeights.* must be >= 0");
				foreach (var kv in ResourceSpawnWeights)
					if (!ResourceSpawnSeeds.ContainsKey(kv.Key))
						throw new MapGenerationException($"ResourceSpawnSeeds does not contain possible resource spawn `{kv.Key}`");

				if (!(terrainInfo.Templates.TryGetValue(LandTile, out var landTemplate) && landTemplate.Contains(0)))
					throw new MapGenerationException("LandTile is not valid");
				if (!(terrainInfo.Templates.TryGetValue(LandTile, out var waterTemplate) && waterTemplate.Contains(0)))
					throw new MapGenerationException("WaterTile is not valid");

				if (Players > 32)

View on GitHub (pinned to a520984d91)

Solutions

  1. Set OreUniformity to 0 or a positive integer.
  2. Increase it for smoother ore fields, decrease toward 0 for clumpier ore.

Example fix

# before
OreUniformity: -5
# after
OreUniformity: 10
Defensive patterns

Strategy: validation

Validate before calling

if (param.OreUniformity < 0)
    throw new InvalidOperationException("OreUniformity must be >= 0");

Type guard

static bool OreUniformityOk(ClassicMapGeneratorInfo.Parameters p) => p.OreUniformity >= 0;

Try / catch

try { mapGenerator.Generate(modData, args); }
catch (MapGenerationException ex) when (ex.Message.Contains("OreUniformity"))
{ /* use 0 or a positive scalar */ }

Prevention

When it happens

Trigger: Map generation with the OreUniformity yaml field set to a negative integer.

Common situations: Sign error or typo; confusion with the 0-1000 fraction fields (this one is a plain non-negative scalar, not a fraction).

Related errors


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