FIFE
be64c707dea6b3250bd4355bf5c825d25920087d
|
#include <routepather.h>
Public Member Functions | |
RoutePather () | |
Constructor. More... | |
Route * | createRoute (const Location &start, const Location &end, bool immediate=false, const std::string &costId="") |
Creates a route between the start and end location that needs be solved. More... | |
bool | solveRoute (Route *route, int32_t priority=MEDIUM_PRIORITY, bool immediate=false) |
Solves the route to create a path. More... | |
bool | followRoute (const Location ¤t, Route *route, double speed, Location &nextLocation) |
Follows the path of the route. More... | |
void | update () |
Updates the route pather. More... | |
bool | cancelSession (const int32_t sessionId) |
Cancels a session. More... | |
void | setMaxTicks (int32_t ticks) |
Sets maximal ticks (update steps) to solve routes. More... | |
int32_t | getMaxTicks () |
Returns maximal ticks (update steps) to solve routes. More... | |
std::string | getName () const |
Returns name of the pathfinder. More... | |
Public Member Functions inherited from FIFE::IPather | |
virtual | ~IPather () |
Private Types | |
typedef std::list< Location > | Path |
A path is a list with locations. Each location holds the coordinate for one cell. More... | |
typedef PriorityQueue< RoutePatherSearch *, int32_t > | SessionQueue |
Holds the searches and their priority. More... | |
typedef std::list< int32_t > | SessionList |
Holds the sessions. More... | |
Private Member Functions | |
void | addSessionId (const int32_t sessionId) |
Adds a session id to the session map. More... | |
int32_t | makeSessionId () |
Makes a new session id. More... | |
bool | locationsEqual (const Location &a, const Location &b) |
Are two locations equivalent from the perspective of pathing (same layer coordinates and layer). More... | |
bool | sessionIdValid (const int32_t sessionId) |
Determines if the given session Id is valid. More... | |
bool | invalidateSessionId (const int32_t sessionId) |
Removes a session id from the session map. More... | |
Private Attributes | |
SessionQueue | m_sessions |
A map of currently running sessions (searches). More... | |
SessionList | m_registeredSessionIds |
A list of session ids that have been registered. More... | |
int32_t | m_nextFreeSessionId |
The next free session id. More... | |
int32_t | m_maxTicks |
The maximum number of ticks allowed. More... | |
Definition at line 45 of file routepather.h.
|
private |
A path is a list with locations. Each location holds the coordinate for one cell.
Definition at line 117 of file routepather.h.
|
private |
Holds the sessions.
Definition at line 123 of file routepather.h.
|
private |
Holds the searches and their priority.
Definition at line 120 of file routepather.h.
|
inline |
Constructor.
Definition at line 50 of file routepather.h.
References cancelSession(), createRoute(), followRoute(), getMaxTicks(), getName(), FIFE::MEDIUM_PRIORITY, setMaxTicks(), solveRoute(), and update().
|
private |
Adds a session id to the session map.
Stores the given session id in the session map.
sessionId | The session id to store. |
Definition at line 96 of file routepather.cpp.
References m_registeredSessionIds.
Referenced by solveRoute().
|
virtual |
Cancels a session.
Cancels a route pather session. Determines if it is an active session or not and acts accordingly.
sessionId | The id of the session to cancel. |
Implements FIFE::IPather.
Definition at line 89 of file routepather.cpp.
References invalidateSessionId().
Referenced by RoutePather().
|
virtual |
Creates a route between the start and end location that needs be solved.
start | A const reference to the start location. |
end | A const reference to the target location. |
immediate | A optional boolean, if true the route bypass the max. ticks limit and solves the path immediately, otherwise false. |
costId | A const reference to the string that holds the cost identifier. You can use it optional then this cost id is used instead of the default cost. |
Implements FIFE::IPather.
Definition at line 121 of file routepather.cpp.
References FIFE::MEDIUM_PRIORITY, FIFE::ROUTE_FAILED, FIFE::Route::setCostId(), FIFE::Route::setRouteStatus(), and solveRoute().
Referenced by RoutePather().
|
virtual |
Follows the path of the route.
current | A const reference to the current location. |
route | A pointer to the route which should be followed. |
speed | A double which holds the speed. |
nextLocation | A reference to the next location returned by the pather. |
Implements FIFE::IPather.
Definition at line 271 of file routepather.cpp.
References FIFE::Layer::cellContainsBlockingInstance(), utf8::distance(), FIFE::doublePt2intPt(), FIFE::Math< T >::Equal(), FIFE::getAngleBetween(), FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::Layer::getCellGrid(), FIFE::CellCache::getCellSpeedMultiplier(), FIFE::Route::getCurrentNode(), FIFE::CellCache::getDefaultSpeedMultiplier(), FIFE::Location::getExactLayerCoordinates(), FIFE::Location::getLayer(), FIFE::Cell::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Cell::getLayerCoordinates(), FIFE::Location::getMapCoordinates(), FIFE::Route::getOccupiedCells(), FIFE::Route::getPath(), FIFE::Route::getPreviousNode(), FIFE::Route::getRotation(), FIFE::Cell::getTransition(), FIFE::CellGrid::getXScale(), FIFE::CellGrid::getYScale(), FIFE::CellGrid::getZShift(), FIFE::CellGrid::isAccessible(), FIFE::Route::isMultiCell(), locationsEqual(), FIFE::TransitionInfo::m_difflayer, FIFE::TransitionInfo::m_immediate, FIFE::TransitionInfo::m_layer, FIFE::TransitionInfo::m_mc, FIFE::Route::setEndNode(), FIFE::Location::setLayer(), FIFE::Location::setLayerCoordinates(), FIFE::Location::setMapCoordinates(), FIFE::Route::setRotation(), FIFE::Math< T >::Sqrt(), FIFE::Route::walkToNextNode(), FIFE::PointType3D< T >::x, FIFE::PointType3D< T >::y, and FIFE::PointType3D< T >::z.
Referenced by RoutePather().
|
virtual |
Returns maximal ticks (update steps) to solve routes.
Implements FIFE::IPather.
Definition at line 437 of file routepather.cpp.
References m_maxTicks.
Referenced by RoutePather().
|
virtual |
Returns name of the pathfinder.
Implements FIFE::IPather.
Definition at line 441 of file routepather.cpp.
Referenced by RoutePather().
|
private |
Removes a session id from the session map.
sessionId | The session id to remove. |
Definition at line 110 of file routepather.cpp.
References m_registeredSessionIds.
Referenced by cancelSession(), and update().
Are two locations equivalent from the perspective of pathing (same layer coordinates and layer).
a | A const reference to the first location to check. |
b | A const reference to the second location to check. |
Definition at line 49 of file routepather.cpp.
References FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::PointType3D< T >::x, and FIFE::PointType3D< T >::y.
Referenced by followRoute(), and solveRoute().
|
private |
Makes a new session id.
Definition at line 45 of file routepather.cpp.
References m_nextFreeSessionId.
Referenced by solveRoute().
|
private |
Determines if the given session Id is valid.
Searches the session list to determine if a search with the given session id has been registered.
sessionId | The session id to check. |
Definition at line 100 of file routepather.cpp.
References m_registeredSessionIds.
Referenced by solveRoute(), and update().
|
virtual |
Sets maximal ticks (update steps) to solve routes.
ticks | A integer which holds the steps. default is 1000 |
Implements FIFE::IPather.
Definition at line 433 of file routepather.cpp.
References m_maxTicks.
Referenced by RoutePather().
|
virtual |
Solves the route to create a path.
route | A pointer to the route which should be solved. |
priority | The priority to assign to search (high are pushed to the front of the queue). |
immediate | A optional boolean, if true the route bypass the max. ticks limit and solves the path immediately, otherwise false. |
Implements FIFE::IPather.
Definition at line 135 of file routepather.cpp.
References addSessionId(), FIFE::RoutePatherSearch::calcPath(), FIFE::CellCache::getCell(), FIFE::Layer::getCellCache(), FIFE::Route::getEndNode(), FIFE::Location::getLayer(), FIFE::Location::getLayerCoordinates(), FIFE::Route::getLimitedAreas(), FIFE::Cell::getNeighbors(), FIFE::RoutePatherSearch::getSearchStatus(), FIFE::Route::getSessionId(), FIFE::Route::getStartNode(), FIFE::Cell::getZone(), FIFE::Route::isAreaLimited(), FIFE::CellCache::isCellInArea(), FIFE::CellCache::isInCellCache(), FIFE::Cell::isZoneProtected(), locationsEqual(), m_sessions, makeSessionId(), FIFE::PriorityQueue< index_type, priority_type >::pushElement(), FIFE::ROUTE_FAILED, FIFE::ROUTE_SOLVED, FIFE::RoutePatherSearch::search_status_complete, FIFE::RoutePatherSearch::search_status_failed, sessionIdValid(), FIFE::Route::setRouteStatus(), FIFE::Route::setSessionId(), and FIFE::RoutePatherSearch::updateSearch().
Referenced by createRoute(), and RoutePather().
|
virtual |
Updates the route pather.
Advances the active search by so many time steps. If the search completes then this function pops it from the active session list and continues updating the next session until it runs out of time.
Implements FIFE::IPather.
Definition at line 57 of file routepather.cpp.
References FIFE::RoutePatherSearch::calcPath(), FIFE::PriorityQueue< index_type, priority_type >::empty(), FIFE::PriorityQueue< index_type, priority_type >::getPriorityElement(), FIFE::RoutePatherSearch::getRoute(), FIFE::Route::getRouteStatus(), FIFE::RoutePatherSearch::getSearchStatus(), FIFE::RoutePatherSearch::getSessionId(), invalidateSessionId(), m_maxTicks, m_sessions, FIFE::PriorityQueue< index_type, priority_type >::popElement(), FIFE::ROUTE_SOLVED, FIFE::RoutePatherSearch::search_status_complete, FIFE::RoutePatherSearch::search_status_failed, sessionIdValid(), and FIFE::RoutePatherSearch::updateSearch().
Referenced by RoutePather().
|
private |
The maximum number of ticks allowed.
Definition at line 173 of file routepather.h.
Referenced by getMaxTicks(), setMaxTicks(), and update().
|
private |
The next free session id.
Definition at line 170 of file routepather.h.
Referenced by makeSessionId().
|
private |
A list of session ids that have been registered.
Definition at line 167 of file routepather.h.
Referenced by addSessionId(), invalidateSessionId(), and sessionIdValid().
|
private |
A map of currently running sessions (searches).
Definition at line 164 of file routepather.h.
Referenced by solveRoute(), and update().