Fix ungarrisoning bug caused by promoting garrisoned entities. Fixes #2471.
This now uses the Autogarrsion order as both already work with an already garrisoned entity. This was SVN commit r14903.
This commit is contained in:
parent
fd4cd56224
commit
fb1827bee7
@ -289,7 +289,7 @@ GuiInterface.prototype.GetEntityState = function(player, ent)
|
||||
"isGuarding": cmpUnitAI.IsGuardOf(),
|
||||
};
|
||||
// Add some information needed for ungarrisoning
|
||||
if (cmpUnitAI.isGarrisoned && ret.player !== undefined)
|
||||
if (cmpUnitAI.IsGarrisoned() && ret.player !== undefined)
|
||||
ret.template = "p" + ret.player + "&" + ret.template;
|
||||
}
|
||||
|
||||
|
@ -75,9 +75,26 @@ Promotion.prototype.Promote = function(promotedTemplateName)
|
||||
cmpPromotedUnitAI.SetHeldPosition(cmpCurrentUnitAI.GetHeldPosition());
|
||||
if (cmpCurrentUnitAI.GetStanceName())
|
||||
cmpPromotedUnitAI.SwitchToStance(cmpCurrentUnitAI.GetStanceName());
|
||||
cmpPromotedUnitAI.Cheer();
|
||||
|
||||
var orders = cmpCurrentUnitAI.GetOrders();
|
||||
if (cmpCurrentUnitAI.IsGarrisoned())
|
||||
{
|
||||
if (orders.length > 0 && orders[0].type == "Garrison")
|
||||
{
|
||||
// Replace the garrison order by an autogarrison order,
|
||||
// as we are already garrisoned and do not need to do
|
||||
// any further checks (or else we should do them here).
|
||||
orders.shift();
|
||||
cmpPromotedUnitAI.Autogarrison();
|
||||
}
|
||||
else
|
||||
warn("Promoted garrisoned entity with empty order queue.");
|
||||
}
|
||||
else
|
||||
cmpPromotedUnitAI.Cheer();
|
||||
|
||||
cmpPromotedUnitAI.AddOrders(orders);
|
||||
|
||||
var workOrders = cmpCurrentUnitAI.GetWorkOrders();
|
||||
cmpPromotedUnitAI.SetWorkOrders(workOrders);
|
||||
cmpPromotedUnitAI.SetGuardOf(cmpCurrentUnitAI.IsGuardOf());
|
||||
|
@ -3608,7 +3608,8 @@ UnitAI.prototype.AddOrders = function(orders)
|
||||
UnitAI.prototype.GetOrderData = function()
|
||||
{
|
||||
var orders = [];
|
||||
for (var i in this.orderQueue) {
|
||||
for (var i in this.orderQueue)
|
||||
{
|
||||
if (this.orderQueue[i].data)
|
||||
orders.push(deepcopy(this.orderQueue[i].data));
|
||||
}
|
||||
@ -4899,7 +4900,8 @@ UnitAI.prototype.Ungarrison = function()
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds autogarrison order to the queue (only used by ProductionQueue for auto-garrisoning)
|
||||
* Adds autogarrison order to the queue (only used by ProductionQueue for auto-garrisoning
|
||||
* and Promotion when promoting already garrisoned entities).
|
||||
*/
|
||||
UnitAI.prototype.Autogarrison = function()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user