mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-19 06:43:58 -07:00
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:
parent
184ed2fb55
commit
b8758c8941
2 changed files with 4 additions and 0 deletions
|
|
@ -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,
|
||||
|
|
|
|||
Loading…
Reference in a new issue