[CORE] Rewritten ScriptMgr to be initialized before server load

Now ScriptMgr can be initialized before config allowing

to create scripts that can change the behaviour of

server before loading anything
This commit is contained in:
Yehonal
2016-08-07 12:28:17 +02:00
parent e5f8ecd7ec
commit 5b824569a9
4 changed files with 178 additions and 86 deletions

View File

@@ -436,6 +436,8 @@ void World::LoadConfigSettings(bool reload)
sLog->ReloadConfig(); // Reload log levels and filters
}
sScriptMgr->OnBeforeConfigLoad(reload);
///- Read the player limit and the Message of the day from the config file
if (!reload)
SetPlayerAmountLimit(sConfigMgr->GetIntDefault("PlayerLimit", 100));
@@ -1236,8 +1238,7 @@ void World::LoadConfigSettings(bool reload)
m_int_configs[CONFIG_BIRTHDAY_TIME] = sConfigMgr->GetIntDefault("BirthdayTime", 1222964635);
// call ScriptMgr if we're reloading the configuration
if (reload)
sScriptMgr->OnConfigLoad(reload);
sScriptMgr->OnAfterConfigLoad(reload);
}
extern void LoadGameObjectModelList();
@@ -1253,6 +1254,9 @@ void World::SetInitialWorldSettings()
///- Initialize detour memory management
dtAllocSetCustom(dtCustomAlloc, dtCustomFree);
sLog->outString("Initializing Scripts...");
sScriptMgr->Initialize();
///- Initialize config settings
LoadConfigSettings();
@@ -1700,9 +1704,8 @@ void World::SetInitialWorldSettings()
sLog->outString("Loading Creature Text Locales...");
sCreatureTextMgr->LoadCreatureTextLocales();
sLog->outString("Initializing Scripts...");
sScriptMgr->Initialize();
sScriptMgr->OnConfigLoad(false); // must be done after the ScriptMgr has been properly initialized
sLog->outString("Loading Scripts...");
sScriptMgr->LoadDatabase();
sLog->outString("Validating spell scripts...");
sObjectMgr->ValidateSpellScripts();