23#ifndef CORSIX_TH_TH_PATHFIND_H_
24#define CORSIX_TH_TH_PATHFIND_H_
Definition th_pathfind.h:95
const level_map * map
Map being searched.
Definition th_pathfind.h:141
void record_neighbour_if_passable(path_node *pNode, map_tile_flags neighbour_flags, bool passable, path_node *pNeighbour)
Definition th_pathfind.cpp:91
virtual int guess_distance(path_node *pNode)=0
Guess distance to the destination for pNode.
virtual ~abstract_pathfinder()=default
virtual bool try_node(path_node *pNode, map_tile_flags flags, path_node *pNeighbour, travel_direction direction)=0
Try the pNeighbour node.
path_node * init(const level_map *pMap, int iStartX, int iStarty)
Initialize the path finder.
Definition th_pathfind.cpp:42
bool search_neighbours(path_node *pNode, map_tile_flags flags, int iWidth)
Expand the pNode to its neighbours.
Definition th_pathfind.cpp:62
pathfinder * parent
Path finder parent object, containing shared data.
Definition th_pathfind.h:140
Definition th_pathfind.h:144
int destination_x
X coordinate of the destination of the path.
Definition th_pathfind.h:156
int destination_y
Y coordinate of the destination of the path.
Definition th_pathfind.h:157
int guess_distance(path_node *pNode) override
Guess distance to the destination for pNode.
Definition th_pathfind.cpp:115
bool try_node(path_node *pNode, map_tile_flags flags, path_node *pNeighbour, travel_direction direction) override
Try the pNeighbour node.
Definition th_pathfind.cpp:121
basic_pathfinder(pathfinder *pf)
Definition th_pathfind.h:146
bool find_path(const level_map *pMap, int iStartX, int iStartY, int iEndX, int iEndY)
Definition th_pathfind.cpp:131
Definition th_pathfind.h:160
hospital_finder(pathfinder *pf)
Definition th_pathfind.h:162
bool find_path_to_hospital(const level_map *pMap, int iStartX, int iStartY)
Definition th_pathfind.cpp:183
int guess_distance(path_node *pNode) override
Guess distance to the destination for pNode.
Definition th_pathfind.cpp:171
bool try_node(path_node *pNode, map_tile_flags flags, path_node *pNeighbour, travel_direction direction) override
Try the pNeighbour node.
Definition th_pathfind.cpp:173
Definition th_pathfind.h:171
double best_distance
Definition th_pathfind.h:198
bool try_node(path_node *pNode, map_tile_flags flags, path_node *pNeighbour, travel_direction direction) override
Try the pNeighbour node.
Definition th_pathfind.cpp:224
int guess_distance(path_node *pNode) override
Guess distance to the destination for pNode.
Definition th_pathfind.cpp:222
int start_x
X coordinate of the start position.
Definition th_pathfind.h:199
idle_tile_finder(pathfinder *pf)
Definition th_pathfind.h:173
path_node * best_next_node
Definition th_pathfind.h:197
bool find_idle_tile(const level_map *pMap, int iStartX, int iStartY, int iN, int parcelId)
Definition th_pathfind.cpp:277
int start_y
Y coordinate of the start position.
Definition th_pathfind.h:200
Interface used for depersisting Lua objects.
Definition persist_lua.h:107
Interface used for persisting Lua objects.
Definition persist_lua.h:44
Definition th_pathfind.h:203
int guess_distance(path_node *pNode) override
Guess distance to the destination for pNode.
Definition th_pathfind.cpp:347
int max_distance
Definition th_pathfind.h:223
object_type target
Definition th_pathfind.h:225
bool visit_objects(const level_map *pMap, int iStartX, int iStartY, object_type eTHOB, int iMaxDistance, lua_State *L, int iVisitFunction, bool anyObjectType)
Definition th_pathfind.cpp:421
bool target_any_object_type
Definition th_pathfind.h:224
bool try_node(path_node *pNode, map_tile_flags flags, path_node *pNeighbour, travel_direction direction) override
Try the pNeighbour node.
Definition th_pathfind.cpp:349
int visit_function_index
Definition th_pathfind.h:222
lua_State * L
Definition th_pathfind.h:221
object_visitor(pathfinder *pf)
Definition th_pathfind.h:205
Finds paths through maps.
Definition th_pathfind.h:243
int dirty_node_count
Definition th_pathfind.h:316
int node_cache_height
Definition th_pathfind.h:315
~pathfinder()
Definition th_pathfind.cpp:473
void open_heap_promote(path_node *pNode)
Definition th_pathfind.cpp:560
std::vector< path_node * > open_heap
Heap of not yet evaluated nodes as a 0-based array.
Definition th_pathfind.h:311
std::vector< path_node > nodes
2D array of nodes, one for each map cell
Definition th_pathfind.h:295
path_node ** dirty_node_list
Array of "dirty" nodes which need to be reset before the next path find.
Definition th_pathfind.h:302
int node_cache_width
Definition th_pathfind.h:314
const level_map * default_map
Definition th_pathfind.h:292
void depersist(lua_persist_reader *pReader)
Definition th_pathfind.cpp:641
void push_result(lua_State *L) const
Definition th_pathfind.cpp:533
bool get_path_end(int *pX, int *pY) const
Definition th_pathfind.cpp:514
bool find_idle_tile(const level_map *pMap, int iStartX, int iStartY, int iN, int parcelId)
Definition th_pathfind.h:255
path_node * pop_from_open_heap()
Definition th_pathfind.cpp:581
void persist(lua_persist_writer *pWriter) const
Definition th_pathfind.cpp:627
bool visit_objects(const level_map *pMap, int iStartX, int iStartY, object_type eTHOB, int iMaxDistance, lua_State *L, int iVisitFunction, bool anyObjectType)
Definition th_pathfind.h:266
bool find_path_to_hospital(const level_map *pMap, int iStartX, int iStartY)
Definition th_pathfind.h:261
bool find_path(const level_map *pMap, int iStartX, int iStartY, int iEndX, int iEndY)
Definition th_pathfind.h:250
path_node * destination
Definition th_pathfind.h:313
void set_default_map(const level_map *pMap)
Definition th_pathfind.cpp:475
pathfinder()
Definition th_pathfind.cpp:460
void allocate_node_cache(int iWidth, int iHeight)
Allocate node cache for all tiles of the map.
Definition th_pathfind.cpp:477
int get_path_length() const
Definition th_pathfind.cpp:506
void push_to_open_heap(path_node *pNode)
Definition th_pathfind.cpp:554
Definition th_pathfind.h:49
int y
Y-position of this cell (constant)
Definition th_pathfind.h:61
int value() const
Total cost of this node.
Definition th_pathfind.h:91
const path_node * prev
Pointer to the previous node in the path to this cell.
Definition th_pathfind.h:55
bool visited
True if the cell has already been visited (popped from the open heap)
Definition th_pathfind.h:84
int x
X-position of this cell (constant)
Definition th_pathfind.h:58
int distance
Current shortest distance to this cell.
Definition th_pathfind.h:68
int guess
Minimum distance from this cell to the goal.
Definition th_pathfind.h:75
size_t open_idx
Index of this cell in the open heap.
Definition th_pathfind.h:81
object_type
Definition th_map.h:46
travel_direction
Definition th_pathfind.h:41
@ south
Move to the south.
@ north
Move to the north.