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

@@ -199,8 +199,7 @@
{
if (!::IsValidTile(tile) || !::IsValidCorner((::Corner)corner)) return -1;
int z;
::Slope slope = ::GetTileSlope(tile, &z);
auto [slope, z] = ::GetTileSlopeZ(tile);
return (z + ::GetSlopeZInCorner(slope, (::Corner)corner));
}

View File

@@ -31,8 +31,7 @@
/* If it's a tunnel already, take the easy way out! */
if (IsTunnelTile(tile)) return ::GetOtherTunnelEnd(tile);
int start_z;
Slope start_tileh = ::GetTileSlope(tile, &start_z);
auto [start_tileh, start_z] = ::GetTileSlopeZ(tile);
DiagDirection direction = ::GetInclinedSlopeDirection(start_tileh);
if (direction == INVALID_DIAGDIR) return INVALID_TILE;
@@ -42,7 +41,7 @@
tile += delta;
if (!::IsValidTile(tile)) return INVALID_TILE;
::GetTileSlope(tile, &end_z);
std::tie(std::ignore, end_z) = ::GetTileSlopeZ(tile);
} while (start_z != end_z);
return tile;