From b905d343afe44638802827ddd8c1b958d6166209 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 11 Oct 2010 19:36:10 +1300 Subject: [PATCH] fix mishandled CancelProduction --- OpenRA.Mods.RA/Player/ProductionQueue.cs | 24 +++++++++--------------- 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs index 2c11fcedd3..2a8817d179 100755 --- a/OpenRA.Mods.RA/Player/ProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs @@ -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().GiveCash(item.TotalCost - item.RemainingCost); // refund what's been paid so far. + self.Owner.PlayerActor.Trait().GiveCash( + item.TotalCost - item.RemainingCost); // refund what has been paid FinishProduction(); } }