mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Game: Move scheduled map scripts counter methods into MapManager
* Since those have nothing to do with core scripts and are
not wished inside the ScriptMgr
(cherry picked from commit 59e3cf82ac)
This commit is contained in:
@@ -4715,7 +4715,7 @@ void ObjectMgr::LoadScripts(ScriptsType type)
|
||||
if (tableName.empty())
|
||||
return;
|
||||
|
||||
if (sScriptMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
|
||||
if (sMapMgr->IsScriptScheduled()) // function cannot be called when scripts are in use.
|
||||
return;
|
||||
|
||||
TC_LOG_INFO("server.loading", "Loading %s...", tableName.c_str());
|
||||
|
||||
@@ -64,7 +64,7 @@ Map::~Map()
|
||||
}
|
||||
|
||||
if (!m_scriptSchedule.empty())
|
||||
sScriptMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
|
||||
sMapMgr->DecreaseScheduledScriptCount(m_scriptSchedule.size());
|
||||
|
||||
MMAP::MMapFactory::createOrGetMMapManager()->unloadMapInstance(GetId(), i_InstanceId);
|
||||
}
|
||||
|
||||
@@ -38,10 +38,10 @@
|
||||
#include "AchievementMgr.h"
|
||||
|
||||
MapManager::MapManager()
|
||||
: _nextInstanceId(0), _scheduledScripts(0)
|
||||
{
|
||||
i_gridCleanUpDelay = sWorld->getIntConfig(CONFIG_INTERVAL_GRIDCLEAN);
|
||||
i_timer.SetInterval(sWorld->getIntConfig(CONFIG_INTERVAL_MAPUPDATE));
|
||||
_nextInstanceId = 0;
|
||||
}
|
||||
|
||||
MapManager::~MapManager() { }
|
||||
|
||||
@@ -126,6 +126,11 @@ class TC_GAME_API MapManager
|
||||
template<typename Worker>
|
||||
void DoForAllMapsWithMapId(uint32 mapId, Worker&& worker);
|
||||
|
||||
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
||||
uint32 DecreaseScheduledScriptCount() { return --_scheduledScripts; }
|
||||
uint32 DecreaseScheduledScriptCount(size_t count) { return _scheduledScripts -= count; }
|
||||
bool IsScriptScheduled() const { return _scheduledScripts > 0; }
|
||||
|
||||
private:
|
||||
typedef std::unordered_map<uint32, Map*> MapMapType;
|
||||
typedef std::vector<bool> InstanceIds;
|
||||
@@ -150,6 +155,9 @@ class TC_GAME_API MapManager
|
||||
InstanceIds _instanceIds;
|
||||
uint32 _nextInstanceId;
|
||||
MapUpdater m_updater;
|
||||
|
||||
// atomic op counter for active scripts amount
|
||||
std::atomic<uint32> _scheduledScripts;
|
||||
};
|
||||
|
||||
template<typename Worker>
|
||||
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "GridNotifiersImpl.h"
|
||||
#include "GossipDef.h"
|
||||
#include "Map.h"
|
||||
#include "MapManager.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "Pet.h"
|
||||
#include "Item.h"
|
||||
@@ -58,7 +59,7 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||
if (iter->first == 0)
|
||||
immedScript = true;
|
||||
|
||||
sScriptMgr->IncreaseScheduledScriptsCount();
|
||||
sMapMgr->IncreaseScheduledScriptsCount();
|
||||
}
|
||||
///- If one of the effects should be immediate, launch the script execution
|
||||
if (/*start &&*/ immedScript && !i_scriptLock)
|
||||
@@ -86,7 +87,7 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||
sa.script = &script;
|
||||
m_scriptSchedule.insert(ScriptScheduleMap::value_type(time_t(sWorld->GetGameTime() + delay), sa));
|
||||
|
||||
sScriptMgr->IncreaseScheduledScriptsCount();
|
||||
sMapMgr->IncreaseScheduledScriptsCount();
|
||||
|
||||
///- If effects should be immediate, launch the script execution
|
||||
if (delay == 0 && !i_scriptLock)
|
||||
@@ -878,6 +879,6 @@ void Map::ScriptsProcess()
|
||||
|
||||
m_scriptSchedule.erase(iter);
|
||||
iter = m_scriptSchedule.begin();
|
||||
sScriptMgr->DecreaseScheduledScriptCount();
|
||||
sMapMgr->DecreaseScheduledScriptCount();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -241,7 +241,7 @@ struct TSpellSummary
|
||||
} *SpellSummary;
|
||||
|
||||
ScriptMgr::ScriptMgr()
|
||||
: _scriptCount(0), _scheduledScripts(0), _script_loader_callback(nullptr)
|
||||
: _scriptCount(0), _script_loader_callback(nullptr)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -1094,20 +1094,10 @@ class TC_GAME_API ScriptMgr
|
||||
void ModifyMeleeDamage(Unit* target, Unit* attacker, uint32& damage);
|
||||
void ModifySpellDamageTaken(Unit* target, Unit* attacker, int32& damage);
|
||||
|
||||
public: /* Scheduled scripts */
|
||||
|
||||
uint32 IncreaseScheduledScriptsCount() { return ++_scheduledScripts; }
|
||||
uint32 DecreaseScheduledScriptCount() { return --_scheduledScripts; }
|
||||
uint32 DecreaseScheduledScriptCount(size_t count) { return _scheduledScripts -= count; }
|
||||
bool IsScriptScheduled() const { return _scheduledScripts > 0; }
|
||||
|
||||
private:
|
||||
|
||||
uint32 _scriptCount;
|
||||
|
||||
//atomic op counter for active scripts amount
|
||||
std::atomic<uint32> _scheduledScripts;
|
||||
|
||||
ScriptLoaderCallbackType _script_loader_callback;
|
||||
};
|
||||
|
||||
|
||||
@@ -251,7 +251,7 @@ public:
|
||||
|
||||
static bool HandleReloadAllScriptsCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
if (sScriptMgr->IsScriptScheduled())
|
||||
if (sMapMgr->IsScriptScheduled())
|
||||
{
|
||||
handler->PSendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -893,7 +893,7 @@ public:
|
||||
|
||||
static bool HandleReloadEventScriptsCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (sScriptMgr->IsScriptScheduled())
|
||||
if (sMapMgr->IsScriptScheduled())
|
||||
{
|
||||
handler->SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -913,7 +913,7 @@ public:
|
||||
|
||||
static bool HandleReloadWpScriptsCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (sScriptMgr->IsScriptScheduled())
|
||||
if (sMapMgr->IsScriptScheduled())
|
||||
{
|
||||
handler->SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
@@ -946,7 +946,7 @@ public:
|
||||
|
||||
static bool HandleReloadSpellScriptsCommand(ChatHandler* handler, const char* args)
|
||||
{
|
||||
if (sScriptMgr->IsScriptScheduled())
|
||||
if (sMapMgr->IsScriptScheduled())
|
||||
{
|
||||
handler->SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||
handler->SetSentErrorMessage(true);
|
||||
|
||||
Reference in New Issue
Block a user