From a855f10f4e64a22da6c1f5c6fcc3c7b186037c2d Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Tue, 15 Apr 2008 21:51:26 +0000 Subject: [PATCH] * Make static array aDirOffset const * Rewrite the Doxygen comment for fpathUpdate() * Some style fixes git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@4648 4a71c877-e1ca-e34f-864e-861f7616d084 --- src/fpath.c | 26 +++++++++++++++----------- src/fpath.h | 5 ----- 2 files changed, 15 insertions(+), 16 deletions(-) diff --git a/src/fpath.c b/src/fpath.c index 4df74363e..87fa540da 100644 --- a/src/fpath.c +++ b/src/fpath.c @@ -50,7 +50,7 @@ #define NUM_DIR 8 // Convert a direction into an offset // dir 0 => x = 0, y = -1 -static Vector2i aDirOffset[NUM_DIR] = +static const Vector2i aDirOffset[NUM_DIR] = { { 0, 1}, {-1, 1}, @@ -91,13 +91,17 @@ BOOL fpathInitialise(void) return true; } -// update routine for the findpath system +/** Updates the pathfinding system. + * @post Pathfinding jobs for objects that died, aren't waiting for a route + * anymore, or the currently calculated route is outdated for, are + * removed from the job queue. + */ void fpathUpdate(void) { - if ((psPartialRouteObj != NULL) && - ((psPartialRouteObj->died) || - (((DROID*)psPartialRouteObj)->sMove.Status != MOVEWAITROUTE) || - ((lastPartialFrame + 5) < (SDWORD)frameGetFrameNumber()) ) ) + if (psPartialRouteObj != NULL + && (psPartialRouteObj->died + || ((DROID*)psPartialRouteObj)->sMove.Status != MOVEWAITROUTE + || (lastPartialFrame + 5) < frameGetFrameNumber())) { psPartialRouteObj = NULL; } @@ -796,12 +800,12 @@ static BOOL fpathFindRoute(DROID *psDroid, SDWORD sX,SDWORD sY, SDWORD tX,SDWORD } // now look for a unit in this formation with a route that can be used - for(psCurr = apsDroidLists[psDroid->player]; psCurr; psCurr = psCurr->psNext) + for (psCurr = apsDroidLists[psDroid->player]; psCurr; psCurr = psCurr->psNext) { - if ((psCurr != psDroid) && - (psCurr != (DROID *)psPartialRouteObj) && - (psCurr->sMove.psFormation == psFormation) && - (psCurr->sMove.numPoints > 0)) + if (psCurr != psDroid + && psCurr != (DROID *)psPartialRouteObj + && psCurr->sMove.psFormation == psFormation + && psCurr->sMove.numPoints > 0) { // find the first route point if (!fpathFindFirstRoutePoint(&psCurr->sMove, &index, sX,sY, (SDWORD)psCurr->pos.x, (SDWORD)psCurr->pos.y)) diff --git a/src/fpath.h b/src/fpath.h index c30aaa1ac..df386b585 100644 --- a/src/fpath.h +++ b/src/fpath.h @@ -40,11 +40,6 @@ typedef enum _fpath_retval /** Initialise the path-finding module. */ extern BOOL fpathInitialise(void); -/** - * Update the findpath system each frame. It checks whether a game object has a - * path-finding job that was not finished in the previous frame, and if this - * game object is dead, remove it from the job queue. - */ extern void fpathUpdate(void); /** Find a route for an object to a location. */