diff --git a/OpenRA.Game/Network/Order.cs b/OpenRA.Game/Network/Order.cs index 90ec7d645a..fd0c4d7c46 100755 --- a/OpenRA.Game/Network/Order.cs +++ b/OpenRA.Game/Network/Order.cs @@ -23,6 +23,7 @@ namespace OpenRA TargetString = 0x04, Queued = 0x08, ExtraLocation = 0x10, + ExtraData = 0x20 } static class OrderFieldsExts @@ -42,12 +43,13 @@ namespace OpenRA public CPos TargetLocation; public string TargetString; public CPos ExtraLocation; + public uint ExtraData; public bool IsImmediate; public Player Player { get { return Subject.Owner; } } Order(string orderString, Actor subject, - Actor targetActor, CPos targetLocation, string targetString, bool queued, CPos extraLocation) + Actor targetActor, CPos targetLocation, string targetString, bool queued, CPos extraLocation, uint extraData) { this.OrderString = orderString; this.Subject = subject; @@ -56,18 +58,19 @@ namespace OpenRA this.TargetString = targetString; this.Queued = queued; this.ExtraLocation = extraLocation; + this.ExtraData = extraData; } // For scripting special powers public Order() - : this(null, null, null, CPos.Zero, null, false, CPos.Zero) { } + : this(null, null, null, CPos.Zero, null, false, CPos.Zero, 0) { } public Order(string orderString, Actor subject, bool queued) - : this(orderString, subject, null, CPos.Zero, null, queued, CPos.Zero) { } + : this(orderString, subject, null, CPos.Zero, null, queued, CPos.Zero, 0) { } public Order(string orderstring, Order order) : this(orderstring, order.Subject, order.TargetActor, order.TargetLocation, - order.TargetString, order.Queued, order.ExtraLocation) {} + order.TargetString, order.Queued, order.ExtraLocation, order.ExtraData) {} public byte[] Serialize() { @@ -102,6 +105,7 @@ namespace OpenRA if (TargetString != null) fields |= OrderFields.TargetString; if (Queued) fields |= OrderFields.Queued; if (ExtraLocation != CPos.Zero) fields |= OrderFields.ExtraLocation; + if (ExtraData != 0) fields |= OrderFields.ExtraData; w.Write((byte)fields); @@ -113,6 +117,8 @@ namespace OpenRA w.Write(TargetString); if (ExtraLocation != CPos.Zero) w.Write(ExtraLocation.ToInt2()); + if (ExtraData != 0) + w.Write(ExtraData); return ret.ToArray(); } @@ -134,12 +140,13 @@ namespace OpenRA var targetString = flags.HasField(OrderFields.TargetString) ? r.ReadString() : null; var queued = flags.HasField(OrderFields.Queued); var extraLocation = (CPos)(flags.HasField(OrderFields.ExtraLocation) ? r.ReadInt2() : int2.Zero); + var extraData = flags.HasField(OrderFields.ExtraData) ? r.ReadUInt32() : 0; Actor subject, targetActor; - if( !TryGetActorFromUInt( world, subjectId, out subject ) || !TryGetActorFromUInt( world, targetActorId, out targetActor ) ) + if (!TryGetActorFromUInt(world, subjectId, out subject) || !TryGetActorFromUInt(world, targetActorId, out targetActor)) return null; - return new Order( order, subject, targetActor, targetLocation, targetString, queued, extraLocation); + return new Order(order, subject, targetActor, targetLocation, targetString, queued, extraLocation, extraData); } case 0xfe: