2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <http://www.gnu.org/licenses/>.
8 /** @file pathfinder_type.h General types related to pathfinders. */
10 #ifndef PATHFINDER_TYPE_H
11 #define PATHFINDER_TYPE_H
13 #include "../tile_type.h"
15 /** Length (penalty) of one tile with NPF */
16 static const int NPF_TILE_LENGTH
= 100;
19 * This penalty is the equivalent of "infinite", which means that paths that
20 * get this penalty will be chosen, but only if there is no other route
21 * without it. Be careful with not applying this penalty too often, or the
22 * total path cost might overflow.
24 static const int NPF_INFINITE_PENALTY
= 1000 * NPF_TILE_LENGTH
;
27 /** Length (penalty) of one tile with YAPF */
28 static const int YAPF_TILE_LENGTH
= 100;
30 /** Length (penalty) of a corner with YAPF */
31 static const int YAPF_TILE_CORNER_LENGTH
= 71;
34 * This penalty is the equivalent of "infinite", which means that paths that
35 * get this penalty will be chosen, but only if there is no other route
36 * without it. Be careful with not applying this penalty too often, or the
37 * total path cost might overflow.
39 static const int YAPF_INFINITE_PENALTY
= 1000 * YAPF_TILE_LENGTH
;
41 /** Maximum length of ship path cache */
42 static const int YAPF_SHIP_PATH_CACHE_LENGTH
= 32;
44 /** Maximum segments of road vehicle path cache */
45 static const int YAPF_ROADVEH_PATH_CACHE_SEGMENTS
= 8;
47 /** Distance from destination road stops to not cache any further */
48 static const int YAPF_ROADVEH_PATH_CACHE_DESTINATION_LIMIT
= 8;
51 * Helper container to find a depot
53 struct FindDepotData
{
54 TileIndex tile
; ///< The tile of the depot
55 uint best_length
; ///< The distance towards the depot in penalty, or UINT_MAX if not found
56 bool reverse
; ///< True if reversing is necessary for the train to get to this depot
59 * Create an instance of this structure.
60 * @param tile the tile of the depot
61 * @param best_length the distance towards the depot, or UINT_MAX if not found
62 * @param reverse whether we need to reverse first.
64 FindDepotData(TileIndex tile
= INVALID_TILE
, uint best_length
= UINT_MAX
, bool reverse
= false) :
65 tile(tile
), best_length(best_length
), reverse(reverse
)
70 #endif /* PATHFINDER_TYPE_H */