diff --git a/contributors.md b/contributors.md index d00eaef55b..f74586273a 100644 --- a/contributors.md +++ b/contributors.md @@ -186,6 +186,7 @@ The following people are not part of the development team, but have been contrib * Rik Smeets (rik-smeets) * Charles Machalow (csm10495) * Alexander Czarnecki (alcz/zuczek4793) +* Lawrence De Mol (lawrencedemol) ## Toolchain * (Balletie) - macOS diff --git a/distribution/changelog.txt b/distribution/changelog.txt index c87689564e..b509de56ce 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -63,6 +63,7 @@ - Fix: [#16162] Go Karts speeds are not correctly randomised, they only go very fast or very slow. - Fix: [#16188] Medium-size banked turns on the Twister and Vertical Roller Coaster have incorrect support placement (partly original bug). - Fix: [#16264, #16572] Placing saved track design crashes game. +- Fix [#16308] Crash when trying to place down a ride on Android. - Fix: [#16327] Crash on malformed network packet. - Fix: [#16449] [Plugin] Viewport doesn't hide when switching tabs. - Fix: [#16450] Banner style not copied when using tile inspector. diff --git a/src/openrct2/actions/GameActionResult.h b/src/openrct2/actions/GameActionResult.h index e79eeb6811..1dce6e8b78 100644 --- a/src/openrct2/actions/GameActionResult.h +++ b/src/openrct2/actions/GameActionResult.h @@ -70,7 +70,15 @@ namespace GameActions CoordsXYZ Position = { LOCATION_NULL, LOCATION_NULL, LOCATION_NULL }; money32 Cost = 0; ExpenditureType Expenditure = ExpenditureType::Count; + +#ifdef __ANDROID__ + // Any_cast throws a bad_any_cast exception on Android + // To avoid this in the Android release, a shared void pointer is used to store the result data. + std::shared_ptr ResultData; +#else + // Other platforms still use Any as this provides type checks std::any ResultData; +#endif Result() = default; Result(GameActions::Status error, rct_string_id title, rct_string_id message, uint8_t* args = nullptr); @@ -82,13 +90,22 @@ namespace GameActions // is still just uint32_t, this guarantees the data is associated with the correct type. template void SetData(const T&& data) { +#ifdef __ANDROID__ + ResultData = std::make_shared(data); +#else ResultData = std::forward(data); +#endif } - // This function will throw std::bad_any_cast if the type mismatches. template T GetData() const { +#ifdef __ANDROID__ + return *static_cast(ResultData.get()); + ; +#else + // This function will throw std::bad_any_cast if the type mismatches. return std::any_cast(ResultData); +#endif } };