From c5b7c43d230c4cd721cac7783c0658986dc435e5 Mon Sep 17 00:00:00 2001 From: Chris Forbes Date: Mon, 20 Sep 2010 19:06:43 +1200 Subject: [PATCH] add pathspam in debug --- OpenRA.Game/Traits/Activities/Move.cs | 14 ++++++++++++-- OpenRA.Game/Traits/Mobile.cs | 4 ++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/OpenRA.Game/Traits/Activities/Move.cs b/OpenRA.Game/Traits/Activities/Move.cs index dbd55f6298..e8d7008fed 100755 --- a/OpenRA.Game/Traits/Activities/Move.cs +++ b/OpenRA.Game/Traits/Activities/Move.cs @@ -102,6 +102,16 @@ namespace OpenRA.Traits.Activities this.nearEnough = 0; } + List EvalPath( Actor self, Mobile mobile ) + { + var path = getPath(self, mobile).TakeWhile(a => a != mobile.toCell).ToList(); + + Log.Write("debug", "EvalPath #{0} {1}", + self.ActorID, string.Join(" ", path.Select(a => a.ToString()).ToArray())); + + return path; + } + public IActivity Tick( Actor self ) { var mobile = self.Trait(); @@ -123,7 +133,7 @@ namespace OpenRA.Traits.Activities return this; } - path = getPath( self, mobile ).TakeWhile( a => a != mobile.toCell ).ToList(); + path = EvalPath(self, mobile); SanityCheckPath( mobile ); } @@ -221,7 +231,7 @@ namespace OpenRA.Traits.Activities return null; mobile.RemoveInfluence(); - var newPath = getPath( self, mobile ).TakeWhile(a => a != mobile.toCell).ToList(); + var newPath = EvalPath(self, mobile); mobile.AddInfluence(); if (newPath.Count != 0) diff --git a/OpenRA.Game/Traits/Mobile.cs b/OpenRA.Game/Traits/Mobile.cs index 0bc8062b68..eb499767fe 100644 --- a/OpenRA.Game/Traits/Mobile.cs +++ b/OpenRA.Game/Traits/Mobile.cs @@ -66,17 +66,21 @@ namespace OpenRA.Traits public int InitialFacing { get { return Info.InitialFacing; } } int2 __fromCell, __toCell; + + [Sync] public int2 fromCell { get { return __fromCell; } set { SetLocation( value, __toCell ); } } + [Sync] public int2 toCell { get { return __toCell; } set { SetLocation( __fromCell, value ); } } + void SetLocation( int2 from, int2 to ) { if( fromCell == from && toCell == to ) return;