Codechange: pass "ground vehicle" to GetTileSlopeZ since for tunnel/bridges there are two states
Previously it checked the position in non-driving direction to "guess" whether a ground vehicle was using the function, so on tunnels/bridges it could either return the Z of the (virtual) ground compared to the Z of the path the vehicle would take.
This commit is contained in:
@@ -134,7 +134,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
|
||||
*/
|
||||
inline void UpdateZPositionAndInclination()
|
||||
{
|
||||
this->z_pos = GetSlopePixelZ(this->x_pos, this->y_pos);
|
||||
this->z_pos = GetSlopePixelZ(this->x_pos, this->y_pos, true);
|
||||
ClrBit(this->gv_flags, GVF_GOINGUP_BIT);
|
||||
ClrBit(this->gv_flags, GVF_GOINGDOWN_BIT);
|
||||
|
||||
@@ -143,7 +143,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
|
||||
* direction it is sloped, we get the 'z' at the center of
|
||||
* the tile (middle_z) and the edge of the tile (old_z),
|
||||
* which we then can compare. */
|
||||
int middle_z = GetSlopePixelZ((this->x_pos & ~TILE_UNIT_MASK) | (TILE_SIZE / 2), (this->y_pos & ~TILE_UNIT_MASK) | (TILE_SIZE / 2));
|
||||
int middle_z = GetSlopePixelZ((this->x_pos & ~TILE_UNIT_MASK) | (TILE_SIZE / 2), (this->y_pos & ~TILE_UNIT_MASK) | (TILE_SIZE / 2), true);
|
||||
|
||||
if (middle_z != this->z_pos) {
|
||||
SetBit(this->gv_flags, (middle_z > this->z_pos) ? GVF_GOINGUP_BIT : GVF_GOINGDOWN_BIT);
|
||||
@@ -200,7 +200,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
|
||||
if (HasBit(this->gv_flags, GVF_GOINGUP_BIT) || HasBit(this->gv_flags, GVF_GOINGDOWN_BIT)) {
|
||||
if (T::From(this)->HasToUseGetSlopePixelZ()) {
|
||||
/* In some cases, we have to use GetSlopePixelZ() */
|
||||
this->z_pos = GetSlopePixelZ(this->x_pos, this->y_pos);
|
||||
this->z_pos = GetSlopePixelZ(this->x_pos, this->y_pos, true);
|
||||
return;
|
||||
}
|
||||
/* DirToDiagDir() is a simple right shift */
|
||||
@@ -220,7 +220,7 @@ struct GroundVehicle : public SpecializedVehicle<T, Type> {
|
||||
this->z_pos += HasBit(this->gv_flags, GVF_GOINGUP_BIT) ? d : -d;
|
||||
}
|
||||
|
||||
assert(this->z_pos == GetSlopePixelZ(this->x_pos, this->y_pos));
|
||||
assert(this->z_pos == GetSlopePixelZ(this->x_pos, this->y_pos, true));
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user