Merge branch 'custom_bridgeheads' into jgrpp
# Conflicts: # docs/landscape_grid.html # src/roadveh_cmd.cpp # src/saveload/afterload.cpp # src/saveload/extended_ver_sl.cpp # src/saveload/extended_ver_sl.h # src/settings_gui.cpp # src/settings_type.h # src/tunnelbridge_cmd.cpp # src/tunnelbridge_map.h
This commit is contained in:
@@ -102,8 +102,9 @@ struct CFollowTrackT
|
||||
{
|
||||
assert(IsTram()); // this function shouldn't be called in other cases
|
||||
|
||||
if (IsNormalRoadTile(tile)) {
|
||||
RoadBits rb = GetRoadBits(tile, ROADTYPE_TRAM);
|
||||
const bool is_bridge = IsRoadCustomBridgeHeadTile(tile);
|
||||
if (is_bridge || IsNormalRoadTile(tile)) {
|
||||
RoadBits rb = is_bridge ? GetCustomBridgeHeadRoadBits(tile, ROADTYPE_TRAM) : GetRoadBits(tile, ROADTYPE_TRAM);
|
||||
switch (rb) {
|
||||
case ROAD_NW: return DIAGDIR_NW;
|
||||
case ROAD_SW: return DIAGDIR_SW;
|
||||
@@ -216,7 +217,7 @@ protected:
|
||||
m_tiles_skipped = GetTunnelBridgeLength(m_new_tile, m_old_tile);
|
||||
return;
|
||||
}
|
||||
assert(ReverseDiagDir(enterdir) == m_exitdir);
|
||||
if (!IsRoadCustomBridgeHeadTile(m_old_tile)) assert(ReverseDiagDir(enterdir) == m_exitdir);
|
||||
}
|
||||
|
||||
/* normal or station tile, do one step */
|
||||
@@ -370,7 +371,12 @@ protected:
|
||||
}
|
||||
}
|
||||
} else { // IsBridge(m_new_tile)
|
||||
if (!m_is_bridge) {
|
||||
if (!m_is_bridge && IsRoadTT() && IsRoadCustomBridgeHeadTile(m_new_tile)) {
|
||||
if (!(DiagDirToRoadBits(ReverseDiagDir(m_exitdir)) & GetCustomBridgeHeadRoadBits(m_new_tile, IsTram() ? ROADTYPE_TRAM : ROADTYPE_ROAD))) {
|
||||
m_err = EC_NO_WAY;
|
||||
return false;
|
||||
}
|
||||
} else if (!m_is_bridge) {
|
||||
DiagDirection ramp_enderdir = GetTunnelBridgeDirection(m_new_tile);
|
||||
if (ramp_enderdir != m_exitdir) {
|
||||
m_err = EC_NO_WAY;
|
||||
|
||||
@@ -112,7 +112,10 @@ public:
|
||||
*/
|
||||
inline bool PfCalcCost(Node &n, const TrackFollower *tf)
|
||||
{
|
||||
int segment_cost = 0;
|
||||
/* this is to handle the case where the starting tile is a junction custom bridge head,
|
||||
* and we have advanced across the bridge in the initial step */
|
||||
int segment_cost = tf->m_tiles_skipped * YAPF_TILE_LENGTH;
|
||||
|
||||
uint tiles = 0;
|
||||
/* start at n.m_key.m_tile / n.m_key.m_td and walk to the end of segment */
|
||||
TileIndex tile = n.m_key.m_tile;
|
||||
@@ -135,6 +138,11 @@ public:
|
||||
TrackFollower F(Yapf().GetVehicle());
|
||||
if (!F.Follow(tile, trackdir)) break;
|
||||
|
||||
/* if we skipped some tunnel tiles, add their cost */
|
||||
/* with custom bridge heads, this cost must be added before checking if the segment has ended */
|
||||
segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
|
||||
tiles += F.m_tiles_skipped + 1;
|
||||
|
||||
/* if there are more trackdirs available & reachable, we are at the end of segment */
|
||||
if (KillFirstBit(F.m_new_td_bits) != TRACKDIR_BIT_NONE) break;
|
||||
|
||||
@@ -143,10 +151,6 @@ public:
|
||||
/* stop if RV is on simple loop with no junctions */
|
||||
if (F.m_new_tile == n.m_key.m_tile && new_td == n.m_key.m_td) return false;
|
||||
|
||||
/* if we skipped some tunnel tiles, add their cost */
|
||||
segment_cost += F.m_tiles_skipped * YAPF_TILE_LENGTH;
|
||||
tiles += F.m_tiles_skipped + 1;
|
||||
|
||||
/* add hilly terrain penalty */
|
||||
segment_cost += Yapf().SlopeCost(tile, F.m_new_tile, trackdir);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user