This commit is contained in:
jarod42 2004-06-25 15:16:22 +00:00
parent f10d5c5c8e
commit 43a340ee34
8 changed files with 368 additions and 362 deletions

View file

@ -49,16 +49,16 @@
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
typedef struct _node_ { typedef struct _node_ {
char Direction; /// Direction for trace back char Direction; ///< Direction for trace back
char InGoal; /// is this point in the goal char InGoal; ///< is this point in the goal
int CostFromStart; /// Real costs to reach this point int CostFromStart; ///< Real costs to reach this point
} Node; } Node;
typedef struct _open_ { typedef struct _open_ {
int X; /// X coordinate int X; ///< X coordinate
int Y; /// Y coordinate int Y; ///< Y coordinate
int O; /// Offset into matrix int O; ///< Offset into matrix
int Costs; /// complete costs to goal int Costs; ///< complete costs to goal
} Open; } Open;
/// heuristic cost fonction for a star /// heuristic cost fonction for a star

View file

@ -28,10 +28,10 @@
// //
// $Id$ // $Id$
//@{
#ifdef MAP_REGIONS #ifdef MAP_REGIONS
//@{
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
-- Includes -- Includes
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -74,7 +74,7 @@ int ZoneNeedRefresh;
** Unassign a tile to a region. ** Unassign a tile to a region.
** Connections are not updated here ** Connections are not updated here
** **
** @param region the region ID ** @param region The region ID
** @param x X coord of the tile ** @param x X coord of the tile
** @param y Y coord of the tile ** @param y Y coord of the tile
*/ */
@ -147,7 +147,7 @@ void RegionUnassignTile(RegionId region, int x, int y)
** Assign a tile to a region. ** Assign a tile to a region.
** Connections are not updated here ** Connections are not updated here
** **
** @param region the region ID ** @param region The region ID
** @param x X coord of the tile ** @param x X coord of the tile
** @param y Y coord of the tile ** @param y Y coord of the tile
*/ */
@ -298,7 +298,7 @@ void UpdateConnections(void)
** **
** @param reg The region to split ** @param reg The region to split
** @param nbarea The number of area ** @param nbarea The number of area
** @param updateConnections indicate if connection should be updated ** @param updateConnections Indicate if connection should be updated
*/ */
void RegionSplitUsingTemp(RegionId reg, int nbarea, int updateConnections) void RegionSplitUsingTemp(RegionId reg, int nbarea, int updateConnections)
{ {
@ -558,7 +558,7 @@ void RegionSplit(RegionId regid, int updateConnections)
/** /**
** Check that the given region is 8 - connex ** Check that the given region is 8 - connex
** ( all its tiles are reachable ) ** (all its tiles are reachable)
** **
** @param reg the region ID ** @param reg the region ID
*/ */
@ -612,7 +612,8 @@ void RegionCheckConnex(RegionId reg)
** @param x x position of the tile ** @param x x position of the tile
** @param y y position of the tile ** @param y y position of the tile
*/ */
static void MapSplitterTileOccuped(int x, int y) { static void MapSplitterTileOccuped(int x, int y)
{
RegionId reg; RegionId reg;
int tx; int tx;
int ty; int ty;
@ -676,7 +677,8 @@ static void MapSplitterTileOccuped(int x, int y) {
** @param x1 x1 coord of the changed rectangle ** @param x1 x1 coord of the changed rectangle
** @param y1 y1 coord of the changed rectangle ** @param y1 y1 coord of the changed rectangle
*/ */
void MapSplitterTilesCleared(int x0, int y0, int x1, int y1) { void MapSplitterTilesCleared(int x0, int y0, int x1, int y1)
{
static int directions[5][2] = {{1,0},{0,1},{-1,0},{0,-1},{0,0}}; static int directions[5][2] = {{1,0},{0,1},{-1,0},{0,-1},{0,0}};
int x; int x;
int y; int y;
@ -985,7 +987,7 @@ void InitaliseMapping(void)
** The point closer to (refx,refy) in (a) is returned ** The point closer to (refx,refy) in (a) is returned
** **
** @param a a zone number ** @param a a zone number
** @param b the other zone number ** @param b The other zone number
** @param refx Search closest to (refx,refy) ** @param refx Search closest to (refx,refy)
** @param refy Search closest to (refx,refy) ** @param refy Search closest to (refx,refy)
** @param rsltx Will hold result X ** @param rsltx Will hold result X
@ -1281,5 +1283,7 @@ void ClearZoneNeedRefresh(void)
} }
} }
#endif // MAP_REGIONS
//@} //@}
#endif // MAP_REGIONS

View file

@ -38,8 +38,8 @@
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
// Should be enough for every one :-) // Should be enough for every one :-)
#define MaxZoneNumber 512 /// Max number of zone ( separated area ) #define MaxZoneNumber 512 ///< Max number of zone ( separated area )
#define MaxRegionNumber 4096 /// Max number of regions ( divisions of zones ) #define MaxRegionNumber 4096 ///< Max number of regions ( divisions of zones )
#define NoRegion ((RegionId)~0UL) #define NoRegion ((RegionId)~0UL)

View file

@ -28,10 +28,10 @@
// //
// $Id$ // $Id$
//@{
#ifdef MAP_REGIONS #ifdef MAP_REGIONS
//@{
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
-- Includes -- Includes
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -52,8 +52,8 @@
/** /**
** Remove a segment from a region ** Remove a segment from a region
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param seg the segment to remove ** @param seg The segment to remove
*/ */
void RegionDelSegment(RegionDefinition* def, RegionSegment* seg) void RegionDelSegment(RegionDefinition* def, RegionSegment* seg)
{ {
@ -75,10 +75,10 @@ void RegionDelSegment(RegionDefinition* def, RegionSegment* seg)
/** /**
** Add a segment to a region ** Add a segment to a region
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param seg the segment to add ** @param seg The segment to add
*/ */
void RegionAddSegment(RegionDefinition * def,int x0,int x1,int y) void RegionAddSegment(RegionDefinition* def,int x0,int x1,int y)
{ {
RegionSegment* seg; RegionSegment* seg;
seg = (RegionSegment*) malloc(sizeof(RegionSegment)); seg = (RegionSegment*) malloc(sizeof(RegionSegment));
@ -101,12 +101,12 @@ void RegionAddSegment(RegionDefinition * def,int x0,int x1,int y)
/** /**
** Add a segment to a region. Eventually, existing segment are collapsed ** Add a segment to a region. Eventually, existing segment are collapsed
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param x0 Minimum x of the segment ** @param x0 Minimum x of the segment
** @param x0 Maximum x of the segment ** @param x1 Maximum x of the segment
** @param y Y coord of the segment ** @param y Y coord of the segment
*/ */
void RegionAppendSegment(RegionDefinition * def,int x0,int x1,int y) void RegionAppendSegment(RegionDefinition* def, int x0, int x1, int y)
{ {
RegionSegment* seg; RegionSegment* seg;
seg = def->FirstSegment; seg = def->FirstSegment;
@ -127,7 +127,7 @@ void RegionAppendSegment(RegionDefinition * def,int x0,int x1,int y)
/** /**
** Update min & max in a region ** Update min & max in a region
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param x X coord of a cell ** @param x X coord of a cell
** @param y Y coord of a cell ** @param y Y coord of a cell
*/ */
@ -158,12 +158,12 @@ void RegionUpdateMinMax(RegionDefinition* adef,int x,int y)
/** /**
** Find A point one a region, closest to a given vertical line (x) ** Find A point one a region, closest to a given vertical line (x)
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param x x coord of the vertical line ** @param x x coord of the vertical line
** @param vx X result value ** @param vx X result value
** @param vy Y result value ** @param vy Y result value
*/ */
void RegionFindPointOnX(RegionDefinition * def,int x,int * vx,int * vy) void RegionFindPointOnX(RegionDefinition* def,int x,int * vx,int * vy)
{ {
RegionSegment *cur; RegionSegment *cur;
int bestx, besty, bestxdelta, bestydelta; int bestx, besty, bestxdelta, bestydelta;
@ -211,12 +211,12 @@ void RegionFindPointOnX(RegionDefinition * def,int x,int * vx,int * vy)
/** /**
** Find A point one a region, closest to a given horizontal line (y) ** Find A point one a region, closest to a given horizontal line (y)
** **
** @param def the RegionDefinition structure ** @param def The RegionDefinition structure
** @param x y coord of the horizontal line ** @param x y coord of the horizontal line
** @param vx X result value ** @param vx X result value
** @param vy Y result value ** @param vy Y result value
*/ */
void RegionFindPointOnY(RegionDefinition * def,int y,int * vx,int * vy) void RegionFindPointOnY(RegionDefinition* def,int y,int * vx,int * vy)
{ {
RegionSegment *cur; RegionSegment *cur;
int bestx, besty, bestxdelta, bestydelta; int bestx, besty, bestxdelta, bestydelta;
@ -280,8 +280,8 @@ void RegionTempStorageFree(void)
/** /**
** Fill a region in the temp storage area ** Fill a region in the temp storage area
** **
** @param adef the region definition ** @param adef The region definition
** @param value value to fill with ** @param value Value to fill with
*/ */
void RegionTempStorageFillRegion(RegionDefinition* adef,int value) void RegionTempStorageFillRegion(RegionDefinition* adef,int value)
{ {
@ -306,8 +306,8 @@ void RegionTempStorageFillRegion(RegionDefinition* adef,int value)
/** /**
** Unmark points of a regions in the temp storage area ** Unmark points of a regions in the temp storage area
** **
** @param regid the regiond ID ** @param regid The regiond ID
** @param markvalue cells with value == markvalue will become 0 ** @param markvalue Cells with value == markvalue will become 0
*/ */
void RegionTempStorageUnmarkPoints(RegionId regid, int markvalue) void RegionTempStorageUnmarkPoints(RegionId regid, int markvalue)
{ {
@ -335,14 +335,14 @@ void RegionTempStorageUnmarkPoints(RegionId regid, int markvalue)
/** /**
** Mark some points of a region in the temp storage area ** Mark some points of a region in the temp storage area
** **
** @param regid the regiond ID ** @param regid The regiond ID
** @param points MapPoint array ** @param points MapPoint array
** @param nbpoint MapPoint array size ** @param nbpoint MapPoint array size
** @param maxmak Maximum number of point to mark ** @param maxmak Maximum number of point to mark
** @param markvalu points get marked with this value ** @param markvalue Points get marked with this value
** @return The number of points marked ** @return The number of points marked
*/ */
static int RegionTempStorageMarkPoints(RegionId regid, MapPoint * points, int nbpoints, int maxmark,int markvalue) static int RegionTempStorageMarkPoints(RegionId regid, MapPoint* points, int nbpoints, int maxmark, int markvalue)
{ {
int id; int id;
int rslt; int rslt;
@ -376,9 +376,9 @@ static int RegionTempStorageMarkPoints(RegionId regid, MapPoint * points, int nb
/** /**
** Mark limits of a regions in the temp storage area ** Mark limits of a regions in the temp storage area
** **
** @param regid the regiond ID ** @param regid The regiond ID
** @param maxmak Maximum number of point to mark ** @param maxmak Maximum number of point to mark
** @param markvalu points get marked with this value ** @param markvalue Points get marked with this value
*/ */
int RegionTempStorageMarkObstacle(RegionId regid, int maxmark,int markvalue) int RegionTempStorageMarkObstacle(RegionId regid, int maxmark,int markvalue)
{ {
@ -475,16 +475,16 @@ int RegionTempStorageMarkObstacle(RegionId regid, int maxmark,int markvalue)
** Make marked points bigger ( mark their adjacent with markvalue + 1 ) ** Make marked points bigger ( mark their adjacent with markvalue + 1 )
** Multiple invoquation lead to bigger marks ** Multiple invoquation lead to bigger marks
** **
** @param regid the regiond ID ** @param regid The regiond ID
** @param maxmak Maximum number of point to mark ** @param maxmak Maximum number of point to mark
** @param markvalu points marked with this value will be "grown" ** @param markvalue Points marked with this value will be "grown"
*/ */
int RegionTempStorageEmbossObstacle(RegionId regid, int maxmark,int markvalue) int RegionTempStorageEmbossObstacle(RegionId regid, int maxmark,int markvalue)
{ {
int markednb; int markednb;
RegionDefinition * adef; RegionDefinition* adef;
RegionSegment * seg; RegionSegment* seg;
MapPoint * marked; MapPoint* marked;
int x,y; int x,y;
int tx,ty; int tx,ty;
int i; int i;
@ -543,7 +543,7 @@ int RegionTempStorageEmbossObstacle(RegionId regid, int maxmark,int markvalue)
*/ */
void RegionSetConnection(RegionId rega, RegionId regb, int value) void RegionSetConnection(RegionId rega, RegionId regb, int value)
{ {
RegionDefinition * adef; RegionDefinition* adef;
int j; int j;
adef = Regions + rega; adef = Regions + rega;
@ -819,7 +819,7 @@ void RegionRescanAdjacents(RegionId regid)
** @param add 1 if cell is added to the region, 0 else ** @param add 1 if cell is added to the region, 0 else
** @param bidir Operate in both directions ** @param bidir Operate in both directions
*/ */
void RegionUpdateConnection(RegionId reg,int x,int y,int add,int bidir) void RegionUpdateConnection(RegionId reg, int x, int y, int add, int bidir)
{ {
int adj; int adj;
int ax, ay; int ax, ay;
@ -846,6 +846,7 @@ void RegionUpdateConnection(RegionId reg,int x,int y,int add,int bidir)
} }
} }
//@}
#endif // MAP_REGIONS #endif // MAP_REGIONS
//@}

View file

@ -28,10 +28,10 @@
// //
// $Id$ // $Id$
//@{
#ifdef MAP_REGIONS #ifdef MAP_REGIONS
//@{
/*---------------------------------------------------------------------------- /*----------------------------------------------------------------------------
-- Includes -- Includes
----------------------------------------------------------------------------*/ ----------------------------------------------------------------------------*/
@ -76,8 +76,8 @@ void ZoneSetClear(ZoneSet* m)
/** /**
** Add a zone to a ZoneSet structure ** Add a zone to a ZoneSet structure
** **
** @param m pointer to a ZoneSet structure ** @param m Pointer to a ZoneSet structure
** @param zone zone to add ** @param zone Zone to add
** @return 1 if the zone is new in the set ** @return 1 if the zone is new in the set
*/ */
int ZoneSetAddZone(ZoneSet * m, int zone) int ZoneSetAddZone(ZoneSet * m, int zone)
@ -160,7 +160,7 @@ void ZoneSetIntersect(ZoneSet* dst, ZoneSet* src)
** @param x X coord of the map cell ** @param x X coord of the map cell
** @param y Y coord of the map cell ** @param y Y coord of the map cell
*/ */
void ZoneSetAddCell(ZoneSet * zs,int x,int y) void ZoneSetAddCell(ZoneSet* zs, int x, int y)
{ {
RegionId region; RegionId region;
@ -177,10 +177,10 @@ void ZoneSetAddCell(ZoneSet * zs,int x,int y)
** Check if a ZoneSet contains a given zone ** Check if a ZoneSet contains a given zone
** **
** @param zs pointer to the ZoneSet ** @param zs pointer to the ZoneSet
** @param zone the zone ** @param zone The zone
** @return 1 if zs contains the zone, 0 else ** @return 1 if zs contains the zone, 0 else
*/ */
int ZoneSetContains(ZoneSet * zs,int zone) int ZoneSetContains(ZoneSet* zs, int zone)
{ {
return zs->Marks[zone] == zs->Id; return zs->Marks[zone] == zs->Id;
} }
@ -196,9 +196,9 @@ int ZoneSetContains(ZoneSet * zs,int zone)
** @param range Range around the rectangle ** @param range Range around the rectangle
** @param mask Mask to check cell for ** @param mask Mask to check cell for
*/ */
static void ZoneSetAddPassableRange(ZoneSet * zs,int x0,int y0,int x1,int y1,int range,int mask) static void ZoneSetAddPassableRange(ZoneSet* zs, int x0, int y0, int x1, int y1, int range, int mask)
{ {
static int turn[5][2]={{1,0},{0,1},{-1,0},{0,-1}}; static const int turn[5][2] = {{1,0},{0,1},{-1,0},{0,-1}};
int x,y; int x,y;
int dir; int dir;
@ -226,8 +226,8 @@ static void ZoneSetAddPassableRange(ZoneSet * zs,int x0,int y0,int x1,int y1,int
/** /**
** Add the zone(s) accessible by an unit ** Add the zone(s) accessible by an unit
** **
** @param source pointer to a ZoneSet ** @param source Pointer to a ZoneSet
** @param src pointer to an unit ** @param src Pointer to an unit
*/ */
void ZoneSetAddUnitZones(ZoneSet * source,Unit * src) void ZoneSetAddUnitZones(ZoneSet * source,Unit * src)
{ {
@ -313,7 +313,7 @@ void ZoneSetAddGoalZones(ZoneSet* dest,Unit* src, int goal_x, int goal_y,int w,i
** Only Water-to-Land connexion are taken into account. ** Only Water-to-Land connexion are taken into account.
** **
** @param dst pointer to a ZoneSet ** @param dst pointer to a ZoneSet
** @param zone the zone which adjacent are searched ** @param zone The zone which adjacent are searched
*/ */
static void ZoneSetAddZoneAdjacents(ZoneSet * dst, int zone) static void ZoneSetAddZoneAdjacents(ZoneSet * dst, int zone)
{ {
@ -356,10 +356,10 @@ void ZoneSetAddConnected(ZoneSet* dst, ZoneSet * src)
** @param path will hold the zones ** @param path will hold the zones
** @param pathlen will hold the path length ** @param pathlen will hold the path length
*/ */
int ZoneSetFindPath(ZoneSet* src,ZoneSet* dst,int * path,int * pathlen) int ZoneSetFindPath(ZoneSet* src, ZoneSet* dst, int* path, int* pathlen)
{ {
static ZoneSet current={0}; static ZoneSet current = {0};
static ZoneSet newzones={0}; static ZoneSet newzones = {0};
int zonedst[MaxZoneNumber]; int zonedst[MaxZoneNumber];
int zonenext[MaxZoneNumber]; int zonenext[MaxZoneNumber];
int i, j, curdst; int i, j, curdst;
@ -425,6 +425,7 @@ int ZoneSetFindPath(ZoneSet* src,ZoneSet* dst,int * path,int * pathlen)
} while(1); } while(1);
} }
#endif // MAP_REGIONS
//@} //@}
#endif // MAP_REGIONS