_________ __                 __
        /   _____//  |_____________ _/  |______     ____  __ __  ______
        \_____  \\   __\_  __ \__  \\   __\__  \   / ___\|  |  \/  ___/
        /        \|  |  |  | \// __ \|  |  / __ \_/ /_/  >  |  /\___ \
       /_______  /|__|  |__|  (____  /__| (____  /\___  /|____//____  >
               \/                  \/          \//_____/            \/
    ______________________                           ______________________
                          T H E   W A R   B E G I N S
                   Stratagus - A free fantasy real time strategy game engine

Classes
pathfinder.h File Reference
#include <queue>
#include "vec2i.h"

Go to the source code of this file.

Classes

class  PathFinderInput
 
class  PathFinderOutput
 
class  PathFinderData
 
class  TerrainTraversal
 

pathfinder.h - The path finder headerfile.

#define AstarDebugPrint(x)
 
enum  _move_return_ {
  PF_FAILED = -3, PF_UNREACHABLE = -2, PF_REACHED = -1, PF_WAIT = 0,
  PF_MOVE = 1
}
 
enum  VisitResult { VisitResult_Finished, VisitResult_DeadEnd, VisitResult_Ok, VisitResult_Cancel }
 
int AStarFixedUnitCrossingCost
 cost associated to move on a tile occupied by a fixed unit More...
 
int AStarMovingUnitCrossingCost
 cost associated to move on a tile occupied by a moving unit More...
 
bool AStarKnowUnseenTerrain
 Whether to have knowledge of terrain that we haven't visited yet. More...
 
int AStarUnknownTerrainCost
 Cost of using a square we haven't seen before. More...
 
int AStarMaxSearchIterations
 Maximum number of iterations of A* before giving up. More...
 
const int Heading2X [9]
 
const int Heading2Y [9]
 
const int XY2Heading [3][3]
 
void InitPathfinder ()
 Init the pathfinder. More...
 
void FreePathfinder ()
 Free the pathfinder. More...
 
int NextPathElement (CUnit &unit, short int *xdp, short int *ydp)
 Returns the next element of the path. More...
 
int UnitReachable (const CUnit &src, const CUnit &dst, int range, bool from_outside_container)
 Return path length to unit 'dst'. More...
 
int CalcPathLengthToUnit (const CUnit &src, const CUnit &dst, const int minrange, const int range)
 Return path length to unit 'dst' or error code. More...
 
int PlaceReachable (const CUnit &src, const Vec2i &pos, int w, int h, int minrange, int maxrange, bool from_outside_container)
 Can the unit 'src' reach the place x,y. More...
 
void SetAStarFixedUnitCrossingCost (int cost)
 
int GetAStarFixedUnitCrossingCost ()
 
void SetAStarMovingUnitCrossingCost (int cost)
 
int GetAStarMovingUnitCrossingCost ()
 
void SetAStarUnknownTerrainCost (int cost)
 
int GetAStarUnknownTerrainCost ()
 
void SetAStarFixedEnemyUnitsUnpassable (const bool value)
 
bool GetAStarFixedEnemyUnitsUnpassable ()
 
void PathfinderCclRegister ()
 

Macro Definition Documentation

◆ AstarDebugPrint

#define AstarDebugPrint (   x)

Enumeration Type Documentation

◆ _move_return_

Result codes of the pathfinder.

Todo:
Another idea is SINT_MAX as reached, SINT_MIN as unreachable stop others how far to goal.
Enumerator
PF_FAILED 
PF_UNREACHABLE 

This Pathfinder failed, try another.

PF_REACHED 

Unreachable stop.

PF_WAIT 

Reached goal stop.

PF_MOVE 

Wait, no time or blocked.

◆ VisitResult

Enumerator
VisitResult_Finished 
VisitResult_DeadEnd 
VisitResult_Ok 
VisitResult_Cancel 

Function Documentation

◆ CalcPathLengthToUnit()

int CalcPathLengthToUnit ( const CUnit src,
const CUnit dst,
const int  minrange,
const int  range 
)

Return path length to unit 'dst' or error code.

Calc path length for the unit 'src' to reach the unit 'dst'.

Parameters
srcUnit for the path.
dstUnit to be reached.
minrangemin range to the tile
rangeRange to the tile.
Returns
path length to dst or error code

change Path Finder setting to don't count tiles with enemy units as passable

restore Path Finder setting

◆ FreePathfinder()

void FreePathfinder ( )

Free the pathfinder.

Free the pathfinder

◆ GetAStarFixedEnemyUnitsUnpassable()

bool GetAStarFixedEnemyUnitsUnpassable ( )

◆ GetAStarFixedUnitCrossingCost()

int GetAStarFixedUnitCrossingCost ( )

◆ GetAStarMovingUnitCrossingCost()

int GetAStarMovingUnitCrossingCost ( )

◆ GetAStarUnknownTerrainCost()

int GetAStarUnknownTerrainCost ( )

◆ InitPathfinder()

void InitPathfinder ( )

Init the pathfinder.

Init the pathfinder

◆ NextPathElement()

int NextPathElement ( CUnit unit,
short int *  pxd,
short int *  pyd 
)

Returns the next element of the path.

Returns the next element of a path.

Parameters
unitUnit that wants the path element.
pxdPointer for the x direction.
pydPointer for the y direction.
Returns
>0 remaining path length, 0 wait for path, -1 reached goal, -2 can't reach the goal.

◆ PathfinderCclRegister()

void PathfinderCclRegister ( )

Register CCL features for pathfinder.

◆ PlaceReachable()

int PlaceReachable ( const CUnit src,
const Vec2i goalPos,
int  w,
int  h,
int  minrange,
int  range,
bool  from_outside_container 
)

Can the unit 'src' reach the place x,y.

Can the unit 'src' reach the place goalPos.

Parameters
srcUnit for the path.
goalPosMap tile position.
wWidth of Goal
hHeight of Goal
minrangemin range to the tile
rangeRange to the tile.
Returns
Distance to place.

change Path Finder setting to don't count tiles with enemy units as passable

restore Path Finder setting

◆ SetAStarFixedEnemyUnitsUnpassable()

void SetAStarFixedEnemyUnitsUnpassable ( const bool  value)

◆ SetAStarFixedUnitCrossingCost()

void SetAStarFixedUnitCrossingCost ( int  cost)

◆ SetAStarMovingUnitCrossingCost()

void SetAStarMovingUnitCrossingCost ( int  cost)

◆ SetAStarUnknownTerrainCost()

void SetAStarUnknownTerrainCost ( int  cost)

◆ UnitReachable()

int UnitReachable ( const CUnit src,
const CUnit dst,
int  range,
bool  from_outside_container 
)

Return path length to unit 'dst'.

Can the unit 'src' reach the unit 'dst'.

Parameters
srcUnit for the path.
dstUnit to be reached.
rangeRange to unit.
Returns
Distance to place.

Variable Documentation

◆ AStarFixedUnitCrossingCost

int AStarFixedUnitCrossingCost

cost associated to move on a tile occupied by a fixed unit

cost associated to move on a tile occupied by a fixed unit

◆ AStarKnowUnseenTerrain

bool AStarKnowUnseenTerrain

Whether to have knowledge of terrain that we haven't visited yet.

◆ AStarMaxSearchIterations

int AStarMaxSearchIterations

Maximum number of iterations of A* before giving up.

◆ AStarMovingUnitCrossingCost

int AStarMovingUnitCrossingCost

cost associated to move on a tile occupied by a moving unit

◆ AStarUnknownTerrainCost

int AStarUnknownTerrainCost

Cost of using a square we haven't seen before.

◆ Heading2X

const int Heading2X[9]

◆ Heading2Y

const int Heading2Y[9]

◆ XY2Heading

const int XY2Heading[3][3]
(C) Copyright 1998-2012 by The Stratagus Project under the GNU General Public License.
All trademarks and copyrights on this page are owned by their respective owners.