Reenable path cache to catch the most stupid path fails (doesn't help the most common fails)
This commit is contained in:
@@ -43,6 +43,7 @@ namespace OpenRA
|
|||||||
public int2 to;
|
public int2 to;
|
||||||
public List<int2> result;
|
public List<int2> result;
|
||||||
public int tick;
|
public int tick;
|
||||||
|
public Actor actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
List<CachedPath> CachedPaths = new List<CachedPath>();
|
List<CachedPath> CachedPaths = new List<CachedPath>();
|
||||||
@@ -50,16 +51,14 @@ namespace OpenRA
|
|||||||
|
|
||||||
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
|
public List<int2> FindUnitPath(int2 from, int2 target, Actor self)
|
||||||
{
|
{
|
||||||
// Todo: Reenable cache on something that isn't umt
|
|
||||||
//var umt = self.traits.Get<Mobile>().GetMovementType();
|
|
||||||
using (new PerfSample("find_unit_path"))
|
using (new PerfSample("find_unit_path"))
|
||||||
{
|
{
|
||||||
//var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.umt == umt);
|
var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.actor == self);
|
||||||
//if (cached != null)
|
if (cached != null)
|
||||||
//{
|
{
|
||||||
// cached.tick = Game.LocalTick;
|
cached.tick = Game.LocalTick;
|
||||||
// return new List<int2>(cached.result);
|
return new List<int2>(cached.result);
|
||||||
//}
|
}
|
||||||
|
|
||||||
var pb = FindBidiPath(
|
var pb = FindBidiPath(
|
||||||
PathSearch.FromPoint(self, target, from, true)
|
PathSearch.FromPoint(self, target, from, true)
|
||||||
@@ -70,8 +69,8 @@ namespace OpenRA
|
|||||||
|
|
||||||
CheckSanePath2(pb, from, target);
|
CheckSanePath2(pb, from, target);
|
||||||
|
|
||||||
//CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge);
|
CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge);
|
||||||
//CachedPaths.Add(new CachedPath { from = from, to = target, umt = umt, result = pb, tick = Game.LocalTick });
|
CachedPaths.Add(new CachedPath { from = from, to = target, actor = self, result = pb, tick = Game.LocalTick });
|
||||||
return new List<int2>(pb);
|
return new List<int2>(pb);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user