(svn r25231) -Fix (r25227): Also update infrastructure counts. (adf88)

This commit is contained in:
frosch 2013-05-07 13:49:18 +00:00
parent 71cfe3d474
commit 1e41b38b7d
1 changed files with 12 additions and 4 deletions

View File

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