store Actors, not ActorIds, in Order.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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();
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user