Core/Misc: move scheduled scripts counter to ScriptMgr (which is more logical, isn't it?)
This commit is contained in:
1 parent
e196dd80bd
commit
1551b8a011
9 files changed
+34
-33
No files matched your search
@@ -28,6 +28,7 @@
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "MapRefManager.h"
|
||||
#include "ScriptMgr.h"
|
||||
|
||||
/// Put scripts in the execution queue
|
||||
void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, Object* target)
|
||||
@@ -53,11 +54,11 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||
sa.ownerGUID = ownerGUID;
|
||||
|
||||
sa.script = &iter->second;
|
||||
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld->GetGameTime() + iter->first), sa));
|
||||
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + iter->first), sa));
|
||||
if (iter->first == 0)
|
||||
immedScript = true;
|
||||
|
||||
sWorld->IncreaseScheduledScriptsCount();
|
||||
sScriptMgr->IncreaseScheduledScriptsCount();
|
||||
}
|
||||
///- If one of the effects should be immediate, launch the script execution
|
||||
if (/*start &&*/ immedScript && !i_scriptLock)
|
||||
@@ -83,9 +84,9 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||
sa.ownerGUID = ownerGUID;
|
||||
|
||||
sa.script = &script;
|
||||
m_scriptSchedule.insert(std::pair<time_t, ScriptAction>(time_t(sWorld->GetGameTime() + delay), sa));
|
||||
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + delay), sa));
|
||||
|
||||
sWorld->IncreaseScheduledScriptsCount();
|
||||
sScriptMgr->IncreaseScheduledScriptsCount();
|
||||
|
||||
///- If effects should be immediate, launch the script execution
|
||||
if (delay == 0 && !i_scriptLock)
|
||||
@@ -289,7 +290,7 @@ void Map::ScriptsProcess()
|
||||
return;
|
||||
|
||||
///- Process overdue queued scripts
|
||||
std::multimap<time_t, ScriptAction>::iterator iter = m_scriptSchedule.begin();
|
||||
ScriptScheduleMap::iterator iter = m_scriptSchedule.begin();
|
||||
// ok as multimap is a *sorted* associative container
|
||||
while (!m_scriptSchedule.empty() && (iter->first <= sWorld->GetGameTime()))
|
||||
{
|
||||
@@ -923,8 +924,7 @@ void Map::ScriptsProcess()
|
||||
}
|
||||
|
||||
m_scriptSchedule.erase(iter);
|
||||
sWorld->DecreaseScheduledScriptCount();
|
||||
|
||||
iter = m_scriptSchedule.begin();
|
||||
sScriptMgr->DecreaseScheduledScriptCount();
|
||||
}
|
||||
}
|
||||
@@ -135,7 +135,7 @@ void DoScriptText(int32 iTextEntry, WorldObject* pSource, Unit* pTarget)
|
||||
}
|
||||
|
||||
ScriptMgr::ScriptMgr()
|
||||
: _scriptCount(0)
|
||||
: _scriptCount(0), _scheduledScripts(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
|
||||
#include "Common.h"
|
||||
#include <ace/Singleton.h>
|
||||
#include <ace/Atomic_Op.h>
|
||||
|
||||
#include "DBCStores.h"
|
||||
#include "Player.h"
|
||||
@@ -766,6 +767,9 @@ class ScriptMgr
|
||||
|
||||
uint32 _scriptCount;
|
||||
|
||||
//atomic op counter for active scripts amount
|
||||
ACE_Atomic_Op<ACE_Thread_Mutex, long> _scheduledScripts;
|
||||
|
||||
public: /* Initialization */
|
||||
|
||||
void Initialize();
|
||||
@@ -971,6 +975,12 @@ class ScriptMgr
|
||||
void OnGroupChangeLeader(Group* group, uint64 newLeaderGuid, uint64 oldLeaderGuid);
|
||||
void OnGroupDisband(Group* group);
|
||||
|
||||
public: /* Scheduled scripts */
|
||||
uint32 IncreaseScheduledScriptsCount() { return uint32(++_scheduledScripts); }
|
||||
uint32 DecreaseScheduledScriptCount() { return uint32(--_scheduledScripts); }
|
||||
uint32 DecreaseScheduledScriptCount(size_t count) { return uint32(_scheduledScripts -= count); }
|
||||
bool IsScriptScheduled() const { return _scheduledScripts > 0; }
|
||||
|
||||
public: /* ScriptRegistry */
|
||||
|
||||
// This is the global static registry of scripts.
|
||||
|
||||
Reference in new issue
Block a user