summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/economy_type.h4
-rw-r--r--src/road_cmd.cpp23
-rw-r--r--src/station_cmd.cpp8
3 files changed, 24 insertions, 11 deletions
diff --git a/src/economy_type.h b/src/economy_type.h
index 3e9519506..85a1bbe4f 100644
--- a/src/economy_type.h
+++ b/src/economy_type.h
@@ -222,6 +222,10 @@ static const int INVALID_PRICE_MODIFIER = MIN_PRICE_MODIFIER - 1;
static const uint TUNNELBRIDGE_TRACKBIT_FACTOR = 4;
/** Multiplier for how many regular track bits a level crossing counts. */
static const uint LEVELCROSSING_TRACKBIT_FACTOR = 2;
+/** Multiplier for how many regular track bits a road depot counts. */
+static const uint ROAD_DEPOT_TRACKBIT_FACTOR = 2;
+/** Multiplier for how many regular track bits a bay stop counts. */
+static const uint ROAD_STOP_TRACKBIT_FACTOR = 2;
/** Multiplier for how many regular tiles a lock counts. */
static const uint LOCK_DEPOT_TILE_FACTOR = 2;
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index bac6f8e1f..d0104cb99 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -1191,7 +1191,7 @@ CommandCost CmdBuildRoadDepot(TileIndex tile, DoCommandFlag flags, uint32 p1, ui
dep->build_date = _date;
/* A road depot has two road bits. */
- UpdateCompanyRoadInfrastructure(rt, _current_company, 2);
+ UpdateCompanyRoadInfrastructure(rt, _current_company, ROAD_DEPOT_TRACKBIT_FACTOR);
MakeRoadDepot(tile, _current_company, dep->index, dir, rt);
MarkTileDirtyByTile(tile);
@@ -1217,7 +1217,7 @@ static CommandCost RemoveRoadDepot(TileIndex tile, DoCommandFlag flags)
/* A road depot has two road bits. */
RoadType rt = GetRoadTypeRoad(tile);
if (rt == INVALID_ROADTYPE) rt = GetRoadTypeTram(tile);
- c->infrastructure.road[rt] -= 2;
+ c->infrastructure.road[rt] -= ROAD_DEPOT_TRACKBIT_FACTOR;
DirtyCompanyInfrastructureWindows(c->index);
}
@@ -2405,14 +2405,22 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
}
}
- uint num_pieces = CountBits(GetAnyRoadBits(tile, rtt));;
+ uint num_pieces = CountBits(GetAnyRoadBits(tile, rtt));
+ if (tt == MP_STATION && IsStandardRoadStopTile(tile)) {
+ num_pieces *= ROAD_STOP_TRACKBIT_FACTOR;
+ } else if (tt == MP_ROAD && IsRoadDepot(tile)) {
+ num_pieces *= ROAD_DEPOT_TRACKBIT_FACTOR;
+ }
+
found_convertible_road = true;
cost.AddCost(num_pieces * RoadConvertCost(from_type, to_type));
if (flags & DC_EXEC) { // we can safely convert, too
/* Update the company infrastructure counters. */
- if (!IsRoadStopTile(tile) && owner == _current_company) {
- ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type);
+ if (owner == _current_company) {
+ Company * c = Company::Get(_current_company);
+ c->infrastructure.road[from_type] -= num_pieces;
+ c->infrastructure.road[to_type] += num_pieces;
}
/* Perform the conversion */
@@ -2460,8 +2468,9 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (flags & DC_EXEC) {
/* Update the company infrastructure counters. */
if (owner == _current_company) {
- ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type);
- ConvertRoadTypeOwner(endtile, num_pieces, owner, from_type, to_type);
+ /* Each piece should be counted TUNNELBRIDGE_TRACKBIT_FACTOR times
+ * for the infrastructure counters (cause of #8297). */
+ ConvertRoadTypeOwner(tile, num_pieces * TUNNELBRIDGE_TRACKBIT_FACTOR, owner, from_type, to_type);
SetTunnelBridgeOwner(tile, endtile, _current_company);
}
diff --git a/src/station_cmd.cpp b/src/station_cmd.cpp
index 64a7adca8..735edd06f 100644
--- a/src/station_cmd.cpp
+++ b/src/station_cmd.cpp
@@ -1933,8 +1933,8 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
if (tram_rt == INVALID_ROADTYPE && RoadTypeIsTram(rt)) tram_rt = rt;
- UpdateCompanyRoadInfrastructure(road_rt, road_owner, 2);
- UpdateCompanyRoadInfrastructure(tram_rt, tram_owner, 2);
+ UpdateCompanyRoadInfrastructure(road_rt, road_owner, ROAD_STOP_TRACKBIT_FACTOR);
+ UpdateCompanyRoadInfrastructure(tram_rt, tram_owner, ROAD_STOP_TRACKBIT_FACTOR);
MakeDriveThroughRoadStop(cur_tile, st->owner, road_owner, tram_owner, st->index, rs_type, road_rt, tram_rt, axis);
road_stop->MakeDriveThrough();
@@ -1942,7 +1942,7 @@ CommandCost CmdBuildRoadStop(TileIndex tile, DoCommandFlag flags, uint32 p1, uin
if (road_rt == INVALID_ROADTYPE && RoadTypeIsRoad(rt)) road_rt = rt;
if (tram_rt == INVALID_ROADTYPE && RoadTypeIsTram(rt)) tram_rt = rt;
/* Non-drive-through stop never overbuild and always count as two road bits. */
- Company::Get(st->owner)->infrastructure.road[rt] += 2;
+ Company::Get(st->owner)->infrastructure.road[rt] += ROAD_STOP_TRACKBIT_FACTOR;
MakeRoadStop(cur_tile, st->owner, st->index, rs_type, road_rt, tram_rt, ddir);
}
Company::Get(st->owner)->infrastructure.station++;
@@ -2031,7 +2031,7 @@ static CommandCost RemoveRoadStop(TileIndex tile, DoCommandFlag flags)
/* Update company infrastructure counts. */
FOR_ALL_ROADTRAMTYPES(rtt) {
RoadType rt = GetRoadType(tile, rtt);
- UpdateCompanyRoadInfrastructure(rt, GetRoadOwner(tile, rtt), -2);
+ UpdateCompanyRoadInfrastructure(rt, GetRoadOwner(tile, rtt), -ROAD_STOP_TRACKBIT_FACTOR);
}
Company::Get(st->owner)->infrastructure.station--;