Make astarInner an `int` and ASSERT that it stays non-negative (i.e. that it doesn't overflow)

git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4725 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2008-04-21 09:25:10 +00:00
parent a36a4fd3c3
commit 489896d627
3 changed files with 8 additions and 2 deletions

View File

@ -41,7 +41,7 @@ static SDWORD astarOuter, astarRemove;
*
* @ingroup pathfinding
*/
SDWORD astarInner;
int astarInner = 0;
// The structure to store a node of the route
typedef struct _fp_node
@ -450,6 +450,8 @@ static FP_NODE *psNearest, *psRoute;
}
astarInner += 1;
ASSERT(astarInner >= 0, "astarInner overflowed!");
// Now insert the point into the appropriate list
if (!psFound)

View File

@ -51,9 +51,11 @@ typedef struct _astar_route
} ASTAR_ROUTE;
// counters for a-star
extern SDWORD astarInner;
extern int astarInner;
/** Reset the A* counters
*
* This function resets astarInner among others.
*
* @ingroup pathfinding
*/

View File

@ -694,6 +694,8 @@ FPATH_RETVAL fpathRoute(DROID* psDroid, MOVE_CONTROL *psMoveCntl,
fpathBlockingTile == fpathLiftBlockingTile,
"fpathRoute: invalid blocking function" );
ASSERT(astarInner >= 0, "astarInner overflowed!");
if (astarInner > FPATH_LOOP_LIMIT)
{
// Time out