Changeset - r20231:ee3fa97a7874
[Not reviewed]
master
0 1 0
frosch - 11 years ago 2013-05-07 13:49:18
frosch@openttd.org
(svn r25231) -Fix (r25227): Also update infrastructure counts. (adf88)
1 file changed with 12 insertions and 4 deletions:
0 comments (0 inline, 0 general)
src/tunnelbridge_cmd.cpp
Show inline comments
 
@@ -295,6 +295,7 @@ CommandCost CmdBuildBridge(TileIndex end
 

	
 
	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
 
		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
 
		}
 

	
 
		owner = company;
 
		is_new_owner = true;
 
	}
 

	
 
	/* do the drill? */
 
@@ -450,8 +453,8 @@ CommandCost CmdBuildBridge(TileIndex end
 
		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
 

	
 
			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
 
			}
 

	
 
			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;
0 comments (0 inline, 0 general)