mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11259] Move scheduled scripts counter to ScriptMgr
Also cleanup forward declarations.
This commit is contained in:
parent
dee6d712c4
commit
a6d155fc54
9 changed files with 33 additions and 33 deletions
|
|
@ -34,8 +34,6 @@ class Unit;
|
||||||
class WorldPacket;
|
class WorldPacket;
|
||||||
class InstanceData;
|
class InstanceData;
|
||||||
class Group;
|
class Group;
|
||||||
struct ScriptInfo;
|
|
||||||
struct ScriptAction;
|
|
||||||
class BattleGround;
|
class BattleGround;
|
||||||
class Map;
|
class Map;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ bool ChatHandler::HandleReloadAllQuestCommand(char* /*args*/)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadAllScriptsCommand(char* /*args*/)
|
bool ChatHandler::HandleReloadAllScriptsCommand(char* /*args*/)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
PSendSysMessage("DB scripts used currently, please attempt reload later.");
|
PSendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -288,7 +288,7 @@ bool ChatHandler::HandleReloadGossipMenuOptionCommand(char* /*args*/)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadGossipScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadGossipScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -701,7 +701,7 @@ bool ChatHandler::HandleReloadBattleEventCommand(char* /*args*/)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadGameObjectScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadGameObjectScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -721,7 +721,7 @@ bool ChatHandler::HandleReloadGameObjectScriptsCommand(char* args)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadEventScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadEventScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if(sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -766,7 +766,7 @@ bool ChatHandler::HandleReloadEventAIScriptsCommand(char* /*args*/)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadQuestEndScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadQuestEndScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -786,7 +786,7 @@ bool ChatHandler::HandleReloadQuestEndScriptsCommand(char* args)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadQuestStartScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadQuestStartScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
@ -806,7 +806,7 @@ bool ChatHandler::HandleReloadQuestStartScriptsCommand(char* args)
|
||||||
|
|
||||||
bool ChatHandler::HandleReloadSpellScriptsCommand(char* args)
|
bool ChatHandler::HandleReloadSpellScriptsCommand(char* args)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled())
|
if (sScriptMgr.IsScriptScheduled())
|
||||||
{
|
{
|
||||||
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
SendSysMessage("DB scripts used currently, please attempt reload later.");
|
||||||
SetSentErrorMessage(true);
|
SetSentErrorMessage(true);
|
||||||
|
|
|
||||||
|
|
@ -43,7 +43,7 @@ Map::~Map()
|
||||||
UnloadAll(true);
|
UnloadAll(true);
|
||||||
|
|
||||||
if(!m_scriptSchedule.empty())
|
if(!m_scriptSchedule.empty())
|
||||||
sWorld.DecreaseScheduledScriptCount(m_scriptSchedule.size());
|
sScriptMgr.DecreaseScheduledScriptCount(m_scriptSchedule.size());
|
||||||
|
|
||||||
if (m_persistentState)
|
if (m_persistentState)
|
||||||
m_persistentState->SetUsedByMapState(NULL); // field pointer can be deleted after this
|
m_persistentState->SetUsedByMapState(NULL); // field pointer can be deleted after this
|
||||||
|
|
@ -1675,11 +1675,11 @@ void Map::ScriptsStart(ScriptMapMap const& scripts, uint32 id, Object* source, O
|
||||||
sa.ownerGuid = ownerGuid;
|
sa.ownerGuid = ownerGuid;
|
||||||
|
|
||||||
sa.script = &iter->second;
|
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)
|
if (iter->first == 0)
|
||||||
immedScript = true;
|
immedScript = true;
|
||||||
|
|
||||||
sWorld.IncreaseScheduledScriptsCount();
|
sScriptMgr.IncreaseScheduledScriptsCount();
|
||||||
}
|
}
|
||||||
///- If one of the effects should be immediate, launch the script execution
|
///- If one of the effects should be immediate, launch the script execution
|
||||||
if (immedScript)
|
if (immedScript)
|
||||||
|
|
@ -1701,9 +1701,9 @@ void Map::ScriptCommandStart(ScriptInfo const& script, uint32 delay, Object* sou
|
||||||
sa.ownerGuid = ownerGuid;
|
sa.ownerGuid = ownerGuid;
|
||||||
|
|
||||||
sa.script = &script;
|
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 effects should be immediate, launch the script execution
|
||||||
if(delay == 0)
|
if(delay == 0)
|
||||||
|
|
@ -1717,7 +1717,7 @@ void Map::ScriptsProcess()
|
||||||
return;
|
return;
|
||||||
|
|
||||||
///- Process overdue queued scripts
|
///- 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
|
// ok as multimap is a *sorted* associative container
|
||||||
while (!m_scriptSchedule.empty() && (iter->first <= sWorld.GetGameTime()))
|
while (!m_scriptSchedule.empty() && (iter->first <= sWorld.GetGameTime()))
|
||||||
{
|
{
|
||||||
|
|
@ -2823,9 +2823,9 @@ void Map::ScriptsProcess()
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scriptSchedule.erase(iter);
|
m_scriptSchedule.erase(iter);
|
||||||
sWorld.DecreaseScheduledScriptCount();
|
|
||||||
|
|
||||||
iter = m_scriptSchedule.begin();
|
iter = m_scriptSchedule.begin();
|
||||||
|
|
||||||
|
sScriptMgr.DecreaseScheduledScriptCount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -319,7 +319,9 @@ class MANGOS_DLL_SPEC Map : public GridRefManager<NGridType>
|
||||||
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
|
std::bitset<TOTAL_NUMBER_OF_CELLS_PER_MAP*TOTAL_NUMBER_OF_CELLS_PER_MAP> marked_cells;
|
||||||
|
|
||||||
std::set<WorldObject *> i_objectsToRemove;
|
std::set<WorldObject *> i_objectsToRemove;
|
||||||
std::multimap<time_t, ScriptAction> m_scriptSchedule;
|
|
||||||
|
typedef std::multimap<time_t, ScriptAction> ScriptScheduleMap;
|
||||||
|
ScriptScheduleMap m_scriptSchedule;
|
||||||
|
|
||||||
InstanceData* i_data;
|
InstanceData* i_data;
|
||||||
uint32 i_script_id;
|
uint32 i_script_id;
|
||||||
|
|
|
||||||
|
|
@ -66,7 +66,9 @@ ScriptMgr::ScriptMgr() :
|
||||||
m_pOnEffectDummyCreature(NULL),
|
m_pOnEffectDummyCreature(NULL),
|
||||||
m_pOnEffectDummyGO(NULL),
|
m_pOnEffectDummyGO(NULL),
|
||||||
m_pOnEffectDummyItem(NULL),
|
m_pOnEffectDummyItem(NULL),
|
||||||
m_pOnAuraDummy(NULL)
|
m_pOnAuraDummy(NULL),
|
||||||
|
|
||||||
|
m_scheduledScripts(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -77,7 +79,7 @@ ScriptMgr::~ScriptMgr()
|
||||||
|
|
||||||
void ScriptMgr::LoadScripts(ScriptMapMap& scripts, const char* tablename)
|
void ScriptMgr::LoadScripts(ScriptMapMap& scripts, const char* tablename)
|
||||||
{
|
{
|
||||||
if (sWorld.IsScriptScheduled()) // function don't must be called in time scripts use.
|
if (IsScriptScheduled()) // function don't must be called in time scripts use.
|
||||||
return;
|
return;
|
||||||
|
|
||||||
sLog.outString("%s :", tablename);
|
sLog.outString("%s :", tablename);
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,7 @@
|
||||||
#include "Policies/Singleton.h"
|
#include "Policies/Singleton.h"
|
||||||
#include "ObjectGuid.h"
|
#include "ObjectGuid.h"
|
||||||
#include "DBCEnums.h"
|
#include "DBCEnums.h"
|
||||||
|
#include "ace/Atomic_Op.h"
|
||||||
|
|
||||||
struct AreaTriggerEntry;
|
struct AreaTriggerEntry;
|
||||||
class Aura;
|
class Aura;
|
||||||
|
|
@ -297,6 +298,7 @@ struct ScriptAction
|
||||||
|
|
||||||
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
|
typedef std::multimap<uint32, ScriptInfo> ScriptMap;
|
||||||
typedef std::map<uint32, ScriptMap > ScriptMapMap;
|
typedef std::map<uint32, ScriptMap > ScriptMapMap;
|
||||||
|
|
||||||
extern ScriptMapMap sQuestEndScripts;
|
extern ScriptMapMap sQuestEndScripts;
|
||||||
extern ScriptMapMap sQuestStartScripts;
|
extern ScriptMapMap sQuestStartScripts;
|
||||||
extern ScriptMapMap sSpellScripts;
|
extern ScriptMapMap sSpellScripts;
|
||||||
|
|
@ -343,6 +345,11 @@ class ScriptMgr
|
||||||
void UnloadScriptLibrary();
|
void UnloadScriptLibrary();
|
||||||
bool IsScriptLibraryLoaded() const { return m_hScriptLib != NULL; }
|
bool IsScriptLibraryLoaded() const { return m_hScriptLib != NULL; }
|
||||||
|
|
||||||
|
uint32 IncreaseScheduledScriptsCount() { return (uint32)++m_scheduledScripts; }
|
||||||
|
uint32 DecreaseScheduledScriptCount() { return (uint32)--m_scheduledScripts; }
|
||||||
|
uint32 DecreaseScheduledScriptCount(size_t count) { return (uint32)(m_scheduledScripts -= count); }
|
||||||
|
bool IsScriptScheduled() const { return m_scheduledScripts > 0; }
|
||||||
|
|
||||||
CreatureAI* GetCreatureAI(Creature* pCreature);
|
CreatureAI* GetCreatureAI(Creature* pCreature);
|
||||||
InstanceData* CreateInstanceData(Map* pMap);
|
InstanceData* CreateInstanceData(Map* pMap);
|
||||||
|
|
||||||
|
|
@ -387,6 +394,9 @@ class ScriptMgr
|
||||||
ScriptNameMap m_scriptNames;
|
ScriptNameMap m_scriptNames;
|
||||||
MANGOS_LIBRARY_HANDLE m_hScriptLib;
|
MANGOS_LIBRARY_HANDLE m_hScriptLib;
|
||||||
|
|
||||||
|
//atomic op counter for active scripts amount
|
||||||
|
ACE_Atomic_Op<ACE_Thread_Mutex, long> m_scheduledScripts;
|
||||||
|
|
||||||
void (MANGOS_IMPORT* m_pOnInitScriptLibrary)();
|
void (MANGOS_IMPORT* m_pOnInitScriptLibrary)();
|
||||||
void (MANGOS_IMPORT* m_pOnFreeScriptLibrary)();
|
void (MANGOS_IMPORT* m_pOnFreeScriptLibrary)();
|
||||||
const char* (MANGOS_IMPORT* m_pGetScriptLibraryVersion)();
|
const char* (MANGOS_IMPORT* m_pGetScriptLibraryVersion)();
|
||||||
|
|
|
||||||
|
|
@ -93,7 +93,6 @@ World::World()
|
||||||
m_maxQueuedSessionCount = 0;
|
m_maxQueuedSessionCount = 0;
|
||||||
m_NextDailyQuestReset = 0;
|
m_NextDailyQuestReset = 0;
|
||||||
m_NextWeeklyQuestReset = 0;
|
m_NextWeeklyQuestReset = 0;
|
||||||
m_scheduledScripts = 0;
|
|
||||||
|
|
||||||
m_defaultDbcLocale = LOCALE_enUS;
|
m_defaultDbcLocale = LOCALE_enUS;
|
||||||
m_availableDbcLocaleMask = 0;
|
m_availableDbcLocaleMask = 0;
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,6 @@
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Policies/Singleton.h"
|
#include "Policies/Singleton.h"
|
||||||
#include "SharedDefines.h"
|
#include "SharedDefines.h"
|
||||||
#include "ace/Atomic_Op.h"
|
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
@ -38,8 +37,6 @@ class WorldPacket;
|
||||||
class WorldSession;
|
class WorldSession;
|
||||||
class Player;
|
class Player;
|
||||||
class Weather;
|
class Weather;
|
||||||
struct ScriptAction;
|
|
||||||
struct ScriptInfo;
|
|
||||||
class SqlResultQueue;
|
class SqlResultQueue;
|
||||||
class QueryResult;
|
class QueryResult;
|
||||||
class WorldSocket;
|
class WorldSocket;
|
||||||
|
|
@ -551,11 +548,6 @@ class World
|
||||||
BanReturn BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_secs, std::string reason, std::string author);
|
BanReturn BanAccount(BanMode mode, std::string nameOrIP, uint32 duration_secs, std::string reason, std::string author);
|
||||||
bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
|
bool RemoveBanAccount(BanMode mode, std::string nameOrIP);
|
||||||
|
|
||||||
uint32 IncreaseScheduledScriptsCount() { return (uint32)++m_scheduledScripts; }
|
|
||||||
uint32 DecreaseScheduledScriptCount() { return (uint32)--m_scheduledScripts; }
|
|
||||||
uint32 DecreaseScheduledScriptCount(size_t count) { return (uint32)(m_scheduledScripts -= count); }
|
|
||||||
bool IsScriptScheduled() const { return m_scheduledScripts > 0; }
|
|
||||||
|
|
||||||
// for max speed access
|
// for max speed access
|
||||||
static float GetMaxVisibleDistanceOnContinents() { return m_MaxVisibleDistanceOnContinents; }
|
static float GetMaxVisibleDistanceOnContinents() { return m_MaxVisibleDistanceOnContinents; }
|
||||||
static float GetMaxVisibleDistanceInInstances() { return m_MaxVisibleDistanceInInstances; }
|
static float GetMaxVisibleDistanceInInstances() { return m_MaxVisibleDistanceInInstances; }
|
||||||
|
|
@ -618,9 +610,6 @@ class World
|
||||||
uint32 m_ShutdownTimer;
|
uint32 m_ShutdownTimer;
|
||||||
uint32 m_ShutdownMask;
|
uint32 m_ShutdownMask;
|
||||||
|
|
||||||
//atomic op counter for active scripts amount
|
|
||||||
ACE_Atomic_Op<ACE_Thread_Mutex, long> m_scheduledScripts;
|
|
||||||
|
|
||||||
time_t m_startTime;
|
time_t m_startTime;
|
||||||
time_t m_gameTime;
|
time_t m_gameTime;
|
||||||
IntervalTimer m_timers[WUPDATE_COUNT];
|
IntervalTimer m_timers[WUPDATE_COUNT];
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11258"
|
#define REVISION_NR "11259"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue