From 74e3d1ad8fd9fa4e22a48294d2398908ad3a74ec Mon Sep 17 00:00:00 2001 From: Wojtek Figat Date: Sat, 23 Jul 2022 16:58:16 +0200 Subject: [PATCH] Fix removing Gameplay Globals --- Source/Engine/Engine/GameplayGlobals.cpp | 30 +++++------------------- Source/Engine/Engine/GameplayGlobals.h | 8 +------ 2 files changed, 7 insertions(+), 31 deletions(-) diff --git a/Source/Engine/Engine/GameplayGlobals.cpp b/Source/Engine/Engine/GameplayGlobals.cpp index 7a48dfbdd..ceae6cad9 100644 --- a/Source/Engine/Engine/GameplayGlobals.cpp +++ b/Source/Engine/Engine/GameplayGlobals.cpp @@ -74,20 +74,11 @@ Dictionary GameplayGlobals::GetValues() const void GameplayGlobals::SetValues(const Dictionary& values) { ScopeLock lock(Locker); - for (auto& e : values) + for (auto it = Variables.Begin(); it.IsNotEnd(); ++it) { - bool hasKey = false; - for (auto& q : values) + if (!values.ContainsKey(it->Key)) { - if (e.Key == q.Key) - { - hasKey = true; - break; - } - } - if (!hasKey) - { - Variables.Remove(e.Key); + Variables.Remove(it); } } for (auto i = values.Begin(); i.IsNotEnd(); ++i) @@ -114,20 +105,11 @@ Dictionary GameplayGlobals::GetDefaultValues() const void GameplayGlobals::SetDefaultValues(const Dictionary& values) { ScopeLock lock(Locker); - for (auto& e : values) + for (auto it = Variables.Begin(); it.IsNotEnd(); ++it) { - bool hasKey = false; - for (auto& q : values) + if (!values.ContainsKey(it->Key)) { - if (e.Key == q.Key) - { - hasKey = true; - break; - } - } - if (!hasKey) - { - Variables.Remove(e.Key); + Variables.Remove(it); } } for (auto i = values.Begin(); i.IsNotEnd(); ++i) diff --git a/Source/Engine/Engine/GameplayGlobals.h b/Source/Engine/Engine/GameplayGlobals.h index 1c6bafaf1..fed2c24c2 100644 --- a/Source/Engine/Engine/GameplayGlobals.h +++ b/Source/Engine/Engine/GameplayGlobals.h @@ -11,9 +11,8 @@ /// API_CLASS(NoSpawn) class FLAXENGINE_API GameplayGlobals : public BinaryAsset { -DECLARE_BINARY_ASSET_HEADER(GameplayGlobals, 2); + DECLARE_BINARY_ASSET_HEADER(GameplayGlobals, 2); public: - /// /// The variable data. /// @@ -31,14 +30,12 @@ public: }; public: - /// /// The collection of gameplay global variables identified by the name. /// Dictionary Variables; public: - /// /// Gets the values (run-time). /// @@ -64,7 +61,6 @@ public: API_PROPERTY() void SetDefaultValues(const Dictionary& values); public: - /// /// Gets the value of the global variable (it must be added first). /// @@ -96,12 +92,10 @@ public: #endif public: - // [BinaryAsset] void InitAsVirtual() override; protected: - // [BinaryAsset] LoadResult load() override; void unload(bool isReloading) override;