src/yapf/yapf_rail.cpp
author KUDr
Fri, 29 Jun 2007 23:45:13 +0000
changeset 7119 afb9000a598e
parent 7099 a1d7e197cb64
child 8144 65cec0877b78
permissions -rw-r--r--
(svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     1
/* $Id$ */
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     2
6121
2aae24b0881f (svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents: 5587
diff changeset
     3
/** @file yapf_rail.cpp */
2aae24b0881f (svn r8857) -Documentation: Added some doxygen @file tags, repaired others (the @file tag MUST be found before any line of code, that includes preprocessor directives).
celestar
parents: 5587
diff changeset
     4
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     5
#include "../stdafx.h"
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     6
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     7
#include "yapf.hpp"
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     8
#include "yapf_node_rail.hpp"
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
     9
#include "yapf_costrail.hpp"
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    10
#include "yapf_destrail.hpp"
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    11
7099
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    12
#define DEBUG_YAPF_CACHE 0
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    13
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    14
int _total_pf_time_us = 0;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    15
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    16
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    17
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    18
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    19
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    20
template <class Types>
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    21
class CYapfFollowAnyDepotRailT
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    22
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    23
public:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    24
	typedef typename Types::Tpf Tpf;                     ///< the pathfinder class (derived from THIS class)
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    25
	typedef typename Types::TrackFollower TrackFollower;
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    26
	typedef typename Types::NodeList::Titem Node;        ///< this will be our node type
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    27
	typedef typename Node::Key Key;                      ///< key to hash tables
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    28
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    29
protected:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    30
	/// to access inherited path finder
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    31
	FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    32
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    33
public:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    34
	/** Called by YAPF to move from the given node to the next tile. For each
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 3923
diff changeset
    35
	 *  reachable trackdir on the new tile creates new node, initializes it
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 3923
diff changeset
    36
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    37
	inline void PfFollowNode(Node& old_node)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    38
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    39
		TrackFollower F(Yapf().GetVehicle());
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    40
		if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()))
6132
8b4edf37c5ff (svn r8869) [YAPF] -Fix: Large Train Stations/Trains makes OpenTTD crash (Jigsaw_Psyche)
KUDr
parents: 6121
diff changeset
    41
			Yapf().AddMultipleNodes(&old_node, F);
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    42
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    43
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
    44
	/// return debug report character to identify the transportation type
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    45
	FORCEINLINE char TransportTypeChar() const {return 't';}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    46
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    47
	static bool stFindNearestDepotTwoWay(Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    48
	{
7099
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    49
		Tpf pf1;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    50
		bool result1 = pf1.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, depot_tile, reversed);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    51
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    52
#if DEBUG_YAPF_CACHE
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    53
		Tpf pf2;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    54
		TileIndex depot_tile2 = INVALID_TILE;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    55
		bool reversed2 = false;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    56
		pf2.DisableCache(true);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    57
		bool result2 = pf2.FindNearestDepotTwoWay(v, t1, td1, t2, td2, max_distance, reverse_penalty, &depot_tile2, &reversed2);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    58
		if (result1 != result2 || (result1 && (*depot_tile != depot_tile2 || *reversed != reversed2))) {
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    59
			DEBUG(yapf, 0, "CACHE ERROR: FindNearestDepotTwoWay() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    60
		}
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    61
#endif
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    62
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
    63
		return result1;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    64
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    65
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    66
	FORCEINLINE bool FindNearestDepotTwoWay(Vehicle *v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    67
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    68
		// set origin and destination nodes
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    69
		Yapf().SetOrigin(t1, td1, t2, td2, reverse_penalty, true);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    70
		Yapf().SetDestination(v);
3923
d5c7744483fc (svn r5057) -Fix: [YAPF] trains can't find depot for servicing (thanks Smoky555)
KUDr
parents: 3914
diff changeset
    71
		Yapf().SetMaxCost(YAPF_TILE_LENGTH * max_distance);
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    72
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    73
		// find the best path
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    74
		bool bFound = Yapf().FindPath(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    75
		if (!bFound) return false;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    76
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    77
		// some path found
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    78
		// get found depot tile
6510
c50a538f16a7 (svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
KUDr
parents: 6132
diff changeset
    79
		Node *n = Yapf().GetBestNode();
c50a538f16a7 (svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
KUDr
parents: 6132
diff changeset
    80
		*depot_tile = n->GetLastTile();
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    81
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    82
		// walk through the path back to the origin
6510
c50a538f16a7 (svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
KUDr
parents: 6132
diff changeset
    83
		Node *pNode = n;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    84
		while (pNode->m_parent != NULL) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    85
			pNode = pNode->m_parent;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    86
		}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    87
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    88
		// if the origin node is our front vehicle tile/Trackdir then we didn't reverse
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    89
		// but we can also look at the cost (== 0 -> not reversed, == reverse_penalty -> reversed)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    90
		*reversed = (pNode->m_cost != 0);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    91
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    92
		return true;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    93
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    94
};
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    95
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    96
template <class Types>
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    97
class CYapfFollowRailT
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    98
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
    99
public:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   100
	typedef typename Types::Tpf Tpf;                     ///< the pathfinder class (derived from THIS class)
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   101
	typedef typename Types::TrackFollower TrackFollower;
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   102
	typedef typename Types::NodeList::Titem Node;        ///< this will be our node type
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   103
	typedef typename Node::Key Key;                      ///< key to hash tables
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   104
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   105
protected:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   106
	/// to access inherited path finder
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   107
	FORCEINLINE Tpf& Yapf() {return *static_cast<Tpf*>(this);}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   108
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   109
public:
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   110
	/** Called by YAPF to move from the given node to the next tile. For each
4549
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 3923
diff changeset
   111
	 *  reachable trackdir on the new tile creates new node, initializes it
106ed18a7675 (svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents: 3923
diff changeset
   112
	 *  and adds it to the open list by calling Yapf().AddNewNode(n) */
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   113
	inline void PfFollowNode(Node& old_node)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   114
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   115
		TrackFollower F(Yapf().GetVehicle());
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   116
		if (F.Follow(old_node.GetLastTile(), old_node.GetLastTrackdir()))
6132
8b4edf37c5ff (svn r8869) [YAPF] -Fix: Large Train Stations/Trains makes OpenTTD crash (Jigsaw_Psyche)
KUDr
parents: 6121
diff changeset
   117
			Yapf().AddMultipleNodes(&old_node, F);
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   118
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   119
3914
6bdd22b93698 (svn r5018) [YAPF] Added some comments to YAPF implementation.
KUDr
parents: 3910
diff changeset
   120
	/// return debug report character to identify the transportation type
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   121
	FORCEINLINE char TransportTypeChar() const {return 't';}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   122
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   123
	static Trackdir stChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   124
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   125
		// create pathfinder instance
7099
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   126
		Tpf pf1;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   127
		Trackdir result1 = pf1.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   128
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   129
#if DEBUG_YAPF_CACHE
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   130
		Tpf pf2;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   131
		pf2.DisableCache(true);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   132
		Trackdir result2 = pf2.ChooseRailTrack(v, tile, enterdir, tracks, path_not_found);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   133
		if (result1 != result2) {
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   134
			DEBUG(yapf, 0, "CACHE ERROR: ChooseRailTrack() = [%d, %d]", result1, result2);
7119
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   135
			DumpTarget dmp1, dmp2;
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   136
			pf1.DumpBase(dmp1);
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   137
			pf2.DumpBase(dmp2);
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   138
			FILE *f1 = fopen("C:\\yapf1.txt", "wt");
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   139
			FILE *f2 = fopen("C:\\yapf2.txt", "wt");
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   140
			fwrite(dmp1.m_out.Data(), 1, dmp1.m_out.Size(), f1);
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   141
			fwrite(dmp2.m_out.Data(), 1, dmp2.m_out.Size(), f2);
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   142
			fclose(f1);
afb9000a598e (svn r10392) -Add [YAPF]: added structured dump support into some essential YAPF classes (node-list, nodes, keys, etc.) and CArrayT
KUDr
parents: 7099
diff changeset
   143
			fclose(f2);
7099
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   144
		}
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   145
#endif
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   146
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   147
		return result1;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   148
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   149
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   150
	FORCEINLINE Trackdir ChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   151
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   152
		// set origin and destination nodes
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   153
		Yapf().SetOrigin(v->tile, GetVehicleTrackdir(v), INVALID_TILE, INVALID_TRACKDIR, 1, true);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   154
		Yapf().SetDestination(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   155
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   156
		// find the best path
4870
2d8c7ffbbac9 (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4865
diff changeset
   157
		bool path_found = Yapf().FindPath(v);
5424
34b624b01ae1 (svn r7628) -Fix: [YAPF] suppress 'Train is lost' message if pathfinding ended on the first two-way red signal due to yapf.rail_firstred_twoway_eol option.
KUDr
parents: 5385
diff changeset
   158
		if (path_not_found != NULL) {
4870
2d8c7ffbbac9 (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4865
diff changeset
   159
			// tell controller that the path was only 'guessed'
5424
34b624b01ae1 (svn r7628) -Fix: [YAPF] suppress 'Train is lost' message if pathfinding ended on the first two-way red signal due to yapf.rail_firstred_twoway_eol option.
KUDr
parents: 5385
diff changeset
   160
			// treat the path as found if stopped on the first two way signal(s)
34b624b01ae1 (svn r7628) -Fix: [YAPF] suppress 'Train is lost' message if pathfinding ended on the first two-way red signal due to yapf.rail_firstred_twoway_eol option.
KUDr
parents: 5385
diff changeset
   161
			*path_not_found = !(path_found || Yapf().m_stopped_on_first_two_way_signal);
4870
2d8c7ffbbac9 (svn r6800) -Feature change: [train is lost] message is now generated immediately when pathfinder can't find the path. (thanks MeusH, peter1138 and Brianetta for ideas and help).
KUDr
parents: 4865
diff changeset
   162
		}
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   163
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   164
		// if path not found - return INVALID_TRACKDIR
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   165
		Trackdir next_trackdir = INVALID_TRACKDIR;
6510
c50a538f16a7 (svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
KUDr
parents: 6132
diff changeset
   166
		Node *pNode = Yapf().GetBestNode();
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   167
		if (pNode != NULL) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   168
			// path was found or at least suggested
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   169
			// walk through the path back to the origin
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   170
			Node* pPrev = NULL;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   171
			while (pNode->m_parent != NULL) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   172
				pPrev = pNode;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   173
				pNode = pNode->m_parent;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   174
			}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   175
			// return trackdir from the best origin node (one of start nodes)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   176
			Node& best_next_node = *pPrev;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   177
			assert(best_next_node.GetTile() == tile);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   178
			next_trackdir = best_next_node.GetTrackdir();
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   179
		}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   180
		return next_trackdir;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   181
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   182
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   183
	static bool stCheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   184
	{
7099
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   185
		Tpf pf1;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   186
		bool result1 = pf1.CheckReverseTrain(v, t1, td1, t2, td2);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   187
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   188
#if DEBUG_YAPF_CACHE
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   189
		Tpf pf2;
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   190
		pf2.DisableCache(true);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   191
		bool result2 = pf2.CheckReverseTrain(v, t1, td1, t2, td2);
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   192
		if (result1 != result2) {
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   193
			DEBUG(yapf, 0, "CACHE ERROR: CheckReverseTrain() = [%s, %s]", result1 ? "T" : "F", result2 ? "T" : "F");
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   194
		}
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   195
#endif
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   196
a1d7e197cb64 (svn r10366) -Codechange [YAPF]: added DEBUG_YAPF_CACHE macro that (when set to 1) allows to track YAPF "cache errors". They are probably responsible for current MP desyncs. (thanks Rubidium for this great idea!).
KUDr
parents: 7084
diff changeset
   197
		return result1;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   198
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   199
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   200
	FORCEINLINE bool CheckReverseTrain(Vehicle* v, TileIndex t1, Trackdir td1, TileIndex t2, Trackdir td2)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   201
	{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   202
		// create pathfinder instance
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   203
		// set origin and destination nodes
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   204
		Yapf().SetOrigin(t1, td1, t2, td2, 1, false);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   205
		Yapf().SetDestination(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   206
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   207
		// find the best path
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   208
		bool bFound = Yapf().FindPath(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   209
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   210
		if (!bFound) return false;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   211
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   212
		// path was found
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   213
		// walk through the path back to the origin
6510
c50a538f16a7 (svn r9693) -Codechange [YAPF]: GetBestNode() now returns pointer to node instead of reference
KUDr
parents: 6132
diff changeset
   214
		Node *pNode = Yapf().GetBestNode();
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   215
		while (pNode->m_parent != NULL) {
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   216
			pNode = pNode->m_parent;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   217
		}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   218
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   219
		// check if it was reversed origin
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   220
		Node& best_org_node = *pNode;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   221
		bool reversed = (best_org_node.m_cost != 0);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   222
		return reversed;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   223
	}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   224
};
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   225
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   226
template <class Tpf_, class Ttrack_follower, class Tnode_list, template <class Types> class TdestinationT, template <class Types> class TfollowT>
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   227
struct CYapfRail_TypesT
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   228
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   229
	typedef CYapfRail_TypesT<Tpf_, Ttrack_follower, Tnode_list, TdestinationT, TfollowT>  Types;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   230
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   231
	typedef Tpf_                                Tpf;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   232
	typedef Ttrack_follower                     TrackFollower;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   233
	typedef Tnode_list                          NodeList;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   234
	typedef CYapfBaseT<Types>                   PfBase;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   235
	typedef TfollowT<Types>                     PfFollow;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   236
	typedef CYapfOriginTileTwoWayT<Types>       PfOrigin;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   237
	typedef TdestinationT<Types>                PfDestination;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   238
	typedef CYapfSegmentCostCacheGlobalT<Types> PfCache;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   239
	typedef CYapfCostRailT<Types>               PfCost;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   240
};
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   241
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   242
struct CYapfRail1         : CYapfT<CYapfRail_TypesT<CYapfRail1        , CFollowTrackRail    , CRailNodeListTrackDir, CYapfDestinationTileOrStationRailT, CYapfFollowRailT> > {};
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   243
struct CYapfRail2         : CYapfT<CYapfRail_TypesT<CYapfRail2        , CFollowTrackRailNo90, CRailNodeListTrackDir, CYapfDestinationTileOrStationRailT, CYapfFollowRailT> > {};
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   244
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   245
struct CYapfAnyDepotRail1 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail1, CFollowTrackRail    , CRailNodeListTrackDir, CYapfDestinationAnyDepotRailT     , CYapfFollowAnyDepotRailT> > {};
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   246
struct CYapfAnyDepotRail2 : CYapfT<CYapfRail_TypesT<CYapfAnyDepotRail2, CFollowTrackRailNo90, CRailNodeListTrackDir, CYapfDestinationAnyDepotRailT     , CYapfFollowAnyDepotRailT> > {};
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   247
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   248
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   249
Trackdir YapfChooseRailTrack(Vehicle *v, TileIndex tile, DiagDirection enterdir, TrackBits tracks, bool *path_not_found)
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   250
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   251
	// default is YAPF type 2
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   252
	typedef Trackdir (*PfnChooseRailTrack)(Vehicle*, TileIndex, DiagDirection, TrackBits, bool*);
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   253
	PfnChooseRailTrack pfnChooseRailTrack = &CYapfRail1::stChooseRailTrack;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   254
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   255
	// check if non-default YAPF type needed
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   256
	if (_patches.forbid_90_deg) {
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   257
		pfnChooseRailTrack = &CYapfRail2::stChooseRailTrack; // Trackdir, forbid 90-deg
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   258
	}
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   259
5587
167d9a91ef02 (svn r8038) -Merge: the cpp branch. Effort of KUDr, Celestar, glx, Smoovius, stillunknown and pv2b.
rubidium
parents: 5475
diff changeset
   260
	Trackdir td_ret = pfnChooseRailTrack(v, tile, enterdir, tracks, path_not_found);
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   261
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   262
	return td_ret;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   263
}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   264
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   265
bool YapfCheckReverseTrain(Vehicle* v)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   266
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   267
	// tile where the engine is
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   268
	TileIndex tile = v->tile;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   269
	// tile where we have last wagon
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   270
	Vehicle* last_veh = GetLastVehicleInChain(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   271
	// if we are in tunnel then give up
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   272
	if (v->u.rail.track == 0x40 || last_veh->u.rail.track == 0x40) return false;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   273
	// get trackdirs of both ends
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   274
	Trackdir td = GetVehicleTrackdir(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   275
	Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh));
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   276
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   277
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   278
	typedef bool (*PfnCheckReverseTrain)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir);
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   279
	PfnCheckReverseTrain pfnCheckReverseTrain = CYapfRail1::stCheckReverseTrain;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   280
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   281
	// check if non-default YAPF type needed
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   282
	if (_patches.forbid_90_deg) {
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   283
		pfnCheckReverseTrain = &CYapfRail2::stCheckReverseTrain; // Trackdir, forbid 90-deg
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   284
	}
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   285
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   286
	bool reverse = pfnCheckReverseTrain(v, tile, td, last_veh->tile, td_rev);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   287
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   288
	return reverse;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   289
}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   290
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   291
bool YapfFindNearestRailDepotTwoWay(Vehicle *v, int max_distance, int reverse_penalty, TileIndex* depot_tile, bool* reversed)
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   292
{
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   293
	*depot_tile = INVALID_TILE;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   294
	*reversed = false;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   295
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   296
	Vehicle* last_veh = GetLastVehicleInChain(v);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   297
5385
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4870
diff changeset
   298
	TileIndex tile = v->tile;
3868f2e6db9b (svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents: 4870
diff changeset
   299
	TileIndex last_tile = last_veh->tile;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   300
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   301
	// their trackdirs
4865
8c4fb07e56f6 (svn r6791) -Fix: [YAPF] YapfFindNearestRailDepotTwoWay() did not work for train inside tunnel.
KUDr
parents: 4549
diff changeset
   302
	Trackdir td = GetVehicleTrackdir(v);
8c4fb07e56f6 (svn r6791) -Fix: [YAPF] YapfFindNearestRailDepotTwoWay() did not work for train inside tunnel.
KUDr
parents: 4549
diff changeset
   303
	Trackdir td_rev = ReverseTrackdir(GetVehicleTrackdir(last_veh));
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   304
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   305
	typedef bool (*PfnFindNearestDepotTwoWay)(Vehicle*, TileIndex, Trackdir, TileIndex, Trackdir, int, int, TileIndex*, bool*);
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   306
	PfnFindNearestDepotTwoWay pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail1::stFindNearestDepotTwoWay;
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   307
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   308
	// check if non-default YAPF type needed
7084
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   309
	if (_patches.forbid_90_deg) {
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   310
		pfnFindNearestDepotTwoWay = &CYapfAnyDepotRail2::stFindNearestDepotTwoWay; // Trackdir, forbid 90-deg
3a9673715c50 (svn r10349) -Fix [FS#941, YAPF, r10301]: tile/trackdir must be used as node key and also as segment key in the cache (SmatZ).
KUDr
parents: 6510
diff changeset
   311
	}
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   312
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   313
	bool ret = pfnFindNearestDepotTwoWay(v, tile, td, last_tile, td_rev, max_distance, reverse_penalty, depot_tile, reversed);
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   314
	return ret;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   315
}
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   316
3910
7cb4295b8f61 (svn r5006) Added comments where doxygen generated warnings to test if it can help.
KUDr
parents: 3900
diff changeset
   317
/** if any track changes, this counter is incremented - that will invalidate segment cost cache */
3900
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   318
int CSegmentCostCacheBase::s_rail_change_counter = 0;
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   319
2c84ed52709d (svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff changeset
   320
void YapfNotifyTrackLayoutChange(TileIndex tile, Track track) {CSegmentCostCacheBase::NotifyTrackLayoutChange(tile, track);}