src/aystar.h
branchcpp_gui
changeset 6298 c30fe89622df
parent 6268 4b5241e5dd10
child 6872 1c4a4a609f85
equal deleted inserted replaced
6297:4bf29d14edba 6298:c30fe89622df
    25 
    25 
    26 enum{
    26 enum{
    27 	AYSTAR_INVALID_NODE = -1,
    27 	AYSTAR_INVALID_NODE = -1,
    28 };
    28 };
    29 
    29 
    30 typedef struct AyStarNode AyStarNode;
       
    31 struct AyStarNode {
    30 struct AyStarNode {
    32 	TileIndex tile;
    31 	TileIndex tile;
    33 	int direction;
    32 	int direction;
    34 	uint user_data[2];
    33 	uint user_data[2];
    35 };
    34 };
    36 
    35 
    37 // The resulting path has nodes looking like this.
    36 // The resulting path has nodes looking like this.
    38 typedef struct PathNode PathNode;
       
    39 struct PathNode {
    37 struct PathNode {
    40 	AyStarNode node;
    38 	AyStarNode node;
    41 	// The parent of this item
    39 	// The parent of this item
    42 	PathNode *parent;
    40 	PathNode *parent;
    43 };
    41 };
    44 
    42 
    45 // For internal use only
    43 // For internal use only
    46 // We do not save the h-value, because it is only needed to calculate the f-value.
    44 // We do not save the h-value, because it is only needed to calculate the f-value.
    47 //  h-value should _always_ be the distance left to the end-tile.
    45 //  h-value should _always_ be the distance left to the end-tile.
    48 typedef struct OpenListNode OpenListNode;
       
    49 struct OpenListNode {
    46 struct OpenListNode {
    50 	int g;
    47 	int g;
    51 	PathNode path;
    48 	PathNode path;
    52 };
    49 };
    53 
    50 
    54 typedef struct AyStar AyStar;
    51 struct AyStar;
    55 /*
    52 /*
    56  * This function is called to check if the end-tile is found
    53  * This function is called to check if the end-tile is found
    57  *  return values can be:
    54  *  return values can be:
    58  *   AYSTAR_FOUND_END_NODE : indicates this is the end tile
    55  *   AYSTAR_FOUND_END_NODE : indicates this is the end tile
    59  *   AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)
    56  *   AYSTAR_DONE : indicates this is not the end tile (or direction was wrong)