summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-11-05 22:43:31 +0100
committerErich Eckner <git@eckner.net>2022-01-16 21:58:15 +0100
commit795c8b2f9c2d5b6a7ccf0504f62d8426a8bc79ec (patch)
tree41abe6fdc04cd8f12f6309891a373fefe310e1e2
parentac2a6b19fc3d83e16d200fdddff2c965bb7d52b3 (diff)
downloadopenttd-795c8b2f9c2d5b6a7ccf0504f62d8426a8bc79ec.tar.xz
UNDERGROUND_COST_MULTIPLIER new
-rw-r--r--src/layer_func.h2
-rw-r--r--src/rail_cmd.cpp24
-rw-r--r--src/road_cmd.cpp6
-rw-r--r--src/station_cmd.cpp10
4 files changed, 22 insertions, 20 deletions
diff --git a/src/layer_func.h b/src/layer_func.h
index 250e79a3d..4cdeeb8c8 100644
--- a/src/layer_func.h
+++ b/src/layer_func.h
@@ -24,6 +24,8 @@ void InstallLayerSystem(uint size_x, uint size_y, uint layer_count);
* (в будущем слои могут менять высоты -- в пределах соседей) */
void FixUndergroundHeights();
+#define UNDERGROUND_COST_MULTIPLIER(tile) (IsUnderground(tile) ? 100 * (1 + (TileHeight(TopTile(tile))-TileHeight(tile))*(TileHeight(TopTile(tile))-TileHeight(tile))) : 1)
+
#define FOR_ALL_LAYERS(var) for (uint var = 0; var < LayerCount(); var++)
diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp
index 88f4adb0f..0197dd6a4 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -538,12 +538,12 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
uint num_new_road_pieces = (road != ROAD_NONE) ? 2 - CountBits(road) : 0;
if (num_new_road_pieces > 0) {
- cost.AddCost(num_new_road_pieces * RoadBuildCost(roadtype_road));
+ cost.AddCost(num_new_road_pieces * RoadBuildCost(roadtype_road) * UNDERGROUND_COST_MULTIPLIER(tile));
}
uint num_new_tram_pieces = (tram != ROAD_NONE) ? 2 - CountBits(tram) : 0;
if (num_new_tram_pieces > 0) {
- cost.AddCost(num_new_tram_pieces * RoadBuildCost(roadtype_tram));
+ cost.AddCost(num_new_tram_pieces * RoadBuildCost(roadtype_tram) * UNDERGROUND_COST_MULTIPLIER(tile));
}
if (flags & DC_EXEC) {
@@ -606,7 +606,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai
YapfNotifyTrackLayoutChange(tile, track);
}
- cost.AddCost(RailBuildCost(railtype));
+ cost.AddCost(RailBuildCost(railtype) * UNDERGROUND_COST_MULTIPLIER(tile));
return cost;
}
@@ -647,7 +647,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track
if (ret.Failed()) return ret;
}
- cost.AddCost(RailClearCost(GetRailType(tile)));
+ cost.AddCost(RailClearCost(GetRailType(tile)) * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
if (HasReservedTracks(tile, trackbit)) {
@@ -681,7 +681,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track
if ((present & trackbit) == 0) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK);
if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true;
- cost.AddCost(RailClearCost(GetRailType(tile)));
+ cost.AddCost(RailClearCost(GetRailType(tile)) * UNDERGROUND_COST_MULTIPLIER(tile));
/* Charge extra to remove signals on the track, if they are there */
if (HasSignalOnTrack(tile, track)) {
@@ -983,7 +983,7 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai
if (!_settings_game.construction.build_on_slopes || !CanBuildDepotByTileh(dir, tileh)) {
return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
}
- cost.AddCost(_price[PR_BUILD_FOUNDATION]);
+ cost.AddCost(_price[PR_BUILD_FOUNDATION] * UNDERGROUND_COST_MULTIPLIER(tile));
}
cost.AddCost(Command<CMD_LANDSCAPE_CLEAR>::Do(flags, tile));
@@ -1008,8 +1008,8 @@ CommandCost CmdBuildTrainDepot(DoCommandFlag flags, TileIndex tile, RailType rai
YapfNotifyTrackLayoutChange(tile, DiagDirToDiagTrack(dir));
}
- cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN]);
- cost.AddCost(RailBuildCost(railtype));
+ cost.AddCost(_price[PR_BUILD_DEPOT_TRAIN] * UNDERGROUND_COST_MULTIPLIER(tile));
+ cost.AddCost(RailBuildCost(railtype) * UNDERGROUND_COST_MULTIPLIER(tile));
return cost;
}
@@ -1641,7 +1641,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
}
found_convertible_track = true;
- cost.AddCost(RailConvertCost(type, totype));
+ cost.AddCost(RailConvertCost(type, totype) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
default: // RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS
@@ -1653,7 +1653,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
}
}
found_convertible_track = true;
- cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
+ cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
}
break;
@@ -1716,7 +1716,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
}
found_convertible_track = true;
- cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype));
+ cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
}
@@ -1727,7 +1727,7 @@ CommandCost CmdConvertRail(DoCommandFlag flags, TileIndex tile, TileIndex area_s
}
found_convertible_track = true;
- cost.AddCost(RailConvertCost(type, totype));
+ cost.AddCost(RailConvertCost(type, totype) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
}
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index 070148111..01740d15b 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -405,7 +405,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
}
} else {
assert(IsDriveThroughStopTile(tile));
- cost.AddCost(RoadClearCost(existing_rt) * 2);
+ cost.AddCost(RoadClearCost(existing_rt) * 2 * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
/* A full diagonal road tile has two road bits. */
UpdateCompanyRoadInfrastructure(existing_rt, GetRoadOwner(tile, rtt), -2);
@@ -879,7 +879,7 @@ do_clear:;
/* Count pieces */
CountBits(pieces);
- cost.AddCost(num_pieces * RoadBuildCost(rt));
+ cost.AddCost(num_pieces * RoadBuildCost(rt) * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
switch (GetTileType(tile)) {
@@ -1170,7 +1170,7 @@ CommandCost CmdBuildRoadDepot(DoCommandFlag flags, TileIndex tile, RoadType rt,
MarkTileDirtyByTile(tile);
MakeDefaultName(dep);
}
- cost.AddCost(_price[PR_BUILD_DEPOT_ROAD]);
+ cost.AddCost(_price[PR_BUILD_DEPOT_ROAD] * UNDERGROUND_COST_MULTIPLIER(tile));
return cost;
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index d833b0ef7..4d76eac82 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -819,7 +819,7 @@ CommandCost CheckBuildableTile(TileIndex tile, uint invalid_dirs, int &allowed_z
return_cmd_error(STR_ERROR_FLAT_LAND_REQUIRED);
}
}
- cost.AddCost(_price[PR_BUILD_FOUNDATION]);
+ cost.AddCost(_price[PR_BUILD_FOUNDATION] * UNDERGROUND_COST_MULTIPLIER(tile));
}
/* The level of this tile must be equal to allowed_z. */
@@ -1057,7 +1057,7 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
ret = Command<CMD_LANDSCAPE_CLEAR>::Do(flags, cur_tile);
if (ret.Failed()) return ret;
cost.AddCost(ret);
- cost.AddCost(RoadBuildCost(rt) * 2);
+ cost.AddCost(RoadBuildCost(rt) * 2 * UNDERGROUND_COST_MULTIPLIER(cur_tile));
}
}
}
@@ -1297,8 +1297,8 @@ CommandCost CmdBuildRailStation(DoCommandFlag flags, TileIndex tile_org, RailTyp
CommandCost cost = CheckFlatLandRailStation(new_location, flags, axis, &est, rt, affected_vehicles, spec_class, spec_index, plat_len, numtracks);
if (cost.Failed()) return cost;
/* Add construction expenses. */
- cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len);
- cost.AddCost(numtracks * plat_len * RailBuildCost(rt));
+ cost.AddCost((numtracks * _price[PR_BUILD_STATION_RAIL] + _price[PR_BUILD_STATION_RAIL_LENGTH]) * plat_len * UNDERGROUND_COST_MULTIPLIER(tile_org));
+ cost.AddCost(numtracks * plat_len * RailBuildCost(rt) * UNDERGROUND_COST_MULTIPLIER(tile_org));
Station *st = nullptr;
ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
@@ -1581,7 +1581,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, std::vector<T *> &affected_st
}
/* If we reached here, the tile is valid so increase the quantity of tiles we will remove */
- quantity++;
+ quantity += UNDERGROUND_COST_MULTIPLIER(tile);
if (keep_rail || IsStationTileBlocked(tile)) {
/* Don't refund the 'steel' of the track when we keep the