Fixes brace style (#248)
This commit is contained in:
parent
a236617ad9
commit
8149620b0c
1503 changed files with 28575 additions and 1717 deletions
|
|
@ -77,17 +77,21 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
var popIndex = 0;
|
||||
|
||||
for (var i = 1; i < openCount; ++i)
|
||||
{
|
||||
if (open[i].g + open[i].h < curF)
|
||||
{
|
||||
curNode = open[i];
|
||||
curF = curNode.g + curNode.h;
|
||||
popIndex = i;
|
||||
}
|
||||
}
|
||||
|
||||
if (curNode.x == goalNode.x && curNode.y == goalNode.y && Math.Abs(curNode.z - goalNode.z) < 16)
|
||||
{
|
||||
if (closedCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
closed[closedCount++] = curNode;
|
||||
|
||||
|
|
@ -96,7 +100,9 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
var zBacktrack = curNode.pz;
|
||||
|
||||
if (pathCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
path[pathCount++] = (Direction)curNode.dir;
|
||||
|
||||
|
|
@ -105,10 +111,13 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
var found = false;
|
||||
|
||||
for (var j = 0; !found && j < closedCount; ++j)
|
||||
{
|
||||
if (closed[j].x == xBacktrack && closed[j].y == yBacktrack && closed[j].z == zBacktrack)
|
||||
{
|
||||
if (pathCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
curNode = closed[j];
|
||||
path[pathCount++] = (Direction)curNode.dir;
|
||||
|
|
@ -117,6 +126,7 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
zBacktrack = curNode.pz;
|
||||
found = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found)
|
||||
{
|
||||
|
|
@ -125,16 +135,22 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
}
|
||||
|
||||
if (pathCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (pathCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
var dirs = new Direction[pathCount];
|
||||
|
||||
while (pathCount > 0)
|
||||
{
|
||||
dirs[iBacktrack++] = path[--pathCount];
|
||||
}
|
||||
|
||||
return dirs;
|
||||
}
|
||||
|
|
@ -142,7 +158,9 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
--openCount;
|
||||
|
||||
for (var i = popIndex; i < openCount; ++i)
|
||||
{
|
||||
open[i] = open[i + 1];
|
||||
}
|
||||
|
||||
var sucCount = 0;
|
||||
|
||||
|
|
@ -208,7 +226,9 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
MoveImpl.Goal = Point3D.Zero;
|
||||
|
||||
if (sucCount == 0 || ++depth > MaxDepth)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
for (var i = 0; i < sucCount; ++i)
|
||||
{
|
||||
|
|
@ -221,25 +241,39 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
int openIndex = -1, closedIndex = -1;
|
||||
|
||||
for (var j = 0; openIndex == -1 && j < openCount; ++j)
|
||||
{
|
||||
if (open[j].x == x && open[j].y == y && open[j].z == z)
|
||||
{
|
||||
openIndex = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (openIndex >= 0 && open[openIndex].g < successors[i].g)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
for (var j = 0; closedIndex == -1 && j < closedCount; ++j)
|
||||
{
|
||||
if (closed[j].x == x && closed[j].y == y && closed[j].z == z)
|
||||
{
|
||||
closedIndex = j;
|
||||
}
|
||||
}
|
||||
|
||||
if (closedIndex >= 0 && closed[closedIndex].g < successors[i].g)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (openIndex >= 0)
|
||||
{
|
||||
--openCount;
|
||||
|
||||
for (var j = openIndex; j < openCount; ++j)
|
||||
{
|
||||
open[j] = open[j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
if (closedIndex >= 0)
|
||||
|
|
@ -247,7 +281,9 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
--closedCount;
|
||||
|
||||
for (var j = closedIndex; j < closedCount; ++j)
|
||||
{
|
||||
closed[j] = closed[j + 1];
|
||||
}
|
||||
}
|
||||
|
||||
successors[i].px = curNode.x;
|
||||
|
|
@ -257,13 +293,17 @@ namespace Server.PathAlgorithms.SlowAStar
|
|||
successors[i].h = Heuristic(x, y, z);
|
||||
|
||||
if (openCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
open[openCount++] = successors[i];
|
||||
}
|
||||
|
||||
if (openCount == MaxNodes || closedCount == MaxNodes)
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
closed[closedCount++] = curNode;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue