yapf.h File Reference

Entry point for OpenTTD to YAPF. More...

#include "../debug.h"
#include "../depot_type.h"
#include "../direction_type.h"
#include "../pbs.h"

Go to the source code of this file.

Enumerations

enum  { YAPF_TILE_LENGTH = 100, YAPF_TILE_CORNER_LENGTH = 71 }
 Base tile length units.

Functions

Trackdir YapfChooseShipTrack (const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks)
 Finds the best path for given ship.
Trackdir YapfChooseRoadTrack (const Vehicle *v, TileIndex tile, DiagDirection enterdir)
 Finds the best path for given road vehicle.
Trackdir YapfChooseRailTrack (const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found, bool reserve_track, PBSTileInfo *target)
 Finds the best path for given train.
uint YapfRoadVehDistanceToTile (const Vehicle *v, TileIndex tile)
 Used by RV multistop feature to find the nearest road stop that has a free slot.
Depot * YapfFindNearestRoadDepot (const Vehicle *v)
 Used when user sends RV to the nearest depot or if RV needs servicing.
bool YapfFindNearestRailDepotTwoWay (const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed)
 Used when user sends train to the nearest depot or if train needs servicing.
bool YapfCheckReverseTrain (const Vehicle *v)
 Returns true if it is better to reverse the train before leaving station.
bool YapfRailFindNearestSafeTile (const Vehicle *v, TileIndex tile, Trackdir td, bool override_railtype)
 Try to extend the reserved path of a train to the nearest safe tile.
void YapfNotifyTrackLayoutChange (TileIndex tile, Track track)
 Use this function to notify YAPF that track layout (or signal configuration) has change.
void * NpfBeginInterval ()
 performance measurement helpers
int NpfEndInterval (void *perf)
 performance measurement helper

Variables

int _aystar_stats_open_size
int _aystar_stats_closed_size


Detailed Description

Entry point for OpenTTD to YAPF.

Definition in file yapf.h.


Function Documentation

Trackdir YapfChooseRailTrack ( const Vehicle *  v,
TileIndex  tile,
DiagDirection  enterdir,
TrackBits  tracks,
bool *  path_not_found,
bool  reserve_track,
PBSTileInfo target 
)

Finds the best path for given train.

Parameters:
v the train that needs to find a path
tile the tile to find the path from (should be next tile the train is about to enter)
enterdir diagonal direction which the RV will enter this new tile from
tracks available trackdirs on the new tile (to choose from)
path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess')
reserve_track indicates whether YAPF should try to reserve the found path
target [out] the target tile of the reservation, free is set to true if path was reserved
Returns:
the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found

Definition at line 510 of file yapf_rail.cpp.

References _settings_game, PathfinderSettings::forbid_90_deg, and GameSettings::pf.

Referenced by DoTrainPathfind().

Trackdir YapfChooseRoadTrack ( const Vehicle *  v,
TileIndex  tile,
DiagDirection  enterdir 
)

Finds the best path for given road vehicle.

Parameters:
v the RV that needs to find a path
tile the tile to find the path from (should be next tile the RV is about to enter)
enterdir diagonal direction which the RV will enter this new tile from
Returns:
the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found

Definition at line 433 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GameSettings::pf, and PathfinderSettings::yapf.

Referenced by RoadFindPathToDest().

Trackdir YapfChooseShipTrack ( const Vehicle *  v,
TileIndex  tile,
DiagDirection  enterdir,
TrackBits  tracks 
)

Finds the best path for given ship.

Parameters:
v the ship that needs to find a path
tile the tile to find the path from (should be next tile the ship is about to enter)
enterdir diagonal direction which the ship will enter this new tile from
tracks available tracks on the new tile (to choose from)
Returns:
the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found

Definition at line 163 of file yapf_ship.cpp.

References _settings_game, ChooseShipTrack(), YAPFSettings::disable_node_optimization, PathfinderSettings::forbid_90_deg, GameSettings::pf, and PathfinderSettings::yapf.

Referenced by ChooseShipTrack().

bool YapfFindNearestRailDepotTwoWay ( const Vehicle *  v,
int  max_distance,
int  reverse_penalty,
TileIndex depot_tile,
bool *  reversed 
)

Used when user sends train to the nearest depot or if train needs servicing.

Parameters:
v train that needs to go to some depot
max_distance max distance (number of track tiles) from the current train position (used also as optimization - the pathfinder can stop path finding if max_distance was reached and no depot was seen)
reverse_penalty penalty that should be added for the path that requires reversing the train first
depot_tile receives the depot tile if depot was found
reversed receives true if train needs to reversed first
Returns:
the true if depot was found.

Definition at line 586 of file yapf_rail.cpp.

References _settings_game, FollowTrainReservation(), PathfinderSettings::forbid_90_deg, GetVehicleTrackdir(), INVALID_TILE, GameSettings::pf, ReverseTrackdir(), PBSTileInfo::tile, and PBSTileInfo::trackdir.

Referenced by FindClosestTrainDepot().

Depot* YapfFindNearestRoadDepot ( const Vehicle *  v  ) 

Used when user sends RV to the nearest depot or if RV needs servicing.

Returns the nearest depot (or NULL if depot was not found).

Definition at line 469 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GetDepotByTile(), GetTileTrackStatus(), GetVehicleTrackdir(), GameSettings::pf, TrackdirToTrackdirBits(), TrackStatusToTrackdirBits(), TRANSPORT_ROAD, and PathfinderSettings::yapf.

bool YapfRailFindNearestSafeTile ( const Vehicle *  v,
TileIndex  tile,
Trackdir  td,
bool  override_railtype 
)

Try to extend the reserved path of a train to the nearest safe tile.

Parameters:
v The train that needs to find a safe tile.
tile Last tile of the current reserved path.
td Last trackdir of the current reserved path.
override_railtype Should all physically compabtible railtypes be searched, even if the vehicle can't on them on it own?
Returns:
True if the path could be extended to a safe tile.

Definition at line 609 of file yapf_rail.cpp.

References _settings_game, PathfinderSettings::forbid_90_deg, and GameSettings::pf.

Referenced by TryReserveSafeTrack().

uint YapfRoadVehDistanceToTile ( const Vehicle *  v,
TileIndex  tile 
)

Used by RV multistop feature to find the nearest road stop that has a free slot.

Parameters:
v RV (its current tile will be the origin)
tile destination tile
Returns:
distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found

Definition at line 448 of file yapf_road.cpp.

References _settings_game, YAPFSettings::disable_node_optimization, GameSettings::pf, and PathfinderSettings::yapf.


Generated on Mon May 11 15:48:23 2009 for OpenTTD by  doxygen 1.5.6