aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Instances/InstanceScript.cpp
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-03-11 17:09:26 +0100
committerNaios <naios-dev@live.de>2016-04-11 21:14:00 +0200
commit9cc97f226d79e8e0bbe1fdc386ec9f065c0a2226 (patch)
tree9a08ab0926432f1be8fad2da5152bd51a3dd64a8 /src/server/game/Instances/InstanceScript.cpp
parentbc0f2b6e5acd24f414508edb3b826a20a12bce62 (diff)
Core/Game: Rewrote the ScriptMgr to support script reloading.
* Finally this commit enables dynamic script hotswapping and finished the PR #15671. * Split the storage layout to use optimized storages for database bound and unbound scripts. * Add several unload workers to reload scripts correctly -> Requires further investigation. * Fixes memory leaks in ScriptMgr when dropping invalid scripts. * Fixes VehicleScripts * Makes OutdoorPvP scripts reloadable * Makes InstanceMapScripts reloadable * Makes CommandScripts reloadable
Diffstat (limited to 'src/server/game/Instances/InstanceScript.cpp')
-rw-r--r--src/server/game/Instances/InstanceScript.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp
index 8892be38d37..b4c56c32394 100644
--- a/src/server/game/Instances/InstanceScript.cpp
+++ b/src/server/game/Instances/InstanceScript.cpp
@@ -29,6 +29,8 @@
#include "Pet.h"
#include "WorldSession.h"
#include "Opcodes.h"
+#include "ScriptReloadMgr.h"
+#include "ScriptMgr.h"
BossBoundaryData::~BossBoundaryData()
{
@@ -36,6 +38,18 @@ BossBoundaryData::~BossBoundaryData()
delete it->Boundary;
}
+InstanceScript::InstanceScript(Map* map) : instance(map), completedEncounters(0)
+{
+#ifdef TRINITY_API_USE_DYNAMIC_LINKING
+ uint32 scriptId = sObjectMgr->GetInstanceTemplate(map->GetId())->ScriptId;
+ auto const scriptname = sObjectMgr->GetScriptName(scriptId);
+ ASSERT(!scriptname.empty());
+ // Acquire a strong reference from the script module
+ // to keep it loaded until this object is destroyed.
+ module_reference = sScriptMgr->AcquireModuleReferenceOfScriptName(scriptname);
+#endif // #ifndef TRINITY_API_USE_DYNAMIC_LINKING
+}
+
void InstanceScript::SaveToDB()
{
std::string data = GetSaveData();