Conditions/DisableMgr: converted from singleton to namespace with free functions.
This commit is contained in:
@@ -143,7 +143,7 @@ namespace VMAP
|
||||
|
||||
bool VMapManager2::isInLineOfSight(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2)
|
||||
{
|
||||
if (!isLineOfSightCalcEnabled() || sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
|
||||
if (!isLineOfSightCalcEnabled() || DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
|
||||
return true;
|
||||
|
||||
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
|
||||
@@ -166,7 +166,7 @@ namespace VMAP
|
||||
*/
|
||||
bool VMapManager2::getObjectHitPos(unsigned int mapId, float x1, float y1, float z1, float x2, float y2, float z2, float& rx, float &ry, float& rz, float modifyDist)
|
||||
{
|
||||
if (isLineOfSightCalcEnabled() && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
|
||||
if (isLineOfSightCalcEnabled() && !DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LOS))
|
||||
{
|
||||
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
|
||||
if (instanceTree != iInstanceMapTrees.end())
|
||||
@@ -196,7 +196,7 @@ namespace VMAP
|
||||
|
||||
float VMapManager2::getHeight(unsigned int mapId, float x, float y, float z, float maxSearchDist)
|
||||
{
|
||||
if (isHeightCalcEnabled() && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_HEIGHT))
|
||||
if (isHeightCalcEnabled() && !DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_HEIGHT))
|
||||
{
|
||||
InstanceTreeMap::iterator instanceTree = iInstanceMapTrees.find(mapId);
|
||||
if (instanceTree != iInstanceMapTrees.end())
|
||||
@@ -215,7 +215,7 @@ namespace VMAP
|
||||
|
||||
bool VMapManager2::getAreaInfo(unsigned int mapId, float x, float y, float& z, uint32& flags, int32& adtId, int32& rootId, int32& groupId) const
|
||||
{
|
||||
if (!sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_AREAFLAG))
|
||||
if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_AREAFLAG))
|
||||
{
|
||||
InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
|
||||
if (instanceTree != iInstanceMapTrees.end())
|
||||
@@ -233,7 +233,7 @@ namespace VMAP
|
||||
|
||||
bool VMapManager2::GetLiquidLevel(uint32 mapId, float x, float y, float z, uint8 reqLiquidType, float& level, float& floor, uint32& type) const
|
||||
{
|
||||
if (!sDisableMgr->IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LIQUIDSTATUS))
|
||||
if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_VMAP, mapId, NULL, VMAP_DISABLE_LIQUIDSTATUS))
|
||||
{
|
||||
InstanceTreeMap::const_iterator instanceTree = iInstanceMapTrees.find(mapId);
|
||||
if (instanceTree != iInstanceMapTrees.end())
|
||||
|
||||
@@ -2133,7 +2133,7 @@ bool AchievementMgr::HasAchieved(AchievementEntry const* achievement) const
|
||||
|
||||
bool AchievementMgr::CanUpdateCriteria(AchievementCriteriaEntry const* criteria, AchievementEntry const* achievement)
|
||||
{
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, NULL))
|
||||
return false;
|
||||
|
||||
if (achievement->mapID != -1 && GetPlayer()->GetMapId() != uint32(achievement->mapID))
|
||||
@@ -2366,7 +2366,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!GetCriteriaDataSet(criteria) && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, entryId, NULL))
|
||||
if (!GetCriteriaDataSet(criteria) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, entryId, NULL))
|
||||
sLog->outErrorDb("Table `achievement_criteria_data` does not have expected data for criteria (Entry: %u Type: %u) for achievement %u.", criteria->ID, criteria->requiredType, criteria->referredAchievement);
|
||||
}
|
||||
|
||||
|
||||
@@ -691,7 +691,7 @@ void BattlegroundMgr::CreateInitialBattlegrounds()
|
||||
Field *fields = result->Fetch();
|
||||
|
||||
uint32 bgTypeID_ = fields[0].GetUInt32();
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeID_, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeID_, NULL))
|
||||
continue;
|
||||
|
||||
// can be overwrite by values from DB
|
||||
|
||||
@@ -16,25 +16,34 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "DisableMgr.h"
|
||||
#include "ObjectMgr.h"
|
||||
#include "OutdoorPvP.h"
|
||||
#include "SpellMgr.h"
|
||||
#include "VMapManager2.h"
|
||||
#include "DisableMgr.h"
|
||||
|
||||
DisableMgr::DisableMgr()
|
||||
namespace DisableMgr
|
||||
{
|
||||
|
||||
namespace
|
||||
{
|
||||
struct DisableData
|
||||
{
|
||||
uint8 flags;
|
||||
std::set<uint32> params[2]; // params0, params1
|
||||
};
|
||||
|
||||
// single disables here with optional data
|
||||
typedef std::map<uint32, DisableData> DisableTypeMap;
|
||||
// global disable map by source
|
||||
typedef std::map<DisableType, DisableTypeMap> DisableMap;
|
||||
|
||||
DisableMap m_DisableMap;
|
||||
|
||||
uint8 MAX_DISABLE_TYPES = 7;
|
||||
}
|
||||
|
||||
DisableMgr::~DisableMgr()
|
||||
{
|
||||
for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
|
||||
itr->second.clear();
|
||||
|
||||
m_DisableMap.clear();
|
||||
}
|
||||
|
||||
void DisableMgr::LoadDisables()
|
||||
void LoadDisables()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -223,7 +232,7 @@ void DisableMgr::LoadDisables()
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
void DisableMgr::CheckQuestDisables()
|
||||
void CheckQuestDisables()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -254,7 +263,7 @@ void DisableMgr::CheckQuestDisables()
|
||||
sLog->outString();
|
||||
}
|
||||
|
||||
bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
|
||||
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
|
||||
{
|
||||
ASSERT(type < MAX_DISABLE_TYPES);
|
||||
if (m_DisableMap[type].empty())
|
||||
@@ -345,3 +354,5 @@ bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit,
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
#ifndef TRINITY_DISABLEMGR_H
|
||||
#define TRINITY_DISABLEMGR_H
|
||||
|
||||
#include <ace/Singleton.h>
|
||||
#include "Define.h"
|
||||
|
||||
class Unit;
|
||||
|
||||
@@ -54,34 +54,11 @@ enum VmapDisableTypes
|
||||
VMAP_DISABLE_LIQUIDSTATUS = 0x8,
|
||||
};
|
||||
|
||||
#define MAX_DISABLE_TYPES 7
|
||||
|
||||
struct DisableData
|
||||
namespace DisableMgr
|
||||
{
|
||||
uint8 flags;
|
||||
std::set<uint32> params[2]; // params0, params1
|
||||
};
|
||||
|
||||
typedef std::map<uint32, DisableData> DisableTypeMap; // single disables here with optional data
|
||||
typedef std::map<DisableType, DisableTypeMap> DisableMap; // global disable map by source
|
||||
|
||||
class DisableMgr
|
||||
{
|
||||
friend class ACE_Singleton<DisableMgr, ACE_Null_Mutex>;
|
||||
DisableMgr();
|
||||
~DisableMgr();
|
||||
|
||||
public:
|
||||
|
||||
void LoadDisables();
|
||||
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
|
||||
void CheckQuestDisables();
|
||||
|
||||
protected:
|
||||
|
||||
DisableMap m_DisableMap;
|
||||
};
|
||||
|
||||
#define sDisableMgr ACE_Singleton<DisableMgr, ACE_Null_Mutex>::instance()
|
||||
void LoadDisables();
|
||||
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
|
||||
void CheckQuestDisables();
|
||||
}
|
||||
|
||||
#endif //TRINITY_DISABLEMGR_H
|
||||
|
||||
@@ -379,7 +379,7 @@ void LFGMgr::InitializeLockedDungeons(Player* plr)
|
||||
LfgLockStatusType locktype = LFG_LOCKSTATUS_OK;
|
||||
if (dungeon->expansion > expansion)
|
||||
locktype = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION;
|
||||
else if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr))
|
||||
else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, plr))
|
||||
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && plr->GetBoundInstance(dungeon->map, Difficulty(dungeon->difficulty)))
|
||||
locktype = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
|
||||
@@ -2086,7 +2086,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
{
|
||||
sLog->outError("Player (GUID: %u, name: %s) tried to enter a forbidden map %u", GetGUIDLow(), GetName(), mapid);
|
||||
SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED);
|
||||
@@ -14531,7 +14531,7 @@ bool Player::CanSeeStartQuest(Quest const *pQuest)
|
||||
SatisfyQuestExclusiveGroup(pQuest, false) && SatisfyQuestReputation(pQuest, false) &&
|
||||
SatisfyQuestPreviousQuest(pQuest, false) && SatisfyQuestNextChain(pQuest, false) &&
|
||||
SatisfyQuestPrevChain(pQuest, false) && SatisfyQuestDay(pQuest, false) && SatisfyQuestWeek(pQuest, false) &&
|
||||
!sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this))
|
||||
!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this))
|
||||
{
|
||||
return getLevel() + sWorld->getIntConfig(CONFIG_QUEST_HIGH_LEVEL_HIDE_DIFF) >= pQuest->GetMinLevel();
|
||||
}
|
||||
@@ -14547,7 +14547,7 @@ bool Player::CanTakeQuest(Quest const *pQuest, bool msg)
|
||||
&& SatisfyQuestPreviousQuest(pQuest, msg) && SatisfyQuestTimed(pQuest, msg)
|
||||
&& SatisfyQuestNextChain(pQuest, msg) && SatisfyQuestPrevChain(pQuest, msg)
|
||||
&& SatisfyQuestDay(pQuest, msg) && SatisfyQuestWeek(pQuest, msg)
|
||||
&& !sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this)
|
||||
&& !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, pQuest->GetQuestId(), this)
|
||||
&& SatisfyQuestConditions(pQuest, msg);
|
||||
}
|
||||
|
||||
@@ -18147,7 +18147,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report
|
||||
else if (ar->item2 && !HasItemCount(ar->item2, 1))
|
||||
missingItem = ar->item2;
|
||||
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, target_map, this))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, target_map, this))
|
||||
{
|
||||
GetSession()->SendAreaTriggerMessage("%s", GetSession()->GetTrinityString(LANG_INSTANCE_CLOSED));
|
||||
return false;
|
||||
|
||||
@@ -2486,7 +2486,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
else if (itemTemplate.Spells[1].SpellId != -1)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
|
||||
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, NULL))
|
||||
if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, NULL))
|
||||
{
|
||||
sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)", entry, 1+1, itemTemplate.Spells[1].SpellId);
|
||||
itemTemplate.Spells[0].SpellId = 0;
|
||||
@@ -2534,7 +2534,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
if (itemTemplate.Spells[j].SpellId && itemTemplate.Spells[j].SpellId != -1)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[j].SpellId);
|
||||
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, NULL))
|
||||
if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, NULL))
|
||||
{
|
||||
sLog->outErrorDb("Item (Entry: %u) has wrong (not existing) spell in spellid_%d (%d)", entry, j+1, itemTemplate.Spells[j].SpellId);
|
||||
itemTemplate.Spells[j].SpellId = 0;
|
||||
@@ -3752,7 +3752,7 @@ void ObjectMgr::LoadQuests()
|
||||
for (QuestMap::iterator iter = mQuestTemplates.begin(); iter != mQuestTemplates.end(); ++iter)
|
||||
{
|
||||
// skip post-loading checks for disabled quests
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, NULL))
|
||||
continue;
|
||||
|
||||
Quest * qinfo = iter->second;
|
||||
|
||||
@@ -60,7 +60,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
|
||||
|
||||
typeId = fields[0].GetUInt32();
|
||||
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, NULL))
|
||||
continue;
|
||||
|
||||
if (typeId >= MAX_OUTDOORPVP_TYPES)
|
||||
|
||||
@@ -91,7 +91,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, NULL))
|
||||
{
|
||||
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
|
||||
return;
|
||||
@@ -669,7 +669,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket & recv_data)
|
||||
return;
|
||||
}
|
||||
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, NULL))
|
||||
{
|
||||
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
|
||||
return;
|
||||
|
||||
@@ -2903,7 +2903,7 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
|
||||
return;
|
||||
}
|
||||
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
||||
{
|
||||
SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
|
||||
finish(false);
|
||||
|
||||
@@ -1337,7 +1337,7 @@ void World::SetInitialWorldSettings()
|
||||
LoadRandomEnchantmentsTable();
|
||||
|
||||
sLog->outString("Loading Disables");
|
||||
sDisableMgr->LoadDisables(); // must be before loading quests and items
|
||||
DisableMgr::LoadDisables(); // must be before loading quests and items
|
||||
|
||||
sLog->outString("Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
|
||||
sObjectMgr->LoadItemTemplates();
|
||||
@@ -1403,7 +1403,7 @@ void World::SetInitialWorldSettings()
|
||||
sObjectMgr->LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables
|
||||
|
||||
sLog->outString("Checking Quest Disables");
|
||||
sDisableMgr->CheckQuestDisables(); // must be after loading quests
|
||||
DisableMgr::CheckQuestDisables(); // must be after loading quests
|
||||
|
||||
sLog->outString("Loading Quest POI");
|
||||
sObjectMgr->LoadQuestPOI();
|
||||
|
||||
@@ -1104,9 +1104,9 @@ public:
|
||||
static bool HandleReloadDisablesCommand(ChatHandler* handler, const char* /*args*/)
|
||||
{
|
||||
sLog->outString("Re-Loading disables table...");
|
||||
sDisableMgr->LoadDisables();
|
||||
DisableMgr::LoadDisables();
|
||||
sLog->outString("Checking quest disables...");
|
||||
sDisableMgr->CheckQuestDisables();
|
||||
DisableMgr::CheckQuestDisables();
|
||||
handler->SendGlobalGMSysMessage("DB table `disables` reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user