From 7f13ac0ccd22f835e12a68d90d78b0a7a650c403 Mon Sep 17 00:00:00 2001 From: hispidence Date: Tue, 24 Jan 2023 19:42:09 +0000 Subject: [PATCH] Remove PreSave and make OnSave take place before data is saved. --- TombEngine/Game/gui.cpp | 3 +-- TombEngine/Scripting/Include/ScriptInterfaceGame.h | 1 - TombEngine/Scripting/Internal/ReservedScriptNames.h | 1 - .../Scripting/Internal/TEN/Logic/LogicHandler.cpp | 12 ++---------- .../Scripting/Internal/TEN/Logic/LogicHandler.h | 1 - 5 files changed, 3 insertions(+), 15 deletions(-) diff --git a/TombEngine/Game/gui.cpp b/TombEngine/Game/gui.cpp index 0a8277a9d..857a11182 100644 --- a/TombEngine/Game/gui.cpp +++ b/TombEngine/Game/gui.cpp @@ -3146,9 +3146,8 @@ namespace TEN::Gui if (GuiIsSelected()) { SoundEffect(SFX_TR4_MENU_CHOOSE, nullptr, SoundEnvironment::Always); - g_GameScript->PreSave(); - SaveGame::Save(SelectedSaveSlot); g_GameScript->OnSave(); + SaveGame::Save(SelectedSaveSlot); return true; } diff --git a/TombEngine/Scripting/Include/ScriptInterfaceGame.h b/TombEngine/Scripting/Include/ScriptInterfaceGame.h index e15a9f6d9..f8829827e 100644 --- a/TombEngine/Scripting/Include/ScriptInterfaceGame.h +++ b/TombEngine/Scripting/Include/ScriptInterfaceGame.h @@ -63,7 +63,6 @@ public: virtual void OnStart() = 0; virtual void OnLoad() = 0; virtual void OnControlPhase(float dt) = 0; - virtual void PreSave() = 0; virtual void OnSave() = 0; virtual void OnEnd() = 0; virtual void ShortenTENCalls() = 0; diff --git a/TombEngine/Scripting/Internal/ReservedScriptNames.h b/TombEngine/Scripting/Internal/ReservedScriptNames.h index 824e17478..6bee46808 100644 --- a/TombEngine/Scripting/Internal/ReservedScriptNames.h +++ b/TombEngine/Scripting/Internal/ReservedScriptNames.h @@ -28,7 +28,6 @@ static constexpr char ScriptReserved_LevelFunc[] = "LevelFunc"; // Built-in LevelFuncs static constexpr char ScriptReserved_OnStart[] = "OnStart"; static constexpr char ScriptReserved_OnLoad[] = "OnLoad"; -static constexpr char ScriptReserved_PreSave[] = "PreSave"; static constexpr char ScriptReserved_OnControlPhase[] = "OnControlPhase"; static constexpr char ScriptReserved_OnSave[] = "OnSave"; static constexpr char ScriptReserved_OnEnd[] = "OnEnd"; diff --git a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp index 8aae4eb3c..e8a591387 100644 --- a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp +++ b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.cpp @@ -722,12 +722,6 @@ void LogicHandler::OnControlPhase(float dt) tryCall(name); } -void LogicHandler::PreSave() -{ - if (m_preSave.valid()) - doCallback(m_preSave); -} - void LogicHandler::OnSave() { if(m_onSave.valid()) @@ -836,11 +830,10 @@ __The order of loading is as follows:__ 5. The control loop, in which `OnControlPhase` will be called once per frame, begins. @tfield function OnStart Will be called when a level is entered by completing a previous level or by selecting it in the menu. Will not be called when loaded from a saved game. -@tfield function OnLoad Will be called whenoa saved game is loaded, just *after* data is loaded +@tfield function OnLoad Will be called when a saved game is loaded, just *after* data is loaded @tfield function(float) OnControlPhase Will be called during the game's update loop, and provides the delta time (a float representing game time since last call) via its argument. -@tfield function PreSave Will be called when the player saves the game, just *before* data is saved -@tfield function OnSave Will be called when the player saves the game, just *after* data is saved +@tfield function OnSave Will be called when the player saves the game, just *before* data is saved @tfield function OnEnd Will be called when leaving a level. This includes finishing it, exiting to the menu, or loading a save in a different level. @table LevelFuncs */ @@ -874,7 +867,6 @@ void LogicHandler::InitCallbacks() assignCB(m_onStart, ScriptReserved_OnStart); assignCB(m_onLoad, ScriptReserved_OnLoad); assignCB(m_onControlPhase, ScriptReserved_OnControlPhase); - assignCB(m_preSave, ScriptReserved_PreSave); assignCB(m_onSave, ScriptReserved_OnSave); assignCB(m_onEnd, ScriptReserved_OnEnd); } diff --git a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.h b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.h index ac5beab9d..af50539d7 100644 --- a/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.h +++ b/TombEngine/Scripting/Internal/TEN/Logic/LogicHandler.h @@ -100,7 +100,6 @@ public: void OnStart() override; void OnLoad() override; void OnControlPhase(float dt) override; - void PreSave() override; void OnSave() override; void OnEnd() override; };