mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-24 07:14:31 +01:00
Apply review requests
This commit is contained in:
@@ -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<void> ResultData;
|
||||
#else
|
||||
// Other platforms still use Any as this provides type checks
|
||||
std::shared_ptr<void> 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<typename T> void SetData(const T&& data)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
ResultDataPtr = std::make_shared<T>(data);
|
||||
ResultData = std::make_shared<T>(data);
|
||||
#else
|
||||
ResultData = std::forward<const T&&>(data);
|
||||
#endif
|
||||
@@ -97,7 +100,8 @@ namespace GameActions
|
||||
template<typename T> T GetData() const
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
return *static_cast<T*>(ResultDataPtr.get());;
|
||||
return *static_cast<T*>(ResultData.get());
|
||||
;
|
||||
#else
|
||||
// This function will throw std::bad_any_cast if the type mismatches.
|
||||
return std::any_cast<T>(ResultData);
|
||||
|
||||
Reference in New Issue
Block a user