Richard Boegli's CnC_Generals_Zero_Hour Fork WIP
This is documentation of Richard Boegil's Zero Hour Fork
 
Loading...
Searching...
No Matches
Pathfinder Class Reference

#include <AIPathfind.h>

Inherits PathfindServicesInterface, and Snapshot.

Public Member Functions

 Pathfinder (void)
 
 ~Pathfinder ()
 
void reset (void)
 Reset system in preparation for new map.
 
void crc (Xfer *xfer)
 run the "light" crc check on this data structure
 
void xfer (Xfer *xfer)
 
void loadPostProcess (void)
 
Bool clientSafeQuickDoesPathExist (const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to)
 Can we build any path at all between the locations (terrain & buildings check - fast)
 
Bool clientSafeQuickDoesPathExistForUI (const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to)
 Can we build any path at all between the locations (terrain onlyk - fast)
 
Bool slowDoesPathExist (Object *obj, const Coord3D *from, const Coord3D *to, ObjectID ignoreObject=INVALID_ID)
 Can we build any path at all between the locations (terrain, buildings & units check - slower)
 
Bool queueForPath (ObjectID id)
 The object wants to request a pathfind, so put it on the list to process.
 
void processPathfindQueue (void)
 Process some or all of the queued pathfinds.
 
void forceMapRecalculation ()
 Force pathfind map recomputation. If region is given, only that area is recomputed.
 
PathgetAircraftPath (const Object *obj, const Coord3D *to)
 
PathfindGroundPath (const Coord3D *from, const Coord3D *to, Int pathRadius, Bool crusher)
 Find a short, valid path of the desired width on the ground.
 
void addObjectToPathfindMap (class Object *obj)
 Classify the given object's cells in the map.
 
void removeObjectFromPathfindMap (class Object *obj)
 De-classify the given object's cells in the map.
 
void removeUnitFromPathfindMap (Object *obj)
 De-classify the given mobile unit's cells in the map.
 
void updateGoal (Object *obj, const Coord3D *newGoalPos, PathfindLayerEnum layer)
 Update the given mobile unit's cells in the map.
 
void updateAircraftGoal (Object *obj, const Coord3D *newGoalPos)
 Update the given aircraft unit's cells in the map.
 
void removeGoal (Object *obj)
 Removes the given mobile unit's goal cells in the map.
 
void updatePos (Object *obj, const Coord3D *newPos)
 Update the given mobile unit's cells in the map.
 
void removePos (Object *obj)
 Removes the unit's position cells from the map.
 
Bool moveAllies (Object *obj, Path *path)
 
void createAWallFromMyFootprint (Object *obj)
 
void removeWallFromMyFootprint (Object *obj)
 
PathgetMoveAwayFromPath (Object *obj, Object *otherObj, Path *pathToAvoid, Object *otherObj2, Path *pathToAvoid2)
 
void changeBridgeState (PathfindLayerEnum layer, Bool repaired)
 
Bool findBrokenBridge (const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to, ObjectID *bridgeID)
 
void newMap (void)
 
PathfindCellgetCell (PathfindLayerEnum layer, Int x, Int y)
 Return the cell at grid coords (x,y)
 
PathfindCellgetCell (PathfindLayerEnum layer, const Coord3D *pos)
 Given a position, return associated grid cell.
 
PathfindCellgetClippedCell (PathfindLayerEnum layer, const Coord3D *pos)
 Given a position, return associated grid cell.
 
void clip (Coord3D *from, Coord3D *to)
 
Bool worldToCell (const Coord3D *pos, ICoord2D *cell)
 Given a world position, return grid cell coordinate.
 
const ICoord2DgetExtent (void) const
 
void setIgnoreObstacleID (ObjectID objID)
 if non-zero, the pathfinder will ignore the given obstacle
 
Bool validMovementPosition (Bool isCrusher, LocomotorSurfaceTypeMask acceptableSurfaces, PathfindCell *toCell, PathfindCell *fromCell=NULL)
 Return true if given position is a valid movement location.
 
Bool validMovementPosition (Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet &locomotorSet, Int x, Int y)
 Return true if given position is a valid movement location.
 
Bool validMovementPosition (Bool isCrusher, PathfindLayerEnum layer, const LocomotorSet &locomotorSet, const Coord3D *pos)
 Return true if given position is a valid movement location.
 
Bool validMovementTerrain (PathfindLayerEnum layer, const Locomotor *locomotor, const Coord3D *pos)
 Return true if given position is a valid movement location.
 
LocomotorchooseBestLocomotorForPosition (PathfindLayerEnum layer, LocomotorSet *locomotorSet, const Coord3D *pos)
 
Bool isViewBlockedByObstacle (const Object *obj, const Object *objOther)
 Return true if the straight line between the given points contains any obstacle, and thus blocks vision.
 
Bool isAttackViewBlockedByObstacle (const Object *obj, const Coord3D &attackerPos, const Object *victim, const Coord3D &victimPos)
 Return true if the straight line between the given points contains any obstacle, and thus blocks vision.
 
Bool isLinePassable (const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces, PathfindLayerEnum layer, const Coord3D &startWorld, const Coord3D &endWorld, Bool blocked, Bool allowPinched)
 Return true if the straight line between the given points is passable.
 
void moveAlliesAwayFromDestination (Object *obj, const Coord3D &destination)
 
Bool isGroundPathPassable (Bool isCrusher, const Coord3D &startWorld, PathfindLayerEnum startLayer, const Coord3D &endWorld, Int pathDiameter)
 Return true if the straight line between the given points is passable.
 
const Coord3DgetDebugPathPosition (void)
 
void setDebugPathPosition (const Coord3D *pos)
 
PathgetDebugPath (void)
 
void setDebugPath (Path *debugpath)
 
void cleanOpenAndClosedLists (void)
 
Bool adjustDestination (Object *obj, const LocomotorSet &locomotorSet, Coord3D *dest, const Coord3D *groupDest=NULL)
 
Bool adjustToLandingDestination (Object *obj, Coord3D *dest)
 
Bool adjustTargetDestination (const Object *obj, const Object *target, const Coord3D *targetPos, const Weapon *weapon, Coord3D *dest)
 
Bool adjustToPossibleDestination (Object *obj, const LocomotorSet &locomotorSet, Coord3D *dest)
 
void snapPosition (Object *obj, Coord3D *pos)
 
void snapClosestGoalPosition (Object *obj, Coord3D *pos)
 
Bool goalPosition (Object *obj, Coord3D *pos)
 
PathfindLayerEnum addBridge (Bridge *theBridge)
 
void addWallPiece (Object *wallPiece)
 
void removeWallPiece (Object *wallPiece)
 
Real getWallHeight (void)
 
Bool isPointOnWall (const Coord3D *pos)
 
void updateLayer (Object *obj, PathfindLayerEnum layer)
 Updates object's layer.
 
Int clearCellForDiameter (Bool crusher, Int cellX, Int cellY, PathfindLayerEnum layer, Int pathDiameter)
 Return true if given position is a valid movement location.
 
- Public Member Functions inherited from Snapshot
 Snapshot (void)
 
 ~Snapshot (void)
 

Static Public Member Functions

static void classifyMapCell (Int x, Int y, PathfindCell *cell)
 Classify the given map cell.
 

Protected Types

enum  { NO_ATTACK =0 }
 
typedef Int(* CellAlongLineProc) (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 

Protected Member Functions

virtual PathinternalFindPath (Object *obj, const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to)
 Find a short, valid path between given locations.
 
PathfindHierarchicalPath (Bool isHuman, const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to, Bool crusher)
 
PathfindClosestHierarchicalPath (Bool isHuman, const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to, Bool crusher)
 
Pathinternal_findHierarchicalPath (Bool isHuman, const LocomotorSurfaceTypeMask locomotorSurface, const Coord3D *from, const Coord3D *to, Bool crusher, Bool closestOK)
 
void processHierarchicalCell (const ICoord2D &scanCell, const ICoord2D &deltaPathfindCell, PathfindCell *parentCell, PathfindCell *goalCell, zoneStorageType parentZone, zoneStorageType *examinedZones, Int &numExZones, Bool crusher, Int &cellCount)
 
Bool checkForAdjust (Object *, const LocomotorSet &locomotorSet, Bool isHuman, Int cellX, Int cellY, PathfindLayerEnum layer, Int iRadius, Bool center, Coord3D *dest, const Coord3D *groupDest)
 
Bool checkForLanding (Int cellX, Int cellY, PathfindLayerEnum layer, Int iRadius, Bool center, Coord3D *dest)
 
Bool checkForTarget (const Object *obj, Int cellX, Int cellY, const Weapon *weapon, const Object *victim, const Coord3D *victimPos, Int iRadius, Bool center, Coord3D *dest)
 
Bool checkForPossible (Bool isCrusher, Int fromZone, Bool center, const LocomotorSet &locomotorSet, Int cellX, Int cellY, PathfindLayerEnum layer, Coord3D *dest, Bool startingInObstacle)
 
void getRadiusAndCenter (const Object *obj, Int &iRadius, Bool &center)
 
void adjustCoordToCell (Int cellX, Int cellY, Bool centerInCell, Coord3D &pos, PathfindLayerEnum layer)
 
Bool checkDestination (const Object *obj, Int cellX, Int cellY, PathfindLayerEnum layer, Int iRadius, Bool centerInCell)
 
Bool checkForMovement (const Object *obj, TCheckMovementInfo &info)
 
Bool segmentIntersectsTallBuilding (const PathNode *curNode, PathNode *nextNode, ObjectID ignoreBuilding, Coord3D *insertPos1, Coord3D *insertPos2, Coord3D *insertPos3)
 Return true if the straight line between the given points intersects a tall building.
 
Bool circleClipsTallBuilding (const Coord3D *from, const Coord3D *to, Real radius, ObjectID ignoreBuilding, Coord3D *adjustTo)
 Return true if the circle at the end of the line between the given points intersects a tall building.
 
Int examineNeighboringCells (PathfindCell *parentCell, PathfindCell *goalCell, const LocomotorSet &locomotorSet, Bool isHumanPlayer, Bool centerInCell, Int radius, const ICoord2D &startCellNdx, const Object *obj, Int attackDistance)
 
Bool pathDestination (Object *obj, const LocomotorSet &locomotorSet, Coord3D *dest, PathfindLayerEnum layer, const Coord3D *groupDest)
 Checks cost between given locations.
 
Int checkPathCost (Object *obj, const LocomotorSet &locomotorSet, const Coord3D *from, const Coord3D *to)
 
void tightenPath (Object *obj, const LocomotorSet &locomotorSet, Coord3D *from, const Coord3D *to)
 
Int iterateCellsAlongLine (const Coord3D &startWorld, const Coord3D &endWorld, PathfindLayerEnum layer, CellAlongLineProc proc, void *userData)
 
Int iterateCellsAlongLine (const ICoord2D &start, const ICoord2D &end, PathfindLayerEnum layer, CellAlongLineProc proc, void *userData)
 
void classifyMap (void)
 Classify all cells in grid as obstacles, etc.
 
void classifyObjectFootprint (Object *obj, Bool insert)
 
void internal_classifyObjectFootprint (Object *obj, Bool insert)
 
void classifyFence (Object *obj, Bool insert)
 
void classifyUnitFootprint (Object *obj, Bool insert, Bool remove, Bool update)
 
void worldToGrid (const Coord3D *pos, ICoord2D *cellIndex)
 Convert world coordinate to array index.
 
Bool evaluateCell (PathfindCell *newCell, PathfindCell *parentCell, const LocomotorSet &locomotorSet, Bool centerInCell, Int radius, const Object *obj, Int attackDistance)
 
PathbuildActualPath (const Object *obj, LocomotorSurfaceTypeMask acceptableSurfaces, const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Bool blocked)
 Work backwards from goal cell to construct final path.
 
PathbuildGroundPath (Bool isCrusher, const Coord3D *fromPos, PathfindCell *goalCell, Bool center, Int pathDiameter)
 Work backwards from goal cell to construct final path.
 
PathbuildHierachicalPath (const Coord3D *fromPos, PathfindCell *goalCell)
 Work backwards from goal cell to construct final path.
 
void prependCells (Path *path, const Coord3D *fromPos, PathfindCell *goalCell, Bool center)
 Add pathfind cells to a path.
 
void debugShowSearch (Bool pathFound)
 Show all cells touched in the last search.
 
void checkChangeLayers (PathfindCell *parentCell)
 

Static Protected Member Functions

static Int linePassableCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int groundPathPassableCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int lineBlockedByObstacleCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int tightenPathCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int attackBlockedByObstacleCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int examineCellsCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int groundCellsCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int moveAlliesDestinationCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static Int segmentIntersectsBuildingCallback (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
 
static LocomotorSurfaceTypeMask validLocomotorSurfacesForCellType (PathfindCell::CellType t)
 

Detailed Description

The Pathfinding engine itself.

Definition at line 592 of file AIPathfind.h.

Member Typedef Documentation

◆ CellAlongLineProc

typedef Int(* Pathfinder::CellAlongLineProc) (Pathfinder *pathfinder, PathfindCell *from, PathfindCell *to, Int to_x, Int to_y, void *userData)
protected

return 0 to continue iterating the line, nonzero to terminate the iteration. the nonzero result will be returned as the result of iterateCellsAlongLine(). iterateCellsAlongLine will return zero if it completes.

Definition at line 781 of file AIPathfind.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
NO_ATTACK 

Definition at line 761 of file AIPathfind.h.

Constructor & Destructor Documentation

◆ Pathfinder()

Pathfinder::Pathfinder ( void )

Definition at line 3828 of file AIPathfind.cpp.

◆ ~Pathfinder()

Pathfinder::~Pathfinder ( void )

Definition at line 3835 of file AIPathfind.cpp.

Member Function Documentation

◆ addBridge()

PathfindLayerEnum Pathfinder::addBridge ( Bridge * theBridge)

Adds a bridge & returns the layer.

Definition at line 3971 of file AIPathfind.cpp.

◆ addObjectToPathfindMap()

void Pathfinder::addObjectToPathfindMap ( class Object * obj)
inline

Classify the given object's cells in the map.

Definition at line 913 of file AIPathfind.h.

◆ addWallPiece()

void Pathfinder::addWallPiece ( Object * wallPiece)

Adds a piece of a wall.

Definition at line 3909 of file AIPathfind.cpp.

◆ adjustCoordToCell()

void Pathfinder::adjustCoordToCell ( Int cellX,
Int cellY,
Bool centerInCell,
Coord3D & pos,
PathfindLayerEnum layer )
protected

Definition at line 8960 of file AIPathfind.cpp.

◆ adjustDestination()

Bool Pathfinder::adjustDestination ( Object * obj,
const LocomotorSet & locomotorSet,
Coord3D * dest,
const Coord3D * groupDest = NULL )

Find an unoccupied spot for a unit to move to. Returns false if there are no spots available within a reasonable radius.

Definition at line 5355 of file AIPathfind.cpp.

◆ adjustTargetDestination()

Bool Pathfinder::adjustTargetDestination ( const Object * obj,
const Object * target,
const Coord3D * targetPos,
const Weapon * weapon,
Coord3D * dest )

Find an unoccupied spot for a unit to move to that can fire at victim. Returns false if there are no spots available within a reasonable radius.

Definition at line 5452 of file AIPathfind.cpp.

◆ adjustToLandingDestination()

Bool Pathfinder::adjustToLandingDestination ( Object * obj,
Coord3D * dest )

Find an unoccupied spot for a unit to land at. Returns false if there are no spots available within a reasonable radius.

Definition at line 5277 of file AIPathfind.cpp.

◆ adjustToPossibleDestination()

Bool Pathfinder::adjustToPossibleDestination ( Object * obj,
const LocomotorSet & locomotorSet,
Coord3D * dest )

Find a pathable spot near the destination. Returns false if there are no spots available within a reasonable radius.

Definition at line 5534 of file AIPathfind.cpp.

◆ attackBlockedByObstacleCallback()

Int Pathfinder::attackBlockedByObstacleCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 9310 of file AIPathfind.cpp.

◆ buildActualPath()

Path * Pathfinder::buildActualPath ( const Object * obj,
LocomotorSurfaceTypeMask acceptableSurfaces,
const Coord3D * fromPos,
PathfindCell * goalCell,
Bool center,
Bool blocked )
protected

Work backwards from goal cell to construct final path.

Work backwards from goal cell to construct final path.

Definition at line 8978 of file AIPathfind.cpp.

◆ buildGroundPath()

Path * Pathfinder::buildGroundPath ( Bool isCrusher,
const Coord3D * fromPos,
PathfindCell * goalCell,
Bool center,
Int pathDiameter )
protected

Work backwards from goal cell to construct final path.

Work backwards from goal cell to construct final path.

Definition at line 6789 of file AIPathfind.cpp.

◆ buildHierachicalPath()

Path * Pathfinder::buildHierachicalPath ( const Coord3D * fromPos,
PathfindCell * goalCell )
protected

Work backwards from goal cell to construct final path.

Work backwards from goal cell to construct final path.

Definition at line 6837 of file AIPathfind.cpp.

◆ changeBridgeState()

void Pathfinder::changeBridgeState ( PathfindLayerEnum layer,
Bool repaired )

Classify the cells under the bridge If 'repaired' is true, bridge is repaired If 'repaired' is false, bridge has been damaged to be impassable

Definition at line 9686 of file AIPathfind.cpp.

◆ checkChangeLayers()

void Pathfinder::checkChangeLayers ( PathfindCell * parentCell)
protected

Definition at line 5966 of file AIPathfind.cpp.

◆ checkDestination()

Bool Pathfinder::checkDestination ( const Object * obj,
Int cellX,
Int cellY,
PathfindLayerEnum layer,
Int iRadius,
Bool centerInCell )
protected

Checks to see if obj can occupy the pathfind cell at x,y. Returns false if there is another unit's goal already there. Assumes your locomotor already said you can go there.

Definition at line 4924 of file AIPathfind.cpp.

◆ checkForAdjust()

Bool Pathfinder::checkForAdjust ( Object * obj,
const LocomotorSet & locomotorSet,
Bool isHuman,
Int cellX,
Int cellY,
PathfindLayerEnum layer,
Int iRadius,
Bool center,
Coord3D * dest,
const Coord3D * groupDest )
protected

Definition at line 5201 of file AIPathfind.cpp.

◆ checkForLanding()

Bool Pathfinder::checkForLanding ( Int cellX,
Int cellY,
PathfindLayerEnum layer,
Int iRadius,
Bool center,
Coord3D * dest )
protected

Definition at line 5252 of file AIPathfind.cpp.

◆ checkForMovement()

Bool Pathfinder::checkForMovement ( const Object * obj,
TCheckMovementInfo & info )
protected

Checks to see if obj can move through the pathfind cell at x,y. Returns false if there are other units already there. Assumes your locomotor already said you can go there.

Definition at line 4995 of file AIPathfind.cpp.

◆ checkForPossible()

Bool Pathfinder::checkForPossible ( Bool isCrusher,
Int fromZone,
Bool center,
const LocomotorSet & locomotorSet,
Int cellX,
Int cellY,
PathfindLayerEnum layer,
Coord3D * dest,
Bool startingInObstacle )
protected

Definition at line 5513 of file AIPathfind.cpp.

◆ checkForTarget()

Bool Pathfinder::checkForTarget ( const Object * obj,
Int cellX,
Int cellY,
const Weapon * weapon,
const Object * victim,
const Coord3D * victimPos,
Int iRadius,
Bool center,
Coord3D * dest )
protected

Definition at line 5433 of file AIPathfind.cpp.

◆ checkPathCost()

Int Pathfinder::checkPathCost ( Object * obj,
const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * to )
protected

Definition at line 8456 of file AIPathfind.cpp.

◆ chooseBestLocomotorForPosition()

Locomotor * Pathfinder::chooseBestLocomotorForPosition ( PathfindLayerEnum layer,
LocomotorSet * locomotorSet,
const Coord3D * pos )

Definition at line 4746 of file AIPathfind.cpp.

◆ circleClipsTallBuilding()

Bool Pathfinder::circleClipsTallBuilding ( const Coord3D * from,
const Coord3D * to,
Real radius,
ObjectID ignoreBuilding,
Coord3D * adjustTo )
protected

Return true if the circle at the end of the line between the given points intersects a tall building.

Definition at line 9546 of file AIPathfind.cpp.

◆ classifyFence()

void Pathfinder::classifyFence ( Object * obj,
Bool insert )
protected

Classify the cells under the given object If 'insert' is true, object is being added If 'insert' is false, object is being removed

Definition at line 4007 of file AIPathfind.cpp.

◆ classifyMap()

void Pathfinder::classifyMap ( void )
protected

Classify all cells in grid as obstacles, etc.

Classify all cells in grid as obstacles, etc.

Definition at line 4603 of file AIPathfind.cpp.

◆ classifyMapCell()

void Pathfinder::classifyMapCell ( Int i,
Int j,
PathfindCell * cell )
static

Classify the given map cell.

Classify the given map cell as WATER, CLIFF, etc. Note that this does NOT classify cells as OBSTACLES. OBSTACLE cells are classified only via objects.

Todo
optimize this - lots of redundant computation

Definition at line 4509 of file AIPathfind.cpp.

◆ classifyObjectFootprint()

void Pathfinder::classifyObjectFootprint ( Object * obj,
Bool insert )
protected

Classify the cells under the given object If 'insert' is true, object is being added If 'insert' is false, object is being removed

For now, all small objects will not be obstacles

Definition at line 4117 of file AIPathfind.cpp.

◆ classifyUnitFootprint()

void Pathfinder::classifyUnitFootprint ( Object * obj,
Bool insert,
Bool remove,
Bool update )
protected

Classify the cells under the given fence object.

◆ cleanOpenAndClosedLists()

void Pathfinder::cleanOpenAndClosedLists ( void )

Definition at line 4812 of file AIPathfind.cpp.

◆ clearCellForDiameter()

Int Pathfinder::clearCellForDiameter ( Bool crusher,
Int cellX,
Int cellY,
PathfindLayerEnum layer,
Int pathDiameter )

Return true if given position is a valid movement location.

Checks to see if there is enough path width at this cell for ground movement. Returns the width available.

Definition at line 6724 of file AIPathfind.cpp.

◆ clientSafeQuickDoesPathExist()

Bool Pathfinder::clientSafeQuickDoesPathExist ( const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * to )

Can we build any path at all between the locations (terrain & buildings check - fast)

Does any path exist from 'from' to 'to' given the locomotor set This is the quick check, only looks at whether the terrain is possible or impossible to path over. Doesn't take other units into account. False means it is impossible to path. True means it is possible given the terrain, but there may be units in the way.

Definition at line 8021 of file AIPathfind.cpp.

◆ clientSafeQuickDoesPathExistForUI()

Bool Pathfinder::clientSafeQuickDoesPathExistForUI ( const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * to )

Can we build any path at all between the locations (terrain onlyk - fast)

Does any path exist from 'from' to 'to' given the locomotor set This is the quick check, only looks at whether the terrain is possible or impossible to path over. Doesn't take other units into account. False means it is impossible to path. True means it is possible given the terrain, but there may be units in the way.

Definition at line 8079 of file AIPathfind.cpp.

◆ clip()

void Pathfinder::clip ( Coord3D * from,
Coord3D * to )

Definition at line 8157 of file AIPathfind.cpp.

◆ crc()

void Pathfinder::crc ( Xfer * xfer)
virtual

run the "light" crc check on this data structure

Implements Snapshot.

Definition at line 11067 of file AIPathfind.cpp.

◆ createAWallFromMyFootprint()

void Pathfinder::createAWallFromMyFootprint ( Object * obj)
inline

Definition at line 655 of file AIPathfind.h.

◆ debugShowSearch()

void Pathfinder::debugShowSearch ( Bool pathFound)
protected

Show all cells touched in the last search.

Show all cells touched in the last search

Definition at line 4692 of file AIPathfind.cpp.

◆ evaluateCell()

Bool Pathfinder::evaluateCell ( PathfindCell * newCell,
PathfindCell * parentCell,
const LocomotorSet & locomotorSet,
Bool centerInCell,
Int radius,
const Object * obj,
Int attackDistance )
protected

◆ examineCellsCallback()

Int Pathfinder::examineCellsCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 6020 of file AIPathfind.cpp.

◆ examineNeighboringCells()

Int Pathfinder::examineNeighboringCells ( PathfindCell * parentCell,
PathfindCell * goalCell,
const LocomotorSet & locomotorSet,
Bool isHumanPlayer,
Bool centerInCell,
Int radius,
const ICoord2D & startCellNdx,
const Object * obj,
Int attackDistance )
protected

Definition at line 6121 of file AIPathfind.cpp.

◆ findBrokenBridge()

Bool Pathfinder::findBrokenBridge ( const LocomotorSet & locoSet,
const Coord3D * from,
const Coord3D * to,
ObjectID * bridgeID )

Does any broken bridge join from and to?
True means that if bridge BridgeID is repaired, there is a land path from to to..

Definition at line 7976 of file AIPathfind.cpp.

◆ findClosestHierarchicalPath()

Path * Pathfinder::findClosestHierarchicalPath ( Bool isHuman,
const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * to,
Bool crusher )
protected

Find a short, valid path between given locations. Uses A* algorithm.

Definition at line 7446 of file AIPathfind.cpp.

◆ findGroundPath()

Path * Pathfinder::findGroundPath ( const Coord3D * from,
const Coord3D * rawTo,
Int pathDiameter,
Bool crusher )

Find a short, valid path of the desired width on the ground.

Find a short, valid path between given locations. Uses A* algorithm.

Definition at line 7004 of file AIPathfind.cpp.

◆ findHierarchicalPath()

Path * Pathfinder::findHierarchicalPath ( Bool isHuman,
const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * to,
Bool crusher )
protected

Find a short, valid path between given locations. Uses A* algorithm.

Definition at line 7435 of file AIPathfind.cpp.

◆ forceMapRecalculation()

void Pathfinder::forceMapRecalculation ( void )

Force pathfind map recomputation. If region is given, only that area is recomputed.

Force pathfind map recomputation.

Definition at line 4684 of file AIPathfind.cpp.

◆ getAircraftPath()

Path * Pathfinder::getAircraftPath ( const Object * obj,
const Coord3D * to )

Returns an aircraft path to the goal.

Create an aircraft path. Just jogs around tall buildings marked with KINDOF_AIRCRAFT_PATH_AROUND.

Definition at line 5805 of file AIPathfind.cpp.

◆ getCell() [1/2]

PathfindCell * Pathfinder::getCell ( PathfindLayerEnum layer,
const Coord3D * pos )
inline

Given a position, return associated grid cell.

Definition at line 943 of file AIPathfind.h.

◆ getCell() [2/2]

PathfindCell * Pathfinder::getCell ( PathfindLayerEnum layer,
Int x,
Int y )
inline

Return the cell at grid coords (x,y)

Definition at line 923 of file AIPathfind.h.

◆ getClippedCell()

PathfindCell * Pathfinder::getClippedCell ( PathfindLayerEnum layer,
const Coord3D * pos )
inline

Given a position, return associated grid cell.

Definition at line 951 of file AIPathfind.h.

◆ getDebugPath()

Path * Pathfinder::getDebugPath ( void )
inline

Definition at line 908 of file AIPathfind.h.

◆ getDebugPathPosition()

const Coord3D * Pathfinder::getDebugPathPosition ( void )
inline

Definition at line 898 of file AIPathfind.h.

◆ getExtent()

const ICoord2D * Pathfinder::getExtent ( void ) const
inline

Definition at line 672 of file AIPathfind.h.

◆ getMoveAwayFromPath()

Path * Pathfinder::getMoveAwayFromPath ( Object * obj,
Object * otherObj,
Path * pathToAvoid,
Object * otherObj2,
Path * pathToAvoid2 )

Moves an allied unit out of the path of another unit. Uses A* algorithm.

Todo
  • Adjust cost intersecting path - closer to front is more expensive. jba.

Definition at line 10195 of file AIPathfind.cpp.

◆ getRadiusAndCenter()

void Pathfinder::getRadiusAndCenter ( const Object * obj,
Int & iRadius,
Bool & center )
protected

Definition at line 9694 of file AIPathfind.cpp.

◆ getWallHeight()

Real Pathfinder::getWallHeight ( void )
inline

Definition at line 726 of file AIPathfind.h.

◆ goalPosition()

Bool Pathfinder::goalPosition ( Object * obj,
Coord3D * pos )

Returns coordinates of goal.

Definition at line 5186 of file AIPathfind.cpp.

◆ groundCellsCallback()

Int Pathfinder::groundCellsCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 6959 of file AIPathfind.cpp.

◆ groundPathPassableCallback()

Int Pathfinder::groundPathPassableCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 9626 of file AIPathfind.cpp.

◆ internal_classifyObjectFootprint()

void Pathfinder::internal_classifyObjectFootprint ( Object * obj,
Bool insert )
protected

Classify the cells under the given object If 'insert' is true, object is being added If 'insert' is false, object is being removed

Todo
This is a very inefficient circle-rasterizer

Definition at line 4199 of file AIPathfind.cpp.

◆ internal_findHierarchicalPath()

Path * Pathfinder::internal_findHierarchicalPath ( Bool isHuman,
const LocomotorSurfaceTypeMask locomotorSurface,
const Coord3D * from,
const Coord3D * rawTo,
Bool crusher,
Bool closestOK )
protected

Find a short, valid path between given locations. Uses A* algorithm.

Definition at line 7458 of file AIPathfind.cpp.

◆ internalFindPath()

Path * Pathfinder::internalFindPath ( Object * obj,
const LocomotorSet & locomotorSet,
const Coord3D * from,
const Coord3D * rawTo )
protectedvirtual

Find a short, valid path between given locations.

Find a short, valid path between given locations. Uses A* algorithm.

Definition at line 6462 of file AIPathfind.cpp.

◆ isAttackViewBlockedByObstacle()

Bool Pathfinder::isAttackViewBlockedByObstacle ( const Object * obj,
const Coord3D & attackerPos,
const Object * victim,
const Coord3D & victimPos )

Return true if the straight line between the given points contains any obstacle, and thus blocks vision.

srj – someone wanna tell me what this magic number means?

jba - Yes, it means that if someone is on a bridge, or rooftop, they can see 3 pathfind cells out of whatever they are standing on.
srj – awesome! thank you very much :-)

Definition at line 9384 of file AIPathfind.cpp.

◆ isGroundPathPassable()

Bool Pathfinder::isGroundPathPassable ( Bool isCrusher,
const Coord3D & startWorld,
PathfindLayerEnum startLayer,
const Coord3D & endWorld,
Int pathDiameter )

Return true if the straight line between the given points is passable.

Given two world-space points, check the line of sight between them for any impassible cells. Uses Bresenham line algorithm from www.gamedev.net.

Definition at line 9669 of file AIPathfind.cpp.

◆ isLinePassable()

Bool Pathfinder::isLinePassable ( const Object * obj,
LocomotorSurfaceTypeMask acceptableSurfaces,
PathfindLayerEnum layer,
const Coord3D & startWorld,
const Coord3D & endWorld,
Bool blocked,
Bool allowPinched )

Return true if the straight line between the given points is passable.

Given two world-space points, check the line of sight between them for any impassible cells. Uses Bresenham line algorithm from www.gamedev.net.

Definition at line 9645 of file AIPathfind.cpp.

◆ isPointOnWall()

Bool Pathfinder::isPointOnWall ( const Coord3D * pos)

Checks if a point is on the wall.

Definition at line 3953 of file AIPathfind.cpp.

◆ isViewBlockedByObstacle()

Bool Pathfinder::isViewBlockedByObstacle ( const Object * obj,
const Object * objOther )

Return true if the straight line between the given points contains any obstacle, and thus blocks vision.

Definition at line 9361 of file AIPathfind.cpp.

◆ iterateCellsAlongLine() [1/2]

Int Pathfinder::iterateCellsAlongLine ( const Coord3D & startWorld,
const Coord3D & endWorld,
PathfindLayerEnum layer,
CellAlongLineProc proc,
void * userData )
protected

Given two world-space points, call callback for each cell. Uses Bresenham line algorithm from www.gamedev.net.

Definition at line 9109 of file AIPathfind.cpp.

◆ iterateCellsAlongLine() [2/2]

Int Pathfinder::iterateCellsAlongLine ( const ICoord2D & start,
const ICoord2D & end,
PathfindLayerEnum layer,
CellAlongLineProc proc,
void * userData )
protected

Given two world-space points, call callback for each cell. Uses Bresenham line algorithm from www.gamedev.net.

Definition at line 9121 of file AIPathfind.cpp.

◆ lineBlockedByObstacleCallback()

Int Pathfinder::lineBlockedByObstacleCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 9263 of file AIPathfind.cpp.

◆ linePassableCallback()

Int Pathfinder::linePassableCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 9577 of file AIPathfind.cpp.

◆ loadPostProcess()

void Pathfinder::loadPostProcess ( void )
virtual

post process phase for loading save games. All save systems have their xfer run using XferLoad mode, and then all systems each have their post process run

Implements Snapshot.

Definition at line 11120 of file AIPathfind.cpp.

◆ moveAllies()

Bool Pathfinder::moveAllies ( Object * obj,
Path * path )

Definition at line 10112 of file AIPathfind.cpp.

◆ moveAlliesAwayFromDestination()

void Pathfinder::moveAlliesAwayFromDestination ( Object * obj,
const Coord3D & destination )

Definition at line 6935 of file AIPathfind.cpp.

◆ moveAlliesDestinationCallback()

Int Pathfinder::moveAlliesDestinationCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 6901 of file AIPathfind.cpp.

◆ newMap()

void Pathfinder::newMap ( void )

Set up for a new map.

Definition at line 4548 of file AIPathfind.cpp.

◆ pathDestination()

Bool Pathfinder::pathDestination ( Object * obj,
const LocomotorSet & locomotorSet,
Coord3D * dest,
PathfindLayerEnum layer,
const Coord3D * groupDest )
protected

Checks cost between given locations.

Definition at line 8178 of file AIPathfind.cpp.

◆ prependCells()

void Pathfinder::prependCells ( Path * path,
const Coord3D * fromPos,
PathfindCell * goalCell,
Bool center )
protected

Add pathfind cells to a path.

Work backwards from goal cell to construct final path.

Definition at line 9030 of file AIPathfind.cpp.

◆ processHierarchicalCell()

void Pathfinder::processHierarchicalCell ( const ICoord2D & scanCell,
const ICoord2D & delta,
PathfindCell * parentCell,
PathfindCell * goalCell,
zoneStorageType parentZone,
zoneStorageType * examinedZones,
Int & numExZones,
Bool crusher,
Int & cellCount )
protected

Find a short, valid path between given locations. Uses A* algorithm.

Todo
  • somehow out of bounds or bogus newZone.

Definition at line 7346 of file AIPathfind.cpp.

◆ processPathfindQueue()

void Pathfinder::processPathfindQueue ( void )

Process some or all of the queued pathfinds.

Process some path requests in the pathfind queue.

Definition at line 5881 of file AIPathfind.cpp.

◆ queueForPath()

Bool Pathfinder::queueForPath ( ObjectID id)

The object wants to request a pathfind, so put it on the list to process.

Queues an object to do a pathfind. It will call the object's ai update->doPathfind() during processPathfindQueue().

Definition at line 5648 of file AIPathfind.cpp.

◆ removeGoal()

void Pathfinder::removeGoal ( Object * obj)

Removes the given mobile unit's goal cells in the map.

Removes the goal cell for an ai unit. Used for a unit that is going to be moving several times, like following a waypoint path, or intentionally collides with other units (like a car bomb). jba

Definition at line 9885 of file AIPathfind.cpp.

◆ removeObjectFromPathfindMap()

void Pathfinder::removeObjectFromPathfindMap ( class Object * obj)
inline

De-classify the given object's cells in the map.

Definition at line 918 of file AIPathfind.h.

◆ removePos()

void Pathfinder::removePos ( Object * obj)

Removes the unit's position cells from the map.

Removes the position cell flags for an ai unit.

Definition at line 10054 of file AIPathfind.cpp.

◆ removeUnitFromPathfindMap()

void Pathfinder::removeUnitFromPathfindMap ( Object * obj)

De-classify the given mobile unit's cells in the map.

Removes a mobile unit from the pathfind grid.

Definition at line 10106 of file AIPathfind.cpp.

◆ removeWallFromMyFootprint()

void Pathfinder::removeWallFromMyFootprint ( Object * obj)
inline

Definition at line 656 of file AIPathfind.h.

◆ removeWallPiece()

void Pathfinder::removeWallPiece ( Object * wallPiece)

Removes a piece of a wall

Definition at line 3920 of file AIPathfind.cpp.

◆ reset()

void Pathfinder::reset ( void )

Reset system in preparation for new map.

Definition at line 3840 of file AIPathfind.cpp.

◆ segmentIntersectsBuildingCallback()

Int Pathfinder::segmentIntersectsBuildingCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 9235 of file AIPathfind.cpp.

◆ segmentIntersectsTallBuilding()

Bool Pathfinder::segmentIntersectsTallBuilding ( const PathNode * curNode,
PathNode * nextNode,
ObjectID ignoreBuilding,
Coord3D * insertPos1,
Coord3D * insertPos2,
Coord3D * insertPos3 )
protected

Return true if the straight line between the given points intersects a tall building.

Definition at line 9488 of file AIPathfind.cpp.

◆ setDebugPath()

void Pathfinder::setDebugPath ( Path * debugpath)

Definition at line 9089 of file AIPathfind.cpp.

◆ setDebugPathPosition()

void Pathfinder::setDebugPathPosition ( const Coord3D * pos)
inline

Definition at line 903 of file AIPathfind.h.

◆ setIgnoreObstacleID()

void Pathfinder::setIgnoreObstacleID ( ObjectID objID)
inline

if non-zero, the pathfinder will ignore the given obstacle

Definition at line 873 of file AIPathfind.h.

◆ slowDoesPathExist()

Bool Pathfinder::slowDoesPathExist ( Object * obj,
const Coord3D * from,
const Coord3D * to,
ObjectID ignoreObject = INVALID_ID )

Can we build any path at all between the locations (terrain, buildings & units check - slower)

Does any path exist from 'from' to 'to' given the locomotor set This is the careful check, looks at whether the terrain, buindings and units are possible or impossible to path over. Takes other units into account. False means it is impossible to path. True means it is possible to path.

Definition at line 8136 of file AIPathfind.cpp.

◆ snapClosestGoalPosition()

void Pathfinder::snapClosestGoalPosition ( Object * obj,
Coord3D * pos )

Adjusts a goal position to the center of it's cell.

Definition at line 5125 of file AIPathfind.cpp.

◆ snapPosition()

void Pathfinder::snapPosition ( Object * obj,
Coord3D * pos )

Adjusts a coordinate to the center of it's cell.

Definition at line 5106 of file AIPathfind.cpp.

◆ tightenPath()

void Pathfinder::tightenPath ( Object * obj,
const LocomotorSet & locomotorSet,
Coord3D * from,
const Coord3D * to )
protected

Definition at line 8438 of file AIPathfind.cpp.

◆ tightenPathCallback()

Int Pathfinder::tightenPathCallback ( Pathfinder * pathfinder,
PathfindCell * from,
PathfindCell * to,
Int to_x,
Int to_y,
void * userData )
staticprotected

Definition at line 8419 of file AIPathfind.cpp.

◆ updateAircraftGoal()

void Pathfinder::updateAircraftGoal ( Object * obj,
const Coord3D * newGoalPos )

Update the given aircraft unit's cells in the map.

Updates the goal cell for an ai unit.

Definition at line 9827 of file AIPathfind.cpp.

◆ updateGoal()

void Pathfinder::updateGoal ( Object * obj,
const Coord3D * newGoalPos,
PathfindLayerEnum layer )

Update the given mobile unit's cells in the map.

Updates the goal cell for an ai unit.

Definition at line 9725 of file AIPathfind.cpp.

◆ updateLayer()

void Pathfinder::updateLayer ( Object * obj,
PathfindLayerEnum layer )

Updates object's layer.

Updates an object's layer, making sure the object is actually on the bridge first.

Definition at line 3991 of file AIPathfind.cpp.

◆ updatePos()

void Pathfinder::updatePos ( Object * obj,
const Coord3D * newPos )

Update the given mobile unit's cells in the map.

Updates the position cell for an ai unit.

Definition at line 9945 of file AIPathfind.cpp.

◆ validLocomotorSurfacesForCellType()

LocomotorSurfaceTypeMask Pathfinder::validLocomotorSurfacesForCellType ( PathfindCell::CellType t)
staticprotected

Definition at line 4758 of file AIPathfind.cpp.

◆ validMovementPosition() [1/3]

Bool Pathfinder::validMovementPosition ( Bool isCrusher,
LocomotorSurfaceTypeMask acceptableSurfaces,
PathfindCell * toCell,
PathfindCell * fromCell = NULL )

Return true if given position is a valid movement location.

Definition at line 4853 of file AIPathfind.cpp.

◆ validMovementPosition() [2/3]

Bool Pathfinder::validMovementPosition ( Bool isCrusher,
PathfindLayerEnum layer,
const LocomotorSet & locomotorSet,
const Coord3D * pos )
inline

Return true if given position is a valid movement location.

Definition at line 889 of file AIPathfind.h.

◆ validMovementPosition() [3/3]

Bool Pathfinder::validMovementPosition ( Bool isCrusher,
PathfindLayerEnum layer,
const LocomotorSet & locomotorSet,
Int x,
Int y )
inline

Return true if given position is a valid movement location.

Definition at line 884 of file AIPathfind.h.

◆ validMovementTerrain()

Bool Pathfinder::validMovementTerrain ( PathfindLayerEnum layer,
const Locomotor * locomotor,
const Coord3D * pos )

Return true if given position is a valid movement location.

Definition at line 4787 of file AIPathfind.cpp.

◆ worldToCell()

Bool Pathfinder::worldToCell ( const Coord3D * pos,
ICoord2D * cell )
inline

Given a world position, return grid cell coordinate.

Definition at line 958 of file AIPathfind.h.

◆ worldToGrid()

void Pathfinder::worldToGrid ( const Coord3D * pos,
ICoord2D * cellIndex )
inlineprotected

Convert world coordinate to array index.

Classify the cells under the given object If 'insert' is true, object is being added

Definition at line 878 of file AIPathfind.h.

◆ xfer()

void Pathfinder::xfer ( Xfer * xfer)
virtual

run save, load, or deep CRC check on this data structure, the type depends on the setup of the Xfer pointer

Implements Snapshot.

Definition at line 11109 of file AIPathfind.cpp.


The documentation for this class was generated from the following files: