From 2a6da319b2578944b2ac6b1a267bf880e5c4d34c Mon Sep 17 00:00:00 2001 From: Matt Kimber Date: Sun, 7 Feb 2021 15:15:46 +0000 Subject: Fix 0125892: Don't crash when towns upgrade road tiles during expansion (#8651) --- src/road_cmd.cpp | 8 +++----- 1 file 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 */ -- cgit v1.2.3-54-g00ecf