summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2018-11-05 22:43:31 +0100
committerErich Eckner <git@eckner.net>2018-11-16 19:11:46 +0100
commit6b519f8b1aac426a281c22660185c50fb2ac409f (patch)
treee06597ee7fdd1451113a4c71991851cb96b86541 /src
parent6644b6b3a42611c8de6c528ae84472e69d89d87f (diff)
downloadopenttd-6b519f8b1aac426a281c22660185c50fb2ac409f.tar.xz
UNDERGROUND_COST_MULTIPLIER new
Diffstat (limited to 'src')
-rw-r--r--src/layer_func.h2
-rw-r--r--src/rail_cmd.cpp22
-rw-r--r--src/road_cmd.cpp6
-rw-r--r--src/station_cmd.cpp10
4 files changed, 21 insertions, 19 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 a0fd968cc..60697b636 100644
--- a/src/rail_cmd.cpp
+++ b/src/rail_cmd.cpp
@@ -531,7 +531,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
/* ...but tram is not required. */
uint num_new_tram_pieces = (tram != ROAD_NONE) ? 2 - CountBits(tram) : 0;
- cost.AddCost((num_new_road_pieces + num_new_tram_pieces) * _price[PR_BUILD_ROAD]);
+ cost.AddCost((num_new_road_pieces + num_new_tram_pieces) * _price[PR_BUILD_ROAD] * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
MakeRoadCrossing(tile, road_owner, tram_owner, _current_company, (track == TRACK_X ? AXIS_Y : AXIS_X), railtype, roadtypes, GetTownIndex(tile));
@@ -590,7 +590,7 @@ CommandCost CmdBuildSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1, u
YapfNotifyTrackLayoutChange(tile, track);
}
- cost.AddCost(RailBuildCost(railtype));
+ cost.AddCost(RailBuildCost(railtype) * UNDERGROUND_COST_MULTIPLIER(tile));
return cost;
}
@@ -634,7 +634,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
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)) {
@@ -667,7 +667,7 @@ CommandCost CmdRemoveSingleRail(TileIndex tile, DoCommandFlag flags, uint32 p1,
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)) {
@@ -980,7 +980,7 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
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(DoCommand(tile, 0, 0, flags, CMD_LANDSCAPE_CLEAR));
@@ -1005,8 +1005,8 @@ CommandCost CmdBuildTrainDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, u
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;
}
@@ -1656,7 +1656,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
InvalidateWindowData(WC_VEHICLE_DEPOT, tile);
InvalidateWindowData(WC_BUILD_VEHICLE, tile);
}
- cost.AddCost(RailConvertCost(type, totype));
+ cost.AddCost(RailConvertCost(type, totype) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
default: // RAIL_TILE_NORMAL, RAIL_TILE_SIGNALS
@@ -1667,7 +1667,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
YapfNotifyTrackLayoutChange(tile, RemoveFirstTrack(&tracks));
}
}
- cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)));
+ cost.AddCost(RailConvertCost(type, totype) * CountBits(GetTrackBits(tile)) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
}
break;
@@ -1729,7 +1729,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
}
- cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype));
+ cost.AddCost((GetTunnelBridgeLength(tile, endtile) + 2) * RailConvertCost(type, totype) * UNDERGROUND_COST_MULTIPLIER(tile));
break;
}
@@ -1739,7 +1739,7 @@ CommandCost CmdConvertRail(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
YapfNotifyTrackLayoutChange(tile, track);
}
- 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 bdc8ce7f3..dce990719 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -255,7 +255,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
}
} else {
assert(IsDriveThroughStopTile(tile));
- cost.AddCost(_price[PR_CLEAR_ROAD] * 2);
+ cost.AddCost(_price[PR_CLEAR_ROAD] * 2 * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
Company *c = Company::GetIfValid(GetRoadOwner(tile, rt));
if (c != NULL) {
@@ -737,7 +737,7 @@ do_clear:;
/* Count pieces */
CountBits(pieces);
- cost.AddCost(num_pieces * _price[PR_BUILD_ROAD]);
+ cost.AddCost(num_pieces * _price[PR_BUILD_ROAD] * UNDERGROUND_COST_MULTIPLIER(tile));
if (flags & DC_EXEC) {
switch (GetTileType(tile)) {
@@ -1046,7 +1046,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
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 fa35b2fdf..5e3f6c04b 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -760,7 +760,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. */
@@ -989,7 +989,7 @@ static CommandCost CheckFlatLandRoadStop(TileArea tile_area, DoCommandFlag flags
}
uint roadbits_to_build = CountBits(rts) * 2 - num_roadbits;
- cost.AddCost(_price[PR_BUILD_ROAD] * roadbits_to_build);
+ cost.AddCost(_price[PR_BUILD_ROAD] * roadbits_to_build * UNDERGROUND_COST_MULTIPLIER(cur_tile));
}
}
@@ -1242,8 +1242,8 @@ CommandCost CmdBuildRailStation(TileIndex tile_org, DoCommandFlag flags, uint32
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 = NULL;
ret = FindJoiningStation(est, station_to_join, adjacent, new_location, &st);
@@ -1513,7 +1513,7 @@ CommandCost RemoveFromRailBaseStation(TileArea ta, SmallVector<T *, 4> &affected
}
/* 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