Merge pull request #106 from H0zen/develop21

Fix previous dbscripts commit.
This commit is contained in:
Antz 2016-03-25 19:08:39 +00:00
commit 2a866d08c1
2 changed files with 22 additions and 9 deletions

View File

@ -55,7 +55,7 @@
INSTANTIATE_SINGLETON_1(ScriptMgr);
ScriptMgr::ScriptMgr() : m_scheduledScripts(0)
ScriptMgr::ScriptMgr() : m_scheduledScripts(0), m_lock(0)
{
m_dbScripts.resize(DBS_END);
@ -70,6 +70,16 @@ ScriptMgr::~ScriptMgr()
m_dbScripts.clear();
}
ScriptChainMap const* ScriptMgr::GetScriptChainMap(DBScriptType type)
{
ACE_GUARD_RETURN(ACE_Thread_Mutex, _guard, m_lock, NULL)
if ((type != DBS_INTERNAL) && type < DBS_END)
return &m_dbScripts[type];
return NULL;
}
// /////////////////////////////////////////////////////////
// DB SCRIPTS (loaders of static data)
// /////////////////////////////////////////////////////////
@ -738,12 +748,17 @@ void ScriptMgr::LoadScripts(DBScriptType type)
void ScriptMgr::LoadDbScripts(DBScriptType t)
{
std::set<uint32> eventIds; // Store possible event ids
if (t == DBS_ON_EVENT)
CollectPossibleEventIds(eventIds);
{
ACE_GUARD(ACE_Thread_Mutex, _g, m_lock)
LoadScripts(t);
}
ScriptChainMap& scm = m_dbScripts[t];
for (ScriptChainMap::const_iterator itr = scm.begin(); itr != scm.end(); ++itr)

View File

@ -30,6 +30,8 @@
#include "ObjectGuid.h"
#include "DBCEnums.h"
#include <ace/Atomic_Op.h>
#include <ace/Thread_Mutex.h>
#include <ace/Guard_T.h>
struct AreaTriggerEntry;
struct SpellEntry;
@ -574,13 +576,7 @@ class ScriptMgr
bool ReloadScriptBinding();
ScriptChainMap const* GetScriptChainMap(DBScriptType type)
{
if ((type != DBS_INTERNAL) && type < DBS_END)
return &m_dbScripts[type];
return NULL;
}
ScriptChainMap const* GetScriptChainMap(DBScriptType type);
const char* GetScriptName(uint32 id) const
{
@ -668,6 +664,8 @@ class ScriptMgr
#endif /* _DEBUG */
// atomic op counter for active scripts amount
ACE_Atomic_Op<ACE_Thread_Mutex, long> m_scheduledScripts;
char __cache_guard[1024];
ACE_Thread_Mutex m_lock;
};
// Starters for events