![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
A path is a succession of moves and actions to go from one location to another. More...
#include <path_finder.h>
Collaboration diagram for freeciv::path_finder:Classes | |
| class | path_finder_private |
Public Types | |
| using | storage_type = std::multimap< const tile *, std::unique_ptr< detail::vertex > > |
| The type of the underlying storage, exposed through destination. More... | |
Public Member Functions | |
| path_finder (const unit *unit) | |
Constructs a path_finder for the given unit. More... | |
| path_finder (const unit *unit, const path::step &init) | |
Constructs a path_finder for the given unit. More... | |
| virtual | ~path_finder () |
| Destructor. More... | |
| path_finder & | operator= (path_finder &&other) |
| Move-assignment operator. More... | |
| void | set_constraint (std::unique_ptr< step_constraint > &&constraint) |
| Sets a constraint to limit the number of steps considered when trying to find a path. More... | |
| void | push_waypoint (const tile *location) |
| Adds a waypoint to the path finding. More... | |
| bool | pop_waypoint () |
| Removes the last added waypoint. More... | |
| void | unit_changed (const unit &unit) |
| Notifies the path finder that some unit died or changed state. More... | |
| std::vector< path > | find_all (const destination &destination) |
| Runs the path finding algorithm, searching for all paths leading to the destination. More... | |
| std::optional< path > | find_path (const destination &destination) |
| Runs the path finding algorithm. More... | |
Private Attributes | |
| std::unique_ptr< path_finder_private > | m_d |
Friends | |
| class | destination |
A path is a succession of moves and actions to go from one location to another.
Definition at line 55 of file path_finder.h.
| using freeciv::path_finder::storage_type = std::multimap<const tile *, std::unique_ptr<detail::vertex> > |
The type of the underlying storage, exposed through destination.
Definition at line 62 of file path_finder.h.
|
explicit |
Constructs a path_finder for the given unit.
Doesn't start the path finding yet.
The path finder becomes useless if the unit state changes.
Definition at line 646 of file path_finder.cpp.
|
explicit |
Constructs a path_finder for the given unit.
Initializes the search from a step in the unit's planned path. Doesn't start the path finding yet.
The path finder becomes useless if the unit state changes.
Definition at line 658 of file path_finder.cpp.
|
virtual |
Destructor.
Definition at line 667 of file path_finder.cpp.
| std::vector< path > freeciv::path_finder::find_all | ( | const destination & | destination | ) |
Runs the path finding algorithm, searching for all paths leading to the destination.
Make sure to set a harsh step constraint before calling this function, or it will become very slow very quickly.
Definition at line 744 of file path_finder.cpp.
| std::optional< path > freeciv::path_finder::find_path | ( | const destination & | destination | ) |
Runs the path finding algorithm.
Definition at line 779 of file path_finder.cpp.
|
inline |
Move-assignment operator.
Definition at line 135 of file path_finder.h.
| bool freeciv::path_finder::pop_waypoint | ( | ) |
Removes the last added waypoint.
Definition at line 706 of file path_finder.cpp.
| void freeciv::path_finder::push_waypoint | ( | const tile * | location | ) |
Adds a waypoint to the path finding.
Waypoints are tiles that the path must go through (in order) before reaching the destination.
Definition at line 691 of file path_finder.cpp.
| void freeciv::path_finder::set_constraint | ( | std::unique_ptr< step_constraint > && | constraint | ) |
Sets a constraint to limit the number of steps considered when trying to find a path.
A path_finder can only have one constraint at a time.
Takes ownership of the constraint.
Definition at line 678 of file path_finder.cpp.
| void freeciv::path_finder::unit_changed | ( | const unit & | unit | ) |
Notifies the path finder that some unit died or changed state.
In many cases, this will trigger a recalculation of the path.
Definition at line 724 of file path_finder.cpp.
|
friend |
Definition at line 56 of file path_finder.h.
|
private |
Definition at line 129 of file path_finder.h.
Referenced by find_all(), find_path(), operator=(), pop_waypoint(), push_waypoint(), set_constraint(), and unit_changed().