author | peter1138 |
Sun, 03 Aug 2008 17:35:08 +0000 | |
changeset 9834 | 7474149531c1 |
parent 9806 | 5d8e73afcf1f |
child 10208 | 72c00af5c95d |
permissions | -rw-r--r-- |
2186 | 1 |
/* $Id$ */ |
2 |
||
9111
48ce04029fe4
(svn r12971) -Documentation: add @file in files that missed them and add something more than whitespace as description of files that don't have a description.
rubidium
parents:
8785
diff
changeset
|
3 |
/** @file npf.h New A* pathfinder. */ |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
4 |
|
1247 | 5 |
#ifndef NPF_H |
6 |
#define NPF_H |
|
7 |
||
8 |
#include "aystar.h" |
|
8785
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8510
diff
changeset
|
9 |
#include "station_type.h" |
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8510
diff
changeset
|
10 |
#include "rail_type.h" |
871586967963
(svn r12489) -Codechange: split station.h into station_base.h and station_func.h.
rubidium
parents:
8510
diff
changeset
|
11 |
#include "player_type.h" |
8139
4e91c448c409
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8108
diff
changeset
|
12 |
#include "vehicle_type.h" |
8108
b42a0e5c67ef
(svn r11669) -Codechange: refactor tile.h -> tile_type.h and tile_map.h
rubidium
parents:
7931
diff
changeset
|
13 |
#include "tile_type.h" |
8139
4e91c448c409
(svn r11701) -Codechange: removal unnecessary inclusions of map.h (and split map.h).
rubidium
parents:
8108
diff
changeset
|
14 |
#include "track_type.h" |
8236
8a5dd0b42e47
(svn r11800) -Codechange: move some functions to a more logical location + some type safety.
rubidium
parents:
8142
diff
changeset
|
15 |
#include "core/bitmath_func.hpp" |
9126
5648d696456b
(svn r12986) -Codechange: move the landscape and transport related types from openttd.h to their own headers.
rubidium
parents:
9111
diff
changeset
|
16 |
#include "transport_type.h" |
1247 | 17 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
18 |
/* mowing grass */ |
1661
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
19 |
enum { |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
20 |
NPF_HASH_BITS = 12, ///< The size of the hash used in pathfinding. Just changing this value should be sufficient to change the hash size. Should be an even value. |
1661
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
21 |
/* Do no change below values */ |
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
22 |
NPF_HASH_SIZE = 1 << NPF_HASH_BITS, |
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
23 |
NPF_HASH_HALFBITS = NPF_HASH_BITS / 2, |
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
24 |
NPF_HASH_HALFMASK = (1 << NPF_HASH_HALFBITS) - 1 |
f3799f2c84fa
(svn r2165) - Codechange: [NPF] Properly enummed NPF hash size, it is easily changable now.
matthijs
parents:
1459
diff
changeset
|
25 |
}; |
1247 | 26 |
|
3358
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
27 |
/* For new pathfinding. Define here so it is globally available without having |
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
28 |
* to include npf.h */ |
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
29 |
enum { |
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
30 |
NPF_TILE_LENGTH = 100 |
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
31 |
}; |
c69b64a580b2
(svn r4153) -Codechange. Changed NPF_TILE_LENGTH into an enum and moved it out of variables.h. Just a drop in the bucket, but it is a start
celestar
parents:
3355
diff
changeset
|
32 |
|
1777
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
33 |
enum { |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
34 |
/** This penalty is the equivalent of "inifite", which means that paths that |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
35 |
* get this penalty will be chosen, but only if there is no other route |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
36 |
* without it. Be careful with not applying this penalty to often, or the |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
37 |
* total path cost might overflow.. |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
38 |
* For now, this is just a Very Big Penalty, we might actually implement |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
39 |
* this in a nicer way :-) |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
40 |
*/ |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
41 |
NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
42 |
}; |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
43 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
44 |
/* Meant to be stored in AyStar.targetdata */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
45 |
struct NPFFindStationOrTileData { |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
46 |
TileIndex dest_coords; ///< An indication of where the station is, for heuristic purposes, or the target tile |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
47 |
StationID station_index; ///< station index we're heading for, or INVALID_STATION when we're heading for a tile |
9804
fbe3e33a2c96
(svn r13946) -Add [YAPP]: Implement track reserving for NPF as well. (michi_cc)
rubidium
parents:
9126
diff
changeset
|
48 |
bool reserve_path; ///< Indicates whether the found path should be reserved |
fbe3e33a2c96
(svn r13946) -Add [YAPP]: Implement track reserving for NPF as well. (michi_cc)
rubidium
parents:
9126
diff
changeset
|
49 |
const Vehicle* v; ///< The vehicle we are pathfinding for |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5475
diff
changeset
|
50 |
}; |
1247 | 51 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
52 |
/* Indices into AyStar.userdata[] */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
53 |
enum { |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
54 |
NPF_TYPE = 0, ///< Contains a TransportTypes value |
6683
b88ae30866ce
(svn r9914) -Codechange: prepare GTTS and the pathfinders to handle multiple road types on a single tile.
rubidium
parents:
6348
diff
changeset
|
55 |
NPF_SUB_TYPE, ///< Contains the sub transport type |
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
56 |
NPF_OWNER, ///< Contains an Owner value |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
57 |
NPF_RAILTYPES, ///< Contains a bitmask the compatible RailTypes of the engine when NPF_TYPE == TRANSPORT_RAIL. Unused otherwise. |
1247 | 58 |
}; |
59 |
||
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
60 |
/* Indices into AyStarNode.userdata[] */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
61 |
enum { |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
62 |
NPF_TRACKDIR_CHOICE = 0, ///< The trackdir chosen to get here |
1247 | 63 |
NPF_NODE_FLAGS, |
64 |
}; |
|
2008
cdb444f6d43c
(svn r2516) - Feature: [pbs] Implement path-based-signalling. This allows multiple trains within the same signal block, provided their paths dont intersect. For this the block must have all exit and entry signals be pbs signals. Place these by ctrl-clicking 4 times on a normal signal.
hackykid
parents:
2006
diff
changeset
|
65 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
66 |
/* Flags for AyStarNode.userdata[NPF_NODE_FLAGS]. Use NPFGetBit() and NPFGetBit() to use them. */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
67 |
enum NPFNodeFlag { |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
68 |
NPF_FLAG_SEEN_SIGNAL, ///< Used to mark that a signal was seen on the way, for rail only |
9805
c6e69a451215
(svn r13947) -Codechange [YAPP]: Added YAPP-related penalties to NPF. (michi_cc)
rubidium
parents:
9804
diff
changeset
|
69 |
NPF_FLAG_2ND_SIGNAL, ///< Used to mark that two signals were seen, rail only |
c6e69a451215
(svn r13947) -Codechange [YAPP]: Added YAPP-related penalties to NPF. (michi_cc)
rubidium
parents:
9804
diff
changeset
|
70 |
NPF_FLAG_3RD_SIGNAL, ///< Used to mark that three signals were seen, rail only |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
71 |
NPF_FLAG_REVERSE, ///< Used to mark that this node was reached from the second start node, if applicable |
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
72 |
NPF_FLAG_LAST_SIGNAL_RED, ///< Used to mark that the last signal on this path was red |
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
73 |
NPF_FLAG_IGNORE_START_TILE, ///< Used to mark that the start tile is invalid, and searching should start from the second tile on |
9804
fbe3e33a2c96
(svn r13946) -Add [YAPP]: Implement track reserving for NPF as well. (michi_cc)
rubidium
parents:
9126
diff
changeset
|
74 |
NPF_FLAG_TARGET_RESERVED, ///< Used to mark that the possible reservation target is already reserved |
9806
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
75 |
NPF_FLAG_IGNORE_RESERVED, ///< Used to mark that reserved tiles should be considered impassable |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5475
diff
changeset
|
76 |
}; |
1247 | 77 |
|
6348
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
78 |
/* Meant to be stored in AyStar.userpath */ |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
79 |
struct NPFFoundTargetData { |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
80 |
uint best_bird_dist; ///< The best heuristic found. Is 0 if the target was found |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
81 |
uint best_path_dist; ///< The shortest path. Is (uint)-1 if no path is found |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
82 |
Trackdir best_trackdir; ///< The trackdir that leads to the shortest path/closest birds dist |
6dd01da7a02b
(svn r9385) -Cleanup: doxygen changes. Today, we are exploring the letter N.
belugas
parents:
6248
diff
changeset
|
83 |
AyStarNode node; ///< The node within the target the search led us to |
9804
fbe3e33a2c96
(svn r13946) -Add [YAPP]: Implement track reserving for NPF as well. (michi_cc)
rubidium
parents:
9126
diff
changeset
|
84 |
bool res_okay; ///< True if a path reservation could be made |
6248
e4a2ed7e5613
(svn r9051) -Codechange: typedef [enum|struct] Y {} X; -> [enum|struct] X {};
rubidium
parents:
5475
diff
changeset
|
85 |
}; |
1247 | 86 |
|
87 |
/* These functions below are _not_ re-entrant, in favor of speed! */ |
|
88 |
||
89 |
/* Will search from the given tile and direction, for a route to the given |
|
90 |
* station for the given transport type. See the declaration of |
|
91 |
* NPFFoundTargetData above for the meaning of the result. */ |
|
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
92 |
NPFFoundTargetData NPFRouteToStationOrTile(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes); |
2951 | 93 |
|
1247 | 94 |
/* Will search as above, but with two start nodes, the second being the |
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
95 |
* reverse. Look at the NPF_FLAG_REVERSE flag in the result node to see which |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
96 |
* direction was taken (NPFGetBit(result.node, NPF_FLAG_REVERSE)) */ |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
97 |
NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, Trackdir trackdir1, bool ignore_start_tile1, TileIndex tile2, Trackdir trackdir2, bool ignore_start_tile2, NPFFindStationOrTileData* target, TransportType type, uint sub_type, Owner owner, RailTypes railtypes); |
1247 | 98 |
|
99 |
/* Will search a route to the closest depot. */ |
|
100 |
||
101 |
/* Search using breadth first. Good for little track choice and inaccurate |
|
1777
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
102 |
* heuristic, such as railway/road.*/ |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
103 |
NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes); |
1777
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
104 |
/* Same as above but with two start nodes, the second being the reverse. Call |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
105 |
* NPFGetBit(result.node, NPF_FLAG_REVERSE) to see from which node the path |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
106 |
* orginated. All pathfs from the second node will have the given |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
107 |
* reverse_penalty applied (NPF_TILE_LENGTH is the equivalent of one full |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
108 |
* tile). |
f703cf05b5b9
(svn r2281) - Fix: [ 1115204 ] [NPF] When pressing the goto depot button, trains will now also look behind it if there is no depot in front. If so, the train reverses immediately. This also work anywhere, not just at stations.
matthijs
parents:
1751
diff
changeset
|
109 |
*/ |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
110 |
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); |
1247 | 111 |
/* Search by trying each depot in order of Manhattan Distance. Good for lots |
1330
5d76a0522a11
(svn r1834) - Fix: NPF does not check the owner of its target, busses try to enter other players' depots. TODO
matthijs
parents:
1247
diff
changeset
|
112 |
* of choices and accurate heuristics, such as water. */ |
8510
1c0456a2feaf
(svn r12085) -Fix(r12058): Road vehicles could get stuck, when NPF told them to reverse on junction tiles. (spotted by SmatZ)
frosch
parents:
8236
diff
changeset
|
113 |
NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, Trackdir trackdir, bool ignore_start_tile, TransportType type, uint sub_type, Owner owner, RailTypes railtypes); |
1247 | 114 |
|
9806
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
115 |
/** |
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
116 |
* Search for any safe tile using a breadth first search and try to reserve a path. |
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
117 |
*/ |
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
118 |
NPFFoundTargetData NPFRouteToSafeTile(const Vehicle *v, TileIndex tile, Trackdir trackdir,bool override_railtype); |
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
119 |
|
5d8e73afcf1f
(svn r13948) -Add [YAPP]: Extend NPF with a function to find a safe tile and reserve a path. (michi_cc)
rubidium
parents:
9805
diff
changeset
|
120 |
|
9804
fbe3e33a2c96
(svn r13946) -Add [YAPP]: Implement track reserving for NPF as well. (michi_cc)
rubidium
parents:
9126
diff
changeset
|
121 |
void NPFFillWithOrderData(NPFFindStationOrTileData *fstd, Vehicle *v, bool reserve_path = false); |
1247 | 122 |
|
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
123 |
|
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
124 |
/* |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
125 |
* Functions to manipulate the various NPF related flags on an AyStarNode. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
126 |
*/ |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
127 |
|
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
128 |
/** |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
129 |
* Returns the current value of the given flag on the given AyStarNode. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
130 |
*/ |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
131 |
static inline bool NPFGetFlag(const AyStarNode* node, NPFNodeFlag flag) |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
132 |
{ |
7928
63e18de69e50
(svn r11481) -Codechange: Rename the HASBIT function to fit with the naming style
skidd13
parents:
6683
diff
changeset
|
133 |
return HasBit(node->user_data[NPF_NODE_FLAGS], flag); |
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
134 |
} |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
135 |
|
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
136 |
/** |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
137 |
* Sets the given flag on the given AyStarNode to the given value. |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
138 |
*/ |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
139 |
static inline void NPFSetFlag(AyStarNode* node, NPFNodeFlag flag, bool value) |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
140 |
{ |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
141 |
if (value) |
7931
b0a46cd92225
(svn r11484) -Codechange: Remove the doubled function SetBitT and rename the remaining to fit with the naming style
skidd13
parents:
7929
diff
changeset
|
142 |
SetBit(node->user_data[NPF_NODE_FLAGS], flag); |
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
143 |
else |
7929
6c9b25842b0f
(svn r11482) -Codechange: Remove the doubled function ClrBitT and rename the remaining to fit with the naming style
skidd13
parents:
7928
diff
changeset
|
144 |
ClrBit(node->user_data[NPF_NODE_FLAGS], flag); |
1459
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
145 |
} |
19333d7f99b3
(svn r1963) - Add: [NPF] Penalty for a red signal that is the last signal on the path.
matthijs
parents:
1330
diff
changeset
|
146 |
|
2436
7d5df545bd5d
(svn r2962) - const correctness for all Get* functions and most Draw* functions that don't change their pointer parameters
Darkvater
parents:
2186
diff
changeset
|
147 |
#endif /* NPF_H */ |