* 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
master
Giel van Schijndel 2008-04-15 21:51:26 +00:00
parent 12ff794e99
commit a855f10f4e
2 changed files with 15 additions and 16 deletions

View File

@ -50,7 +50,7 @@
#define NUM_DIR 8 #define NUM_DIR 8
// Convert a direction into an offset // Convert a direction into an offset
// dir 0 => x = 0, y = -1 // dir 0 => x = 0, y = -1
static Vector2i aDirOffset[NUM_DIR] = static const Vector2i aDirOffset[NUM_DIR] =
{ {
{ 0, 1}, { 0, 1},
{-1, 1}, {-1, 1},
@ -91,13 +91,17 @@ BOOL fpathInitialise(void)
return true; 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) void fpathUpdate(void)
{ {
if ((psPartialRouteObj != NULL) && if (psPartialRouteObj != NULL
((psPartialRouteObj->died) || && (psPartialRouteObj->died
(((DROID*)psPartialRouteObj)->sMove.Status != MOVEWAITROUTE) || || ((DROID*)psPartialRouteObj)->sMove.Status != MOVEWAITROUTE
((lastPartialFrame + 5) < (SDWORD)frameGetFrameNumber()) ) ) || (lastPartialFrame + 5) < frameGetFrameNumber()))
{ {
psPartialRouteObj = NULL; 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 // 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) && if (psCurr != psDroid
(psCurr != (DROID *)psPartialRouteObj) && && psCurr != (DROID *)psPartialRouteObj
(psCurr->sMove.psFormation == psFormation) && && psCurr->sMove.psFormation == psFormation
(psCurr->sMove.numPoints > 0)) && psCurr->sMove.numPoints > 0)
{ {
// find the first route point // find the first route point
if (!fpathFindFirstRoutePoint(&psCurr->sMove, &index, sX,sY, (SDWORD)psCurr->pos.x, (SDWORD)psCurr->pos.y)) if (!fpathFindFirstRoutePoint(&psCurr->sMove, &index, sX,sY, (SDWORD)psCurr->pos.x, (SDWORD)psCurr->pos.y))

View File

@ -40,11 +40,6 @@ typedef enum _fpath_retval
/** Initialise the path-finding module. */ /** Initialise the path-finding module. */
extern BOOL fpathInitialise(void); 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); extern void fpathUpdate(void);
/** Find a route for an object to a location. */ /** Find a route for an object to a location. */