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-861f7616d084master
parent
a36a4fd3c3
commit
489896d627
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue