diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index 57935d4076..2c9406bba4 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3591,8 +3591,8 @@ void ride_construction_toolupdate_construct(ScreenCoordsXY screenCoords) return; } - // search for appropriate z value for ghost, up to max ride height (2^12 - 16) - int numAttempts = (z <= 2032 ? (2032 - z) / 8 + 1 : 2); + // search for appropriate z value for ghost, up to max ride height + int numAttempts = (z <= (8 * MAX_TRACK_HEIGHT) ? MAX_TRACK_HEIGHT - (z / 8) + 1 : 2); for (int zAttempts = numAttempts; zAttempts > 1; zAttempts--) { window_ride_construction_update_state( @@ -3855,8 +3855,8 @@ void ride_construction_tooldown_construct(ScreenCoordsXY screenCoords) return; } - // search for appropriate z value, up to max ride height (2^12 - 16) - int numAttempts = (z <= 2032 ? (2032 - z) / 8 + 1 : 2); + // search for z value to build at, up to max ride height + int numAttempts = (z <= (8 * MAX_TRACK_HEIGHT) ? MAX_TRACK_HEIGHT - (z / 8) + 1 : 2); for (int32_t zAttempts = numAttempts; zAttempts > 0; zAttempts--) { diff --git a/src/openrct2/actions/TrackPlaceAction.hpp b/src/openrct2/actions/TrackPlaceAction.hpp index 4d97ad7ba2..3dfaa88e51 100644 --- a/src/openrct2/actions/TrackPlaceAction.hpp +++ b/src/openrct2/actions/TrackPlaceAction.hpp @@ -224,7 +224,7 @@ public: clearanceZ = (clearanceZ / 8) + baseZ; - if (clearanceZ >= 255) + if (clearanceZ > MAX_TRACK_HEIGHT) { return std::make_unique(GA_ERROR::INVALID_PARAMETERS, STR_TOO_HIGH); } diff --git a/src/openrct2/ride/Track.h b/src/openrct2/ride/Track.h index e2a323acb4..2055d95957 100644 --- a/src/openrct2/ride/Track.h +++ b/src/openrct2/ride/Track.h @@ -78,6 +78,7 @@ enum }; #define MAX_STATION_PLATFORM_LENGTH 32 +constexpr uint16_t const MAX_TRACK_HEIGHT = 254; enum {