From 96f7ce4bfa0942ee75362d94a21435dbe388ffb3 Mon Sep 17 00:00:00 2001 From: Traesh Date: Sun, 1 Jan 2017 03:22:05 +0100 Subject: [PATCH] Core/Scripting: Added missing hotswap code for SceneScripts --- src/server/game/Scripting/ScriptMgr.cpp | 29 +++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp index 726aa79fccad3..0aaa76a2bcda1 100644 --- a/src/server/game/Scripting/ScriptMgr.cpp +++ b/src/server/game/Scripting/ScriptMgr.cpp @@ -662,6 +662,35 @@ class ScriptRegistrySwapHooks bool swapped; }; +/// This hook is responsible for swapping SceneScript's +template +class ScriptRegistrySwapHooks + : public ScriptRegistrySwapHookBase +{ +public: + ScriptRegistrySwapHooks() : swapped(false) { } + + void BeforeReleaseContext(std::string const& context) final override + { + auto const bounds = static_cast(this)->_ids_of_contexts.equal_range(context); + if (bounds.first != bounds.second) + swapped = true; + } + + void BeforeSwapContext(bool /*initialize*/) override + { + swapped = false; + } + + void BeforeUnload() final override + { + ASSERT(!swapped); + } + +private: + bool swapped; +}; + /// This hook is responsible for swapping SpellScriptLoader's template class ScriptRegistrySwapHooks