1
0
forked from 0ad/0ad

fix failing unit training in Aegis and Petra

This was SVN commit r15243.
This commit is contained in:
mimo 2014-05-29 20:18:29 +00:00
parent e0218fff8d
commit 7105dabca7
2 changed files with 16 additions and 3 deletions

View File

@ -526,9 +526,6 @@ m.HQ.prototype.tryResearchTechs = function(gameState, queues)
if (techName.indexOf("heal_rate") !== -1 || techName.indexOf("heal_range") !== -1 ||
techName.indexOf("heal_temple") !== -1 || techName.indexOf("unlock_females_house") !== -1)
possibilities.splice(i--, 1);
// temporary hack for upgrade problem TODO fix that
else if (techName.slice(0, 12) === "upgrade_rank")
possibilities.splice(i--, 1);
}
if (possibilities.length === 0)
return;

View File

@ -260,6 +260,22 @@ var commands = {
{
var queue = Engine.QueryInterface(ent, IID_ProductionQueue);
// Check if the building can train the unit
// TODO: the AI API does not take promotion technologies into account for the list of trainable units
// (it is taken directly from the unit template). Here is a temporary fix.
if (queue && data.cmpPlayer.IsAI())
{
var len = cmd.template.length;
var list = queue.GetEntitiesList();
if (cmd.template.substr(len-2,2) === "_b" && list.indexOf(cmd.template) === -1)
{
var promo_a = cmd.template.substr(0,len-2) + "_a";
var promo_e = cmd.template.substr(0,len-2) + "_e";
if (list.indexOf(promo_a) !== -1)
cmd.template = promo_a;
else if (list.indexOf(promo_e) !== -1)
cmd.template = promo_e;
}
}
if (queue && queue.GetEntitiesList().indexOf(cmd.template) != -1)
if ("metadata" in cmd)
queue.AddBatch(cmd.template, "unit", +cmd.count, cmd.metadata);