Codechange: use smart pointers when cloning iterators
This commit is contained in:
@@ -2400,7 +2400,7 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
CommandCost error = CommandCost((rtt == RTT_TRAM) ? STR_ERROR_NO_SUITABLE_TRAMWAY : STR_ERROR_NO_SUITABLE_ROAD); // by default, there is no road to convert.
|
||||
bool found_convertible_road = false; // whether we actually did convert any road/tram (see bug #7633)
|
||||
|
||||
TileIterator *iter = new OrthogonalTileIterator(area_start, area_end);
|
||||
std::unique_ptr<TileIterator> iter = std::make_unique<OrthogonalTileIterator>(area_start, area_end);
|
||||
for (; (tile = *iter) != INVALID_TILE; ++(*iter)) {
|
||||
/* Is road present on tile? */
|
||||
if (!MayHaveRoad(tile)) continue;
|
||||
@@ -2556,7 +2556,6 @@ CommandCost CmdConvertRoad(DoCommandFlag flags, TileIndex tile, TileIndex area_s
|
||||
}
|
||||
}
|
||||
|
||||
delete iter;
|
||||
return found_convertible_road ? cost : error;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user