mirror of https://github.com/OpenTTD/OpenTTD
Fix: MayHaveRoad claimed rail station tiles had road, so the custom stationspec index would be read as roadtype. (#13949)
parent
cedc511324
commit
8846f347f2
|
@ -132,11 +132,11 @@ inline void MakeBridgeRamp(Tile t, Owner o, BridgeType bridgetype, DiagDirection
|
|||
SetDockingTile(t, false);
|
||||
t.m2() = 0;
|
||||
t.m3() = 0;
|
||||
t.m4() = INVALID_ROADTYPE;
|
||||
t.m4() = 0;
|
||||
t.m5() = 1 << 7 | tt << 2 | d;
|
||||
SB(t.m6(), 2, 4, bridgetype);
|
||||
t.m7() = 0;
|
||||
t.m8() = INVALID_ROADTYPE << 6;
|
||||
t.m8() = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -200,7 +200,7 @@ void ConvertRoadTypes()
|
|||
break;
|
||||
|
||||
case MP_STATION:
|
||||
if (IsStationRoadStop(t) || IsRoadWaypoint(t)) {
|
||||
if (IsAnyRoadStop(t)) {
|
||||
if (RoadType rt = GetRoadTypeRoad(t); rt != INVALID_ROADTYPE) SetRoadTypeRoad(t, roadtype_conversion_map[rt]);
|
||||
if (RoadType rt = GetRoadTypeTram(t); rt != INVALID_ROADTYPE) SetRoadTypeTram(t, roadtype_conversion_map[rt]);
|
||||
}
|
||||
|
|
|
@ -13,6 +13,27 @@
|
|||
|
||||
#include "safeguards.h"
|
||||
|
||||
/**
|
||||
* Test whether a tile can have road/tram types.
|
||||
* @param t Tile to query.
|
||||
* @return true if tile can be queried about road/tram types.
|
||||
*/
|
||||
bool MayHaveRoad(Tile t)
|
||||
{
|
||||
switch (GetTileType(t)) {
|
||||
case MP_ROAD:
|
||||
return true;
|
||||
|
||||
case MP_STATION:
|
||||
return IsAnyRoadStop(t);
|
||||
|
||||
case MP_TUNNELBRIDGE:
|
||||
return GetTunnelBridgeTransportType(t) == TRANSPORT_ROAD;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the RoadBits on an arbitrary tile
|
||||
|
@ -44,12 +65,12 @@ RoadBits GetAnyRoadBits(Tile tile, RoadTramType rtt, bool straight_tunnel_bridge
|
|||
}
|
||||
|
||||
case MP_STATION:
|
||||
if (!IsAnyRoadStopTile(tile)) return ROAD_NONE;
|
||||
assert(IsAnyRoadStopTile(tile)); // ensured by MayHaveRoad
|
||||
if (IsDriveThroughStopTile(tile)) return AxisToRoadBits(GetDriveThroughStopAxis(tile));
|
||||
return DiagDirToRoadBits(GetBayRoadStopDir(tile));
|
||||
|
||||
case MP_TUNNELBRIDGE:
|
||||
if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) return ROAD_NONE;
|
||||
assert(GetTunnelBridgeTransportType(tile) == TRANSPORT_ROAD); // ensured by MayHaveRoad
|
||||
return straight_tunnel_bridge_entrance ?
|
||||
AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) :
|
||||
DiagDirToRoadBits(ReverseDiagDir(GetTunnelBridgeDirection(tile)));
|
||||
|
|
|
@ -25,23 +25,7 @@ enum RoadTileType : uint8_t {
|
|||
ROAD_TILE_DEPOT, ///< Depot (one entrance)
|
||||
};
|
||||
|
||||
/**
|
||||
* Test whether a tile can have road/tram types.
|
||||
* @param t Tile to query.
|
||||
* @return true if tile can be queried about road/tram types.
|
||||
*/
|
||||
inline bool MayHaveRoad(Tile t)
|
||||
{
|
||||
switch (GetTileType(t)) {
|
||||
case MP_ROAD:
|
||||
case MP_STATION:
|
||||
case MP_TUNNELBRIDGE:
|
||||
return true;
|
||||
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
bool MayHaveRoad(Tile t);
|
||||
|
||||
/**
|
||||
* Get the type of the road tile.
|
||||
|
|
|
@ -3190,15 +3190,6 @@ bool AfterLoadGame()
|
|||
}
|
||||
}
|
||||
|
||||
if (IsSavegameVersionBeforeOrAt(SLV_ENDING_YEAR)) {
|
||||
/* Reset roadtype/streetcartype info for non-road bridges. */
|
||||
for (const auto t : Map::Iterate()) {
|
||||
if (IsTileType(t, MP_TUNNELBRIDGE) && GetTunnelBridgeTransportType(t) != TRANSPORT_ROAD) {
|
||||
SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Make sure all industries exclusive supplier/consumer set correctly. */
|
||||
if (IsSavegameVersionBefore(SLV_GS_INDUSTRY_CONTROL)) {
|
||||
for (Industry *i : Industry::Iterate()) {
|
||||
|
|
|
@ -82,7 +82,6 @@ inline void MakeRailTunnel(Tile t, Owner o, DiagDirection d, RailType r)
|
|||
t.m7() = 0;
|
||||
t.m8() = 0;
|
||||
SetRailType(t, r);
|
||||
SetRoadTypes(t, INVALID_ROADTYPE, INVALID_ROADTYPE);
|
||||
}
|
||||
|
||||
#endif /* TUNNEL_MAP_H */
|
||||
|
|
Loading…
Reference in New Issue