src/npf.h
changeset 9804 fbe3e33a2c96
parent 9126 5648d696456b
child 9805 c6e69a451215
equal deleted inserted replaced
9803:cb1362dac242 9804:fbe3e33a2c96
    43 
    43 
    44 /* Meant to be stored in AyStar.targetdata */
    44 /* Meant to be stored in AyStar.targetdata */
    45 struct NPFFindStationOrTileData {
    45 struct NPFFindStationOrTileData {
    46 	TileIndex dest_coords;   ///< An indication of where the station is, for heuristic purposes, or the target tile
    46 	TileIndex dest_coords;   ///< An indication of where the station is, for heuristic purposes, or the target tile
    47 	StationID station_index; ///< station index we're heading for, or INVALID_STATION when we're heading for a tile
    47 	StationID station_index; ///< station index we're heading for, or INVALID_STATION when we're heading for a tile
       
    48 	bool      reserve_path;  ///< Indicates whether the found path should be reserved
       
    49 	const Vehicle* v;        ///< The vehicle we are pathfinding for
    48 };
    50 };
    49 
    51 
    50 /* Indices into AyStar.userdata[] */
    52 /* Indices into AyStar.userdata[] */
    51 enum {
    53 enum {
    52 	NPF_TYPE = 0,  ///< Contains a TransportTypes value
    54 	NPF_TYPE = 0,  ///< Contains a TransportTypes value
    65 enum NPFNodeFlag {
    67 enum NPFNodeFlag {
    66 	NPF_FLAG_SEEN_SIGNAL,       ///< Used to mark that a signal was seen on the way, for rail only
    68 	NPF_FLAG_SEEN_SIGNAL,       ///< Used to mark that a signal was seen on the way, for rail only
    67 	NPF_FLAG_REVERSE,           ///< Used to mark that this node was reached from the second start node, if applicable
    69 	NPF_FLAG_REVERSE,           ///< Used to mark that this node was reached from the second start node, if applicable
    68 	NPF_FLAG_LAST_SIGNAL_RED,   ///< Used to mark that the last signal on this path was red
    70 	NPF_FLAG_LAST_SIGNAL_RED,   ///< Used to mark that the last signal on this path was red
    69 	NPF_FLAG_IGNORE_START_TILE, ///< Used to mark that the start tile is invalid, and searching should start from the second tile on
    71 	NPF_FLAG_IGNORE_START_TILE, ///< Used to mark that the start tile is invalid, and searching should start from the second tile on
       
    72 	NPF_FLAG_TARGET_RESERVED,   ///< Used to mark that the possible reservation target is already reserved
    70 };
    73 };
    71 
    74 
    72 /* Meant to be stored in AyStar.userpath */
    75 /* Meant to be stored in AyStar.userpath */
    73 struct NPFFoundTargetData {
    76 struct NPFFoundTargetData {
    74 	uint best_bird_dist;    ///< The best heuristic found. Is 0 if the target was found
    77 	uint best_bird_dist;    ///< The best heuristic found. Is 0 if the target was found
    75 	uint best_path_dist;    ///< The shortest path. Is (uint)-1 if no path is found
    78 	uint best_path_dist;    ///< The shortest path. Is (uint)-1 if no path is found
    76 	Trackdir best_trackdir; ///< The trackdir that leads to the shortest path/closest birds dist
    79 	Trackdir best_trackdir; ///< The trackdir that leads to the shortest path/closest birds dist
    77 	AyStarNode node;        ///< The node within the target the search led us to
    80 	AyStarNode node;        ///< The node within the target the search led us to
       
    81 	bool res_okay;          ///< True if a path reservation could be made
    78 };
    82 };
    79 
    83 
    80 /* These functions below are _not_ re-entrant, in favor of speed! */
    84 /* These functions below are _not_ re-entrant, in favor of speed! */
    81 
    85 
    82 /* Will search from the given tile and direction, for a route to the given
    86 /* Will search from the given tile and direction, for a route to the given
   103 NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty);
   107 NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, TransportType type, uint sub_type, Owner owner, RailTypes railtypes, uint reverse_penalty);
   104 /* Search by trying each depot in order of Manhattan Distance. Good for lots
   108 /* Search by trying each depot in order of Manhattan Distance. Good for lots
   105  * of choices and accurate heuristics, such as water. */
   109  * of choices and accurate heuristics, such as water. */
   106 NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
   110 NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes);
   107 
   111 
   108 void NPFFillWithOrderData(NPFFindStationOrTileData* fstd, Vehicle* v);
   112 void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reserve_path = false);
   109 
   113 
   110 
   114 
   111 /*
   115 /*
   112  * Functions to manipulate the various NPF related flags on an AyStarNode.
   116  * Functions to manipulate the various NPF related flags on an AyStarNode.
   113  */
   117  */