diff options
author | frosch <frosch@openttd.org> | 2013-01-13 13:17:12 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-01-13 13:17:12 +0000 |
commit | eda4cfeabea022f887871dd0b40f6f6d47ae36a7 (patch) | |
tree | 0391dca58d6db63be22b70b0d4a865d400710873 | |
parent | 1ec4cf6ff195d09abe5a9a2f9db422af068c4e08 (diff) | |
download | openttd-eda4cfeabea022f887871dd0b40f6f6d47ae36a7.tar.xz |
(svn r24912) -Fix [FS#5389]: Upgrading bridges could steal road types. (adf88)
-rw-r--r-- | src/bridge_map.h | 8 | ||||
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 14 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/bridge_map.h b/src/bridge_map.h index 5ab4fd552..8ee658ce7 100644 --- a/src/bridge_map.h +++ b/src/bridge_map.h @@ -161,15 +161,17 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D * Make a bridge ramp for roads. * @param t the tile to make a bridge ramp * @param o the new owner of the bridge ramp + * @param owner_road the new owner of the road on the bridge + * @param owner_tram the new owner of the tram on the bridge * @param bridgetype the type of bridge this bridge ramp belongs to * @param d the direction this ramp must be facing * @param r the road type of the bridge */ -static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, DiagDirection d, RoadTypes r) +static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, BridgeType bridgetype, DiagDirection d, RoadTypes r) { MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0); - SetRoadOwner(t, ROADTYPE_ROAD, o); - if (o != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, o); + SetRoadOwner(t, ROADTYPE_ROAD, owner_road); + if (owner_tram != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, owner_tram); SetRoadTypes(t, r); } diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 87edbc27d..1bcbf7163 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -455,18 +455,24 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u SetTunnelBridgeReservation(tile_end, pbs_reservation); break; - case TRANSPORT_ROAD: + case TRANSPORT_ROAD: { + RoadTypes prev_roadtypes = IsBridgeTile(tile_start) ? GetRoadTypes(tile_start) : ROADTYPES_NONE; if (c != NULL) { /* Add all new road types to the company infrastructure counter. */ RoadType new_rt; - FOR_EACH_SET_ROADTYPE(new_rt, roadtypes ^ (IsBridgeTile(tile_start) ? GetRoadTypes(tile_start) : ROADTYPES_NONE)) { + FOR_EACH_SET_ROADTYPE(new_rt, roadtypes ^ prev_roadtypes) { /* A full diagonal road tile has two road bits. */ Company::Get(owner)->infrastructure.road[new_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR; } } - MakeRoadBridgeRamp(tile_start, owner, bridge_type, dir, roadtypes); - MakeRoadBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), roadtypes); + Owner owner_road = owner; + Owner owner_tram = owner; + if (HasBit(prev_roadtypes, ROADTYPE_ROAD)) owner_road = GetRoadOwner(tile_start, ROADTYPE_ROAD); + if (HasBit(prev_roadtypes, ROADTYPE_TRAM)) owner_tram = GetRoadOwner(tile_start, ROADTYPE_TRAM); + MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir, roadtypes); + MakeRoadBridgeRamp(tile_end, owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes); break; + } case TRANSPORT_WATER: if (!IsBridgeTile(tile_start) && c != NULL) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR; |