Codechange: Use std::tuple for slope functions with two return values

This commit is contained in:
Michael Lutz
2024-03-08 12:12:41 +01:00
parent 5806c2aba4
commit 8dda387f82
21 changed files with 79 additions and 113 deletions

View File

@@ -34,7 +34,7 @@ byte LowestSnowLine();
void ClearSnowLine();
int GetSlopeZInCorner(Slope tileh, Corner corner);
Slope GetFoundationSlope(TileIndex tile, int *z = nullptr);
std::tuple<Slope, int> GetFoundationSlope(TileIndex tile);
uint GetPartialPixelZ(int x, int y, Slope corners);
int GetSlopePixelZ(int x, int y, bool ground_vehicle = false);
@@ -60,15 +60,12 @@ inline int GetSlopePixelZInCorner(Slope tileh, Corner corner)
* If a tile does not have a foundation, the function returns the same as GetTilePixelSlope.
*
* @param tile The tile of interest.
* @param z returns the z of the foundation slope. (Can be nullptr, if not needed)
* @return The slope on top of the foundation.
* @return The slope on top of the foundation and the z of the foundation.
*/
inline Slope GetFoundationPixelSlope(TileIndex tile, int *z)
inline std::tuple<Slope, int> GetFoundationPixelSlope(TileIndex tile)
{
assert(z != nullptr);
Slope s = GetFoundationSlope(tile, z);
*z *= TILE_HEIGHT;
return s;
auto [s, z] = GetFoundationSlope(tile);
return {s, z * TILE_HEIGHT};
}
/**