From c76378bc8bf5e63ef50b229726ecfcbe57f54ca2 Mon Sep 17 00:00:00 2001 From: aw20368 Date: Sun, 16 Jun 2019 08:52:54 -0400 Subject: [PATCH] Fix #8064 Ride construction errors shown as (undefined string) The search for height to build track ended at a half-height, leading to (undefined string) error. Changed to always end at whole height and search as high as possible. --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/RideConstruction.cpp | 25 ++++++++++---------- src/openrct2/network/Network.cpp | 2 +- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index 593d56ac8a..3dd3d800f1 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -98,6 +98,7 @@ - Fix: [#7700, #8079, #8969] Crash when unloading buggy custom rides. - Fix: [#7829] Rotated information kiosk can cause 'unreachable' messages. - Fix: [#7878] Scroll shortcut keys ignore SHIFT/CTRL/ALT modifiers. +- Fix: [#8064] Ride construction errors shown as (undefined string) - Fix: [#8219] Faulty folder recreation in "save" folder. - Fix: [#8480, #8535] Crash when mirroring track design. - Fix: [#8507] Incorrect change in vehicle rolling direction. diff --git a/src/openrct2-ui/windows/RideConstruction.cpp b/src/openrct2-ui/windows/RideConstruction.cpp index bd70b82642..57935d4076 100644 --- a/src/openrct2-ui/windows/RideConstruction.cpp +++ b/src/openrct2-ui/windows/RideConstruction.cpp @@ -3591,7 +3591,9 @@ void ride_construction_toolupdate_construct(ScreenCoordsXY screenCoords) return; } - for (;;) + // search for appropriate z value for ghost, up to max ride height (2^12 - 16) + int numAttempts = (z <= 2032 ? (2032 - z) / 8 + 1 : 2); + for (int zAttempts = numAttempts; zAttempts > 1; zAttempts--) { window_ride_construction_update_state( &trackType, &trackDirection, &rideIndex, &liftHillAndAlternativeState, &mapCoords->x, &mapCoords->y, &z, nullptr); @@ -3600,16 +3602,11 @@ void ride_construction_toolupdate_construct(ScreenCoordsXY screenCoords) if (_currentTrackPrice != MONEY32_UNDEFINED) break; - bx--; - if (bx == 0) - break; - _currentTrackBegin.z -= 8; if (_currentTrackBegin.z < 0) break; - if (bx >= 0) - _currentTrackBegin.z += 16; + _currentTrackBegin.z += 16; } if (_autoRotatingShop && _rideConstructionState == RIDE_CONSTRUCTION_STATE_PLACE @@ -3858,7 +3855,10 @@ void ride_construction_tooldown_construct(ScreenCoordsXY screenCoords) return; } - for (int32_t zAttempts = 41; zAttempts >= 0; zAttempts--) + // search for appropriate z value, up to max ride height (2^12 - 16) + int numAttempts = (z <= 2032 ? (2032 - z) / 8 + 1 : 2); + + for (int32_t zAttempts = numAttempts; zAttempts > 0; zAttempts--) { _rideConstructionState = RIDE_CONSTRUCTION_STATE_FRONT; _currentTrackBegin.x = mapCoords.x; @@ -3881,7 +3881,8 @@ void ride_construction_tooldown_construct(ScreenCoordsXY screenCoords) z -= 8; if (errorText == STR_NOT_ENOUGH_CASH_REQUIRES || errorText == STR_CAN_ONLY_BUILD_THIS_UNDERWATER || errorText == STR_CAN_ONLY_BUILD_THIS_ON_WATER || errorText == STR_CAN_ONLY_BUILD_THIS_ABOVE_GROUND - || errorText == STR_TOO_HIGH_FOR_SUPPORTS || zAttempts == 0 || z < 0) + || errorText == STR_TOO_HIGH_FOR_SUPPORTS || errorText == STR_TOO_HIGH + || errorText == STR_LOCAL_AUTHORITY_WONT_ALLOW_CONSTRUCTION_ABOVE_TREE_HEIGHT || zAttempts == 1 || z < 0) { int32_t saveTrackDirection = _currentTrackPieceDirection; int32_t saveCurrentTrackCurve = _currentTrackCurve; @@ -3906,10 +3907,8 @@ void ride_construction_tooldown_construct(ScreenCoordsXY screenCoords) audio_play_sound(SoundId::Error, 0, state->position.x); break; } - else if (zAttempts >= 0) - { - z += 16; - } + + z += 16; } else { diff --git a/src/openrct2/network/Network.cpp b/src/openrct2/network/Network.cpp index 0fc18d1d49..df2bca971c 100644 --- a/src/openrct2/network/Network.cpp +++ b/src/openrct2/network/Network.cpp @@ -31,7 +31,7 @@ // This string specifies which version of network stream current build uses. // It is used for making sure only compatible builds get connected, even within // single OpenRCT2 version. -#define NETWORK_STREAM_VERSION "15" +#define NETWORK_STREAM_VERSION "16" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr;