mirror of https://github.com/OpenRCT2/OpenRCT2.git
Merge pull request #16843 from lawrencedemol/Android_GameActionResult_Crash
Fix #16308: Crash when trying to place down a ride on Android
This commit is contained in:
commit
2df360ce11
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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<void> 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<typename T> void SetData(const T&& data)
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
ResultData = std::make_shared<T>(data);
|
||||
#else
|
||||
ResultData = std::forward<const T&&>(data);
|
||||
#endif
|
||||
}
|
||||
|
||||
// This function will throw std::bad_any_cast if the type mismatches.
|
||||
template<typename T> T GetData() const
|
||||
{
|
||||
#ifdef __ANDROID__
|
||||
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);
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in New Issue