OpenRA/OpenRA · error · MapGenerationException

MinimumBuildings must be >= 0

Error message

MinimumBuildings must be >= 0

What it means

Thrown when MinimumBuildings is negative. MinimumBuildings is the lower bound on civilian building count placed per region; negative values are meaningless for a count and would corrupt the building placement loop.

Source

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

					throw new MapGenerationException("SpawnResourceSpawns must be >= 0");
				if (ResourceSpawnReservation < 1)
					throw new MapGenerationException("ResourceSpawnReservation must be >= 1");
				if (MaximumExpansionResourceSpawns < 0)
					throw new MapGenerationException("MaximumExpansionResourceSpawns must be >= 0");
				if (MinimumExpansionSize < 1)
					throw new MapGenerationException("MinimumExpansionSize must be >= 1");
				if (MaximumExpansionSize < 1)
					throw new MapGenerationException("MaximumExpansionSize must be >= 1");
				if (MinimumExpansionSize > MaximumExpansionSize)
					throw new MapGenerationException("MinimumExpansionSize must be <= maximumExpansionSize");
				if (ExpansionBorder < 1)
					throw new MapGenerationException("ExpansionBorder must be >= 1");
				if (ExpansionInner < 1)
					throw new MapGenerationException("ExpansionInner must be >= 1");
				if (MaximumResourceSpawnsPerExpansion < 1)
					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");

View on GitHub (pinned to a520984d91)

Solutions

  1. Set MinimumBuildings to 0 or a positive integer.
  2. Ensure MinimumBuildings <= MaximumBuildings (see error 507).

Example fix

# before
MinimumBuildings: -1
# after
MinimumBuildings: 0
Defensive patterns

Strategy: validation

Validate before calling

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

Type guard

static bool MinimumBuildingsOk(ClassicMapGeneratorInfo.Parameters p) => p.MinimumBuildings >= 0;

Try / catch

try { mapGenerator.Generate(modData, args); }
catch (MapGenerationException ex) when (ex.Message.Contains("MinimumBuildings must be >="))
{ /* use 0 or a positive value */ }

Prevention

When it happens

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

Common situations: Typo/negative value in the yaml, or copying a config and sign-flipping the number. Note 0 is allowed (no minimum).

Related errors


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