FIFE  be64c707dea6b3250bd4355bf5c825d25920087d
FIFE::RoutePather Class Reference

#include <routepather.h>

+ Inheritance diagram for FIFE::RoutePather:
+ Collaboration diagram for FIFE::RoutePather:

Public Member Functions

 RoutePather ()
 Constructor. More...
 
RoutecreateRoute (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 &current, 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< LocationPath
 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...
 

Detailed Description

Definition at line 45 of file routepather.h.

Member Typedef Documentation

◆ Path

typedef std::list<Location> FIFE::RoutePather::Path
private

A path is a list with locations. Each location holds the coordinate for one cell.

Definition at line 117 of file routepather.h.

◆ SessionList

typedef std::list<int32_t> FIFE::RoutePather::SessionList
private

Holds the sessions.

Definition at line 123 of file routepather.h.

◆ SessionQueue

Holds the searches and their priority.

Definition at line 120 of file routepather.h.

Constructor & Destructor Documentation

◆ RoutePather()

FIFE::RoutePather::RoutePather ( )
inline

Member Function Documentation

◆ addSessionId()

void FIFE::RoutePather::addSessionId ( const int32_t  sessionId)
private

Adds a session id to the session map.

Stores the given session id in the session map.

Parameters
sessionIdThe session id to store.

Definition at line 96 of file routepather.cpp.

References m_registeredSessionIds.

Referenced by solveRoute().

+ Here is the caller graph for this function:

◆ cancelSession()

bool FIFE::RoutePather::cancelSession ( const int32_t  sessionId)
virtual

Cancels a session.

Cancels a route pather session. Determines if it is an active session or not and acts accordingly.

Parameters
sessionIdThe id of the session to cancel.
Returns
True if the session could be canceled false otherwise.

Implements FIFE::IPather.

Definition at line 89 of file routepather.cpp.

References invalidateSessionId().

Referenced by RoutePather().

+ Here is the caller graph for this function:

◆ createRoute()

Route * FIFE::RoutePather::createRoute ( const Location start,
const Location end,
bool  immediate = false,
const std::string &  costId = "" 
)
virtual

Creates a route between the start and end location that needs be solved.

Parameters
startA const reference to the start location.
endA const reference to the target location.
immediateA optional boolean, if true the route bypass the max. ticks limit and solves the path immediately, otherwise false.
costIdA 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().

+ Here is the caller graph for this function:

◆ followRoute()

bool FIFE::RoutePather::followRoute ( const Location current,
Route route,
double  speed,
Location nextLocation 
)
virtual

Follows the path of the route.

Parameters
currentA const reference to the current location.
routeA pointer to the route which should be followed.
speedA double which holds the speed.
nextLocationA reference to the next location returned by the pather.
Returns
A boolean, if true the route could be followed, otherwise false.

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().

+ Here is the caller graph for this function:

◆ getMaxTicks()

int32_t FIFE::RoutePather::getMaxTicks ( )
virtual

Returns maximal ticks (update steps) to solve routes.

See also
update()
Returns
A integer which holds the steps. default is 1000

Implements FIFE::IPather.

Definition at line 437 of file routepather.cpp.

References m_maxTicks.

Referenced by RoutePather().

+ Here is the caller graph for this function:

◆ getName()

std::string FIFE::RoutePather::getName ( ) const
virtual

Returns name of the pathfinder.

Returns
A string that contains the name of the pathfinder.

Implements FIFE::IPather.

Definition at line 441 of file routepather.cpp.

Referenced by RoutePather().

+ Here is the caller graph for this function:

◆ invalidateSessionId()

bool FIFE::RoutePather::invalidateSessionId ( const int32_t  sessionId)
private

Removes a session id from the session map.

Parameters
sessionIdThe session id to remove.
Returns
True if the sessionId could be removed, false otherwise.

Definition at line 110 of file routepather.cpp.

References m_registeredSessionIds.

Referenced by cancelSession(), and update().

+ Here is the caller graph for this function:

◆ locationsEqual()

bool FIFE::RoutePather::locationsEqual ( const Location a,
const Location b 
)
private

Are two locations equivalent from the perspective of pathing (same layer coordinates and layer).

Parameters
aA const reference to the first location to check.
bA const reference to the second location to check.
Returns
A boolean, true if the locations are equal, false otherwise.

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().

+ Here is the caller graph for this function:

◆ makeSessionId()

int32_t FIFE::RoutePather::makeSessionId ( )
private

Makes a new session id.

Returns
The new session id.

Definition at line 45 of file routepather.cpp.

References m_nextFreeSessionId.

Referenced by solveRoute().

+ Here is the caller graph for this function:

◆ sessionIdValid()

bool FIFE::RoutePather::sessionIdValid ( const int32_t  sessionId)
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.

Parameters
sessionIdThe session id to check.
Returns
true if one has, false otherwise.

Definition at line 100 of file routepather.cpp.

References m_registeredSessionIds.

Referenced by solveRoute(), and update().

+ Here is the caller graph for this function:

◆ setMaxTicks()

void FIFE::RoutePather::setMaxTicks ( int32_t  ticks)
virtual

Sets maximal ticks (update steps) to solve routes.

See also
update()
Parameters
ticksA 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().

+ Here is the caller graph for this function:

◆ solveRoute()

bool FIFE::RoutePather::solveRoute ( Route route,
int32_t  priority = MEDIUM_PRIORITY,
bool  immediate = false 
)
virtual

◆ update()

void FIFE::RoutePather::update ( )
virtual

Member Data Documentation

◆ m_maxTicks

int32_t FIFE::RoutePather::m_maxTicks
private

The maximum number of ticks allowed.

Definition at line 173 of file routepather.h.

Referenced by getMaxTicks(), setMaxTicks(), and update().

◆ m_nextFreeSessionId

int32_t FIFE::RoutePather::m_nextFreeSessionId
private

The next free session id.

Definition at line 170 of file routepather.h.

Referenced by makeSessionId().

◆ m_registeredSessionIds

SessionList FIFE::RoutePather::m_registeredSessionIds
private

A list of session ids that have been registered.

Definition at line 167 of file routepather.h.

Referenced by addSessionId(), invalidateSessionId(), and sessionIdValid().

◆ m_sessions

SessionQueue FIFE::RoutePather::m_sessions
private

A map of currently running sessions (searches).

Definition at line 164 of file routepather.h.

Referenced by solveRoute(), and update().


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