From 0654f18f22f5f8650e36b48811a692fb20bcb143 Mon Sep 17 00:00:00 2001 From: Paul Chote Date: Thu, 29 Mar 2018 19:52:26 +0100 Subject: [PATCH] Break out of cancellation loop when there is nothing left to cancel. --- OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs index 9efcf14f22..75d39f7a6a 100644 --- a/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs +++ b/OpenRA.Mods.Common/Traits/Player/ProductionQueue.cs @@ -427,10 +427,11 @@ namespace OpenRA.Mods.Common.Traits protected void CancelProduction(string itemName, uint numberToCancel) { 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); @@ -444,6 +445,10 @@ namespace OpenRA.Mods.Common.Traits playerResources.GiveCash(item.TotalCost - item.RemainingCost); FinishProduction(); } + else + return false; + + return true; } public void FinishProduction()