(svn r24912) -Fix [FS#5389]: Upgrading bridges could steal road types. (adf88)

This commit is contained in:
frosch 2013-01-13 13:17:12 +00:00
parent 1ec4cf6ff1
commit eda4cfeabe
2 changed files with 15 additions and 7 deletions

View File

@ -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);
}

View File

@ -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;