mirror of https://github.com/OpenTTD/OpenTTD
Fix 44984f8410: Changing ownership of a tunnel/bridge did not check for road transport type. (#13963)
Changing ownership changed ownership of road components without checking if the tunnel/bridge is actually a road tunnel/bridge.pull/13967/head
parent
4310d7c7f5
commit
68fd949a52
|
@ -1795,6 +1795,9 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner
|
|||
* don't want to update the infrastructure counts twice. */
|
||||
uint num_pieces = tile < other_end ? (GetTunnelBridgeLength(tile, other_end) + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR : 0;
|
||||
|
||||
TransportType tt = GetTunnelBridgeTransportType(tile);
|
||||
|
||||
if (tt == TRANSPORT_ROAD) {
|
||||
for (RoadTramType rtt : _roadtramtypes) {
|
||||
/* Update all roadtypes, no matter if they are present */
|
||||
if (GetRoadOwner(tile, rtt) == old_owner) {
|
||||
|
@ -1809,12 +1812,12 @@ static void ChangeTileOwner_TunnelBridge(TileIndex tile, Owner old_owner, Owner
|
|||
SetRoadOwner(tile, rtt, new_owner == INVALID_OWNER ? OWNER_NONE : new_owner);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!IsTileOwner(tile, old_owner)) return;
|
||||
|
||||
/* Update company infrastructure counts for rail and water as well.
|
||||
* No need to dirty windows here, we'll redraw the whole screen anyway. */
|
||||
TransportType tt = GetTunnelBridgeTransportType(tile);
|
||||
Company *old = Company::Get(old_owner);
|
||||
if (tt == TRANSPORT_RAIL) {
|
||||
old->infrastructure.rail[GetRailType(tile)] -= num_pieces;
|
||||
|
|
Loading…
Reference in New Issue