From 07dbdfbd342a4c2f8bf9a7a4b8147374d760a35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 5 Oct 2017 22:33:11 +0200 Subject: [PATCH] Make GameActionResult destructor virtual to ensure proper teardown --- src/openrct2/actions/GameAction.h | 16 +++++++++------- src/openrct2/actions/PlaceParkEntranceAction.hpp | 3 ++- src/openrct2/actions/RideCreateAction.hpp | 3 ++- 3 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/openrct2/actions/GameAction.h b/src/openrct2/actions/GameAction.h index 7995249ea3..3c0d3de1d9 100644 --- a/src/openrct2/actions/GameAction.h +++ b/src/openrct2/actions/GameAction.h @@ -56,11 +56,18 @@ namespace GA_FLAGS constexpr uint16 EDITOR_ONLY = 1 << 2; } +#ifdef __WARN_SUGGEST_FINAL_METHODS__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wsuggest-final-methods" +#pragma GCC diagnostic ignored "-Wsuggest-final-types" +#endif + /** * Represents the result of a game action query or execution. */ -struct GameActionResult +class GameActionResult { +public: typedef std::unique_ptr Ptr; GA_ERROR Error = GA_ERROR::OK; @@ -74,14 +81,9 @@ struct GameActionResult GameActionResult(); GameActionResult(GA_ERROR error, rct_string_id message); GameActionResult(const GameActionResult&) = delete; + virtual ~GameActionResult() {}; }; -#ifdef __WARN_SUGGEST_FINAL_METHODS__ -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wsuggest-final-methods" -#pragma GCC diagnostic ignored "-Wsuggest-final-types" -#endif - struct GameAction { public: diff --git a/src/openrct2/actions/PlaceParkEntranceAction.hpp b/src/openrct2/actions/PlaceParkEntranceAction.hpp index 1e932d70e1..2cca42bbab 100644 --- a/src/openrct2/actions/PlaceParkEntranceAction.hpp +++ b/src/openrct2/actions/PlaceParkEntranceAction.hpp @@ -26,8 +26,9 @@ #include "../world/park.h" #include "../world/footpath.h" -struct PlaceParkEntranceGameActionResult : public GameActionResult +class PlaceParkEntranceGameActionResult final : public GameActionResult { +public: PlaceParkEntranceGameActionResult() : GameActionResult(GA_ERROR::OK, 0) {} PlaceParkEntranceGameActionResult(GA_ERROR error, rct_string_id message) : GameActionResult(error, message) { diff --git a/src/openrct2/actions/RideCreateAction.hpp b/src/openrct2/actions/RideCreateAction.hpp index cb5b21c857..802bc844f9 100644 --- a/src/openrct2/actions/RideCreateAction.hpp +++ b/src/openrct2/actions/RideCreateAction.hpp @@ -30,8 +30,9 @@ #include "../ride/ride.h" #include "../ride/station.h" -struct RideCreateGameActionResult : public GameActionResult +class RideCreateGameActionResult final : public GameActionResult { +public: RideCreateGameActionResult() : GameActionResult(GA_ERROR::OK, 0) {} RideCreateGameActionResult(GA_ERROR error, rct_string_id message) : GameActionResult(error, message) {}