diff --git a/OpenRa.Game/Controller.cs b/OpenRa.Game/Controller.cs index c58809c124..eb17ecb269 100644 --- a/OpenRa.Game/Controller.cs +++ b/OpenRa.Game/Controller.cs @@ -47,8 +47,7 @@ namespace OpenRa { if (orderGenerator == null) return; - var orders = orderGenerator.Order(xy.ToInt2(), mi) - .Where(order => order.Validate()).ToArray(); + var orders = orderGenerator.Order(xy.ToInt2(), mi).ToArray(); recentOrders.AddRange( orders ); var voicedActor = orders.Select(o => o.Subject) diff --git a/OpenRa.Game/Orders/Order.cs b/OpenRa.Game/Orders/Order.cs index 221dad9228..b6a4b013b6 100644 --- a/OpenRa.Game/Orders/Order.cs +++ b/OpenRa.Game/Orders/Order.cs @@ -8,41 +8,24 @@ namespace OpenRa public sealed class Order { public readonly string OrderString; - readonly uint SubjectId; - readonly uint TargetActorId; + public readonly Actor Subject; + public readonly Actor TargetActor; public readonly int2 TargetLocation; public readonly string TargetString; public bool IsImmediate; - public Actor Subject { get { return ActorFromUInt(SubjectId); } } - public Actor TargetActor { get { return ActorFromUInt(TargetActorId); } } public Player Player { get { return Subject.Owner; } } public Order(string orderString, Actor subject, Actor targetActor, int2 targetLocation, string targetString) - : this( orderString, UIntFromActor( subject ), - UIntFromActor( targetActor ), targetLocation, targetString) {} - - Order(string orderString, uint subjectId, - uint targetActorId, int2 targetLocation, string targetString) { this.OrderString = orderString; - this.SubjectId = subjectId; - this.TargetActorId = targetActorId; + this.Subject = subject; + this.TargetActor = targetActor; this.TargetLocation = targetLocation; this.TargetString = targetString; } - public bool Validate() - { - if ((SubjectId != 0xffffffff) && Subject == null) - return false; - if ((TargetActorId != 0xffffffff) && TargetActor == null) - return false; - - return true; - } - public byte[] Serialize() { if (IsImmediate) /* chat, whatever */ @@ -69,8 +52,8 @@ namespace OpenRa var w = new BinaryWriter(ret); w.Write( (byte)0xFF ); w.Write(OrderString); - w.Write(SubjectId); - w.Write(TargetActorId); + w.Write(UIntFromActor(Subject)); + w.Write(UIntFromActor(TargetActor)); w.Write(TargetLocation.X); w.Write(TargetLocation.Y); w.Write(TargetString != null); @@ -103,7 +86,7 @@ namespace OpenRa if (r.ReadBoolean()) targetString = r.ReadString(); - return new Order( order, subjectId, targetActorId, targetLocation, targetString); + return new Order( order, ActorFromUInt( subjectId ), ActorFromUInt( targetActorId ), targetLocation, targetString); } case 0xfe: diff --git a/OpenRa.Game/Orders/OrderManager.cs b/OpenRa.Game/Orders/OrderManager.cs index debcc6c362..85edf10ac4 100644 --- a/OpenRa.Game/Orders/OrderManager.cs +++ b/OpenRa.Game/Orders/OrderManager.cs @@ -59,7 +59,6 @@ namespace OpenRa.Orders var orders = sources .SelectMany(s => s.OrdersForFrame(frame)) .SelectMany(x => x.ToOrderList()) - .Where(o => o.Validate()) /* drop bogus things */ .OrderBy(o => o.Player.Index) .ToList(); diff --git a/OpenRa.Game/Orders/UnitOrderGenerator.cs b/OpenRa.Game/Orders/UnitOrderGenerator.cs index ce8cff226d..30599a7fe7 100644 --- a/OpenRa.Game/Orders/UnitOrderGenerator.cs +++ b/OpenRa.Game/Orders/UnitOrderGenerator.cs @@ -45,7 +45,6 @@ namespace OpenRa.Orders { var p = Game.controller.MousePosition; var c = Order(p.ToInt2(), mi) - .Where(o => o.Validate()) .Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation)) .FirstOrDefault(a => a != null);