refactor(Core/Disables): Convert from Namespace to Class Structure (#21109)
This commit is contained in:
parent
3b12decaae
commit
47c5ff904f
@ -2438,7 +2438,7 @@ bool AchievementMgr::HasAchieved(uint32 achievementId) const
|
||||
|
||||
bool AchievementMgr::CanUpdateCriteria(AchievementCriteriaEntry const* criteria, AchievementEntry const* achievement)
|
||||
{
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, criteria->ID, nullptr))
|
||||
return false;
|
||||
|
||||
if (achievement->mapID != -1 && GetPlayer()->GetMapId() != uint32(achievement->mapID))
|
||||
@ -2917,7 +2917,7 @@ void AchievementGlobalMgr::LoadAchievementCriteriaData()
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!GetCriteriaDataSet(criteria) && !DisableMgr::IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, entryId, nullptr))
|
||||
if (!GetCriteriaDataSet(criteria) && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_ACHIEVEMENT_CRITERIA, entryId, nullptr))
|
||||
LOG_ERROR("sql.sql", "Table `achievement_criteria_data` does not have expected data for criteria (Entry: {} Type: {}) for achievement {}.", criteria->ID, criteria->requiredType, criteria->referredAchievement);
|
||||
}
|
||||
|
||||
|
||||
@ -467,7 +467,7 @@ void BattlegroundMgr::LoadBattlegroundTemplates()
|
||||
|
||||
BattlegroundTypeId bgTypeId = static_cast<BattlegroundTypeId>(fields[0].Get<uint32>());
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId, nullptr))
|
||||
continue;
|
||||
|
||||
// can be overwrite by values from DB
|
||||
|
||||
@ -28,393 +28,418 @@
|
||||
#include "VMapMgr2.h"
|
||||
#include "World.h"
|
||||
|
||||
namespace DisableMgr
|
||||
std::map<DisableType, std::map<uint32, DisableData>> DisableMgr::m_DisableMap;
|
||||
|
||||
DisableMgr::DisableMgr() {}
|
||||
DisableMgr::~DisableMgr() {}
|
||||
|
||||
DisableMgr* DisableMgr::instance()
|
||||
{
|
||||
namespace
|
||||
static DisableMgr instance;
|
||||
return &instance;
|
||||
}
|
||||
|
||||
void DisableMgr::LoadDisables()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// reload case
|
||||
for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
|
||||
itr->second.clear();
|
||||
|
||||
m_DisableMap.clear();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");
|
||||
|
||||
uint32 total_count = 0;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
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 = 11;
|
||||
}
|
||||
|
||||
void LoadDisables()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
// reload case
|
||||
for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
|
||||
itr->second.clear();
|
||||
|
||||
m_DisableMap.clear();
|
||||
|
||||
QueryResult result = WorldDatabase.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");
|
||||
|
||||
uint32 total_count = 0;
|
||||
|
||||
if (!result)
|
||||
{
|
||||
LOG_WARN("server.loading", ">> Loaded 0 disables. DB table `disables` is empty!");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
Field* fields;
|
||||
do
|
||||
{
|
||||
fields = result->Fetch();
|
||||
DisableType type = DisableType(fields[0].Get<uint32>());
|
||||
if (type >= MAX_DISABLE_TYPES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Invalid type {} specified in `disables` table, skipped.", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
uint8 flags = fields[2].Get<uint8>();
|
||||
std::string params_0 = fields[3].Get<std::string>();
|
||||
std::string params_1 = fields[4].Get<std::string>();
|
||||
|
||||
DisableData data;
|
||||
data.flags = flags;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISABLE_TYPE_GO_LOS:
|
||||
if (!sObjectMgr->GetGameObjectTemplate(entry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Gameobject entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for gameobject {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_SPELL:
|
||||
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Spell entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!flags || flags > MAX_SPELL_DISABLE_TYPE)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Disable flags for spell {} are invalid, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (flags & SPELL_DISABLE_MAP)
|
||||
{
|
||||
for (std::string_view mapStr : Acore::Tokenize(params_0, ',', true))
|
||||
{
|
||||
if (Optional<uint32> mapId = Acore::StringTo<uint32>(mapStr))
|
||||
data.params[0].insert(*mapId);
|
||||
else
|
||||
LOG_ERROR("sql.sql", "Disable map '{}' for spell {} is invalid, skipped.", mapStr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
if (flags & SPELL_DISABLE_AREA)
|
||||
{
|
||||
for (std::string_view areaStr : Acore::Tokenize(params_1, ',', true))
|
||||
{
|
||||
if (Optional<uint32> areaId = Acore::StringTo<uint32>(areaStr))
|
||||
data.params[1].insert(*areaId);
|
||||
else
|
||||
LOG_ERROR("sql.sql", "Disable area '{}' for spell {} is invalid, skipped.", areaStr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
// xinef: if spell has disabled los, add flag
|
||||
if (flags & SPELL_DISABLE_LOS)
|
||||
{
|
||||
SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->GetSpellInfo(entry));
|
||||
spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT;
|
||||
}
|
||||
|
||||
break;
|
||||
// checked later
|
||||
case DISABLE_TYPE_QUEST:
|
||||
break;
|
||||
case DISABLE_TYPE_MAP:
|
||||
case DISABLE_TYPE_LFG_MAP:
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (!mapEntry)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
bool isFlagInvalid = false;
|
||||
switch (mapEntry->map_type)
|
||||
{
|
||||
case MAP_COMMON:
|
||||
if (flags)
|
||||
isFlagInvalid = true;
|
||||
break;
|
||||
case MAP_INSTANCE:
|
||||
case MAP_RAID:
|
||||
if (flags & DUNGEON_STATUSFLAG_HEROIC && !GetMapDifficultyData(entry, DUNGEON_DIFFICULTY_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
else if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
else if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
break;
|
||||
case MAP_BATTLEGROUND:
|
||||
case MAP_ARENA:
|
||||
LOG_ERROR("sql.sql", "Battleground map {} specified to be disabled in map case, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
if (isFlagInvalid)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Disable flags for map {} are invalid, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_BATTLEGROUND:
|
||||
if (!sBattlemasterListStore.LookupEntry(entry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Battleground entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for battleground {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_OUTDOORPVP:
|
||||
if (entry > MAX_OUTDOORPVP_TYPES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "OutdoorPvPTypes value {} from `disables` is invalid, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for outdoor PvP {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
|
||||
if (!sAchievementCriteriaStore.LookupEntry(entry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Achievement Criteria entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for Achievement Criteria {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_VMAP:
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (!mapEntry)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
continue;
|
||||
}
|
||||
switch (mapEntry->map_type)
|
||||
{
|
||||
case MAP_COMMON:
|
||||
if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
|
||||
LOG_INFO("disable", "Areaflag disabled for world map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LIQUIDSTATUS)
|
||||
LOG_INFO("disable", "Liquid status disabled for world map {}.", entry);
|
||||
break;
|
||||
case MAP_INSTANCE:
|
||||
case MAP_RAID:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for instance map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for instance map {}.", entry);
|
||||
break;
|
||||
case MAP_BATTLEGROUND:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for battleground map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for battleground map {}.", entry);
|
||||
break;
|
||||
case MAP_ARENA:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for arena map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for arena map {}.", entry);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
{
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
|
||||
if (activeEvents.find(entry) != activeEvents.end())
|
||||
{
|
||||
sGameEventMgr->StopEvent(entry);
|
||||
LOG_INFO("disable", "Event entry {} was stopped because it has been disabled.", entry);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_LOOT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
||||
++total_count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Disables in {} ms", total_count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_WARN("server.loading", ">> Loaded 0 disables. DB table `disables` is empty!");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
void CheckQuestDisables()
|
||||
Field* fields;
|
||||
do
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
|
||||
if (!count)
|
||||
fields = result->Fetch();
|
||||
DisableType type = DisableType(fields[0].Get<uint32>());
|
||||
if (type >= MAX_DISABLE_TYPES)
|
||||
{
|
||||
LOG_INFO("server.loading", ">> Checked 0 quest disables.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
LOG_ERROR("sql.sql", "Invalid type {} specified in `disables` table, skipped.", type);
|
||||
continue;
|
||||
}
|
||||
|
||||
// check only quests, rest already done at startup
|
||||
for (DisableTypeMap::iterator itr = m_DisableMap[DISABLE_TYPE_QUEST].begin(); itr != m_DisableMap[DISABLE_TYPE_QUEST].end();)
|
||||
uint32 entry = fields[1].Get<uint32>();
|
||||
uint8 flags = fields[2].Get<uint8>();
|
||||
std::string params_0 = fields[3].Get<std::string>();
|
||||
std::string params_1 = fields[4].Get<std::string>();
|
||||
|
||||
DisableData data;
|
||||
data.flags = flags;
|
||||
|
||||
if (!HandleDisableType(type, entry, flags, params_0, params_1, data))
|
||||
continue;
|
||||
|
||||
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
||||
++total_count;
|
||||
} while (result->NextRow());
|
||||
|
||||
LOG_INFO("server.loading", ">> Loaded {} Disables in {} ms", total_count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Allow to add disables without adding it to the database. Useful for modules.
|
||||
*
|
||||
* @param type Disable type
|
||||
* @param entry Entry of Spell/Quest/Map/BG/Achievement/Map/GameEvent/Item
|
||||
* @param flags Flag depending on Type
|
||||
* @param param0 MapId if DISABLE_TYPE_SPELL used, 0 for all maps.
|
||||
* @param param1 AreaId if DISABLE_TYPE_SPELL used, 0 for all areas.
|
||||
*/
|
||||
void DisableMgr::AddDisable(DisableType type, uint32 entry, uint8 flags, std::string param0, std::string param1)
|
||||
{
|
||||
if (type >= MAX_DISABLE_TYPES)
|
||||
{
|
||||
LOG_ERROR("disables", "AddDisable: Invalid type {} specified for entry {}, skipped.", type);
|
||||
return;
|
||||
}
|
||||
|
||||
DisableData data;
|
||||
data.flags = flags;
|
||||
|
||||
if (!HandleDisableType(type, entry, flags, param0, param1, data))
|
||||
return;
|
||||
|
||||
m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
|
||||
}
|
||||
|
||||
bool DisableMgr::HandleDisableType(DisableType type, uint32 entry, uint8 flags, std::string const& params_0, std::string const& params_1, DisableData& data)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case DISABLE_TYPE_GO_LOS:
|
||||
if (!sObjectMgr->GetGameObjectTemplate(entry))
|
||||
{
|
||||
const uint32 entry = itr->first;
|
||||
if (!sObjectMgr->GetQuestTemplate(entry))
|
||||
LOG_ERROR("sql.sql", "Gameobject entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for gameobject {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_SPELL:
|
||||
if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Spell entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!flags || flags > MAX_SPELL_DISABLE_TYPE)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Disable flags for spell {} are invalid, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flags & SPELL_DISABLE_MAP)
|
||||
{
|
||||
for (std::string_view mapStr : Acore::Tokenize(params_0, ',', true))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Quest entry {} from `disables` doesn't exist, skipped.", entry);
|
||||
m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++);
|
||||
continue;
|
||||
if (Optional<uint32> mapId = Acore::StringTo<uint32>(mapStr))
|
||||
data.params[0].insert(*mapId);
|
||||
else
|
||||
LOG_ERROR("sql.sql", "Disable map '{}' for spell {} is invalid, skipped.", mapStr, entry);
|
||||
}
|
||||
if (itr->second.flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for quest {}, useless data.", entry);
|
||||
++itr;
|
||||
}
|
||||
|
||||
LOG_INFO("server.loading", ">> Checked {} Quest Disables in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
if (flags & SPELL_DISABLE_AREA)
|
||||
{
|
||||
for (std::string_view areaStr : Acore::Tokenize(params_1, ',', true))
|
||||
{
|
||||
if (Optional<uint32> areaId = Acore::StringTo<uint32>(areaStr))
|
||||
data.params[1].insert(*areaId);
|
||||
else
|
||||
LOG_ERROR("sql.sql", "Disable area '{}' for spell {} is invalid, skipped.", areaStr, entry);
|
||||
}
|
||||
}
|
||||
|
||||
// xinef: if spell has disabled los, add flag
|
||||
if (flags & SPELL_DISABLE_LOS)
|
||||
{
|
||||
SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->GetSpellInfo(entry));
|
||||
spellInfo->AttributesEx2 |= SPELL_ATTR2_IGNORE_LINE_OF_SIGHT;
|
||||
}
|
||||
|
||||
break;
|
||||
// checked later
|
||||
case DISABLE_TYPE_QUEST:
|
||||
break;
|
||||
case DISABLE_TYPE_MAP:
|
||||
case DISABLE_TYPE_LFG_MAP:
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (!mapEntry)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
bool isFlagInvalid = false;
|
||||
switch (mapEntry->map_type)
|
||||
{
|
||||
case MAP_COMMON:
|
||||
if (flags)
|
||||
isFlagInvalid = true;
|
||||
break;
|
||||
case MAP_INSTANCE:
|
||||
case MAP_RAID:
|
||||
if (flags & DUNGEON_STATUSFLAG_HEROIC && !GetMapDifficultyData(entry, DUNGEON_DIFFICULTY_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
else if (flags & RAID_STATUSFLAG_10MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_10MAN_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
else if (flags & RAID_STATUSFLAG_25MAN_HEROIC && !GetMapDifficultyData(entry, RAID_DIFFICULTY_25MAN_HEROIC))
|
||||
isFlagInvalid = true;
|
||||
break;
|
||||
case MAP_BATTLEGROUND:
|
||||
case MAP_ARENA:
|
||||
LOG_ERROR("sql.sql", "Battleground map {} specified to be disabled in map case, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
if (isFlagInvalid)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Disable flags for map {} are invalid, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_BATTLEGROUND:
|
||||
if (!sBattlemasterListStore.LookupEntry(entry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Battleground entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for battleground {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_OUTDOORPVP:
|
||||
if (entry > MAX_OUTDOORPVP_TYPES)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "OutdoorPvPTypes value {} from `disables` is invalid, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for outdoor PvP {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
|
||||
if (!sAchievementCriteriaStore.LookupEntry(entry))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Achievement Criteria entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
if (flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for Achievement Criteria {}, useless data.", entry);
|
||||
break;
|
||||
case DISABLE_TYPE_VMAP:
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (!mapEntry)
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
|
||||
return false;
|
||||
}
|
||||
switch (mapEntry->map_type)
|
||||
{
|
||||
case MAP_COMMON:
|
||||
if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
|
||||
LOG_INFO("disable", "Areaflag disabled for world map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LIQUIDSTATUS)
|
||||
LOG_INFO("disable", "Liquid status disabled for world map {}.", entry);
|
||||
break;
|
||||
case MAP_INSTANCE:
|
||||
case MAP_RAID:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for instance map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for instance map {}.", entry);
|
||||
break;
|
||||
case MAP_BATTLEGROUND:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for battleground map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for battleground map {}.", entry);
|
||||
break;
|
||||
case MAP_ARENA:
|
||||
if (flags & VMAP::VMAP_DISABLE_HEIGHT)
|
||||
LOG_INFO("disable", "Height disabled for arena map {}.", entry);
|
||||
if (flags & VMAP::VMAP_DISABLE_LOS)
|
||||
LOG_INFO("disable", "LoS disabled for arena map {}.", entry);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
{
|
||||
GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
|
||||
if (activeEvents.find(entry) != activeEvents.end())
|
||||
{
|
||||
sGameEventMgr->StopEvent(entry);
|
||||
LOG_INFO("disable", "Event entry {} was stopped because it has been disabled.", entry);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_LOOT:
|
||||
break;
|
||||
case MAX_DISABLE_TYPES:
|
||||
{
|
||||
LOG_ERROR("disable", "SourceType out of range for entry {}, skipped", entry);
|
||||
return false;
|
||||
}
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DisableMgr::CheckQuestDisables()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
|
||||
if (!count)
|
||||
{
|
||||
LOG_INFO("server.loading", ">> Checked 0 quest disables.");
|
||||
LOG_INFO("server.loading", " ");
|
||||
return;
|
||||
}
|
||||
|
||||
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
|
||||
// check only quests, rest already done at startup
|
||||
for (DisableTypeMap::iterator itr = m_DisableMap[DISABLE_TYPE_QUEST].begin(); itr != m_DisableMap[DISABLE_TYPE_QUEST].end();)
|
||||
{
|
||||
if (type > MAX_DISABLE_TYPES)
|
||||
const uint32 entry = itr->first;
|
||||
if (!sObjectMgr->GetQuestTemplate(entry))
|
||||
{
|
||||
LOG_ERROR("server", "Disables::IsDisabledFor() called with unknown disable type {}! (entry {}, flags {}).", type, entry, flags);
|
||||
return false;
|
||||
LOG_ERROR("sql.sql", "Quest entry {} from `disables` doesn't exist, skipped.", entry);
|
||||
m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++);
|
||||
continue;
|
||||
}
|
||||
if (itr->second.flags)
|
||||
LOG_ERROR("sql.sql", "Disable flags specified for quest {}, useless data.", entry);
|
||||
++itr;
|
||||
}
|
||||
|
||||
if (m_DisableMap[type].empty())
|
||||
return false;
|
||||
|
||||
DisableTypeMap::iterator itr = m_DisableMap[type].find(entry);
|
||||
if (itr == m_DisableMap[type].end()) // not disabled
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case DISABLE_TYPE_SPELL:
|
||||
{
|
||||
uint8 spellFlags = itr->second.flags;
|
||||
if (unit)
|
||||
{
|
||||
if ((spellFlags & SPELL_DISABLE_PLAYER && unit->IsPlayer()) ||
|
||||
(unit->IsCreature() && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
|
||||
{
|
||||
if (spellFlags & SPELL_DISABLE_MAP)
|
||||
{
|
||||
std::set<uint32> const& mapIds = itr->second.params[0];
|
||||
if (mapIds.find(unit->GetMapId()) != mapIds.end())
|
||||
return true; // Spell is disabled on current map
|
||||
|
||||
if (!(spellFlags & SPELL_DISABLE_AREA))
|
||||
return false; // Spell is disabled on another map, but not this one, return false
|
||||
|
||||
// Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
|
||||
}
|
||||
|
||||
if (spellFlags & SPELL_DISABLE_AREA)
|
||||
{
|
||||
std::set<uint32> const& areaIds = itr->second.params[1];
|
||||
if (areaIds.find(unit->GetAreaId()) != areaIds.end())
|
||||
return true; // Spell is disabled in this area
|
||||
return false; // Spell is disabled in another area, but not this one, return false
|
||||
}
|
||||
else
|
||||
return true; // Spell disabled for all maps
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_MAP:
|
||||
case DISABLE_TYPE_LFG_MAP:
|
||||
if (Player const* player = unit->ToPlayer())
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (mapEntry->IsDungeon())
|
||||
{
|
||||
uint8 disabledModes = itr->second.flags;
|
||||
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
|
||||
GetDownscaledMapDifficultyData(entry, targetDifficulty);
|
||||
switch (targetDifficulty)
|
||||
{
|
||||
case DUNGEON_DIFFICULTY_NORMAL:
|
||||
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
|
||||
case DUNGEON_DIFFICULTY_HEROIC:
|
||||
return disabledModes & DUNGEON_STATUSFLAG_HEROIC;
|
||||
case RAID_DIFFICULTY_10MAN_HEROIC:
|
||||
return disabledModes & RAID_STATUSFLAG_10MAN_HEROIC;
|
||||
case RAID_DIFFICULTY_25MAN_HEROIC:
|
||||
return disabledModes & RAID_STATUSFLAG_25MAN_HEROIC;
|
||||
}
|
||||
}
|
||||
else if (mapEntry->map_type == MAP_COMMON)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
case DISABLE_TYPE_QUEST:
|
||||
return true;
|
||||
case DISABLE_TYPE_BATTLEGROUND:
|
||||
case DISABLE_TYPE_OUTDOORPVP:
|
||||
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
|
||||
return true;
|
||||
case DISABLE_TYPE_VMAP:
|
||||
return flags & itr->second.flags;
|
||||
case DISABLE_TYPE_GO_LOS:
|
||||
return true;
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
return true;
|
||||
case DISABLE_TYPE_LOOT:
|
||||
return true;
|
||||
}
|
||||
LOG_INFO("server.loading", ">> Checked {} Quest Disables in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
LOG_INFO("server.loading", " ");
|
||||
}
|
||||
|
||||
bool DisableMgr::IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags)
|
||||
{
|
||||
if (type >= MAX_DISABLE_TYPES)
|
||||
{
|
||||
LOG_ERROR("server", "Disables::IsDisabledFor() called with unknown disable type {}! (entry {}, flags {}).", type, entry, flags);
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsVMAPDisabledFor(uint32 entry, uint8 flags)
|
||||
{
|
||||
return IsDisabledFor(DISABLE_TYPE_VMAP, entry, nullptr, flags);
|
||||
}
|
||||
if (m_DisableMap[type].empty())
|
||||
return false;
|
||||
|
||||
bool IsPathfindingEnabled(const Map* map)
|
||||
DisableTypeMap::iterator itr = m_DisableMap[type].find(entry);
|
||||
if (itr == m_DisableMap[type].end()) // not disabled
|
||||
return false;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
if (!map)
|
||||
case DISABLE_TYPE_SPELL:
|
||||
{
|
||||
uint8 spellFlags = itr->second.flags;
|
||||
if (unit)
|
||||
{
|
||||
if ((spellFlags & SPELL_DISABLE_PLAYER && unit->IsPlayer()) ||
|
||||
(unit->IsCreature() && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
|
||||
{
|
||||
if (spellFlags & SPELL_DISABLE_MAP)
|
||||
{
|
||||
std::set<uint32> const& mapIds = itr->second.params[0];
|
||||
if (mapIds.find(unit->GetMapId()) != mapIds.end())
|
||||
return true; // Spell is disabled on current map
|
||||
|
||||
if (!(spellFlags & SPELL_DISABLE_AREA))
|
||||
return false; // Spell is disabled on another map, but not this one, return false
|
||||
|
||||
// Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
|
||||
}
|
||||
|
||||
if (spellFlags & SPELL_DISABLE_AREA)
|
||||
{
|
||||
std::set<uint32> const& areaIds = itr->second.params[1];
|
||||
if (areaIds.find(unit->GetAreaId()) != areaIds.end())
|
||||
return true; // Spell is disabled in this area
|
||||
return false; // Spell is disabled in another area, but not this one, return false
|
||||
}
|
||||
else
|
||||
return true; // Spell disabled for all maps
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
|
||||
return true;
|
||||
|
||||
break;
|
||||
}
|
||||
case DISABLE_TYPE_MAP:
|
||||
case DISABLE_TYPE_LFG_MAP:
|
||||
if (Player const* player = unit->ToPlayer())
|
||||
{
|
||||
MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
|
||||
if (mapEntry->IsDungeon())
|
||||
{
|
||||
uint8 disabledModes = itr->second.flags;
|
||||
Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
|
||||
GetDownscaledMapDifficultyData(entry, targetDifficulty);
|
||||
switch (targetDifficulty)
|
||||
{
|
||||
case DUNGEON_DIFFICULTY_NORMAL:
|
||||
return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
|
||||
case DUNGEON_DIFFICULTY_HEROIC:
|
||||
return disabledModes & DUNGEON_STATUSFLAG_HEROIC;
|
||||
case RAID_DIFFICULTY_10MAN_HEROIC:
|
||||
return disabledModes & RAID_STATUSFLAG_10MAN_HEROIC;
|
||||
case RAID_DIFFICULTY_25MAN_HEROIC:
|
||||
return disabledModes & RAID_STATUSFLAG_25MAN_HEROIC;
|
||||
}
|
||||
}
|
||||
else if (mapEntry->map_type == MAP_COMMON)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
return !MMAP::MMapFactory::forbiddenMaps[map->GetId()] && (sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS) ? true : map->IsBattlegroundOrArena());
|
||||
case DISABLE_TYPE_VMAP:
|
||||
return flags & itr->second.flags;
|
||||
case DISABLE_TYPE_QUEST:
|
||||
case DISABLE_TYPE_BATTLEGROUND:
|
||||
case DISABLE_TYPE_OUTDOORPVP:
|
||||
case DISABLE_TYPE_ACHIEVEMENT_CRITERIA:
|
||||
case DISABLE_TYPE_GO_LOS:
|
||||
case DISABLE_TYPE_GAME_EVENT:
|
||||
case DISABLE_TYPE_LOOT:
|
||||
return true;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} // Namespace
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DisableMgr::IsVMAPDisabledFor(uint32 entry, uint8 flags)
|
||||
{
|
||||
return IsDisabledFor(DISABLE_TYPE_VMAP, entry, nullptr, flags);
|
||||
}
|
||||
|
||||
bool DisableMgr::IsPathfindingEnabled(Map const* map)
|
||||
{
|
||||
if (!map)
|
||||
return false;
|
||||
|
||||
return !MMAP::MMapFactory::forbiddenMaps[map->GetId()] && (sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS) ? true : map->IsBattlegroundOrArena());
|
||||
}
|
||||
|
||||
@ -15,8 +15,8 @@
|
||||
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ACORE_DISABLEMGR_H
|
||||
#define ACORE_DISABLEMGR_H
|
||||
#ifndef _DISABLEMGR_H
|
||||
#define _DISABLEMGR_H
|
||||
|
||||
#include "Define.h"
|
||||
#include "Map.h"
|
||||
@ -34,7 +34,8 @@ enum DisableType
|
||||
DISABLE_TYPE_GO_LOS = 7,
|
||||
DISABLE_TYPE_LFG_MAP = 8,
|
||||
DISABLE_TYPE_GAME_EVENT = 9,
|
||||
DISABLE_TYPE_LOOT = 10
|
||||
DISABLE_TYPE_LOOT = 10,
|
||||
MAX_DISABLE_TYPES
|
||||
};
|
||||
|
||||
enum SpellDisableTypes
|
||||
@ -46,18 +47,43 @@ enum SpellDisableTypes
|
||||
SPELL_DISABLE_MAP = 0x10,
|
||||
SPELL_DISABLE_AREA = 0x20,
|
||||
SPELL_DISABLE_LOS = 0x40,
|
||||
MAX_SPELL_DISABLE_TYPE = ( SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
|
||||
SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA |
|
||||
SPELL_DISABLE_LOS)
|
||||
MAX_SPELL_DISABLE_TYPE = (SPELL_DISABLE_PLAYER | SPELL_DISABLE_CREATURE | SPELL_DISABLE_PET |
|
||||
SPELL_DISABLE_DEPRECATED_SPELL | SPELL_DISABLE_MAP | SPELL_DISABLE_AREA |
|
||||
SPELL_DISABLE_LOS)
|
||||
};
|
||||
|
||||
namespace DisableMgr
|
||||
struct DisableData
|
||||
{
|
||||
void LoadDisables();
|
||||
bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
|
||||
void CheckQuestDisables();
|
||||
bool IsVMAPDisabledFor(uint32 entry, uint8 flags);
|
||||
bool IsPathfindingEnabled(const Map* map);
|
||||
}
|
||||
uint8 flags;
|
||||
std::set<uint32> params[2]; // params0, params1
|
||||
};
|
||||
|
||||
#endif //ACORE_DISABLEMGR_H
|
||||
class DisableMgr
|
||||
{
|
||||
private:
|
||||
DisableMgr();
|
||||
~DisableMgr();
|
||||
|
||||
public:
|
||||
static DisableMgr* instance();
|
||||
|
||||
void LoadDisables();
|
||||
void AddDisable(DisableType type, uint32 entry, uint8 flags, std::string param0, std::string param1);
|
||||
bool HandleDisableType(DisableType type, uint32 entry, uint8 flags, std::string const& params_0, std::string const& params_1, DisableData& data);
|
||||
static bool IsDisabledFor(DisableType type, uint32 entry, Unit const* unit, uint8 flags = 0);
|
||||
void CheckQuestDisables();
|
||||
static bool IsVMAPDisabledFor(uint32 entry, uint8 flags);
|
||||
static bool IsPathfindingEnabled(Map const* map);
|
||||
|
||||
private:
|
||||
// single disables here with optional data
|
||||
typedef std::map<uint32, DisableData> DisableTypeMap;
|
||||
// global disable map by source
|
||||
typedef std::map<DisableType, DisableTypeMap> DisableMap;
|
||||
|
||||
static DisableMap m_DisableMap;
|
||||
};
|
||||
|
||||
#define sDisableMgr DisableMgr::instance()
|
||||
|
||||
#endif //_DISABLEMGR_H
|
||||
|
||||
@ -410,9 +410,9 @@ namespace lfg
|
||||
uint32 lockData = 0;
|
||||
if (dungeon->expansion > expansion || (onlySeasonalBosses && !dungeon->seasonal))
|
||||
lockData = LFG_LOCKSTATUS_INSUFFICIENT_EXPANSION;
|
||||
else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
|
||||
else if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, dungeon->map, player))
|
||||
lockData = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
else if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
|
||||
else if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_LFG_MAP, dungeon->map, player))
|
||||
lockData = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
else if (dungeon->difficulty > DUNGEON_DIFFICULTY_NORMAL && (!mapEntry || !mapEntry->IsRaid()) && sInstanceSaveMgr->PlayerIsPermBoundToInstance(player->GetGUID(), dungeon->map, Difficulty(dungeon->difficulty)))
|
||||
lockData = LFG_LOCKSTATUS_RAID_LOCKED;
|
||||
|
||||
@ -2594,7 +2594,7 @@ void GameObject::EnableCollision(bool enable)
|
||||
GetMap()->InsertGameObjectModel(*m_model);*/
|
||||
|
||||
uint32 phaseMask = 0;
|
||||
if (enable && !DisableMgr::IsDisabledFor(DISABLE_TYPE_GO_LOS, GetEntry(), nullptr))
|
||||
if (enable && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_GO_LOS, GetEntry(), nullptr))
|
||||
phaseMask = GetPhaseMask();
|
||||
|
||||
m_model->enable(phaseMask);
|
||||
|
||||
@ -1340,7 +1340,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
||||
return false;
|
||||
}
|
||||
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
if (AccountMgr::IsPlayerAccount(GetSession()->GetSecurity()) && sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, mapid, this))
|
||||
{
|
||||
LOG_ERROR("entities.player", "Player ({}, name: {}) tried to enter a forbidden map {}", GetGUID().ToString(), GetName(), mapid);
|
||||
SendTransferAborted(mapid, TRANSFER_ABORT_MAP_NOT_ALLOWED);
|
||||
|
||||
@ -236,7 +236,7 @@ Quest const* Player::GetNextQuest(ObjectGuid guid, Quest const* quest)
|
||||
|
||||
bool Player::CanSeeStartQuest(Quest const* quest)
|
||||
{
|
||||
if (!DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) &&
|
||||
if (!sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this) && SatisfyQuestClass(quest, false) && SatisfyQuestRace(quest, false) &&
|
||||
SatisfyQuestSkill(quest, false) && SatisfyQuestExclusiveGroup(quest, false) && SatisfyQuestReputation(quest, false) &&
|
||||
SatisfyQuestPreviousQuest(quest, false) && SatisfyQuestNextChain(quest, false) &&
|
||||
SatisfyQuestPrevChain(quest, false) && SatisfyQuestDay(quest, false) && SatisfyQuestWeek(quest, false) &&
|
||||
@ -250,7 +250,7 @@ bool Player::CanSeeStartQuest(Quest const* quest)
|
||||
|
||||
bool Player::CanTakeQuest(Quest const* quest, bool msg)
|
||||
{
|
||||
return !DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this)
|
||||
return !sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, quest->GetQuestId(), this)
|
||||
&& SatisfyQuestStatus(quest, msg) && SatisfyQuestExclusiveGroup(quest, msg)
|
||||
&& SatisfyQuestClass(quest, msg) && SatisfyQuestRace(quest, msg) && SatisfyQuestLevel(quest, msg)
|
||||
&& SatisfyQuestSkill(quest, msg) && SatisfyQuestReputation(quest, msg)
|
||||
|
||||
@ -6722,7 +6722,7 @@ bool Player::Satisfy(DungeonProgressionRequirements const* ar, uint32 target_map
|
||||
LevelMax = ar->levelMax;
|
||||
}
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_MAP, target_map, this))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_MAP, target_map, this))
|
||||
{
|
||||
GetSession()->SendAreaTriggerMessage("{}", GetSession()->GetAcoreString(LANG_INSTANCE_CLOSED));
|
||||
return false;
|
||||
|
||||
@ -20413,7 +20413,7 @@ void Unit::PetSpellFail(SpellInfo const* spellInfo, Unit* target, uint32 result)
|
||||
if (!charmInfo || !IsCreature())
|
||||
return;
|
||||
|
||||
if ((DisableMgr::IsPathfindingEnabled(GetMap()) || result != SPELL_FAILED_LINE_OF_SIGHT) && target)
|
||||
if ((sDisableMgr->IsPathfindingEnabled(GetMap()) || result != SPELL_FAILED_LINE_OF_SIGHT) && target)
|
||||
{
|
||||
if ((result == SPELL_FAILED_LINE_OF_SIGHT || result == SPELL_FAILED_OUT_OF_RANGE) || !ToCreature()->HasReactState(REACT_PASSIVE))
|
||||
if (Unit* owner = GetOwner())
|
||||
|
||||
@ -133,7 +133,7 @@ void GameEventMgr::StartInternalEvent(uint16 event_id)
|
||||
|
||||
bool GameEventMgr::StartEvent(uint16 event_id, bool overwrite)
|
||||
{
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_GAME_EVENT, event_id, nullptr) && !overwrite)
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_GAME_EVENT, event_id, nullptr) && !overwrite)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -3072,7 +3072,7 @@ void ObjectMgr::LoadItemTemplates()
|
||||
else if (itemTemplate.Spells[1].SpellId != -1)
|
||||
{
|
||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(itemTemplate.Spells[1].SpellId);
|
||||
if (!spellInfo && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
|
||||
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[1].SpellId, nullptr))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, 1 + 1, itemTemplate.Spells[1].SpellId);
|
||||
itemTemplate.Spells[0].SpellId = 0;
|
||||
@ -3120,7 +3120,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 && !DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
|
||||
if (!spellInfo && !sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, itemTemplate.Spells[j].SpellId, nullptr))
|
||||
{
|
||||
LOG_ERROR("sql.sql", "Item (Entry: {}) has wrong (not existing) spell in spellid_{} ({})", entry, j + 1, itemTemplate.Spells[j].SpellId);
|
||||
itemTemplate.Spells[j].SpellId = 0;
|
||||
@ -4616,7 +4616,7 @@ void ObjectMgr::LoadQuests()
|
||||
for (QuestMap::iterator iter = _questTemplates.begin(); iter != _questTemplates.end(); ++iter)
|
||||
{
|
||||
// skip post-loading checks for disabled quests
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_QUEST, iter->first, nullptr))
|
||||
continue;
|
||||
|
||||
Quest* qinfo = iter->second;
|
||||
|
||||
@ -90,7 +90,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// chosen battleground type is disabled
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, bgTypeId_, nullptr))
|
||||
{
|
||||
ChatHandler(this).PSendSysMessage(LANG_BG_DISABLED);
|
||||
return;
|
||||
@ -721,7 +721,7 @@ void WorldSession::HandleBattlemasterJoinArena(WorldPacket& recvData)
|
||||
}
|
||||
|
||||
// arenas disabled
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_BATTLEGROUND, BATTLEGROUND_AA, nullptr))
|
||||
{
|
||||
ChatHandler(this).PSendSysMessage(LANG_ARENA_DISABLED);
|
||||
return;
|
||||
|
||||
@ -158,7 +158,7 @@ void WorldSession::HandleCalendarGetCalendar(WorldPacket& /*recvData*/)
|
||||
{
|
||||
HolidaysEntry const* holiday = sHolidaysStore.LookupEntry(entry);
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_GAME_EVENT, sGameEventMgr->GetHolidayEventId(holiday->Id), nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_GAME_EVENT, sGameEventMgr->GetHolidayEventId(holiday->Id), nullptr))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -232,7 +232,7 @@ void WorldSession::HandlePetActionHelper(Unit* pet, ObjectGuid guid1, uint32 spe
|
||||
return;
|
||||
|
||||
// Not let attack through obstructions
|
||||
bool checkLos = !DisableMgr::IsPathfindingEnabled(pet->GetMap()) ||
|
||||
bool checkLos = !sDisableMgr->IsPathfindingEnabled(pet->GetMap()) ||
|
||||
(TargetUnit->IsCreature() && (TargetUnit->ToCreature()->isWorldBoss() || TargetUnit->ToCreature()->IsDungeonBoss()));
|
||||
|
||||
if (checkLos && !pet->IsWithinLOSInMap(TargetUnit))
|
||||
|
||||
@ -421,7 +421,7 @@ bool LootItem::AllowedForPlayer(Player const* player, ObjectGuid source) const
|
||||
return false;
|
||||
}
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_LOOT, itemid, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_LOOT, itemid, nullptr))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -145,7 +145,7 @@ bool Map::ExistVMap(uint32 mapid, int gx, int gy)
|
||||
|
||||
void Map::LoadMMap(int gx, int gy)
|
||||
{
|
||||
if (!DisableMgr::IsPathfindingEnabled(this)) // pussywizard
|
||||
if (!sDisableMgr->IsPathfindingEnabled(this)) // pussywizard
|
||||
return;
|
||||
|
||||
int mmapLoadResult = MMAP::MMapFactory::createOrGetMMapMgr()->loadMap(GetId(), gx, gy);
|
||||
|
||||
@ -63,7 +63,7 @@ void HomeMovementGenerator<Creature>::_setTargetLocation(Creature* owner)
|
||||
}
|
||||
|
||||
owner->UpdateAllowedPositionZ(x, y, z);
|
||||
init.MoveTo(x, y, z, DisableMgr::IsPathfindingEnabled(owner->FindMap()), true);
|
||||
init.MoveTo(x, y, z, sDisableMgr->IsPathfindingEnabled(owner->FindMap()), true);
|
||||
init.SetWalk(_walk);
|
||||
init.Launch();
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ PathGenerator::PathGenerator(WorldObject const* owner) :
|
||||
memset(_pathPolyRefs, 0, sizeof(_pathPolyRefs));
|
||||
|
||||
uint32 mapId = _source->GetMapId();
|
||||
//if (DisableMgr::IsPathfindingEnabled(_sourceUnit->FindMap()))
|
||||
//if (sDisableMgr->IsPathfindingEnabled(_sourceUnit->FindMap()))
|
||||
{
|
||||
MMAP::MMapMgr* mmap = MMAP::MMapFactory::createOrGetMMapMgr();
|
||||
_navMesh = mmap->GetNavMesh(mapId);
|
||||
|
||||
@ -60,7 +60,7 @@ void OutdoorPvPMgr::InitOutdoorPvP()
|
||||
{
|
||||
typeId = fields[0].Get<uint8>();
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, nullptr))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_OUTDOORPVP, typeId, nullptr))
|
||||
continue;
|
||||
|
||||
if (typeId >= MAX_OUTDOORPVP_TYPES)
|
||||
|
||||
@ -3530,7 +3530,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
|
||||
_spellEvent = new SpellEvent(this);
|
||||
m_caster->m_Events.AddEvent(_spellEvent, m_caster->m_Events.CalculateTime(1));
|
||||
|
||||
if (DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
||||
if (sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, m_spellInfo->Id, m_caster))
|
||||
{
|
||||
SendCastResult(SPELL_FAILED_SPELL_UNAVAILABLE);
|
||||
finish(false);
|
||||
@ -6247,7 +6247,7 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
return SPELL_FAILED_BAD_TARGETS;
|
||||
// Xinef: Pass only explicit unit target spells
|
||||
// pussywizard:
|
||||
if (DisableMgr::IsPathfindingEnabled(m_caster->FindMap()) && m_spellInfo->NeedsExplicitUnitTarget())
|
||||
if (sDisableMgr->IsPathfindingEnabled(m_caster->FindMap()) && m_spellInfo->NeedsExplicitUnitTarget())
|
||||
{
|
||||
Unit* target = m_targets.GetUnitTarget();
|
||||
if (!target)
|
||||
@ -7960,7 +7960,7 @@ bool Spell::CheckEffectTarget(Unit const* target, uint32 eff) const
|
||||
|
||||
// if spell is triggered, need to check for LOS disable on the aura triggering it and inherit that behaviour
|
||||
if (IsTriggered() && m_triggeredByAuraSpell && (m_triggeredByAuraSpell.spellInfo->HasAttribute(SPELL_ATTR2_IGNORE_LINE_OF_SIGHT) ||
|
||||
DisableMgr::IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell.spellInfo->Id, nullptr, SPELL_DISABLE_LOS)))
|
||||
sDisableMgr->IsDisabledFor(DISABLE_TYPE_SPELL, m_triggeredByAuraSpell.spellInfo->Id, nullptr, SPELL_DISABLE_LOS)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -1721,7 +1721,7 @@ void World::SetInitialWorldSettings()
|
||||
LoadRandomEnchantmentsTable();
|
||||
|
||||
LOG_INFO("server.loading", "Loading Disables");
|
||||
DisableMgr::LoadDisables(); // must be before loading quests and items
|
||||
sDisableMgr->LoadDisables(); // must be before loading quests and items
|
||||
|
||||
LOG_INFO("server.loading", "Loading Items..."); // must be after LoadRandomEnchantmentsTable and LoadPageTexts
|
||||
sObjectMgr->LoadItemTemplates();
|
||||
@ -1802,7 +1802,7 @@ void World::SetInitialWorldSettings()
|
||||
sObjectMgr->LoadQuests(); // must be loaded after DBCs, creature_template, item_template, gameobject tables
|
||||
|
||||
LOG_INFO("server.loading", "Checking Quest Disables");
|
||||
DisableMgr::CheckQuestDisables(); // must be after loading quests
|
||||
sDisableMgr->CheckQuestDisables(); // must be after loading quests
|
||||
|
||||
LOG_INFO("server.loading", "Loading Quest POI");
|
||||
sObjectMgr->LoadQuestPOI();
|
||||
|
||||
@ -217,8 +217,7 @@ public:
|
||||
static bool HandleMmapStatsCommand(ChatHandler* handler)
|
||||
{
|
||||
handler->PSendSysMessage("mmap stats:");
|
||||
//handler->PSendSysMessage(" global mmap pathfinding is {}abled", DisableMgr::IsPathfindingEnabled(mapId) ? "en" : "dis");
|
||||
|
||||
//handler->PSendSysMessage(" global mmap pathfinding is {}abled", sDisableMgr->IsPathfindingEnabled(mapId) ? "en" : "dis");
|
||||
MMAP::MMapMgr* manager = MMAP::MMapFactory::createOrGetMMapMgr();
|
||||
handler->PSendSysMessage(" {} maps loaded with {} tiles overall", manager->getLoadedMapsCount(), manager->getLoadedTilesCount());
|
||||
|
||||
|
||||
@ -1063,9 +1063,9 @@ public:
|
||||
static bool HandleReloadDisablesCommand(ChatHandler* handler)
|
||||
{
|
||||
LOG_INFO("server.loading", "Reloading disables table...");
|
||||
DisableMgr::LoadDisables();
|
||||
sDisableMgr->LoadDisables();
|
||||
LOG_INFO("server.loading", "Checking quest disables...");
|
||||
DisableMgr::CheckQuestDisables();
|
||||
sDisableMgr->CheckQuestDisables();
|
||||
handler->SendGlobalGMSysMessage("DB table `disables` reloaded.");
|
||||
return true;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user