diff options
| author | Naios <naios-dev@live.de> | 2016-03-16 15:34:25 +0100 |
|---|---|---|
| committer | Naios <naios-dev@live.de> | 2016-03-18 02:53:00 +0100 |
| commit | 96bc31924a5a418d37bd961ef2880f9072126348 (patch) | |
| tree | 5d0815f372761d041916e7d9cc3498c91c4533d9 /src/server/game/Scripting | |
| parent | 469f2d3ade168de0b5be18112008c337067a8e03 (diff) | |
CMake: Use inherited dependencies in scripts
* Removes the circular dependency between game <-> scripts
Diffstat (limited to 'src/server/game/Scripting')
| -rw-r--r-- | src/server/game/Scripting/ScriptLoader.cpp | 53 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptLoader.h | 23 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.cpp | 13 | ||||
| -rw-r--r-- | src/server/game/Scripting/ScriptMgr.h | 11 |
4 files changed, 21 insertions, 79 deletions
diff --git a/src/server/game/Scripting/ScriptLoader.cpp b/src/server/game/Scripting/ScriptLoader.cpp deleted file mode 100644 index 07ac1a2ed5b..00000000000 --- a/src/server/game/Scripting/ScriptLoader.cpp +++ /dev/null @@ -1,53 +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 AddEventsScripts(); -void AddPetScripts(); -void AddOutdoorPvPScripts(); -void AddCustomScripts(); -#endif - -void AddScripts() -{ - AddSpellsScripts(); - AddSC_SmartScripts(); - AddCommandsScripts(); -#ifdef SCRIPTS - AddWorldScripts(); - AddEasternKingdomsScripts(); - AddKalimdorScripts(); - AddOutlandScripts(); - AddNorthrendScripts(); - 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 bc43ee10f3d..96477e2013e 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 905513da896..c22ffaf05a4 100644 --- a/src/server/game/Scripting/ScriptMgr.h +++ b/src/server/game/Scripting/ScriptMgr.h @@ -864,6 +864,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(); @@ -1098,6 +1107,8 @@ class ScriptMgr //atomic op counter for active scripts amount std::atomic<uint32> _scheduledScripts; + + ScriptLoaderCallbackType _script_loader_callback; }; #endif |
