Allow garrisoned entities to upgrade.

Since its introduction in b2f4b0f494 garrisoned entities were not
allowed to upgrade (b2f4b0f494#inline-4821) but that is not needed (at
least since 4fadd75ace).

Changing templates to anything not being able to garrison will still
fail (#5906) but that can also be done with this code.

Differential revision: D3251
Comment by: @bb
This was SVN commit r24958.
This commit is contained in:
Freagarach 2021-02-28 06:47:36 +00:00
parent f4c9305eee
commit 41a5650a62
2 changed files with 0 additions and 24 deletions

View File

@ -710,16 +710,6 @@ var g_Commands = {
continue;
}
if (!CanGarrisonedChangeTemplate(ent, cmd.template))
{
var cmpGUIInterface = Engine.QueryInterface(SYSTEM_ENTITY, IID_GuiInterface);
cmpGUIInterface.PushNotification({
"players": [player],
"message": markForTranslation("Cannot upgrade a garrisoned entity.")
});
continue;
}
// Check entity limits
var cmpEntityLimits = QueryPlayerIDInterface(player, IID_EntityLimits);
if (cmpEntityLimits && !cmpEntityLimits.AllowedToReplace(ent, cmd.template))

View File

@ -140,19 +140,6 @@ function ChangeEntityTemplate(oldEnt, newTemplate)
return newEnt;
}
function CanGarrisonedChangeTemplate(ent, template)
{
var cmpPosition = Engine.QueryInterface(ent, IID_Position);
var unitAI = Engine.QueryInterface(ent, IID_UnitAI);
if (cmpPosition && !cmpPosition.IsInWorld() && unitAI && unitAI.IsGarrisoned())
{
// We're a garrisoned unit, assume impossibility as I've been unable to find a way to get the holder ID.
// TODO: change this if that ever becomes possibles
return false;
}
return true;
}
function CopyControlGroups(oldEnt, newEnt)
{
let cmpObstruction = Engine.QueryInterface(oldEnt, IID_Obstruction);
@ -277,5 +264,4 @@ function TransferGarrisonedUnits(oldEnt, newEnt)
}
Engine.RegisterGlobal("ChangeEntityTemplate", ChangeEntityTemplate);
Engine.RegisterGlobal("CanGarrisonedChangeTemplate", CanGarrisonedChangeTemplate);
Engine.RegisterGlobal("ObstructionsBlockingTemplateChange", ObstructionsBlockingTemplateChange);