mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
Merge branch 'custom_bridgeheads' into jgrpp
# Conflicts: # src/tunnelbridge_cmd.cpp
This commit is contained in:
commit
714b9711e4
@ -153,13 +153,20 @@ static inline void MakeBridgeRamp(TileIndex t, Owner o, BridgeType bridgetype, D
|
||||
* @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
|
||||
* @param upgrade whether the bridge is an upgrade instead of a totally new bridge
|
||||
*/
|
||||
static inline void MakeRoadBridgeRamp(TileIndex t, Owner o, Owner owner_road, Owner owner_tram, 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, bool upgrade)
|
||||
{
|
||||
// Backup custom bridgehead data.
|
||||
uint custom_bridge_head_backup = GB(_m[t].m2, 0, 8);
|
||||
|
||||
MakeBridgeRamp(t, o, bridgetype, d, TRANSPORT_ROAD, 0);
|
||||
SetRoadOwner(t, ROADTYPE_ROAD, owner_road);
|
||||
if (owner_tram != OWNER_TOWN) SetRoadOwner(t, ROADTYPE_TRAM, owner_tram);
|
||||
SetRoadTypes(t, r);
|
||||
|
||||
// Restore custom bridgehead data if we're upgrading an existing bridge.
|
||||
if (upgrade) SB(_m[t].m2, 0, 8, custom_bridge_head_backup);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -358,6 +358,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
CommandCost cost(EXPENSES_CONSTRUCTION);
|
||||
Owner owner;
|
||||
bool is_new_owner;
|
||||
bool is_upgrade = false;
|
||||
if (IsBridgeTile(tile_start) && IsBridgeTile(tile_end) &&
|
||||
GetOtherBridgeEnd(tile_start) == tile_end &&
|
||||
GetTunnelBridgeTransportType(tile_start) == transport_type) {
|
||||
@ -412,6 +413,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
|
||||
default: break;
|
||||
}
|
||||
|
||||
is_upgrade = true;
|
||||
} else {
|
||||
/* Build a new bridge. */
|
||||
|
||||
@ -538,18 +541,12 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
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;
|
||||
FOR_EACH_SET_ROADTYPE(new_rt, roadtypes ^ prev_roadtypes) {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
c->infrastructure.road[new_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
}
|
||||
}
|
||||
if (is_upgrade) SubtractRoadTunnelBridgeInfrastructure(tile_start, tile_end);
|
||||
Owner owner_road = HasBit(prev_roadtypes, ROADTYPE_ROAD) ? GetRoadOwner(tile_start, ROADTYPE_ROAD) : company;
|
||||
Owner owner_tram = HasBit(prev_roadtypes, ROADTYPE_TRAM) ? GetRoadOwner(tile_start, ROADTYPE_TRAM) : company;
|
||||
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);
|
||||
MakeRoadBridgeRamp(tile_start, owner, owner_road, owner_tram, bridge_type, dir, roadtypes, is_upgrade);
|
||||
MakeRoadBridgeRamp(tile_end, owner, owner_road, owner_tram, bridge_type, ReverseDiagDir(dir), roadtypes, is_upgrade);
|
||||
AddRoadTunnelBridgeInfrastructure(tile_start, tile_end);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user