Update to 1.11.0-beta1
This commit is contained in:
+49
-16
@@ -206,13 +206,45 @@ CommandCost CheckBridgeAvailability(BridgeType bridge_type, uint bridge_len, DoC
|
||||
const BridgeSpec *b = GetBridgeSpec(bridge_type);
|
||||
if (b->avail_year > _cur_year) return CMD_ERROR;
|
||||
|
||||
uint max = min(b->max_length, _settings_game.construction.max_bridge_length);
|
||||
uint max = std::min(b->max_length, _settings_game.construction.max_bridge_length);
|
||||
|
||||
if (b->min_length > bridge_len) return CMD_ERROR;
|
||||
if (bridge_len <= max) return CommandCost();
|
||||
return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculate the base cost of clearing a tunnel/bridge per tile.
|
||||
* @param tile Start tile of the tunnel/bridge.
|
||||
* @return How much clearing this tunnel/bridge costs per tile.
|
||||
*/
|
||||
static Money TunnelBridgeClearCost(TileIndex tile, Price base_price)
|
||||
{
|
||||
Money base_cost = _price[base_price];
|
||||
|
||||
/* Add the cost of the transport that is on the tunnel/bridge. */
|
||||
switch (GetTunnelBridgeTransportType(tile)) {
|
||||
case TRANSPORT_ROAD: {
|
||||
RoadType road_rt = GetRoadTypeRoad(tile);
|
||||
RoadType tram_rt = GetRoadTypeTram(tile);
|
||||
|
||||
if (road_rt != INVALID_ROADTYPE) {
|
||||
base_cost += 2 * RoadClearCost(road_rt);
|
||||
}
|
||||
if (tram_rt != INVALID_ROADTYPE) {
|
||||
base_cost += 2 * RoadClearCost(tram_rt);
|
||||
}
|
||||
} break;
|
||||
|
||||
case TRANSPORT_RAIL: base_cost += RailClearCost(GetRailType(tile)); break;
|
||||
/* Aquaducts have their own clear price. */
|
||||
case TRANSPORT_WATER: base_cost = _price[PR_CLEAR_AQUEDUCT]; break;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return base_cost;
|
||||
}
|
||||
|
||||
/**
|
||||
* Build a Bridge
|
||||
* @param end_tile end tile
|
||||
@@ -296,6 +328,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
} else {
|
||||
if (bridge_len > _settings_game.construction.max_bridge_length) return_cmd_error(STR_ERROR_BRIDGE_TOO_LONG);
|
||||
}
|
||||
bridge_len += 2; // begin and end tiles/ramps
|
||||
|
||||
int z_start;
|
||||
int z_end;
|
||||
@@ -372,7 +405,8 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
return_cmd_error(STR_ERROR_AREA_IS_OWNED_BY_ANOTHER);
|
||||
}
|
||||
|
||||
cost.AddCost((bridge_len + 1) * _price[PR_CLEAR_BRIDGE]); // The cost of clearing the current bridge.
|
||||
/* The cost of clearing the current bridge. */
|
||||
cost.AddCost(bridge_len * TunnelBridgeClearCost(tile_start, PR_CLEAR_BRIDGE));
|
||||
owner = GetTileOwner(tile_start);
|
||||
|
||||
/* If bridge belonged to bankrupt company, it has a new owner now */
|
||||
@@ -497,7 +531,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_RAIL:
|
||||
/* Add to company infrastructure count if required. */
|
||||
if (is_new_owner && c != nullptr) c->infrastructure.rail[railtype] += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
if (is_new_owner && c != nullptr) c->infrastructure.rail[railtype] += bridge_len * 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);
|
||||
@@ -514,11 +548,11 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
/* Add all new road types to the company infrastructure counter. */
|
||||
if (!hasroad && road_rt != INVALID_ROADTYPE) {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
c->infrastructure.road[road_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
c->infrastructure.road[road_rt] += bridge_len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
}
|
||||
if (!hastram && tram_rt != INVALID_ROADTYPE) {
|
||||
/* A full diagonal road tile has two road bits. */
|
||||
c->infrastructure.road[tram_rt] += (bridge_len + 2) * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
c->infrastructure.road[tram_rt] += bridge_len * 2 * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
}
|
||||
}
|
||||
Owner owner_road = hasroad ? GetRoadOwner(tile_start, RTT_ROAD) : company;
|
||||
@@ -529,7 +563,7 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
}
|
||||
|
||||
case TRANSPORT_WATER:
|
||||
if (is_new_owner && c != nullptr) c->infrastructure.water += (bridge_len + 2) * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
if (is_new_owner && c != nullptr) c->infrastructure.water += bridge_len * TUNNELBRIDGE_TRACKBIT_FACTOR;
|
||||
MakeAqueductBridgeRamp(tile_start, owner, dir);
|
||||
MakeAqueductBridgeRamp(tile_end, owner, ReverseDiagDir(dir));
|
||||
CheckForDockingTile(tile_start);
|
||||
@@ -557,8 +591,6 @@ CommandCost CmdBuildBridge(TileIndex end_tile, DoCommandFlag flags, uint32 p1, u
|
||||
* For (non-spectated) AI, Towns this has to be of course calculated. */
|
||||
Company *c = Company::GetIfValid(company);
|
||||
if (!(flags & DC_QUERY_COST) || (c != nullptr && c->is_ai && company != _local_company)) {
|
||||
bridge_len += 2; // begin and end tiles/ramps
|
||||
|
||||
switch (transport_type) {
|
||||
case TRANSPORT_ROAD:
|
||||
if (road_rt != INVALID_ROADTYPE) {
|
||||
@@ -710,8 +742,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
||||
* Do this for all tiles (like trees), not only objects. */
|
||||
ClearedObjectArea *coa = FindClearedObject(end_tile);
|
||||
if (coa == nullptr) {
|
||||
/*C++17: coa = &*/ _cleared_object_areas.push_back({end_tile, TileArea(end_tile, 1, 1)});
|
||||
coa = &_cleared_object_areas.back();
|
||||
coa = &_cleared_object_areas.emplace_back(ClearedObjectArea{ end_tile, TileArea(end_tile, 1, 1) });
|
||||
}
|
||||
|
||||
/* Hide the tile from the terraforming command */
|
||||
@@ -720,7 +751,7 @@ CommandCost CmdBuildTunnel(TileIndex start_tile, DoCommandFlag flags, uint32 p1,
|
||||
|
||||
/* CMD_TERRAFORM_LAND may append further items to _cleared_object_areas,
|
||||
* however it will never erase or re-order existing items.
|
||||
* _cleared_object_areas is a value-type SmallVector, therefore appending items
|
||||
* _cleared_object_areas is a value-type self-resizing vector, therefore appending items
|
||||
* may result in a backing-store re-allocation, which would invalidate the coa pointer.
|
||||
* The index of the coa pointer into the _cleared_object_areas vector remains valid,
|
||||
* and can be used safely after the CMD_TERRAFORM_LAND operation.
|
||||
@@ -851,6 +882,7 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags);
|
||||
}
|
||||
|
||||
Money base_cost = TunnelBridgeClearCost(tile, PR_CLEAR_TUNNEL);
|
||||
uint len = GetTunnelBridgeLength(tile, endtile) + 2; // Don't forget the end tiles.
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -891,7 +923,8 @@ static CommandCost DoClearTunnel(TileIndex tile, DoCommandFlag flags)
|
||||
DoClearSquare(endtile);
|
||||
}
|
||||
}
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_CLEAR_TUNNEL] * len);
|
||||
|
||||
return CommandCost(EXPENSES_CONSTRUCTION, len * base_cost);
|
||||
}
|
||||
|
||||
|
||||
@@ -930,7 +963,7 @@ static CommandCost DoClearBridge(TileIndex tile, DoCommandFlag flags)
|
||||
ChangeTownRating(t, RATING_TUNNEL_BRIDGE_DOWN_STEP, RATING_TUNNEL_BRIDGE_MINIMUM, flags);
|
||||
}
|
||||
|
||||
Money base_cost = (GetTunnelBridgeTransportType(tile) != TRANSPORT_WATER) ? _price[PR_CLEAR_BRIDGE] : _price[PR_CLEAR_AQUEDUCT];
|
||||
Money base_cost = TunnelBridgeClearCost(tile, PR_CLEAR_BRIDGE);
|
||||
uint len = GetTunnelBridgeLength(tile, endtile) + 2; // Don't forget the end tiles.
|
||||
|
||||
if (flags & DC_EXEC) {
|
||||
@@ -1080,8 +1113,8 @@ static void DrawBridgePillars(const PalSpriteID *psid, const TileInfo *ti, Axis
|
||||
GetSlopePixelZOnEdge(ti->tileh, ReverseDiagDir(south_dir), &z_front_north, &z_back_north);
|
||||
|
||||
/* Shared height of pillars */
|
||||
int z_front = max(z_front_north, z_front_south);
|
||||
int z_back = max(z_back_north, z_back_south);
|
||||
int z_front = std::max(z_front_north, z_front_south);
|
||||
int z_back = std::max(z_back_north, z_back_south);
|
||||
|
||||
/* x and y size of bounding-box of pillars */
|
||||
int w = bounding_box_size[axis];
|
||||
@@ -1913,7 +1946,7 @@ static VehicleEnterTileStatus VehicleEnter_TunnelBridge(Vehicle *v, TileIndex ti
|
||||
|
||||
if (v->type == VEH_ROAD) spd *= 2;
|
||||
Vehicle *first = v->First();
|
||||
first->cur_speed = min(first->cur_speed, spd);
|
||||
first->cur_speed = std::min(first->cur_speed, spd);
|
||||
}
|
||||
|
||||
if (vdir == dir) {
|
||||
|
||||
Reference in New Issue
Block a user