author | rubidium |
Sat, 02 Aug 2008 22:50:38 +0000 | |
changeset 9797 | 3b2e6f55e7d0 |
parent 9490 | 01c07bde5e84 |
child 9802 | 6589c004f0d9 |
permissions | -rw-r--r-- |
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:
6012
diff
changeset
|
3 |
/** @file follow_track.hpp Template function for track followers */ |
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:
6012
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 |
#ifndef FOLLOW_TRACK_HPP |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
6 |
#define FOLLOW_TRACK_HPP |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
7 |
|
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.hpp" |
8962
1b263c69799d
(svn r12754) -Codechange: split depot.h into depot_map.h, depot_func.h and depot_base.h and remove quite a lot of unneeded (before this) includes of depot.h.
rubidium
parents:
8954
diff
changeset
|
9 |
#include "../depot_map.h" |
8636
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
10 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
11 |
/** Track follower helper template class (can serve pathfinders and vehicle |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4407
diff
changeset
|
12 |
* controllers). See 6 different typedefs below for 3 different transport |
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4407
diff
changeset
|
13 |
* types w/ of w/o 90-deg turns allowed */ |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
14 |
template <TransportType Ttr_type_, bool T90deg_turns_allowed_ = true> |
8636
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
15 |
struct CFollowTrackT |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
16 |
{ |
8636
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
17 |
enum ErrorCode { |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
18 |
EC_NONE, |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
19 |
EC_OWNER, |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
20 |
EC_RAIL_TYPE, |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
21 |
EC_90DEG, |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
22 |
EC_NO_WAY, |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
23 |
}; |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
24 |
|
9439 | 25 |
const Vehicle *m_veh; ///< moving vehicle |
8636
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
26 |
TileIndex m_old_tile; ///< the origin (vehicle moved from) before move |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
27 |
Trackdir m_old_td; ///< the trackdir (the vehicle was on) before move |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
28 |
TileIndex m_new_tile; ///< the new tile (the vehicle has entered) |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
29 |
TrackdirBits m_new_td_bits; ///< the new set of available trackdirs |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
30 |
DiagDirection m_exitdir; ///< exit direction (leaving the old tile) |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
31 |
bool m_is_tunnel; ///< last turn passed tunnel |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
32 |
bool m_is_bridge; ///< last turn passed bridge ramp |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
33 |
bool m_is_station; ///< last turn passed station |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
34 |
int m_tiles_skipped; ///< number of skipped tunnel or station tiles |
9dc7e26247b7
(svn r12252) -Fix [FS#1801]: Broken FollowTrack_t related functions (thanks michi_cc).
KUDr
parents:
8616
diff
changeset
|
35 |
ErrorCode m_err; |
9439 | 36 |
CPerformanceTimer *m_pPerf; |
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
37 |
RailTypes m_railtypes; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
38 |
|
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
39 |
FORCEINLINE CFollowTrackT(const Vehicle *v = NULL, RailTypes railtype_override = INVALID_RAILTYPES, CPerformanceTimer *pPerf = NULL) |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
40 |
{ |
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
41 |
Init(v, railtype_override, pPerf); |
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 |
|
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
44 |
FORCEINLINE void Init(const Vehicle *v, RailTypes railtype_override, CPerformanceTimer *pPerf) |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
45 |
{ |
6259
471b91a4b1d8
(svn r9068) -Codechange: capitalize the VEH_Train etc. enums to match the coding style (and rest of the code).
rubidium
parents:
6154
diff
changeset
|
46 |
assert(!IsRailTT() || (v != NULL && v->type == VEH_TRAIN)); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
47 |
m_veh = v; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
48 |
m_pPerf = pPerf; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
49 |
// don't worry, all is inlined so compiler should remove unnecessary initializations |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
50 |
m_new_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
|
51 |
m_new_td_bits = TRACKDIR_BIT_NONE; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
52 |
m_exitdir = INVALID_DIAGDIR; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
53 |
m_is_station = m_is_bridge = m_is_tunnel = false; |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
54 |
m_tiles_skipped = 0; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
55 |
m_err = EC_NONE; |
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
56 |
if (IsRailTT()) m_railtypes = railtype_override == INVALID_RAILTYPES ? v->u.rail.compatible_railtypes : railtype_override; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
57 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
58 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
59 |
FORCEINLINE static TransportType TT() {return Ttr_type_;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
60 |
FORCEINLINE static bool IsWaterTT() {return TT() == TRANSPORT_WATER;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
61 |
FORCEINLINE static bool IsRailTT() {return TT() == TRANSPORT_RAIL;} |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
62 |
FORCEINLINE bool IsTram() {return IsRoadTT() && HasBit(m_veh->u.road.compatible_roadtypes, ROADTYPE_TRAM);} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
63 |
FORCEINLINE static bool IsRoadTT() {return TT() == TRANSPORT_ROAD;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
64 |
FORCEINLINE static bool Allow90degTurns() {return T90deg_turns_allowed_;} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
65 |
|
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
66 |
/** Tests if a tile is a road tile with a single tramtrack (tram can reverse) */ |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
67 |
FORCEINLINE DiagDirection GetSingleTramBit(TileIndex tile) |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
68 |
{ |
8563
13b1a41e46f1
(svn r12141) -Codechange: Introduce IsNormalRoad[Tile](), IsRoadDepot[Tile]() and HasTileRoadType(); and use them.
frosch
parents:
8491
diff
changeset
|
69 |
if (IsTram() && IsNormalRoadTile(tile)) { |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
70 |
RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM); |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
71 |
switch (rb) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
72 |
case ROAD_NW: return DIAGDIR_NW; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
73 |
case ROAD_SW: return DIAGDIR_SW; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
74 |
case ROAD_SE: return DIAGDIR_SE; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
75 |
case ROAD_NE: return DIAGDIR_NE; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
76 |
default: break; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
77 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
78 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
79 |
return INVALID_DIAGDIR; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
80 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
81 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
82 |
/** main follower routine. Fills all members and return true on success. |
4549
106ed18a7675
(svn r6381) -Cleanup: make the '/* */' comments that span multiple lines more uniform.
rubidium
parents:
4407
diff
changeset
|
83 |
* Otherwise returns false if track can't be followed. */ |
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
84 |
inline bool Follow(TileIndex old_tile, Trackdir old_td) |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
85 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
86 |
m_old_tile = old_tile; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
87 |
m_old_td = old_td; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
88 |
m_err = EC_NONE; |
8616
fd862a55c47f
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
8563
diff
changeset
|
89 |
assert(((TrackStatusToTrackdirBits(GetTileTrackStatus(m_old_tile, TT(), m_veh->u.road.compatible_roadtypes)) & TrackdirToTrackdirBits(m_old_td)) != 0) || |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
90 |
(GetSingleTramBit(m_old_tile) != INVALID_DIAGDIR)); // Disable the assertion for single tram bits |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
91 |
m_exitdir = TrackdirToExitdir(m_old_td); |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
92 |
if (ForcedReverse()) return true; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
93 |
if (!CanExitOldTile()) return false; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
94 |
FollowTileExit(); |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
95 |
if (!QueryNewTileTrackStatus()) return TryReverse(); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
96 |
if (!CanEnterNewTile()) return false; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
97 |
m_new_td_bits &= DiagdirReachesTrackdirs(m_exitdir); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
98 |
if (m_new_td_bits == TRACKDIR_BIT_NONE) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
99 |
m_err = EC_NO_WAY; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
100 |
return false; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
101 |
} |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
102 |
if (!Allow90degTurns()) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
103 |
m_new_td_bits &= (TrackdirBits)~(int)TrackdirCrossesTrackdirs(m_old_td); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
104 |
if (m_new_td_bits == TRACKDIR_BIT_NONE) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
105 |
m_err = EC_90DEG; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
106 |
return false; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
107 |
} |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
108 |
} |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
109 |
return true; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
110 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
111 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
112 |
protected: |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
113 |
/** Follow the m_exitdir from m_old_tile and fill m_new_tile and m_tiles_skipped */ |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
114 |
FORCEINLINE void FollowTileExit() |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
115 |
{ |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
116 |
m_is_station = m_is_bridge = m_is_tunnel = false; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
117 |
m_tiles_skipped = 0; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
118 |
|
8398
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
119 |
// extra handling for tunnels and bridges in our direction |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
120 |
if (IsTileType(m_old_tile, MP_TUNNELBRIDGE)) { |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
121 |
DiagDirection enterdir = GetTunnelBridgeDirection(m_old_tile); |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
122 |
if (enterdir == m_exitdir) { |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
123 |
// we are entering the tunnel / bridge |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
124 |
if (IsTunnel(m_old_tile)) { |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
125 |
m_is_tunnel = true; |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
126 |
m_new_tile = GetOtherTunnelEnd(m_old_tile); |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
127 |
} else { // IsBridge(m_old_tile) |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
128 |
m_is_bridge = true; |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
129 |
m_new_tile = GetOtherBridgeEnd(m_old_tile); |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
130 |
} |
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
131 |
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
132 |
return; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
133 |
} |
8398
1e181e2e4e15
(svn r11968) -Codechange: remove redundant FindLengthOfTunnel(), use GetTunnelBridgeLength() and/or GetOtherTunnelEnd() instead
smatz
parents:
8390
diff
changeset
|
134 |
assert(ReverseDiagDir(enterdir) == m_exitdir); |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
135 |
} |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
136 |
|
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
137 |
// normal or station tile, do one step |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
138 |
TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
139 |
m_new_tile = TILE_ADD(m_old_tile, diff); |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
140 |
|
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
141 |
// special handling for stations |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
142 |
if (IsRailTT() && IsRailwayStationTile(m_new_tile)) { |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
143 |
m_is_station = true; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
144 |
} else if (IsRoadTT() && IsRoadStopTile(m_new_tile)) { |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
145 |
m_is_station = true; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
146 |
} else { |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
147 |
m_is_station = false; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
148 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
149 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
150 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
151 |
/** stores track status (available trackdirs) for the new tile into m_new_td_bits */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
152 |
FORCEINLINE bool QueryNewTileTrackStatus() |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
153 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
154 |
CPerfStart perf(*m_pPerf); |
3912
08c70885ec45
(svn r5013) -Fix: [YAPF] RVs trying to plan route through railway.
KUDr
parents:
3900
diff
changeset
|
155 |
if (IsRailTT() && GetTileType(m_new_tile) == MP_RAILWAY && IsPlainRailTile(m_new_tile)) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
156 |
m_new_td_bits = (TrackdirBits)(GetTrackBits(m_new_tile) * 0x101); |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
157 |
} else { |
8616
fd862a55c47f
(svn r12199) -Codechange: Remove magic around the results of GetTileTrackStatus().
frosch
parents:
8563
diff
changeset
|
158 |
m_new_td_bits = TrackStatusToTrackdirBits(GetTileTrackStatus(m_new_tile, TT(), m_veh->u.road.compatible_roadtypes)); |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
159 |
|
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
160 |
if (m_new_td_bits == 0) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
161 |
/* GetTileTrackStatus() returns 0 for single tram bits. |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
162 |
* As we cannot change it there (easily) without breaking something, change it here */ |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
163 |
switch (GetSingleTramBit(m_new_tile)) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
164 |
case DIAGDIR_NE: |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
165 |
case DIAGDIR_SW: |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
166 |
m_new_td_bits = TRACKDIR_BIT_X_NE | TRACKDIR_BIT_X_SW; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
167 |
break; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
168 |
|
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
169 |
case DIAGDIR_NW: |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
170 |
case DIAGDIR_SE: |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
171 |
m_new_td_bits = TRACKDIR_BIT_Y_NW | TRACKDIR_BIT_Y_SE; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
172 |
break; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
173 |
|
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
174 |
default: break; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
175 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
176 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
177 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
178 |
return (m_new_td_bits != TRACKDIR_BIT_NONE); |
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 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
181 |
/** return true if we can leave m_old_tile in m_exitdir */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
182 |
FORCEINLINE bool CanExitOldTile() |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
183 |
{ |
6012
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5998
diff
changeset
|
184 |
// road stop can be left at one direction only unless it's a drive-through stop |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5998
diff
changeset
|
185 |
if (IsRoadTT() && IsStandardRoadStopTile(m_old_tile)) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
186 |
DiagDirection exitdir = GetRoadStopDir(m_old_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
187 |
if (exitdir != m_exitdir) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
188 |
m_err = EC_NO_WAY; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
189 |
return false; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
190 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
191 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
192 |
|
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
193 |
/* single tram bits can only be left in one direction */ |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
194 |
DiagDirection single_tram = GetSingleTramBit(m_old_tile); |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
195 |
if (single_tram != INVALID_DIAGDIR && single_tram != m_exitdir) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
196 |
m_err = EC_NO_WAY; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
197 |
return false; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
198 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
199 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
200 |
// road depots can be also left in one direction only |
8954
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8636
diff
changeset
|
201 |
if (IsRoadTT() && IsDepotTypeTile(m_old_tile, TT())) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
202 |
DiagDirection exitdir = GetRoadDepotDirection(m_old_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
203 |
if (exitdir != m_exitdir) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
204 |
m_err = EC_NO_WAY; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
205 |
return false; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
206 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
207 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
208 |
return true; |
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 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
211 |
/** return true if we can enter m_new_tile from m_exitdir */ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
212 |
FORCEINLINE bool CanEnterNewTile() |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
213 |
{ |
6012
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5998
diff
changeset
|
214 |
if (IsRoadTT() && IsStandardRoadStopTile(m_new_tile)) { |
065d7234a7a9
(svn r8735) -Feature: drive-through road stops made possible by the hard work of mart3p.
rubidium
parents:
5998
diff
changeset
|
215 |
// road stop can be entered from one direction only unless it's a drive-through stop |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
216 |
DiagDirection exitdir = GetRoadStopDir(m_new_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
217 |
if (ReverseDiagDir(exitdir) != m_exitdir) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
218 |
m_err = EC_NO_WAY; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
219 |
return false; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
220 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
221 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
222 |
|
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
223 |
/* single tram bits can only be entered from one direction */ |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
224 |
DiagDirection single_tram = GetSingleTramBit(m_new_tile); |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
225 |
if (single_tram != INVALID_DIAGDIR && single_tram != ReverseDiagDir(m_exitdir)) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
226 |
m_err = EC_NO_WAY; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
227 |
return false; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
228 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
229 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
230 |
// road and rail depots can also be entered from one direction only |
8954
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8636
diff
changeset
|
231 |
if (IsRoadTT() && IsDepotTypeTile(m_new_tile, TT())) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
232 |
DiagDirection exitdir = GetRoadDepotDirection(m_new_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
233 |
if (ReverseDiagDir(exitdir) != m_exitdir) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
234 |
m_err = EC_NO_WAY; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
235 |
return false; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
236 |
} |
4407
685c613f3fec
(svn r6160) -Fix [ 1519167 ] Bus trying to service in depot of other company (mart3p)
KUDr
parents:
3977
diff
changeset
|
237 |
// don't try to enter other player's depots |
685c613f3fec
(svn r6160) -Fix [ 1519167 ] Bus trying to service in depot of other company (mart3p)
KUDr
parents:
3977
diff
changeset
|
238 |
if (GetTileOwner(m_new_tile) != m_veh->owner) { |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
239 |
m_err = EC_OWNER; |
4407
685c613f3fec
(svn r6160) -Fix [ 1519167 ] Bus trying to service in depot of other company (mart3p)
KUDr
parents:
3977
diff
changeset
|
240 |
return false; |
685c613f3fec
(svn r6160) -Fix [ 1519167 ] Bus trying to service in depot of other company (mart3p)
KUDr
parents:
3977
diff
changeset
|
241 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
242 |
} |
8954
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8636
diff
changeset
|
243 |
if (IsRailTT() && IsDepotTypeTile(m_new_tile, TT())) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
244 |
DiagDirection exitdir = GetRailDepotDirection(m_new_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
245 |
if (ReverseDiagDir(exitdir) != m_exitdir) { |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
246 |
m_err = EC_NO_WAY; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
247 |
return false; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
248 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
249 |
} |
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 |
// rail transport is possible only on tiles with the same owner as vehicle |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
252 |
if (IsRailTT() && GetTileOwner(m_new_tile) != m_veh->owner) { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
253 |
// different owner |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
254 |
m_err = EC_NO_WAY; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
255 |
return false; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
256 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
257 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
258 |
// rail transport is possible only on compatible rail types |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
259 |
if (IsRailTT()) { |
6154 | 260 |
RailType rail_type = GetTileRailType(m_new_tile); |
9797
3b2e6f55e7d0
(svn r13939) -Add [YAPP]: Extend YAPF with the possibility to override the railtype info of the vehicle. (michi_cc)
rubidium
parents:
9490
diff
changeset
|
261 |
if (!HasBit(m_railtypes, rail_type)) { |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
262 |
// incompatible rail type |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
263 |
m_err = EC_RAIL_TYPE; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
264 |
return false; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
265 |
} |
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 |
|
5420
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
268 |
// tunnel holes and bridge ramps can be entered only from proper direction |
9490
01c07bde5e84
(svn r13464) -Codechange: support NewGRF Action 0x05, type 12.
rubidium
parents:
9439
diff
changeset
|
269 |
if (IsTileType(m_new_tile, MP_TUNNELBRIDGE)) { |
5420
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
270 |
if (IsTunnel(m_new_tile)) { |
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
271 |
if (!m_is_tunnel) { |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
7928
diff
changeset
|
272 |
DiagDirection tunnel_enterdir = GetTunnelBridgeDirection(m_new_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
273 |
if (tunnel_enterdir != m_exitdir) { |
7214
529dee3b770b
(svn r10492) -Fix [YAPF, r10491]: commands with no effect (glx)
KUDr
parents:
7211
diff
changeset
|
274 |
m_err = EC_NO_WAY; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
275 |
return false; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
276 |
} |
5420
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
277 |
} |
8390
f88f515e6557
(svn r11960) -Cleanup: simplify some IsTunnel(Tile) / IsBridge(Tile) conditions
smatz
parents:
8083
diff
changeset
|
278 |
} else { // IsBridge(m_new_tile) |
5420
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
279 |
if (!m_is_bridge) { |
8083
ad22eade501f
(svn r11644) -Codechange: merge some functions from tunnel_map.h and bridge_map.h into tunnelbridge_map.h
smatz
parents:
7928
diff
changeset
|
280 |
DiagDirection ramp_enderdir = GetTunnelBridgeDirection(m_new_tile); |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
281 |
if (ramp_enderdir != m_exitdir) { |
7214
529dee3b770b
(svn r10492) -Fix [YAPF, r10491]: commands with no effect (glx)
KUDr
parents:
7211
diff
changeset
|
282 |
m_err = EC_NO_WAY; |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
283 |
return false; |
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
284 |
} |
5420
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
285 |
} |
265af7def3aa
(svn r7623) - Fix: [YAPF] trains/roadvehs trying to enter the bridge ramp from under bridge rail/road (introduced by bridge merge r7573)
KUDr
parents:
5385
diff
changeset
|
286 |
} |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
287 |
} |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
288 |
|
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
289 |
// special handling for rail stations - get to the end of platform |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
290 |
if (IsRailTT() && m_is_station) { |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
291 |
// entered railway station |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
292 |
// get platform length |
5998
2bfbade143ac
(svn r8709) -Fix/Codechange: Rename the function GetStationPlatforms into GetPlatformLength because that is what it really does. Overload it because there is already a GetPlatformLength (one gives the length of the whole platform, the other gives the remaining length in a given direction). Turned both functions into methods of Station. While messing around with it, fix a problem where loading times for overhanging trains are miscomputed.
celestar
parents:
5826
diff
changeset
|
293 |
uint length = GetStationByTile(m_new_tile)->GetPlatformLength(m_new_tile, TrackdirToExitdir(m_old_td)); |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
294 |
// how big step we must do to get to the last platform tile; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
295 |
m_tiles_skipped = length - 1; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
296 |
// move to the platform end |
4559
aa0c13e39840
(svn r6406) -Codechange: Rename TileOffsByDir to TileOffsByDiagDir because it accepts
Darkvater
parents:
4549
diff
changeset
|
297 |
TileIndexDiff diff = TileOffsByDiagDir(m_exitdir); |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
298 |
diff *= m_tiles_skipped; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
299 |
m_new_tile = TILE_ADD(m_new_tile, diff); |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
300 |
return true; |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
301 |
} |
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
302 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
303 |
return true; |
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 |
|
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
306 |
/** return true if we must reverse (in depots and single tram bits) */ |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
307 |
FORCEINLINE bool ForcedReverse() |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
308 |
{ |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
309 |
// rail and road depots cause reversing |
8954
3993bae3bfb8
(svn r12745) -Codechange: a bit of naming conventions, introduce Is*DepotTile()
smatz
parents:
8636
diff
changeset
|
310 |
if (!IsWaterTT() && IsDepotTypeTile(m_old_tile, TT())) { |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
311 |
DiagDirection exitdir = IsRailTT() ? GetRailDepotDirection(m_old_tile) : GetRoadDepotDirection(m_old_tile); |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
312 |
if (exitdir != m_exitdir) { |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
313 |
// reverse |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
314 |
m_new_tile = m_old_tile; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
315 |
m_new_td_bits = TrackdirToTrackdirBits(ReverseTrackdir(m_old_td)); |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
316 |
m_exitdir = exitdir; |
3931
b946fc6e7188
(svn r5066) -Feature: [YAPF] Train selects the best station platform by length
KUDr
parents:
3915
diff
changeset
|
317 |
m_tiles_skipped = 0; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
318 |
m_is_tunnel = m_is_bridge = m_is_station = false; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
319 |
return true; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
320 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
321 |
} |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
322 |
|
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
323 |
// single tram bits cause reversing |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
324 |
if (GetSingleTramBit(m_old_tile) == ReverseDiagDir(m_exitdir)) { |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
325 |
// reverse |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
326 |
m_new_tile = m_old_tile; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
327 |
m_new_td_bits = TrackdirToTrackdirBits(ReverseTrackdir(m_old_td)); |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
328 |
m_exitdir = ReverseDiagDir(m_exitdir); |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
329 |
m_tiles_skipped = 0; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
330 |
m_is_tunnel = m_is_bridge = m_is_station = false; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
331 |
return true; |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
332 |
} |
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
333 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
334 |
return false; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
335 |
} |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
336 |
|
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
337 |
/** return true if we successfully reversed at end of road/track */ |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
338 |
FORCEINLINE bool TryReverse() |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
339 |
{ |
8465
349d2e76eeef
(svn r12035) -Fix [FS#1702]: Teach YAPF where trams can reverse, and where not.
frosch
parents:
8398
diff
changeset
|
340 |
if (IsRoadTT() && !IsTram()) { |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
341 |
// if we reached the end of road, we can reverse the RV and continue moving |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
342 |
m_exitdir = ReverseDiagDir(m_exitdir); |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
343 |
// new tile will be the same as old one |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
344 |
m_new_tile = m_old_tile; |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
345 |
// set new trackdir bits to all reachable trackdirs |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
346 |
QueryNewTileTrackStatus(); |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
347 |
m_new_td_bits &= DiagdirReachesTrackdirs(m_exitdir); |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
348 |
if (m_new_td_bits != TRACKDIR_BIT_NONE) { |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
349 |
// we have some trackdirs reachable after reversal |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
350 |
return true; |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
351 |
} |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
352 |
} |
7211
ebabbe55f70e
(svn r10489) -Codechange [YAPF]: FollowTrack_t now has new data member - m_err. It indicates the reason why the given track/trackdir can't be followed when method CFollowTrackT<>::Follow() returned false.
KUDr
parents:
7037
diff
changeset
|
353 |
m_err = EC_NO_WAY; |
3976
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
354 |
return false; |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
355 |
} |
6135bc445350
(svn r5153) - Fix: [YAPF] RVs can now plan path reversing in depot or end of road
KUDr
parents:
3933
diff
changeset
|
356 |
|
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
357 |
public: |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
358 |
/** Helper for pathfinders - get min/max speed on the m_old_tile/m_old_td */ |
7037
64249224bb74
(svn r10301) -Fix [FS#901, YAPF]: another assert violation in some special cases (immeR)
KUDr
parents:
6683
diff
changeset
|
359 |
int GetSpeedLimit(int *pmin_speed = NULL) const |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
360 |
{ |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
361 |
int min_speed = 0; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
362 |
int max_speed = INT_MAX; // no limit |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
363 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
364 |
// for now we handle only on-bridge speed limit |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
365 |
if (!IsWaterTT() && IsBridgeTile(m_old_tile)) { |
8491
97fcf662c3c3
(svn r12066) -Codechange: Rename GetBridge for the more common GetBridgeSpec
belugas
parents:
8465
diff
changeset
|
366 |
int spd = GetBridgeSpec(GetBridgeType(m_old_tile))->speed; |
5385
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
367 |
if (IsRoadTT()) spd *= 2; |
3868f2e6db9b
(svn r7573) -Merged the bridge branch. Allows to build bridges of arbitrary rail/road combinations (including signals)
celestar
parents:
4559
diff
changeset
|
368 |
if (max_speed > spd) max_speed = spd; |
3900
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
369 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
370 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
371 |
// if min speed was requested, return it |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
372 |
if (pmin_speed) *pmin_speed = min_speed; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
373 |
return max_speed; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
374 |
} |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
375 |
}; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
376 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
377 |
typedef CFollowTrackT<TRANSPORT_WATER, true > CFollowTrackWater; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
378 |
typedef CFollowTrackT<TRANSPORT_ROAD , true > CFollowTrackRoad; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
379 |
typedef CFollowTrackT<TRANSPORT_RAIL , true > CFollowTrackRail; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
380 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
381 |
typedef CFollowTrackT<TRANSPORT_WATER, false> CFollowTrackWaterNo90; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
382 |
typedef CFollowTrackT<TRANSPORT_ROAD , false> CFollowTrackRoadNo90; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
383 |
typedef CFollowTrackT<TRANSPORT_RAIL , false> CFollowTrackRailNo90; |
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
384 |
|
2c84ed52709d
(svn r4987) Feature: Merged YAPF into trunk. Thanks to devs for continuous support and users for testing.
KUDr
parents:
diff
changeset
|
385 |
#endif /* FOLLOW_TRACK_HPP */ |