mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Merge remote-tracking branch 'tc/3.3.5' into 4.3.4
Conflicts: sql/base/characters_database.sql sql/updates/world/2016_01_26_00_world.sql sql/updates/world/2016_01_31_00_world.sql sql/updates/world/2016_02_07_00_world.sql src/server/authserver/Server/AuthSession.cpp src/server/database/Database/Implementation/LoginDatabase.cpp src/server/database/Database/Implementation/LoginDatabase.h src/server/game/AI/ScriptedAI/ScriptedCreature.cpp src/server/game/AI/ScriptedAI/ScriptedCreature.h src/server/game/Achievements/AchievementMgr.cpp src/server/game/Chat/Chat.cpp src/server/game/DataStores/DBCStores.cpp src/server/game/DataStores/DBCStructure.h src/server/game/DataStores/DBCfmt.h src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Unit/Unit.cpp src/server/game/Globals/ObjectMgr.cpp src/server/game/Handlers/AuctionHouseHandler.cpp src/server/game/Handlers/MailHandler.cpp src/server/game/Handlers/MovementHandler.cpp src/server/game/Server/WorldSocket.cpp src/server/game/Server/WorldSocket.h src/server/game/Spells/Auras/SpellAuraEffects.cpp src/server/game/Spells/SpellEffects.cpp src/server/game/Spells/SpellMgr.cpp src/server/scripts/Spells/spell_druid.cpp src/server/scripts/Spells/spell_generic.cpp src/server/scripts/Spells/spell_hunter.cpp src/server/scripts/Spells/spell_rogue.cpp src/server/scripts/Spells/spell_shaman.cpp src/server/shared/Networking/AsyncAcceptor.h src/tools/map_extractor/CMakeLists.txt src/tools/map_extractor/System.cpp src/tools/map_extractor/adt.h src/tools/mmaps_generator/MapBuilder.cpp
This commit is contained in:
@@ -37,7 +37,6 @@
|
||||
|
||||
// namespace
|
||||
// {
|
||||
UnusedScriptContainer UnusedScripts;
|
||||
UnusedScriptNamesContainer UnusedScriptNames;
|
||||
// }
|
||||
|
||||
@@ -107,8 +106,9 @@ class ScriptRegistry
|
||||
// The actual list of scripts. This will be accessed concurrently, so it must not be modified
|
||||
// after server startup.
|
||||
static ScriptMap ScriptPointerList;
|
||||
static std::vector<TScript*> Scripts;
|
||||
|
||||
static void AddScript(TScript* const script)
|
||||
static void AddScript(TScript* const script, bool addToDeleteContainer = true)
|
||||
{
|
||||
ASSERT(script);
|
||||
|
||||
@@ -126,6 +126,8 @@ class ScriptRegistry
|
||||
}
|
||||
|
||||
AddScript(is_script_database_bound<TScript>{}, script);
|
||||
if (addToDeleteContainer)
|
||||
Scripts.push_back(script);
|
||||
}
|
||||
|
||||
// Gets a script by its ID (assigned by ObjectMgr).
|
||||
@@ -186,11 +188,6 @@ class ScriptRegistry
|
||||
{
|
||||
// The script uses a script name from database, but isn't assigned to anything.
|
||||
TC_LOG_ERROR("sql.sql", "Script named '%s' does not have a script name assigned in database.", script->GetName().c_str());
|
||||
|
||||
// Avoid calling "delete script;" because we are currently in the script constructor
|
||||
// In a valid scenario this will not happen because every script has a name assigned in the database
|
||||
UnusedScripts.push_back(script);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -210,6 +207,7 @@ class ScriptRegistry
|
||||
#define SCR_REG_MAP(T) ScriptRegistry<T>::ScriptMap
|
||||
#define SCR_REG_ITR(T) ScriptRegistry<T>::ScriptMapIterator
|
||||
#define SCR_REG_LST(T) ScriptRegistry<T>::ScriptPointerList
|
||||
#define SCR_REG_VEC(T) ScriptRegistry<T>::Scripts
|
||||
|
||||
// Utility macros for looping over scripts.
|
||||
#define FOR_SCRIPTS(T, C, E) \
|
||||
@@ -266,17 +264,15 @@ void ScriptMgr::Initialize()
|
||||
}
|
||||
#endif
|
||||
|
||||
UnloadUnusedScripts();
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u C++ scripts in %u ms", GetScriptCount(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void ScriptMgr::Unload()
|
||||
{
|
||||
#define SCR_CLEAR(T) \
|
||||
for (SCR_REG_ITR(T) itr = SCR_REG_LST(T).begin(); itr != SCR_REG_LST(T).end(); ++itr) \
|
||||
delete itr->second; \
|
||||
SCR_REG_LST(T).clear();
|
||||
for (T* scr : SCR_REG_VEC(T)) \
|
||||
delete scr; \
|
||||
SCR_REG_VEC(T).clear();
|
||||
|
||||
// Clear scripts for every script type.
|
||||
SCR_CLEAR(SpellScriptLoader);
|
||||
@@ -308,19 +304,10 @@ void ScriptMgr::Unload()
|
||||
|
||||
#undef SCR_CLEAR
|
||||
|
||||
UnloadUnusedScripts();
|
||||
|
||||
delete[] SpellSummary;
|
||||
delete[] UnitAI::AISpellInfo;
|
||||
}
|
||||
|
||||
void ScriptMgr::UnloadUnusedScripts()
|
||||
{
|
||||
for (size_t i = 0; i < UnusedScripts.size(); ++i)
|
||||
delete UnusedScripts[i];
|
||||
UnusedScripts.clear();
|
||||
}
|
||||
|
||||
void ScriptMgr::LoadDatabase()
|
||||
{
|
||||
sScriptSystemMgr->LoadScriptWaypoints();
|
||||
@@ -1368,9 +1355,9 @@ void ScriptMgr::OnPlayerSave(Player* player)
|
||||
FOREACH_SCRIPT(PlayerScript)->OnSave(player);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent)
|
||||
void ScriptMgr::OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent, uint8 extendState)
|
||||
{
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent);
|
||||
FOREACH_SCRIPT(PlayerScript)->OnBindToInstance(player, difficulty, mapid, permanent, extendState);
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea)
|
||||
@@ -1555,8 +1542,7 @@ FormulaScript::FormulaScript(const char* name)
|
||||
UnitScript::UnitScript(const char* name, bool addToScripts)
|
||||
: ScriptObject(name)
|
||||
{
|
||||
if (addToScripts)
|
||||
ScriptRegistry<UnitScript>::AddScript(this);
|
||||
ScriptRegistry<UnitScript>::AddScript(this, addToScripts);
|
||||
}
|
||||
|
||||
WorldMapScript::WorldMapScript(const char* name, uint32 mapId)
|
||||
@@ -1696,6 +1682,7 @@ GroupScript::GroupScript(const char* name)
|
||||
|
||||
// Instantiate static members of ScriptRegistry.
|
||||
template<class TScript> std::map<uint32, TScript*> ScriptRegistry<TScript>::ScriptPointerList;
|
||||
template<class TScript> std::vector<TScript*> ScriptRegistry<TScript>::Scripts;
|
||||
template<class TScript> uint32 ScriptRegistry<TScript>::_scriptIdCounter = 0;
|
||||
|
||||
// Specialize for each script type class like so:
|
||||
|
||||
Reference in New Issue
Block a user