sync the last path generated, to try and catch this MUCH earlier

This commit is contained in:
Chris Forbes
2010-09-21 21:43:16 +12:00
parent b35a7d9f8d
commit 3a617f8934
2 changed files with 15 additions and 0 deletions

View File

@@ -102,6 +102,16 @@ namespace OpenRA.Traits.Activities
this.nearEnough = 0; this.nearEnough = 0;
} }
static int HashList<T>(List<T> xs)
{
int hash = 0;
int n = 0;
foreach (var x in xs)
hash += n++ * x.GetHashCode();
return hash;
}
List<int2> EvalPath( Actor self, Mobile mobile ) List<int2> EvalPath( Actor self, Mobile mobile )
{ {
var path = getPath(self, mobile).TakeWhile(a => a != mobile.toCell).ToList(); var path = getPath(self, mobile).TakeWhile(a => a != mobile.toCell).ToList();
@@ -109,6 +119,8 @@ namespace OpenRA.Traits.Activities
Log.Write("debug", "EvalPath #{0} {1}", Log.Write("debug", "EvalPath #{0} {1}",
self.ActorID, string.Join(" ", path.Select(a => a.ToString()).ToArray())); self.ActorID, string.Join(" ", path.Select(a => a.ToString()).ToArray()));
mobile.PathHash = HashList(path);
return path; return path;
} }

View File

@@ -98,6 +98,9 @@ namespace OpenRA.Traits
set { SetLocation( __fromCell, value ); } set { SetLocation( __fromCell, value ); }
} }
[Sync]
public int PathHash; // written by Move.EvalPath, to temporarily debug this crap.
void SetLocation(int2 from, int2 to) void SetLocation(int2 from, int2 to)
{ {
if (fromCell == from && toCell == to) return; if (fromCell == from && toCell == to) return;