{"record":{"id":"dc440c57bcc5b4d8","repo":"OpenRA/OpenRA","slug":"playableareadensitybonus-must-be-0","errorCode":null,"errorMessage":"PlayableAreaDensityBonus must be >= 0","messagePattern":"PlayableAreaDensityBonus must be >= 0","errorType":"exception","errorClass":"MapGenerationException","httpStatus":null,"severity":"error","filePath":"OpenRA.Mods.Common/Traits/World/ClassicMapGenerator.cs","lineNumber":357,"sourceCode":"\t\t\t\t\tthrow new MapGenerationException(\"MaximumAltitude must be >= 0\");\n\t\t\t\tif (MinimumTerrainContourSpacing < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumTerrainContourSpacing must be >= 0\");\n\t\t\t\tif (WaterRoughness > 0 && MinimumBeachLength < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumBeachLength must be >= 1\");\n\t\t\t\tif (WaterRoughness > 0 && MinimumCliffLength < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumWaterCliffLength must be >= 1\");\n\t\t\t\tif (MinimumCliffLength < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumCliffLength must be >= 1\");\n\t\t\t\tif (RoadSpacing < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"RoadSpacing must be >= 0\");\n\t\t\t\tif (RoadShrink < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"RoadShrink must be >= 0\");\n\t\t\t\tif (Players < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"Players must be >= 0\");\n\t\t\t\tif (CentralSpawnReservationFraction < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"CentralSpawnReservationFraction must be >= 0\");\n\t\t\t\tif (AreaEntityBonus < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"PlayableAreaDensityBonus must be >= 0\");\n\t\t\t\tif (PlayerCountEntityBonus < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"PlayerCountDensityBonus must be >= 0\");\n\t\t\t\tif (SpawnRegionSize < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"SpawnRegionSize must be >= 1\");\n\t\t\t\tif (SpawnReservation < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"SpawnReservation must be >= 1\");\n\t\t\t\tif (SpawnBuildSize < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"SpawnBuildSize must be >= 1\");\n\t\t\t\tif (MinimumSpawnRadius < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumSpawnRadius must be >= 1\");\n\t\t\t\tif (SpawnResourceSpawns < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"SpawnResourceSpawns must be >= 0\");\n\t\t\t\tif (ResourceSpawnReservation < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"ResourceSpawnReservation must be >= 1\");\n\t\t\t\tif (MaximumExpansionResourceSpawns < 0)\n\t\t\t\t\tthrow new MapGenerationException(\"MaximumExpansionResourceSpawns must be >= 0\");\n\t\t\t\tif (MinimumExpansionSize < 1)\n\t\t\t\t\tthrow new MapGenerationException(\"MinimumExpansionSize must be >= 1\");","sourceCodeStart":339,"sourceCodeEnd":375,"githubUrl":"https://github.com/OpenRA/OpenRA/blob/a520984d91eda9de48a62b1d15c1e3bad0d4fb1a/OpenRA.Mods.Common/Traits/World/ClassicMapGenerator.cs#L339-L375","documentation":"MISLEADING MESSAGE. The text reads 'PlayableAreaDensityBonus must be >= 0', but the condition at ClassicMapGenerator.cs:356 actually checks the AreaEntityBonus field (line 98). There is no field named PlayableAreaDensityBonus; the message is a stale/renamed label. To clear the error you must raise AreaEntityBonus, not search for a non-existent key. This is a source bug: the guard and the message disagree.","triggerScenarios":"Map generation where AreaEntityBonus is set below 0. Validate() at line 356 throws MapGenerationException labelled 'PlayableAreaDensityBonus', but AreaEntityBonus is the offending field.","commonSituations":"A developer searches the config for PlayableAreaDensityBonus, finds nothing, and is stuck. Typically hit when tuning entity/density bonuses and entering a negative AreaEntityBonus value.","solutions":["Set AreaEntityBonus to 0 or a positive integer (this is the field actually checked).","Do not look for a PlayableAreaDensityBonus key; it does not exist.","Keep the value within 0..1000000 (the EntityBonusMax bound declared at line 29).","Consider fixing the upstream message to name AreaEntityBonus."],"exampleFix":"# before (message says PlayableAreaDensityBonus, but the checked field is AreaEntityBonus)\nAreaEntityBonus: -5\n# after\nAreaEntityBonus: 100","handlingStrategy":"validation","validationCode":"// NOTE: message says PlayableAreaDensityBonus, but the checked field is AreaEntityBonus.\nint areaEntityBonus = Exts.TryParseInt32Invariant(yaml.NodeWithKey(\"AreaEntityBonus\").Value.Value, out var aeb) ? aeb : 0;\nif (areaEntityBonus < 0)\n    throw new InvalidOperationException(\"AreaEntityBonus must be >= 0 (generator mislabels it 'PlayableAreaDensityBonus')\");","typeGuard":"static bool IsValidAreaEntityBonus(int value) => value >= 0 && value <= 1000000;","tryCatchPattern":"try { generator.Generate(map, yaml); }\ncatch (MapGenerationException ex) when (ex.Message.Contains(\"PlayableAreaDensityBonus\"))\n{ /* the REAL fix is AreaEntityBonus >= 0; no PlayableAreaDensityBonus key exists */ }","preventionTips":["Map the error text 'PlayableAreaDensityBonus' to the field AreaEntityBonus in your troubleshooting notes.","Clamp all *EntityBonus fields to 0..1000000 (EntityBonusMax) in your preset editor."],"tags":["map-generation","config-validation","openra","classic-map-generator","misleading-message"],"backgroundTag":null,"analyzedSha":"a520984d91eda9de48a62b1d15c1e3bad0d4fb1a","analyzedAt":"2026-08-13T15:30:14.787Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}