From ab86d195104b952e878fb85e5dc5b31281b45c2d Mon Sep 17 00:00:00 2001 From: tupaschoal Date: Mon, 28 Mar 2022 20:40:53 +0200 Subject: [PATCH] Apply review requests --- src/openrct2/actions/GameActionResult.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/openrct2/actions/GameActionResult.h b/src/openrct2/actions/GameActionResult.h index 29b4802602..1dce6e8b78 100644 --- a/src/openrct2/actions/GameActionResult.h +++ b/src/openrct2/actions/GameActionResult.h @@ -71,11 +71,14 @@ namespace GameActions 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::shared_ptr ResultDataPtr; std::any ResultData; +#endif Result() = default; Result(GameActions::Status error, rct_string_id title, rct_string_id message, uint8_t* args = nullptr); @@ -88,7 +91,7 @@ namespace GameActions template void SetData(const T&& data) { #ifdef __ANDROID__ - ResultDataPtr = std::make_shared(data); + ResultData = std::make_shared(data); #else ResultData = std::forward(data); #endif @@ -97,7 +100,8 @@ namespace GameActions template T GetData() const { #ifdef __ANDROID__ - return *static_cast(ResultDataPtr.get());; + return *static_cast(ResultData.get()); + ; #else // This function will throw std::bad_any_cast if the type mismatches. return std::any_cast(ResultData);