KUDr@3900: /* $Id$ */ KUDr@3900: rubidium@10455: /** @file yapf.h Entry point for OpenTTD to YAPF. */ celestar@6447: KUDr@3900: #ifndef YAPF_H KUDr@3900: #define YAPF_H KUDr@3900: KUDr@3900: #include "../debug.h" rubidium@9837: #include "../depot_type.h" rubidium@9837: #include "../direction_type.h" KUDr@3900: KUDr@4462: /** Finds the best path for given ship. rubidium@4549: * @param v the ship that needs to find a path rubidium@4549: * @param tile the tile to find the path from (should be next tile the ship is about to enter) rubidium@4549: * @param enterdir diagonal direction which the ship will enter this new tile from rubidium@4549: * @param tracks available tracks on the new tile (to choose from) rubidium@4549: * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found KUDr@4462: */ glx@10829: Trackdir YapfChooseShipTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks); KUDr@4462: KUDr@4462: /** Finds the best path for given road vehicle. rubidium@4549: * @param v the RV that needs to find a path rubidium@4549: * @param tile the tile to find the path from (should be next tile the RV is about to enter) rubidium@4549: * @param enterdir diagonal direction which the RV will enter this new tile from rubidium@4549: * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found rubidium@4549: */ glx@10829: Trackdir YapfChooseRoadTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir); KUDr@4462: KUDr@4462: /** Finds the best path for given train. rubidium@4549: * @param v the train that needs to find a path rubidium@4549: * @param tile the tile to find the path from (should be next tile the train is about to enter) rubidium@4549: * @param enterdir diagonal direction which the RV will enter this new tile from rubidium@9601: * @param tracks available trackdirs on the new tile (to choose from) rubidium@9601: * @param path_not_found [out] true is returned if no path can be found (returned Trackdir is only a 'guess') rubidium@4549: * @return the best trackdir for next turn or INVALID_TRACKDIR if the path could not be found rubidium@4549: */ glx@10829: Trackdir YapfChooseRailTrack(const Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found); KUDr@3900: KUDr@4462: /** Used by RV multistop feature to find the nearest road stop that has a free slot. rubidium@4549: * @param v RV (its current tile will be the origin) rubidium@4549: * @param tile destination tile rubidium@4549: * @return distance from origin tile to the destination (number of road tiles) or UINT_MAX if path not found rubidium@4549: */ KUDr@3915: uint YapfRoadVehDistanceToTile(const Vehicle* v, TileIndex tile); KUDr@3915: KUDr@4462: /** Used when user sends RV to the nearest depot or if RV needs servicing. rubidium@4549: * Returns the nearest depot (or NULL if depot was not found). rubidium@4549: */ KUDr@3900: Depot* YapfFindNearestRoadDepot(const Vehicle *v); KUDr@4462: KUDr@4462: /** Used when user sends train to the nearest depot or if train needs servicing. rubidium@9601: * @param v train that needs to go to some depot rubidium@9601: * @param max_distance max distance (number of track tiles) from the current train position rubidium@4549: * (used also as optimization - the pathfinder can stop path finding if max_distance rubidium@4549: * was reached and no depot was seen) rubidium@9601: * @param reverse_penalty penalty that should be added for the path that requires reversing the train first rubidium@9601: * @param depot_tile receives the depot tile if depot was found rubidium@9601: * @param reversed receives true if train needs to reversed first rubidium@4549: * @return the true if depot was found. rubidium@4549: */ glx@10829: bool YapfFindNearestRailDepotTwoWay(const Vehicle *v, int max_distance, int reverse_penalty, TileIndex *depot_tile, bool *reversed); KUDr@3900: KUDr@4462: /** Returns true if it is better to reverse the train before leaving station */ glx@10829: bool YapfCheckReverseTrain(const Vehicle* v); KUDr@3900: KUDr@4462: /** Use this function to notify YAPF that track layout (or signal configuration) has change */ KUDr@3900: void YapfNotifyTrackLayoutChange(TileIndex tile, Track track); KUDr@3900: KUDr@4462: /** performance measurement helpers */ rubidium@6573: void* NpfBeginInterval(); glx@10829: int NpfEndInterval(void *perf); KUDr@3900: KUDr@4462: KUDr@3900: extern int _aystar_stats_open_size; KUDr@3900: extern int _aystar_stats_closed_size; KUDr@3900: KUDr@3900: KUDr@4462: /** Base tile length units */ KUDr@3900: enum { KUDr@3900: YAPF_TILE_LENGTH = 100, KUDr@3900: YAPF_TILE_CORNER_LENGTH = 71 KUDr@3900: }; KUDr@3900: KUDr@3900: #endif /* YAPF_H */