store Actors, not ActorIds, in Order.
This commit is contained in:
@@ -47,8 +47,7 @@ namespace OpenRa
|
|||||||
{
|
{
|
||||||
if (orderGenerator == null) return;
|
if (orderGenerator == null) return;
|
||||||
|
|
||||||
var orders = orderGenerator.Order(xy.ToInt2(), mi)
|
var orders = orderGenerator.Order(xy.ToInt2(), mi).ToArray();
|
||||||
.Where(order => order.Validate()).ToArray();
|
|
||||||
recentOrders.AddRange( orders );
|
recentOrders.AddRange( orders );
|
||||||
|
|
||||||
var voicedActor = orders.Select(o => o.Subject)
|
var voicedActor = orders.Select(o => o.Subject)
|
||||||
|
|||||||
@@ -8,41 +8,24 @@ namespace OpenRa
|
|||||||
public sealed class Order
|
public sealed class Order
|
||||||
{
|
{
|
||||||
public readonly string OrderString;
|
public readonly string OrderString;
|
||||||
readonly uint SubjectId;
|
public readonly Actor Subject;
|
||||||
readonly uint TargetActorId;
|
public readonly Actor TargetActor;
|
||||||
public readonly int2 TargetLocation;
|
public readonly int2 TargetLocation;
|
||||||
public readonly string TargetString;
|
public readonly string TargetString;
|
||||||
public bool IsImmediate;
|
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 Player Player { get { return Subject.Owner; } }
|
||||||
|
|
||||||
public Order(string orderString, Actor subject,
|
public Order(string orderString, Actor subject,
|
||||||
Actor targetActor, int2 targetLocation, string targetString)
|
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.OrderString = orderString;
|
||||||
this.SubjectId = subjectId;
|
this.Subject = subject;
|
||||||
this.TargetActorId = targetActorId;
|
this.TargetActor = targetActor;
|
||||||
this.TargetLocation = targetLocation;
|
this.TargetLocation = targetLocation;
|
||||||
this.TargetString = targetString;
|
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()
|
public byte[] Serialize()
|
||||||
{
|
{
|
||||||
if (IsImmediate) /* chat, whatever */
|
if (IsImmediate) /* chat, whatever */
|
||||||
@@ -69,8 +52,8 @@ namespace OpenRa
|
|||||||
var w = new BinaryWriter(ret);
|
var w = new BinaryWriter(ret);
|
||||||
w.Write( (byte)0xFF );
|
w.Write( (byte)0xFF );
|
||||||
w.Write(OrderString);
|
w.Write(OrderString);
|
||||||
w.Write(SubjectId);
|
w.Write(UIntFromActor(Subject));
|
||||||
w.Write(TargetActorId);
|
w.Write(UIntFromActor(TargetActor));
|
||||||
w.Write(TargetLocation.X);
|
w.Write(TargetLocation.X);
|
||||||
w.Write(TargetLocation.Y);
|
w.Write(TargetLocation.Y);
|
||||||
w.Write(TargetString != null);
|
w.Write(TargetString != null);
|
||||||
@@ -103,7 +86,7 @@ namespace OpenRa
|
|||||||
if (r.ReadBoolean())
|
if (r.ReadBoolean())
|
||||||
targetString = r.ReadString();
|
targetString = r.ReadString();
|
||||||
|
|
||||||
return new Order( order, subjectId, targetActorId, targetLocation, targetString);
|
return new Order( order, ActorFromUInt( subjectId ), ActorFromUInt( targetActorId ), targetLocation, targetString);
|
||||||
}
|
}
|
||||||
|
|
||||||
case 0xfe:
|
case 0xfe:
|
||||||
|
|||||||
@@ -59,7 +59,6 @@ namespace OpenRa.Orders
|
|||||||
var orders = sources
|
var orders = sources
|
||||||
.SelectMany(s => s.OrdersForFrame(frame))
|
.SelectMany(s => s.OrdersForFrame(frame))
|
||||||
.SelectMany(x => x.ToOrderList())
|
.SelectMany(x => x.ToOrderList())
|
||||||
.Where(o => o.Validate()) /* drop bogus things */
|
|
||||||
.OrderBy(o => o.Player.Index)
|
.OrderBy(o => o.Player.Index)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ namespace OpenRa.Orders
|
|||||||
{
|
{
|
||||||
var p = Game.controller.MousePosition;
|
var p = Game.controller.MousePosition;
|
||||||
var c = Order(p.ToInt2(), mi)
|
var c = Order(p.ToInt2(), mi)
|
||||||
.Where(o => o.Validate())
|
|
||||||
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
|
.Select(o => CursorForOrderString(o.OrderString, o.Subject, o.TargetLocation))
|
||||||
.FirstOrDefault(a => a != null);
|
.FirstOrDefault(a => a != null);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user