From 653826ba9934ffaae4cf5f1f5e20a357d659829e Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Thu, 1 May 2025 23:25:15 +0200 Subject: [PATCH] Clear plugin storage when converting save game for scenario (#24069) --- distribution/changelog.txt | 1 + src/openrct2-ui/windows/EditorBottomToolbar.cpp | 7 +++++++ src/openrct2/Editor.cpp | 8 +++++++- 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/distribution/changelog.txt b/distribution/changelog.txt index a546ceb433..f90e2ed23e 100644 --- a/distribution/changelog.txt +++ b/distribution/changelog.txt @@ -19,6 +19,7 @@ - Fix: [#22634] Asset packs with sound effect overrides are not loaded correctly at startup. - Fix: [#23108] Missing pieces on Hypercoaster and Hyper-Twister, even with the ‘all drawable track pieces’ cheat enabled. - Fix: [#24013] Failure to load a scenario preview image (minimap) could lead to an uncaught exception error message. +- Fix: [#24045] [Plugin] Data storage is not cleared when converting save game to scenario. - Fix: [#24121] Checkbox labels run beyond the edge of the window if they’re too long to fit. - Fix: [#24142] [Plugin] Track origin is miscalculated on downward slopes. - Fix: [#24220] Narrow station platforms have missing sides on certain rotations. diff --git a/src/openrct2-ui/windows/EditorBottomToolbar.cpp b/src/openrct2-ui/windows/EditorBottomToolbar.cpp index 7aab0b3b1d..a737351b88 100644 --- a/src/openrct2-ui/windows/EditorBottomToolbar.cpp +++ b/src/openrct2-ui/windows/EditorBottomToolbar.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -296,6 +297,12 @@ namespace OpenRCT2::Ui::Windows return; } +#ifdef ENABLE_SCRIPTING + // Clear the plugin storage before saving + auto& scriptEngine = GetContext()->GetScriptEngine(); + scriptEngine.ClearParkStorage(); +#endif + auto* windowMgr = Ui::GetWindowManager(); windowMgr->CloseAll(); diff --git a/src/openrct2/Editor.cpp b/src/openrct2/Editor.cpp index 64149ef701..ea06a3201a 100644 --- a/src/openrct2/Editor.cpp +++ b/src/openrct2/Editor.cpp @@ -38,6 +38,7 @@ #include "object/ObjectRepository.h" #include "peep/PeepAnimations.h" #include "rct1/RCT1.h" +#include "scripting/ScriptEngine.h" #include "ui/WindowManager.h" #include "windows/Intent.h" #include "world/Climate.h" @@ -160,6 +161,12 @@ namespace OpenRCT2::Editor GameLoadScripts(); GameNotifyMapChanged(); + +#ifdef ENABLE_SCRIPTING + // Clear the plugin storage before saving + auto& scriptEngine = GetContext()->GetScriptEngine(); + scriptEngine.ClearParkStorage(); +#endif } /** @@ -279,7 +286,6 @@ namespace OpenRCT2::Editor RideInitAll(); - // for (auto* guest : EntityList()) { guest->SetName({});