diff --git a/OpenRA.Game/PathFinder.cs b/OpenRA.Game/PathFinder.cs index dcaf7e4dbd..93eb77a28d 100644 --- a/OpenRA.Game/PathFinder.cs +++ b/OpenRA.Game/PathFinder.cs @@ -43,6 +43,7 @@ namespace OpenRA public int2 to; public List result; public int tick; + public Actor actor; } List CachedPaths = new List(); @@ -50,16 +51,14 @@ namespace OpenRA public List FindUnitPath(int2 from, int2 target, Actor self) { - // Todo: Reenable cache on something that isn't umt - //var umt = self.traits.Get().GetMovementType(); using (new PerfSample("find_unit_path")) { - //var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.umt == umt); - //if (cached != null) - //{ - // cached.tick = Game.LocalTick; - // return new List(cached.result); - //} + var cached = CachedPaths.FirstOrDefault(p => p.from == from && p.to == target && p.actor == self); + if (cached != null) + { + cached.tick = Game.LocalTick; + return new List(cached.result); + } var pb = FindBidiPath( PathSearch.FromPoint(self, target, from, true) @@ -70,8 +69,8 @@ namespace OpenRA CheckSanePath2(pb, from, target); - //CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge); - //CachedPaths.Add(new CachedPath { from = from, to = target, umt = umt, result = pb, tick = Game.LocalTick }); + CachedPaths.RemoveAll(p => Game.LocalTick - p.tick > MaxPathAge); + CachedPaths.Add(new CachedPath { from = from, to = target, actor = self, result = pb, tick = Game.LocalTick }); return new List(pb); } }