forked from mirrors/0ad
Prevent ProductionQueue.AddItem for going over the entity limits / Fix autoqueue being able to train infinite heroes.
Autoqueue can ignore entity limits like Heroes, because AddItem does not check for them, only commands.js. This changes that, fixing the autoqueue. Reported by: Player of 0AD Tested by: langbart Refs #6213 Differential Revision: https://code.wildfiregames.com/D4133 This was SVN commit r25753.
This commit is contained in:
@@ -417,6 +417,9 @@ ProductionQueue.prototype.AddItem = function(templateName, type, count, metadata
|
||||
let cmpPlayerEntityLimits = QueryPlayerIDInterface(player, IID_EntityLimits);
|
||||
if (cmpPlayerEntityLimits)
|
||||
{
|
||||
if (!cmpPlayerEntityLimits.AllowedToTrain(unitCategory, count, templateName, template.TrainingRestrictions.MatchLimit))
|
||||
// Already warned, return.
|
||||
return false;
|
||||
cmpPlayerEntityLimits.ChangeCount(unitCategory, count);
|
||||
if (template.TrainingRestrictions.MatchLimit)
|
||||
cmpPlayerEntityLimits.ChangeMatchCount(templateName, count);
|
||||
|
||||
@@ -501,6 +501,7 @@ function test_token_changes()
|
||||
"GetPlayerID": () => 1,
|
||||
// entitylimits
|
||||
"ChangeCount": () => {},
|
||||
"AllowedToTrain": () => true,
|
||||
// techmanager
|
||||
"CheckTechnologyRequirements": () => true,
|
||||
"IsTechnologyResearched": () => false,
|
||||
|
||||
Reference in New Issue
Block a user