oops, that was a bit expensive
This commit is contained in:
@@ -60,7 +60,7 @@ namespace OpenRa.Game
|
||||
using (new PerfSample("find_path_to_path"))
|
||||
{
|
||||
|
||||
var cellInfo = InitCellInfo();
|
||||
CellInfo[,] cellInfo = null;// var cellInfo = InitCellInfo();
|
||||
var queue = new PriorityQueue<PathDistance>();
|
||||
var estimator = DefaultEstimator(from);
|
||||
|
||||
@@ -72,12 +72,16 @@ namespace OpenRa.Game
|
||||
if ( /*i == 0 || */(Game.BuildingInfluence.CanMoveHere(path[i]) && Game.UnitInfluence.GetUnitAt(path[i]) == null))
|
||||
{
|
||||
queue.Add(new PathDistance(estimator(sl), sl));
|
||||
if (cellInfo == null)
|
||||
cellInfo = InitCellInfo();
|
||||
|
||||
cellInfo[sl.X, sl.Y] = new CellInfo(cost, prev, false);
|
||||
}
|
||||
var d = sl - prev;
|
||||
cost += ((d.X * d.Y != 0) ? 1.414213563 : 1.0) * passableCost[(int)umt][sl.X, sl.Y];
|
||||
prev = sl;
|
||||
}
|
||||
if (queue.Empty) return new List<int2>();
|
||||
var ret = FindPath(cellInfo, queue, estimator, umt, true);
|
||||
ret.Reverse();
|
||||
Game.PathToPathTime += sw.ElapsedTime();
|
||||
@@ -107,7 +111,8 @@ namespace OpenRa.Game
|
||||
|
||||
List<int2> FindPath( CellInfo[ , ] cellInfo, PriorityQueue<PathDistance> queue, Func<int2, double> estimator, UnitMovementType umt, bool checkForBlock )
|
||||
{
|
||||
|
||||
using (new PerfSample("find_path_inner"))
|
||||
{
|
||||
while (!queue.Empty)
|
||||
{
|
||||
PathDistance p = queue.Pop();
|
||||
@@ -149,6 +154,7 @@ namespace OpenRa.Game
|
||||
// no path exists
|
||||
return new List<int2>();
|
||||
}
|
||||
}
|
||||
|
||||
static CellInfo[ , ] InitCellInfo()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user