summaryrefslogtreecommitdiff
path: root/npf.h
diff options
context:
space:
mode:
authormatthijs <matthijs@openttd.org>2005-05-07 22:00:36 +0000
committermatthijs <matthijs@openttd.org>2005-05-07 22:00:36 +0000
commit0e08878a68c51db31ee39852d40c0d1d1ff4fb77 (patch)
treeea2c82a9f54adb580c94594906be4727b4d72723 /npf.h
parentf2bc27718a6c89f4395b7f3b27bab5bd70fa2704 (diff)
downloadopenttd-0e08878a68c51db31ee39852d40c0d1d1ff4fb77.tar.xz
(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.
- Add: [NPF] Reversing inside of depots now has a penalty. It also applies to trains only, other vehicles shouldn't bother reversing. - Fix: [NPF] When checking whether to reverse a train, the trackdir of the first loc was used instead of the last vehicle as a starting node for pathfindig. This might have caused some trains not reversing when they should have (or vice versa). Typo introduced when converting to GetVehicleTrackdir() in r2256. - CodeChange: [NPF] Removed duplicate code by letting NPFRouteTjoStationOrTile() call NPFRouteToStationOrTileTwoWay(). - Add: [NPF] NPFRouteToDepotBreadthFirstTwoWay() to find a depot while also looking backwards. - Add: It is now possibly to specify a path cost for aystar starting nodes.
Diffstat (limited to 'npf.h')
-rw-r--r--npf.h20
1 files changed, 19 insertions, 1 deletions
diff --git a/npf.h b/npf.h
index 1b6eabf45..9c290d360 100644
--- a/npf.h
+++ b/npf.h
@@ -14,6 +14,17 @@ enum {
NPF_HASH_HALFMASK = (1 << NPF_HASH_HALFBITS) - 1
};
+enum {
+ /** This penalty is the equivalent of "inifite", which means that paths that
+ * get this penalty will be chosen, but only if there is no other route
+ * without it. Be careful with not applying this penalty to often, or the
+ * total path cost might overflow..
+ * For now, this is just a Very Big Penalty, we might actually implement
+ * this in a nicer way :-)
+ */
+ NPF_INFINITE_PENALTY = 1000 * NPF_TILE_LENGTH
+};
+
typedef struct NPFFindStationOrTileData { /* Meant to be stored in AyStar.targetdata */
TileIndex dest_coords; /* An indication of where the station is, for heuristic purposes, or the target tile */
int station_index; /* station index we're heading for, or -1 when we're heading for a tile */
@@ -62,8 +73,15 @@ NPFFoundTargetData NPFRouteToStationOrTileTwoWay(TileIndex tile1, byte trackdir1
/* Will search a route to the closest depot. */
/* Search using breadth first. Good for little track choice and inaccurate
- * heuristic, such as railway/road */
+ * heuristic, such as railway/road.*/
NPFFoundTargetData NPFRouteToDepotBreadthFirst(TileIndex tile, byte trackdir, TransportType type, Owner owner);
+/* Same as above but with two start nodes, the second being the reverse. Call
+ * NPFGetBit(result.node, NPF_FLAG_REVERSE) to see from which node the path
+ * orginated. All pathfs from the second node will have the given
+ * reverse_penalty applied (NPF_TILE_LENGTH is the equivalent of one full
+ * tile).
+ */
+NPFFoundTargetData NPFRouteToDepotBreadthFirstTwoWay(TileIndex tile1, byte trackdir1, TileIndex tile2, byte trackdir2, TransportType type, Owner owner, uint reverse_penalty);
/* Search by trying each depot in order of Manhattan Distance. Good for lots
* of choices and accurate heuristics, such as water. */
NPFFoundTargetData NPFRouteToDepotTrialError(TileIndex tile, byte trackdir, TransportType type, Owner owner);