diff options
author | Matt Kimber <mattkimber@users.noreply.github.com> | 2021-02-07 15:15:46 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-07 16:15:46 +0100 |
commit | 2a6da319b2578944b2ac6b1a267bf880e5c4d34c (patch) | |
tree | 98efde96526c0834628bd83f7de1fdd46ab31bdb | |
parent | 9322b40df1bf0987a440404fbb2c72dfb4410ba3 (diff) | |
download | openttd-2a6da319b2578944b2ac6b1a267bf880e5c4d34c.tar.xz |
Fix 0125892: Don't crash when towns upgrade road tiles during expansion (#8651)
-rw-r--r-- | src/road_cmd.cpp | 8 |
1 files changed, 3 insertions, 5 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index c94beb0b1..b47641689 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -2291,7 +2291,7 @@ static bool CanConvertUnownedRoadType(Owner owner, RoadTramType rtt) } /** - * Convert the ownership of the RoadType of the tile if applyable + * Convert the ownership of the RoadType of the tile if applicable * @param tile the tile of which convert ownership * @param num_pieces the count of the roadbits to assign to the new owner * @param owner the current owner of the RoadType @@ -2428,11 +2428,9 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3 cost.AddCost(num_pieces * RoadConvertCost(from_type, to_type)); if (flags & DC_EXEC) { // we can safely convert, too - /* Update the company infrastructure counters. */ + /* Call ConvertRoadTypeOwner() to update the company infrastructure counters. */ if (owner == _current_company) { - Company * c = Company::Get(_current_company); - c->infrastructure.road[from_type] -= num_pieces; - c->infrastructure.road[to_type] += num_pieces; + ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type); } /* Perform the conversion */ |