1
0
forked from mirrors/0ad

Add fallback values for pop cap and pop cap type

Make InitGame.js responsible for providing proper (defined) values.

Refs #7850
Fixes #7695
This commit is contained in:
Vantha
2025-11-26 21:49:07 +01:00
parent f856565de9
commit 3a73dffc1c
2 changed files with 11 additions and 9 deletions
@@ -17,13 +17,11 @@ PopulationCapManager.prototype.Init = function()
*/
PopulationCapManager.prototype.SetPopulationCapType = function(type)
{
if ([this.CAPTYPE_PLAYER_POPULATION, this.CAPTYPE_TEAM_POPULATION, this.CAPTYPE_WORLD_POPULATION].includes(type))
this.popCapType = type;
else
{
warn(`Attempted to set an unknown population capacity type: '${type}'. Continuing with type 'Player Population'...`);
this.popCapType = this.CAPTYPE_PLAYER_POPULATION;
}
if (![this.CAPTYPE_PLAYER_POPULATION, this.CAPTYPE_TEAM_POPULATION, this.CAPTYPE_WORLD_POPULATION].includes(type))
error("Invalid population cap type specified: " + type);
this.popCapType = type;
if (this.popCap)
this.InitializePopCaps();
};
@@ -65,8 +65,12 @@ function InitGame(settings)
}
const cmpPopulationCapManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_PopulationCapManager);
cmpPopulationCapManager.SetPopulationCapType(settings.PopulationCapType);
cmpPopulationCapManager.SetPopulationCap(settings.PopulationCap);
if ([cmpPopulationCapManager.CAPTYPE_PLAYER_POPULATION, cmpPopulationCapManager.CAPTYPE_TEAM_POPULATION,
cmpPopulationCapManager.CAPTYPE_WORLD_POPULATION].includes(settings.PopulationCapType))
cmpPopulationCapManager.SetPopulationCapType(settings.PopulationCapType);
else
cmpPopulationCapManager.SetPopulationCapType(cmpPopulationCapManager.CAPTYPE_PLAYER_POPULATION);
cmpPopulationCapManager.SetPopulationCap(settings.PopulationCap || 300);
// Update the grid with all entities created for the map init.
Engine.QueryInterface(SYSTEM_ENTITY, IID_Pathfinder).UpdateGrid();