Renormalize line endings and fix copyright headers again.

This commit is contained in:
Paul Chote
2011-04-07 21:15:42 +12:00
parent 1a49b46af1
commit b0425aff3b
144 changed files with 8076 additions and 7746 deletions

View File

@@ -87,12 +87,12 @@ namespace OpenRA.Mods.RA.Move
{
using (new PerfSample("Pathfinder"))
{
using(search)
while (!search.queue.Empty)
{
var p = search.Expand(world);
if (search.heuristic(p) == 0)
return MakePath(search.cellInfo, p);
using(search)
while (!search.queue.Empty)
{
var p = search.Expand(world);
if (search.heuristic(p) == 0)
return MakePath(search.cellInfo, p);
}
// no path exists
@@ -114,35 +114,35 @@ namespace OpenRA.Mods.RA.Move
ret.Add(pathNode);
CheckSanePath(ret);
return ret;
}
public List<int2> FindBidiPath( /* searches from both ends toward each other */
PathSearch fromSrc,
PathSearch fromDest)
{
using (new PerfSample("Pathfinder"))
{
using (fromSrc)
using (fromDest)
while (!fromSrc.queue.Empty && !fromDest.queue.Empty)
{
/* make some progress on the first search */
var p = fromSrc.Expand(world);
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p);
/* make some progress on the second search */
var q = fromDest.Expand(world);
if (fromSrc.cellInfo[q.X, q.Y].Seen && fromSrc.cellInfo[q.X, q.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, q);
}
return new List<int2>();
}
}
public List<int2> FindBidiPath( /* searches from both ends toward each other */
PathSearch fromSrc,
PathSearch fromDest)
{
using (new PerfSample("Pathfinder"))
{
using (fromSrc)
using (fromDest)
while (!fromSrc.queue.Empty && !fromDest.queue.Empty)
{
/* make some progress on the first search */
var p = fromSrc.Expand(world);
if (fromDest.cellInfo[p.X, p.Y].Seen && fromDest.cellInfo[p.X, p.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, p);
/* make some progress on the second search */
var q = fromDest.Expand(world);
if (fromSrc.cellInfo[q.X, q.Y].Seen && fromSrc.cellInfo[q.X, q.Y].MinCost < float.PositiveInfinity)
return MakeBidiPath(fromSrc, fromDest, q);
}
return new List<int2>();
}
}
static List<int2> MakeBidiPath(PathSearch a, PathSearch b, int2 p)

View File

@@ -191,37 +191,37 @@ namespace OpenRA.Mods.RA.Move
search.AddInitialCell( sl );
return search;
}
static readonly Queue<CellInfo[,]> cellInfoPool = new Queue<CellInfo[,]>();
static CellInfo[,] GetFromPool()
{
lock (cellInfoPool)
return cellInfoPool.Dequeue();
}
static void PutBackIntoPool(CellInfo[,] ci)
{
lock (cellInfoPool)
cellInfoPool.Enqueue(ci);
}
static readonly Queue<CellInfo[,]> cellInfoPool = new Queue<CellInfo[,]>();
static CellInfo[,] GetFromPool()
{
lock (cellInfoPool)
return cellInfoPool.Dequeue();
}
static void PutBackIntoPool(CellInfo[,] ci)
{
lock (cellInfoPool)
cellInfoPool.Enqueue(ci);
}
CellInfo[ , ] InitCellInfo()
{
CellInfo[,] result = null;
while (cellInfoPool.Count > 0)
{
var cellInfo = GetFromPool();
if (cellInfo.GetUpperBound(0) != world.Map.MapSize.X - 1 ||
cellInfo.GetUpperBound(1) != world.Map.MapSize.Y - 1)
{
Log.Write("debug", "Discarding old pooled CellInfo of wrong size.");
continue;
}
result = cellInfo;
break;
{
CellInfo[,] result = null;
while (cellInfoPool.Count > 0)
{
var cellInfo = GetFromPool();
if (cellInfo.GetUpperBound(0) != world.Map.MapSize.X - 1 ||
cellInfo.GetUpperBound(1) != world.Map.MapSize.Y - 1)
{
Log.Write("debug", "Discarding old pooled CellInfo of wrong size.");
continue;
}
result = cellInfo;
break;
}
if (result == null)
@@ -243,20 +243,20 @@ namespace OpenRA.Mods.RA.Move
int straight = Math.Abs( d.X - d.Y );
return (3400 * diag / 24) + (100 * straight);
};
}
bool disposed;
public void Dispose()
{
if (disposed)
return;
disposed = true;
GC.SuppressFinalize(this);
PutBackIntoPool(cellInfo);
cellInfo = null;
}
~PathSearch() { Dispose(); }
}
bool disposed;
public void Dispose()
{
if (disposed)
return;
disposed = true;
GC.SuppressFinalize(this);
PutBackIntoPool(cellInfo);
cellInfo = null;
}
~PathSearch() { Dispose(); }
}
}