|
|
|
@ -163,44 +163,44 @@ Point InverseRemapCoords2(int x, int y, bool clamp_to_map, bool *clamped)
|
|
|
|
|
* @param s The #Slope to modify.
|
|
|
|
|
* @return Increment to the tile Z coordinate.
|
|
|
|
|
*/
|
|
|
|
|
uint ApplyFoundationToSlope(Foundation f, Slope *s)
|
|
|
|
|
uint ApplyFoundationToSlope(Foundation f, Slope &s)
|
|
|
|
|
{
|
|
|
|
|
if (!IsFoundation(f)) return 0;
|
|
|
|
|
|
|
|
|
|
if (IsLeveledFoundation(f)) {
|
|
|
|
|
uint dz = 1 + (IsSteepSlope(*s) ? 1 : 0);
|
|
|
|
|
*s = SLOPE_FLAT;
|
|
|
|
|
uint dz = 1 + (IsSteepSlope(s) ? 1 : 0);
|
|
|
|
|
s = SLOPE_FLAT;
|
|
|
|
|
return dz;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (f != FOUNDATION_STEEP_BOTH && IsNonContinuousFoundation(f)) {
|
|
|
|
|
*s = HalftileSlope(*s, GetHalftileFoundationCorner(f));
|
|
|
|
|
s = HalftileSlope(s, GetHalftileFoundationCorner(f));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (IsSpecialRailFoundation(f)) {
|
|
|
|
|
*s = SlopeWithThreeCornersRaised(OppositeCorner(GetRailFoundationCorner(f)));
|
|
|
|
|
s = SlopeWithThreeCornersRaised(OppositeCorner(GetRailFoundationCorner(f)));
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
uint dz = IsSteepSlope(*s) ? 1 : 0;
|
|
|
|
|
Corner highest_corner = GetHighestSlopeCorner(*s);
|
|
|
|
|
uint dz = IsSteepSlope(s) ? 1 : 0;
|
|
|
|
|
Corner highest_corner = GetHighestSlopeCorner(s);
|
|
|
|
|
|
|
|
|
|
switch (f) {
|
|
|
|
|
case FOUNDATION_INCLINED_X:
|
|
|
|
|
*s = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? SLOPE_SW : SLOPE_NE);
|
|
|
|
|
s = (((highest_corner == CORNER_W) || (highest_corner == CORNER_S)) ? SLOPE_SW : SLOPE_NE);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FOUNDATION_INCLINED_Y:
|
|
|
|
|
*s = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? SLOPE_SE : SLOPE_NW);
|
|
|
|
|
s = (((highest_corner == CORNER_S) || (highest_corner == CORNER_E)) ? SLOPE_SE : SLOPE_NW);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FOUNDATION_STEEP_LOWER:
|
|
|
|
|
*s = SlopeWithOneCornerRaised(highest_corner);
|
|
|
|
|
s = SlopeWithOneCornerRaised(highest_corner);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case FOUNDATION_STEEP_BOTH:
|
|
|
|
|
*s = HalftileSlope(SlopeWithOneCornerRaised(highest_corner), highest_corner);
|
|
|
|
|
s = HalftileSlope(SlopeWithOneCornerRaised(highest_corner), highest_corner);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
default: NOT_REACHED();
|
|
|
|
@ -347,7 +347,7 @@ int GetSlopeZInCorner(Slope tileh, Corner corner)
|
|
|
|
|
* @param z1 Gets incremented by the height of the first corner of the edge. (near corner wrt. the camera)
|
|
|
|
|
* @param z2 Gets incremented by the height of the second corner of the edge. (far corner wrt. the camera)
|
|
|
|
|
*/
|
|
|
|
|
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
|
|
|
|
|
void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int &z1, int &z2)
|
|
|
|
|
{
|
|
|
|
|
static const Slope corners[4][4] = {
|
|
|
|
|
/* corner | steep slope
|
|
|
|
@ -359,13 +359,13 @@ void GetSlopePixelZOnEdge(Slope tileh, DiagDirection edge, int *z1, int *z2)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int halftile_test = (IsHalftileSlope(tileh) ? SlopeWithOneCornerRaised(GetHalftileSlopeCorner(tileh)) : 0);
|
|
|
|
|
if (halftile_test == corners[edge][0]) *z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side.
|
|
|
|
|
if (halftile_test == corners[edge][1]) *z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side.
|
|
|
|
|
if (halftile_test == corners[edge][0]) z2 += TILE_HEIGHT; // The slope is non-continuous in z2. z2 is on the upper side.
|
|
|
|
|
if (halftile_test == corners[edge][1]) z1 += TILE_HEIGHT; // The slope is non-continuous in z1. z1 is on the upper side.
|
|
|
|
|
|
|
|
|
|
if ((tileh & corners[edge][0]) != 0) *z1 += TILE_HEIGHT; // z1 is raised
|
|
|
|
|
if ((tileh & corners[edge][1]) != 0) *z2 += TILE_HEIGHT; // z2 is raised
|
|
|
|
|
if (RemoveHalftileSlope(tileh) == corners[edge][2]) *z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope
|
|
|
|
|
if (RemoveHalftileSlope(tileh) == corners[edge][3]) *z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope
|
|
|
|
|
if ((tileh & corners[edge][0]) != 0) z1 += TILE_HEIGHT; // z1 is raised
|
|
|
|
|
if ((tileh & corners[edge][1]) != 0) z2 += TILE_HEIGHT; // z2 is raised
|
|
|
|
|
if (RemoveHalftileSlope(tileh) == corners[edge][2]) z1 += TILE_HEIGHT; // z1 is highest corner of a steep slope
|
|
|
|
|
if (RemoveHalftileSlope(tileh) == corners[edge][3]) z2 += TILE_HEIGHT; // z2 is highest corner of a steep slope
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -379,7 +379,7 @@ std::tuple<Slope, int> GetFoundationSlope(TileIndex tile)
|
|
|
|
|
{
|
|
|
|
|
auto [tileh, z] = GetTileSlopeZ(tile);
|
|
|
|
|
Foundation f = _tile_type_procs[GetTileType(tile)]->get_foundation_proc(tile, tileh);
|
|
|
|
|
z += ApplyFoundationToSlope(f, &tileh);
|
|
|
|
|
z += ApplyFoundationToSlope(f, tileh);
|
|
|
|
|
return {tileh, z};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -388,12 +388,12 @@ bool HasFoundationNW(TileIndex tile, Slope slope_here, uint z_here)
|
|
|
|
|
{
|
|
|
|
|
int z_W_here = z_here;
|
|
|
|
|
int z_N_here = z_here;
|
|
|
|
|
GetSlopePixelZOnEdge(slope_here, DIAGDIR_NW, &z_W_here, &z_N_here);
|
|
|
|
|
GetSlopePixelZOnEdge(slope_here, DIAGDIR_NW, z_W_here, z_N_here);
|
|
|
|
|
|
|
|
|
|
auto [slope, z] = GetFoundationPixelSlope(TILE_ADDXY(tile, 0, -1));
|
|
|
|
|
int z_W = z;
|
|
|
|
|
int z_N = z;
|
|
|
|
|
GetSlopePixelZOnEdge(slope, DIAGDIR_SE, &z_W, &z_N);
|
|
|
|
|
GetSlopePixelZOnEdge(slope, DIAGDIR_SE, z_W, z_N);
|
|
|
|
|
|
|
|
|
|
return (z_N_here > z_N) || (z_W_here > z_W);
|
|
|
|
|
}
|
|
|
|
@ -403,12 +403,12 @@ bool HasFoundationNE(TileIndex tile, Slope slope_here, uint z_here)
|
|
|
|
|
{
|
|
|
|
|
int z_E_here = z_here;
|
|
|
|
|
int z_N_here = z_here;
|
|
|
|
|
GetSlopePixelZOnEdge(slope_here, DIAGDIR_NE, &z_E_here, &z_N_here);
|
|
|
|
|
GetSlopePixelZOnEdge(slope_here, DIAGDIR_NE, z_E_here, z_N_here);
|
|
|
|
|
|
|
|
|
|
auto [slope, z] = GetFoundationPixelSlope(TILE_ADDXY(tile, -1, 0));
|
|
|
|
|
int z_E = z;
|
|
|
|
|
int z_N = z;
|
|
|
|
|
GetSlopePixelZOnEdge(slope, DIAGDIR_SW, &z_E, &z_N);
|
|
|
|
|
GetSlopePixelZOnEdge(slope, DIAGDIR_SW, z_E, z_N);
|
|
|
|
|
|
|
|
|
|
return (z_N_here > z_N) || (z_E_here > z_E);
|
|
|
|
|
}
|
|
|
|
@ -451,7 +451,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Corner highest_corner = GetHighestSlopeCorner(ti->tileh);
|
|
|
|
|
ti->z += ApplyPixelFoundationToSlope(f, &ti->tileh);
|
|
|
|
|
ti->z += ApplyPixelFoundationToSlope(f, ti->tileh);
|
|
|
|
|
|
|
|
|
|
if (IsInclinedFoundation(f)) {
|
|
|
|
|
/* inclined foundation */
|
|
|
|
@ -519,7 +519,7 @@ void DrawFoundation(TileInfo *ti, Foundation f)
|
|
|
|
|
);
|
|
|
|
|
OffsetGroundSprite(0, 0);
|
|
|
|
|
}
|
|
|
|
|
ti->z += ApplyPixelFoundationToSlope(f, &ti->tileh);
|
|
|
|
|
ti->z += ApplyPixelFoundationToSlope(f, ti->tileh);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|