Break out of cancellation loop when there is nothing left to cancel.
This commit is contained in:
@@ -427,10 +427,11 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
protected void CancelProduction(string itemName, uint numberToCancel)
|
protected void CancelProduction(string itemName, uint numberToCancel)
|
||||||
{
|
{
|
||||||
for (var i = 0; i < numberToCancel; i++)
|
for (var i = 0; i < numberToCancel; i++)
|
||||||
CancelProductionInner(itemName);
|
if (!CancelProductionInner(itemName))
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CancelProductionInner(string itemName)
|
bool CancelProductionInner(string itemName)
|
||||||
{
|
{
|
||||||
var lastIndex = queue.FindLastIndex(a => a.Item == itemName);
|
var lastIndex = queue.FindLastIndex(a => a.Item == itemName);
|
||||||
|
|
||||||
@@ -444,6 +445,10 @@ namespace OpenRA.Mods.Common.Traits
|
|||||||
playerResources.GiveCash(item.TotalCost - item.RemainingCost);
|
playerResources.GiveCash(item.TotalCost - item.RemainingCost);
|
||||||
FinishProduction();
|
FinishProduction();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void FinishProduction()
|
public void FinishProduction()
|
||||||
|
|||||||
Reference in New Issue
Block a user