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:
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user