aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Scripting
diff options
context:
space:
mode:
authorNaios <naios-dev@live.de>2016-03-16 15:34:25 +0100
committerNaios <naios-dev@live.de>2016-03-19 23:19:54 +0100
commit28d8f7f70dcf01b5c849f30846c6b86a11dea7e7 (patch)
tree34ad6f626603ef4533a7b7b49d3c7c9987ef729f /src/server/game/Scripting
parent5fe83abbe57c9c640bbfc506f0e879c2ae4f81a9 (diff)
CMake: Use inherited dependencies in scripts
* Removes the circular dependency between game <-> scripts (cherry picked from commit 96bc31924a5a418d37bd961ef2880f9072126348)
Diffstat (limited to 'src/server/game/Scripting')
-rw-r--r--src/server/game/Scripting/ScriptLoader.cpp55
-rw-r--r--src/server/game/Scripting/ScriptLoader.h23
-rw-r--r--src/server/game/Scripting/ScriptMgr.cpp13
-rw-r--r--src/server/game/Scripting/ScriptMgr.h11
4 files changed, 21 insertions, 81 deletions
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp
deleted file mode 100644
index ccc4c39ccd1..00000000000
--- a/src/server/game/Scripting/ScriptLoader.cpp
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#include "ScriptLoader.h"
-#include "World.h"
-
-void AddSpellsScripts();
-void AddSC_SmartScripts();
-void AddCommandsScripts();
-
-#ifdef SCRIPTS
-void AddWorldScripts();
-void AddEasternKingdomsScripts();
-void AddKalimdorScripts();
-void AddOutlandScripts();
-void AddNorthrendScripts();
-void AddMaelstromScripts();
-void AddEventsScripts();
-void AddPetScripts();
-void AddOutdoorPvPScripts();
-void AddCustomScripts();
-#endif
-
-void AddScripts()
-{
- AddSpellsScripts();
- AddSC_SmartScripts();
- AddCommandsScripts();
-#ifdef SCRIPTS
- AddWorldScripts();
- AddEasternKingdomsScripts();
- AddKalimdorScripts();
- AddOutlandScripts();
- AddNorthrendScripts();
- AddMaelstromScripts();
- AddEventsScripts();
- AddPetScripts();
- AddOutdoorPvPScripts();
- AddCustomScripts();
-#endif
-}
diff --git a/src/server/game/Scripting/ScriptLoader.h b/src/server/game/Scripting/ScriptLoader.h
deleted file mode 100644
index 57b62df22d1..00000000000
--- a/src/server/game/Scripting/ScriptLoader.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms of the GNU General Public License as published by the
- * Free Software Foundation; either version 2 of the License, or (at your
- * option) any later version.
- *
- * This program is distributed in the hope that it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program. If not, see <http://www.gnu.org/licenses/>.
- */
-
-#ifndef SC_SCRIPTLOADER_H
-#define SC_SCRIPTLOADER_H
-
-void AddScripts();
-
-#endif
diff --git a/src/server/game/Scripting/ScriptMgr.cpp b/src/server/game/Scripting/ScriptMgr.cpp
index 7e2146b4751..2184899de02 100644
--- a/src/server/game/Scripting/ScriptMgr.cpp
+++ b/src/server/game/Scripting/ScriptMgr.cpp
@@ -22,10 +22,10 @@
#include "DBCStores.h"
#include "ObjectMgr.h"
#include "OutdoorPvPMgr.h"
-#include "ScriptLoader.h"
#include "ScriptSystem.h"
#include "Transport.h"
#include "Vehicle.h"
+#include "SmartAI.h"
#include "SpellInfo.h"
#include "SpellScript.h"
#include "GossipDef.h"
@@ -240,7 +240,8 @@ struct TSpellSummary
uint8 Effects; // set of enum SelectEffect
} *SpellSummary;
-ScriptMgr::ScriptMgr() : _scriptCount(0), _scheduledScripts(0)
+ScriptMgr::ScriptMgr()
+ : _scriptCount(0), _scheduledScripts(0), _script_loader_callback(nullptr)
{
}
@@ -261,7 +262,13 @@ void ScriptMgr::Initialize()
TC_LOG_INFO("server.loading", "Loading C++ scripts");
FillSpellSummary();
- AddScripts();
+
+ AddSC_SmartScripts();
+
+ ASSERT(_script_loader_callback,
+ "Script loader callback wasn't registered!");
+
+ _script_loader_callback();
#ifdef SCRIPTS
for (std::string const& scriptName : UnusedScriptNames)
diff --git a/src/server/game/Scripting/ScriptMgr.h b/src/server/game/Scripting/ScriptMgr.h
index fc04b0c7b8b..79c1bc3f60f 100644
--- a/src/server/game/Scripting/ScriptMgr.h
+++ b/src/server/game/Scripting/ScriptMgr.h
@@ -863,6 +863,15 @@ class ScriptMgr
void IncrementScriptCount() { ++_scriptCount; }
uint32 GetScriptCount() const { return _scriptCount; }
+ typedef void(*ScriptLoaderCallbackType)();
+
+ /// Sets the script loader callback which is invoked to load scripts
+ /// (Workaround for circular dependency game <-> scripts)
+ void SetScriptLoader(ScriptLoaderCallbackType script_loader_callback)
+ {
+ _script_loader_callback = script_loader_callback;
+ }
+
public: /* Unloading */
void Unload();
@@ -1097,6 +1106,8 @@ class ScriptMgr
//atomic op counter for active scripts amount
std::atomic<uint64> _scheduledScripts;
+
+ ScriptLoaderCallbackType _script_loader_callback;
};
#endif