fix mishandled CancelProduction
This commit is contained in:
@@ -196,27 +196,21 @@ namespace OpenRA.Mods.RA
|
||||
|
||||
protected void CancelProduction(string itemName, int numberToCancel)
|
||||
{
|
||||
if (Queue.Count == 0)
|
||||
return; // Nothing to do here
|
||||
for (var i = 0; i < numberToCancel; i++)
|
||||
CancelProductionInner(itemName);
|
||||
}
|
||||
|
||||
void CancelProductionInner(string itemName)
|
||||
{
|
||||
var lastIndex = Queue.FindLastIndex(a => a.Item == itemName);
|
||||
|
||||
while (lastIndex > 0)
|
||||
{
|
||||
|
||||
if (lastIndex > 0)
|
||||
Queue.RemoveAt(lastIndex);
|
||||
lastIndex = Queue.FindLastIndex(a => a.Item == itemName);
|
||||
if (numberToCancel > 0)
|
||||
--numberToCancel;
|
||||
if (numberToCancel == 0)
|
||||
break;
|
||||
//else negative, continue deleting all orders
|
||||
}
|
||||
|
||||
if (lastIndex == 0)
|
||||
else if (lastIndex == 0)
|
||||
{
|
||||
var item = Queue[0];
|
||||
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far.
|
||||
self.Owner.PlayerActor.Trait<PlayerResources>().GiveCash(
|
||||
item.TotalCost - item.RemainingCost); // refund what has been paid
|
||||
FinishProduction();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user