Changeset - r26744:108afc18327b
[Not reviewed]
master
0 5 0
Rubidium - 23 months ago 2023-01-13 16:54:53
rubidium@openttd.org
Codechange: use smart pointers when cloning iterators
5 files changed with 12 insertions and 13 deletions:
0 comments (0 inline, 0 general)
src/bitmap_type.h
Show inline comments
 
@@ -126,9 +126,9 @@ public:
 
		return *this;
 
	}
 

	
 
	virtual TileIterator *Clone() const
 
	virtual std::unique_ptr<TileIterator> Clone() const
 
	{
 
		return new BitmapTileIterator(*this);
 
		return std::make_unique<BitmapTileIterator>(*this);
 
	}
 
};
 

	
src/newgrf_airport.h
Show inline comments
 
@@ -58,9 +58,9 @@ public:
 
		return this->att->gfx;
 
	}
 

	
 
	virtual AirportTileTableIterator *Clone() const
 
	virtual std::unique_ptr<TileIterator> Clone() const
 
	{
 
		return new AirportTileTableIterator(*this);
 
		return std::make_unique<AirportTileTableIterator>(*this);
 
	}
 
};
 

	
src/road_cmd.cpp
Show inline comments
 
@@ -2400,7 +2400,7 @@ CommandCost CmdConvertRoad(DoCommandFlag
 
	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
 
		}
 
	}
 

	
 
	delete iter;
 
	return found_convertible_road ? cost : error;
 
}
 

	
src/station_base.h
Show inline comments
 
@@ -555,9 +555,9 @@ public:
 
		return *this;
 
	}
 

	
 
	virtual TileIterator *Clone() const
 
	virtual std::unique_ptr<TileIterator> Clone() const
 
	{
 
		return new AirportTileIterator(*this);
 
		return std::make_unique<AirportTileIterator>(*this);
 
	}
 
};
 

	
src/tilearea_type.h
Show inline comments
 
@@ -146,7 +146,7 @@ public:
 
	/**
 
	 * Allocate a new iterator that is a copy of this one.
 
	 */
 
	virtual TileIterator *Clone() const = 0;
 
	virtual std::unique_ptr<TileIterator> Clone() const = 0;
 

	
 
	/**
 
	 * Equality comparison.
 
@@ -225,9 +225,9 @@ public:
 
		return *this;
 
	}
 

	
 
	virtual TileIterator *Clone() const
 
	virtual std::unique_ptr<TileIterator> Clone() const
 
	{
 
		return new OrthogonalTileIterator(*this);
 
		return std::make_unique<OrthogonalTileIterator>(*this);
 
	}
 
};
 

	
 
@@ -264,9 +264,9 @@ public:
 

	
 
	TileIterator& operator ++();
 

	
 
	virtual TileIterator *Clone() const
 
	virtual std::unique_ptr<TileIterator> Clone() const
 
	{
 
		return new DiagonalTileIterator(*this);
 
		return std::make_unique<DiagonalTileIterator>(*this);
 
	}
 
};
 

	
0 comments (0 inline, 0 general)