From 9ff36167171268ff7592f8339658b8c7b66b88d0 Mon Sep 17 00:00:00 2001 From: Robosturm Date: Tue, 3 Oct 2023 19:53:59 +0200 Subject: [PATCH] added script variables to map object --- game/gamemap.cpp | 5 +++++ game/gamemap.h | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/game/gamemap.cpp b/game/gamemap.cpp index af8dd4875..c7592e67d 100644 --- a/game/gamemap.cpp +++ b/game/gamemap.cpp @@ -1498,6 +1498,7 @@ void GameMap::serializeObject(QDataStream& pStream, bool forHash) const pStream << m_recordFile; pStream << m_replayActionCount; } + m_Variables.serializeObject(pStream, forHash); } void GameMap::updateMapFlags() const @@ -1768,6 +1769,10 @@ void GameMap::deserializer(QDataStream& pStream, bool fast) pStream >> m_recordFile; pStream >> m_replayActionCount; } + if (m_headerInfo.m_Version > 13) + { + m_Variables.deserializeObject(pStream); + } } if (showLoadingScreen) { diff --git a/game/gamemap.h b/game/gamemap.h index 0f8faf346..4bce3485a 100644 --- a/game/gamemap.h +++ b/game/gamemap.h @@ -174,7 +174,7 @@ class GameMap final : public QObject, public FileSerializable, public oxygine::A */ inline virtual qint32 getVersion() const override { - return 13; + return 14; } /** * @brief clearMap @@ -917,6 +917,14 @@ class GameMap final : public QObject, public FileSerializable, public oxygine::A * @brief showDamageCalculator */ Q_INVOKABLE void showDamageCalculator(); + /** + * @brief getVariables + * @return + */ + Q_INVOKABLE inline ScriptVariables* getVariables() + { + return &m_Variables; + } private slots: void zoomChanged(); private: @@ -954,6 +962,7 @@ private slots: spCampaign m_Campaign; spGameRecorder m_Recorder{MemoryManagement::create(this)}; spGameScript m_GameScript{MemoryManagement::create(this)}; + ScriptVariables m_Variables; static const char* const m_GameAnimationFactory; bool m_loaded{false}; QString m_mapMusic;