diff --git a/contributors.md b/contributors.md index e43dcf1044..6418274a39 100644 --- a/contributors.md +++ b/contributors.md @@ -195,6 +195,7 @@ The following people are not part of the development team, but have been contrib * Hoby R. (hobyr) * Huu Kim Nguyen (CoderUndefined) * Henry Cheng (jazzysoggy) +* Dan Stevens (MajeureX) ## Toolchain * (Balletie) - macOS diff --git a/src/openrct2/network/NetworkBase.cpp b/src/openrct2/network/NetworkBase.cpp index c168570b19..cba0f19f86 100644 --- a/src/openrct2/network/NetworkBase.cpp +++ b/src/openrct2/network/NetworkBase.cpp @@ -42,7 +42,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 "6" +#define NETWORK_STREAM_VERSION "7" #define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION static Peep* _pickup_peep = nullptr; diff --git a/src/openrct2/ride/RideRatings.cpp b/src/openrct2/ride/RideRatings.cpp index 22ad080b25..f849fa1352 100644 --- a/src/openrct2/ride/RideRatings.cpp +++ b/src/openrct2/ride/RideRatings.cpp @@ -739,32 +739,36 @@ static void ride_ratings_calculate(RideRatingUpdateState& state, Ride* ride) #endif #ifdef ENABLE_SCRIPTING - auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); - if (hookEngine.HasSubscriptions(HOOK_TYPE::RIDE_RATINGS_CALCULATE)) + // Only call the 'ride.ratings.calculate' API hook if testing of the ride is complete + if (ride->lifecycle_flags & RIDE_LIFECYCLE_TESTED) { - auto ctx = GetContext()->GetScriptEngine().GetContext(); - auto originalExcitement = ride->excitement; - auto originalIntensity = ride->intensity; - auto originalNausea = ride->nausea; + auto& hookEngine = GetContext()->GetScriptEngine().GetHookEngine(); + if (hookEngine.HasSubscriptions(HOOK_TYPE::RIDE_RATINGS_CALCULATE)) + { + auto ctx = GetContext()->GetScriptEngine().GetContext(); + auto originalExcitement = ride->excitement; + auto originalIntensity = ride->intensity; + auto originalNausea = ride->nausea; - // Create event args object - auto obj = DukObject(ctx); - obj.Set("rideId", ride->id.ToUnderlying()); - obj.Set("excitement", originalExcitement); - obj.Set("intensity", originalIntensity); - obj.Set("nausea", originalNausea); + // Create event args object + auto obj = DukObject(ctx); + obj.Set("rideId", ride->id.ToUnderlying()); + obj.Set("excitement", originalExcitement); + obj.Set("intensity", originalIntensity); + obj.Set("nausea", originalNausea); - // Call the subscriptions - auto e = obj.Take(); - hookEngine.Call(HOOK_TYPE::RIDE_RATINGS_CALCULATE, e, true); + // Call the subscriptions + auto e = obj.Take(); + hookEngine.Call(HOOK_TYPE::RIDE_RATINGS_CALCULATE, e, true); - auto scriptExcitement = AsOrDefault(e["excitement"], static_cast(originalExcitement)); - auto scriptIntensity = AsOrDefault(e["intensity"], static_cast(originalIntensity)); - auto scriptNausea = AsOrDefault(e["nausea"], static_cast(originalNausea)); + auto scriptExcitement = AsOrDefault(e["excitement"], static_cast(originalExcitement)); + auto scriptIntensity = AsOrDefault(e["intensity"], static_cast(originalIntensity)); + auto scriptNausea = AsOrDefault(e["nausea"], static_cast(originalNausea)); - ride->excitement = std::clamp(scriptExcitement, 0, INT16_MAX); - ride->intensity = std::clamp(scriptIntensity, 0, INT16_MAX); - ride->nausea = std::clamp(scriptNausea, 0, INT16_MAX); + ride->excitement = std::clamp(scriptExcitement, 0, INT16_MAX); + ride->intensity = std::clamp(scriptIntensity, 0, INT16_MAX); + ride->nausea = std::clamp(scriptNausea, 0, INT16_MAX); + } } #endif }