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

#include <AIPathfind.h>

Public Types

enum  CellType {
  CELL_CLEAR = 0x00 , CELL_WATER = 0x01 , CELL_CLIFF = 0x02 , CELL_RUBBLE = 0x03 ,
  CELL_OBSTACLE = 0x04 , CELL_BRIDGE_IMPASSABLE = 0x05 , CELL_IMPASSABLE = 0x06
}
 
enum  CellFlags {
  NO_UNITS = 0x00 , UNIT_GOAL = 0x01 , UNIT_PRESENT_MOVING = 0x02 , UNIT_PRESENT_FIXED = 0x03 ,
  UNIT_GOAL_OTHER_MOVING = 0x05
}
 

Public Member Functions

void reset ()
 reset the cell
 
 PathfindCell (void)
 
 ~PathfindCell (void)
 
Bool setTypeAsObstacle (Object *obstacle, Bool isFence, const ICoord2D &pos)
 flag this cell as an obstacle, from the given one
 
Bool removeObstacle (Object *obstacle)
 unflag this cell as an obstacle, from the given one
 
void setType (CellType type)
 set the cell type
 
CellType getType (void) const
 get the cell type
 
CellFlags getFlags (void) const
 get the cell type
 
Bool isAircraftGoal (void) const
 
Bool isObstaclePresent (ObjectID objID) const
 return true if the given object ID is registered as an obstacle in this cell
 
Bool isObstacleTransparent () const
 return true if the obstacle in the cell is KINDOF_CAN_SEE_THROUGHT_STRUCTURE
 
Bool isObstacleFence (void) const
 return true if the given obstacle in the cell is a fence.
 
UnsignedInt costToGoal (PathfindCell *goal)
 Return estimated cost from given cell to reach goal cell.
 
UnsignedInt costToHierGoal (PathfindCell *goal)
 
UnsignedInt costSoFar (PathfindCell *parent)
 
PathfindCellputOnSortedOpenList (PathfindCell *list)
 put self on "open" list in ascending cost order, return new list
 
PathfindCellremoveFromOpenList (PathfindCell *list)
 remove self from "open" list
 
PathfindCellputOnClosedList (PathfindCell *list)
 put self on "closed" list, return new list
 
PathfindCellremoveFromClosedList (PathfindCell *list)
 remove self from "closed" list
 
PathfindCellgetNextOpen (void)
 
UnsignedShort getXIndex (void) const
 
UnsignedShort getYIndex (void) const
 
Bool isBlockedByAlly (void) const
 
void setBlockedByAlly (Bool blocked)
 
Bool getOpen (void) const
 
Bool getClosed (void) const
 
UnsignedInt getCostSoFar (void) const
 
UnsignedInt getTotalCost (void) const
 
void setCostSoFar (UnsignedInt cost)
 
void setTotalCost (UnsignedInt cost)
 
void setParentCell (PathfindCell *parent)
 
void clearParentCell (void)
 
void setParentCellHierarchical (PathfindCell *parent)
 
PathfindCellgetParentCell (void) const
 
Bool startPathfind (PathfindCell *goalCell)
 
Bool getPinched (void) const
 
void setPinched (Bool pinch)
 
Bool allocateInfo (const ICoord2D &pos)
 
void releaseInfo (void)
 
Bool hasInfo (void) const
 
zoneStorageType getZone (void) const
 
void setZone (zoneStorageType zone)
 
void setGoalUnit (ObjectID unit, const ICoord2D &pos)
 
void setGoalAircraft (ObjectID unit, const ICoord2D &pos)
 
void setPosUnit (ObjectID unit, const ICoord2D &pos)
 
ObjectID getGoalUnit (void) const
 
ObjectID getGoalAircraft (void) const
 
ObjectID getPosUnit (void) const
 
ObjectID getObstacleID (void) const
 
void setLayer (PathfindLayerEnum layer)
 set the cell layer
 
PathfindLayerEnum getLayer (void) const
 get the cell layer
 
void setConnectLayer (PathfindLayerEnum layer)
 set the cell layer connect id
 
PathfindLayerEnum getConnectLayer (void) const
 get the cell layer connect id
 

Static Public Member Functions

static Int releaseClosedList (PathfindCell *list)
 remove all cells from closed list.
 
static Int releaseOpenList (PathfindCell *list)
 remove all cells from closed list.
 

Detailed Description

This represents one cell in the pathfinding grid. These cells categorize the world into idealized cellular states, and are also used for efficient A* pathfinding.

Todo
Optimize memory usage of pathfind grid.

Definition at line 253 of file AIPathfind.h.

Member Enumeration Documentation

◆ CellFlags

Enumerator
NO_UNITS 

No units in this cell.

UNIT_GOAL 

A unit is heading to this cell.

UNIT_PRESENT_MOVING 

A unit is moving through this cell.

UNIT_PRESENT_FIXED 

A unit is stationary in this cell.

UNIT_GOAL_OTHER_MOVING 

A unit is moving through this cell, and another unit has this as it's goal.

Definition at line 268 of file AIPathfind.h.

◆ CellType

Enumerator
CELL_CLEAR 

clear, unobstructed ground

CELL_WATER 

water area

CELL_CLIFF 

steep altitude change

CELL_RUBBLE 

Cell is occupied by rubble.

CELL_OBSTACLE 

Occupied by a structure.

CELL_BRIDGE_IMPASSABLE 

Piece of a bridge that is impassable.

CELL_IMPASSABLE 

Just plain impassable except for aircraft.

Definition at line 257 of file AIPathfind.h.

Constructor & Destructor Documentation

◆ PathfindCell()

PathfindCell::PathfindCell ( void )

Constructor

Definition at line 1192 of file AIPathfind.cpp.

◆ ~PathfindCell()

PathfindCell::~PathfindCell ( void )

Destructor

Definition at line 1200 of file AIPathfind.cpp.

Member Function Documentation

◆ allocateInfo()

Bool PathfindCell::allocateInfo ( const ICoord2D & pos)

Allocates an info record for a cell.

Definition at line 1285 of file AIPathfind.cpp.

◆ clearParentCell()

void PathfindCell::clearParentCell ( void )

Reset the parent cell.

Definition at line 1275 of file AIPathfind.cpp.

◆ costSoFar()

UnsignedInt PathfindCell::costSoFar ( PathfindCell * parent)

Definition at line 1715 of file AIPathfind.cpp.

◆ costToGoal()

UnsignedInt PathfindCell::costToGoal ( PathfindCell * goal)

Return estimated cost from given cell to reach goal cell.

Definition at line 1678 of file AIPathfind.cpp.

◆ costToHierGoal()

UnsignedInt PathfindCell::costToHierGoal ( PathfindCell * goal)

Definition at line 1702 of file AIPathfind.cpp.

◆ getClosed()

Bool PathfindCell::getClosed ( void ) const
inline

Definition at line 330 of file AIPathfind.h.

◆ getConnectLayer()

PathfindLayerEnum PathfindCell::getConnectLayer ( void ) const
inline

get the cell layer connect id

Definition at line 364 of file AIPathfind.h.

◆ getCostSoFar()

UnsignedInt PathfindCell::getCostSoFar ( void ) const
inline

Definition at line 331 of file AIPathfind.h.

◆ getFlags()

CellFlags PathfindCell::getFlags ( void ) const
inline

get the cell type

Definition at line 287 of file AIPathfind.h.

◆ getGoalAircraft()

ObjectID PathfindCell::getGoalAircraft ( void ) const
inline

Definition at line 355 of file AIPathfind.h.

◆ getGoalUnit()

ObjectID PathfindCell::getGoalUnit ( void ) const
inline

Definition at line 354 of file AIPathfind.h.

◆ getLayer()

PathfindLayerEnum PathfindCell::getLayer ( void ) const
inline

get the cell layer

Definition at line 361 of file AIPathfind.h.

◆ getNextOpen()

PathfindCell * PathfindCell::getNextOpen ( void )
inline

Definition at line 321 of file AIPathfind.h.

◆ getObstacleID()

ObjectID PathfindCell::getObstacleID ( void ) const
inline

Definition at line 358 of file AIPathfind.h.

◆ getOpen()

Bool PathfindCell::getOpen ( void ) const
inline

Definition at line 329 of file AIPathfind.h.

◆ getParentCell()

PathfindCell * PathfindCell::getParentCell ( void ) const
inline

Definition at line 340 of file AIPathfind.h.

◆ getPinched()

Bool PathfindCell::getPinched ( void ) const
inline

Definition at line 343 of file AIPathfind.h.

◆ getPosUnit()

ObjectID PathfindCell::getPosUnit ( void ) const
inline

Definition at line 356 of file AIPathfind.h.

◆ getTotalCost()

UnsignedInt PathfindCell::getTotalCost ( void ) const
inline

Definition at line 332 of file AIPathfind.h.

◆ getType()

CellType PathfindCell::getType ( void ) const
inline

get the cell type

Definition at line 286 of file AIPathfind.h.

◆ getXIndex()

UnsignedShort PathfindCell::getXIndex ( void ) const
inline

Definition at line 323 of file AIPathfind.h.

◆ getYIndex()

UnsignedShort PathfindCell::getYIndex ( void ) const
inline

Definition at line 324 of file AIPathfind.h.

◆ getZone()

zoneStorageType PathfindCell::getZone ( void ) const
inline

Definition at line 349 of file AIPathfind.h.

◆ hasInfo()

Bool PathfindCell::hasInfo ( void ) const
inline

Definition at line 348 of file AIPathfind.h.

◆ isAircraftGoal()

Bool PathfindCell::isAircraftGoal ( void ) const
inline

Definition at line 288 of file AIPathfind.h.

◆ isBlockedByAlly()

Bool PathfindCell::isBlockedByAlly ( void ) const
inline

Definition at line 326 of file AIPathfind.h.

◆ isObstacleFence()

Bool PathfindCell::isObstacleFence ( void ) const
inline

return true if the given obstacle in the cell is a fence.

Definition at line 294 of file AIPathfind.h.

◆ isObstaclePresent()

Bool PathfindCell::isObstaclePresent ( ObjectID objID) const
inline

return true if the given object ID is registered as an obstacle in this cell

Return true if the given object ID is registered as an obstacle in this cell

Definition at line 973 of file AIPathfind.h.

◆ isObstacleTransparent()

Bool PathfindCell::isObstacleTransparent ( ) const
inline

return true if the obstacle in the cell is KINDOF_CAN_SEE_THROUGHT_STRUCTURE

Definition at line 292 of file AIPathfind.h.

◆ putOnClosedList()

PathfindCell * PathfindCell::putOnClosedList ( PathfindCell * list)

put self on "closed" list, return new list

Definition at line 1632 of file AIPathfind.cpp.

◆ putOnSortedOpenList()

PathfindCell * PathfindCell::putOnSortedOpenList ( PathfindCell * list)

put self on "open" list in ascending cost order, return new list

Definition at line 1511 of file AIPathfind.cpp.

◆ releaseClosedList()

Int PathfindCell::releaseClosedList ( PathfindCell * list)
static

remove all cells from closed list.

remove all cells from "closed" list

Definition at line 1608 of file AIPathfind.cpp.

◆ releaseInfo()

void PathfindCell::releaseInfo ( void )

Releases an info record for a cell.

Definition at line 1297 of file AIPathfind.cpp.

◆ releaseOpenList()

Int PathfindCell::releaseOpenList ( PathfindCell * list)
static

remove all cells from closed list.

remove all cells from "open" list

Definition at line 1584 of file AIPathfind.cpp.

◆ removeFromClosedList()

PathfindCell * PathfindCell::removeFromClosedList ( PathfindCell * list)

remove self from "closed" list

Definition at line 1654 of file AIPathfind.cpp.

◆ removeFromOpenList()

PathfindCell * PathfindCell::removeFromOpenList ( PathfindCell * list)

remove self from "open" list

Definition at line 1564 of file AIPathfind.cpp.

◆ removeObstacle()

Bool PathfindCell::removeObstacle ( Object * obstacle)

unflag this cell as an obstacle, from the given one

Unflag this cell as an obstacle, from the given one. Return true if this cell was previously flagged as an obstacle by this object.

Definition at line 1497 of file AIPathfind.cpp.

◆ reset()

void PathfindCell::reset ( )

reset the cell

Reset the cell to default values

Definition at line 1214 of file AIPathfind.cpp.

◆ setBlockedByAlly()

void PathfindCell::setBlockedByAlly ( Bool blocked)
inline

Definition at line 327 of file AIPathfind.h.

◆ setConnectLayer()

void PathfindCell::setConnectLayer ( PathfindLayerEnum layer)
inline

set the cell layer connect id

Definition at line 363 of file AIPathfind.h.

◆ setCostSoFar()

void PathfindCell::setCostSoFar ( UnsignedInt cost)
inline

Definition at line 334 of file AIPathfind.h.

◆ setGoalAircraft()

void PathfindCell::setGoalAircraft ( ObjectID unitID,
const ICoord2D & pos )

Sets the goal aircraft into the info record for a cell.

Definition at line 1368 of file AIPathfind.cpp.

◆ setGoalUnit()

void PathfindCell::setGoalUnit ( ObjectID unitID,
const ICoord2D & pos )

Sets the goal unit into the info record for a cell.

Definition at line 1326 of file AIPathfind.cpp.

◆ setLayer()

void PathfindCell::setLayer ( PathfindLayerEnum layer)
inline

set the cell layer

Definition at line 360 of file AIPathfind.h.

◆ setParentCell()

void PathfindCell::setParentCell ( PathfindCell * parent)

Set the parent pointer.

Definition at line 1252 of file AIPathfind.cpp.

◆ setParentCellHierarchical()

void PathfindCell::setParentCellHierarchical ( PathfindCell * parent)

Set the parent pointer.

Definition at line 1266 of file AIPathfind.cpp.

◆ setPinched()

void PathfindCell::setPinched ( Bool pinch)
inline

Definition at line 344 of file AIPathfind.h.

◆ setPosUnit()

void PathfindCell::setPosUnit ( ObjectID unitID,
const ICoord2D & pos )

Sets the position unit into the info record for a cell.

Definition at line 1398 of file AIPathfind.cpp.

◆ setTotalCost()

void PathfindCell::setTotalCost ( UnsignedInt cost)
inline

Definition at line 335 of file AIPathfind.h.

◆ setType()

void PathfindCell::setType ( CellType type)

set the cell type

Flag this cell as given type.

Definition at line 1483 of file AIPathfind.cpp.

◆ setTypeAsObstacle()

Bool PathfindCell::setTypeAsObstacle ( Object * obstacle,
Bool isFence,
const ICoord2D & pos )

flag this cell as an obstacle, from the given one

Flag this cell as an obstacle, from the given one. Return true if cell was flagged.

Definition at line 1445 of file AIPathfind.cpp.

◆ setZone()

void PathfindCell::setZone ( zoneStorageType zone)
inline

Definition at line 350 of file AIPathfind.h.

◆ startPathfind()

Bool PathfindCell::startPathfind ( PathfindCell * goalCell)

Reset the pathfinding values in the cell.

Definition at line 1234 of file AIPathfind.cpp.


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