Also restore the LOS optimization of paths for trunk, removed in r4637, so

that long paths work again.


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4841 4a71c877-e1ca-e34f-864e-861f7616d084
master
Per Inge Mathisen 2008-04-28 18:33:07 +00:00
parent eedd38bd80
commit 63d537d458
1 changed files with 38 additions and 0 deletions

View File

@ -322,6 +322,41 @@ BOOL fpathTileLOS(SDWORD x1,SDWORD y1, SDWORD x2,SDWORD y2)
return !obstruction;
}
// Optimise the route
static void fpathOptimise(FP_NODE *psRoute)
{
FP_NODE *psCurr, *psSearch, *psTest;
BOOL los;
ASSERT( psRoute != NULL,
"fpathOptimise: NULL route pointer" );
psCurr = psRoute;
do
{
// work down the route looking for a failed LOS
los = true;
psSearch = psCurr->psRoute;
while (psSearch)
{
psTest = psSearch->psRoute;
if (psTest)
{
los = fpathTileLOS(psCurr->x,psCurr->y, psTest->x,psTest->y);
}
if (!los)
{
break;
}
psSearch = psTest;
}
// store the previous successful point
psCurr->psRoute = psSearch;
psCurr = psSearch;
} while (psCurr);
}
SDWORD fpathAStarRoute(SDWORD routeMode, ASTAR_ROUTE *psRoutePoints,
SDWORD sx, SDWORD sy, SDWORD fx, SDWORD fy)
{
@ -487,6 +522,9 @@ static FP_NODE *psNearest, *psRoute;
if (psRoute)
{
// optimise the route if one was found
fpathOptimise(psRoute);
// get the route in the correct order
// If as I suspect this is to reverse the list, then it's my suspicion that
// we could route from destination to source as opposed to source to