diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs index fd0c4d7c46..cdc5532035 100755 --- a/OpenRA.Game/Network/Order.cs +++ b/OpenRA.Game/Network/Order.cs @@ -224,17 +224,17 @@ namespace OpenRA public static Order StartProduction(Actor subject, string item, int count) { - return new Order("StartProduction", subject, false) { TargetLocation = new CPos(count, 0), TargetString = item }; + return new Order("StartProduction", subject, false) { ExtraData = (uint)count, TargetString = item }; } public static Order PauseProduction(Actor subject, string item, bool pause) { - return new Order("PauseProduction", subject, false) { TargetLocation = new CPos(pause ? 1 : 0, 0), TargetString = item }; + return new Order("PauseProduction", subject, false) { ExtraData = pause ? 1u : 0u, TargetString = item }; } public static Order CancelProduction(Actor subject, string item, int count) { - return new Order("CancelProduction", subject, false) { TargetLocation = new CPos(count, 0), TargetString = item }; + return new Order("CancelProduction", subject, false) { ExtraData = (uint)count, TargetString = item }; } } } diff --git a/OpenRA.Mods.RA/Player/ProductionQueue.cs b/OpenRA.Mods.RA/Player/ProductionQueue.cs index 554032ab26..7911b9fb8b 100755 --- a/OpenRA.Mods.RA/Player/ProductionQueue.cs +++ b/OpenRA.Mods.RA/Player/ProductionQueue.cs @@ -221,15 +221,20 @@ namespace OpenRA.Mods.RA return; /* you can't build that!! */ // Check if the player is trying to build more units that they are allowed + var fromLimit = int.MaxValue; if (bi.BuildLimit > 0) { var inQueue = Queue.Count(pi => pi.Item == order.TargetString); var owned = self.Owner.World.ActorsWithTrait().Count(a => a.Actor.Info.Name == order.TargetString && a.Actor.Owner == self.Owner); - if (inQueue + owned >= bi.BuildLimit) + fromLimit = bi.BuildLimit - (inQueue + owned); + + if (fromLimit <= 0) return; } - for (var n = 0; n < order.TargetLocation.X; n++) // repeat count + var amountToBuild = Math.Min(fromLimit, order.ExtraData); + + for (var n = 0; n < amountToBuild; n++) // repeat count { bool hasPlayedSound = false; BeginProduction(new ProductionItem(this, order.TargetString, cost, PlayerPower, @@ -256,12 +261,12 @@ namespace OpenRA.Mods.RA case "PauseProduction": { if (Queue.Count > 0 && Queue[0].Item == order.TargetString) - Queue[0].Paused = ( order.TargetLocation.X != 0 ); + Queue[0].Paused = ( order.ExtraData != 0 ); break; } case "CancelProduction": { - CancelProduction(order.TargetString, order.TargetLocation.X); + CancelProduction(order.TargetString, order.ExtraData); break; } } @@ -281,7 +286,7 @@ namespace OpenRA.Mods.RA return (int) time; } - protected void CancelProduction(string itemName, int numberToCancel) + protected void CancelProduction(string itemName, uint numberToCancel) { for (var i = 0; i < numberToCancel; i++) CancelProductionInner(itemName);