diff options
author | frosch <frosch@openttd.org> | 2013-05-07 13:49:18 +0000 |
---|---|---|
committer | frosch <frosch@openttd.org> | 2013-05-07 13:49:18 +0000 |
commit | 1e41b38b7d3d43e554422e919e97d67c43983363 (patch) | |
tree | d308339f0a2a44ea6e41dc14c59b097b834686ac | |
parent | 71cfe3d474e75c25df37c3947bfaa04b917c603e (diff) | |
download | openttd-1e41b38b7d3d43e554422e919e97d67c43983363.tar.xz |
(svn r25231) -Fix (r25227): Also update infrastructure counts. (adf88)
-rw-r--r-- | src/tunnelbridge_cmd.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 2eae016c9..b0a4c6ad8 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -295,6 +295,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u CommandCost cost(EXPENSES_CONSTRUCTION); Owner owner; + bool is_new_owner; if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) && GetOtherBridgeEnd(tile_start) == tile_end && GetTunnelBridgeTransportType(tile_start) == transport_type) { @@ -333,7 +334,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u owner = GetTileOwner(tile_start); /* If bridge belonged to bankrupt company, it has a new owner now */ - if (owner == OWNER_NONE) owner = company; + is_new_owner = (owner == OWNER_NONE); + if (is_new_owner) owner = company; switch (transport_type) { case TRANSPORT_RAIL: @@ -441,6 +443,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u } owner = company; + is_new_owner = true; } /* do the drill? */ @@ -450,8 +453,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u Company *c = Company::GetIfValid(owner); switch (transport_type) { case TRANSPORT_RAIL: - /* Add to company infrastructure count if building a new bridge. */ - if (!IsBridgeTile(tile_start) && c != NULL) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR; + /* Add to company infrastructure count if required. */ + if (is_new_owner && c != NULL) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR; MakeRailBridgeRamp(tile_start, owner, bridge_type, dir, railtype); MakeRailBridgeRamp(tile_end, owner, bridge_type, ReverseDiagDir(dir), railtype); SetTunnelBridgeReservation(tile_start, pbs_reservation); @@ -460,6 +463,11 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u case TRANSPORT_ROAD: { RoadTypes prev_roadtypes = IsBridgeTile(tile_start) ? GetRoadTypes(tile_start) : ROADTYPES_NONE; + if (is_new_owner) { + /* Also give unowned present roadtypes to new owner */ + if (HasBit(prev_roadtypes, ROADTYPE_ROAD) && GetRoadOwner(tile_start, ROADTYPE_ROAD) == OWNER_NONE) ClrBit(prev_roadtypes, ROADTYPE_ROAD); + if (HasBit(prev_roadtypes, ROADTYPE_TRAM) && GetRoadOwner(tile_start, ROADTYPE_TRAM) == OWNER_NONE) ClrBit(prev_roadtypes, ROADTYPE_TRAM); + } if (c != NULL) { /* Add all new road types to the company infrastructure counter. */ RoadType new_rt; @@ -478,7 +486,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u } case TRANSPORT_WATER: - if (!IsBridgeTile(tile_start) && c != NULL) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR; + if (is_new_owner && c != NULL) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR; MakeAqueductBridgeRamp(tile_start, owner, dir); MakeAqueductBridgeRamp(tile_end, owner, ReverseDiagDir(dir)); break; |