Public roads: Handle non-trivial existing foundations

This commit is contained in:
Jonathan G Rennison
2023-02-25 22:12:31 +00:00
parent 2d1b3fb6e7
commit ff189e44e4
3 changed files with 64 additions and 18 deletions

View File

@@ -431,6 +431,14 @@ void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
if (RemoveHalftileSlope(tileh) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope
}
Slope GetFoundationSlopeFromTileSlope(TileIndex tile, Slope tileh, int *z)
{
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh);
uint z_inc = ApplyFoundationToSlope(f, &tileh);
if (z != nullptr) *z += z_inc;
return tileh;
}
/**
* Get slope of a tile on top of a (possible) foundation
* If a tile does not have a foundation, the function returns the same as GetTileSlope.
@@ -442,10 +450,7 @@ void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
Slope GetFoundationSlope(TileIndex tile, int *z)
{
Slope tileh = GetTileSlope(tile, z);
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh);
uint z_inc = ApplyFoundationToSlope(f, &tileh);
if (z != nullptr) *z += z_inc;
return tileh;
return GetFoundationSlopeFromTileSlope(tile, tileh, z);
}