AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
DisableMgr Class Reference

#include "DisableMgr.h"

Public Types

typedef std::unordered_map< uint32, DisableDataDisableTypeMap
 
typedef std::array< DisableTypeMap, MAX_DISABLE_TYPESDisableMap
 

Public Member Functions

void LoadDisables ()
 
void AddDisable (DisableType type, uint32 entry, uint8 flags, std::string const &param0, std::string const &param1)
 Allow to add disables without adding it to the database. Useful for modules.
 
bool HandleDisableType (DisableType type, uint32 entry, uint8 flags, std::string const &params_0, std::string const &params_1, DisableData &data)
 
void CheckQuestDisables ()
 

Static Public Member Functions

static DisableMgrinstance ()
 
static bool IsDisabledFor (DisableType type, uint32 entry, Unit const *unit, uint8 flags=0)
 
static bool IsVMAPDisabledFor (uint32 entry, uint8 flags)
 
static bool IsPathfindingEnabled (Map const *map)
 

Private Member Functions

 DisableMgr ()
 
 ~DisableMgr ()
 

Static Private Attributes

static DisableMap m_DisableMap
 

Detailed Description

Member Typedef Documentation

◆ DisableMap

◆ DisableTypeMap

typedef std::unordered_map<uint32, DisableData> DisableMgr::DisableTypeMap

Constructor & Destructor Documentation

◆ DisableMgr()

DisableMgr::DisableMgr ( )
private
33{}

◆ ~DisableMgr()

DisableMgr::~DisableMgr ( )
private
34{}

Member Function Documentation

◆ AddDisable()

void DisableMgr::AddDisable ( DisableType  type,
uint32  entry,
uint8  flags,
std::string const &  param0,
std::string const &  param1 
)

Allow to add disables without adding it to the database. Useful for modules.

Parameters
typeDisable type
entryEntry of Spell/Quest/Map/BG/Achievement/Map/GameEvent/Item
flagsFlag depending on Type
param0MapId if DISABLE_TYPE_SPELL used, 0 for all maps.
param1AreaId if DISABLE_TYPE_SPELL used, 0 for all areas.
101{
102 if (type >= MAX_DISABLE_TYPES)
103 {
104 LOG_ERROR("disables", "AddDisable: Invalid type {} specified for entry {}, skipped.", type);
105 return;
106 }
107
108 DisableData data;
109 data.flags = flags;
110
111 if (!HandleDisableType(type, entry, flags, param0, param1, data))
112 return;
113
114 m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
115}
@ MAX_DISABLE_TYPES
Definition DisableMgr.h:39
#define LOG_ERROR(filterType__,...)
Definition Log.h:157
bool HandleDisableType(DisableType type, uint32 entry, uint8 flags, std::string const &params_0, std::string const &params_1, DisableData &data)
Definition DisableMgr.cpp:117
static DisableMap m_DisableMap
Definition DisableMgr.h:85
Definition DisableMgr.h:57
uint8 flags
Definition DisableMgr.h:58

References DisableData::flags, HandleDisableType(), LOG_ERROR, m_DisableMap, and MAX_DISABLE_TYPES.

◆ CheckQuestDisables()

void DisableMgr::CheckQuestDisables ( )
304{
305 uint32 oldMSTime = getMSTime();
306
307 uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
308 if (!count)
309 {
310 LOG_INFO("server.loading", ">> Checked 0 quest disables.");
311 LOG_INFO("server.loading", " ");
312 return;
313 }
314
315 // check only quests, rest already done at startup
316 for (DisableTypeMap::iterator itr = m_DisableMap[DISABLE_TYPE_QUEST].begin(); itr != m_DisableMap[DISABLE_TYPE_QUEST].end();)
317 {
318 const uint32 entry = itr->first;
319 if (!sObjectMgr->GetQuestTemplate(entry))
320 {
321 LOG_ERROR("sql.sql", "Quest entry {} from `disables` doesn't exist, skipped.", entry);
322 m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++);
323 continue;
324 }
325 if (itr->second.flags)
326 LOG_ERROR("sql.sql", "Disable flags specified for quest {}, useless data.", entry);
327 ++itr;
328 }
329
330 LOG_INFO("server.loading", ">> Checked {} Quest Disables in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
331 LOG_INFO("server.loading", " ");
332}
std::uint32_t uint32
Definition Define.h:107
@ DISABLE_TYPE_QUEST
Definition DisableMgr.h:29
#define LOG_INFO(filterType__,...)
Definition Log.h:165
#define sObjectMgr
Definition ObjectMgr.h:1636
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103

References DISABLE_TYPE_QUEST, getMSTime(), GetMSTimeDiffToNow(), LOG_ERROR, LOG_INFO, m_DisableMap, and sObjectMgr.

◆ HandleDisableType()

bool DisableMgr::HandleDisableType ( DisableType  type,
uint32  entry,
uint8  flags,
std::string const &  params_0,
std::string const &  params_1,
DisableData data 
)
118{
119 switch (type)
120 {
122 if (!sObjectMgr->GetGameObjectTemplate(entry))
123 {
124 LOG_ERROR("sql.sql", "Gameobject entry {} from `disables` doesn't exist in dbc, skipped.", entry);
125 return false;
126 }
127 if (flags)
128 LOG_ERROR("sql.sql", "Disable flags specified for gameobject {}, useless data.", entry);
129 break;
131 if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
132 {
133 LOG_ERROR("sql.sql", "Spell entry {} from `disables` doesn't exist in dbc, skipped.", entry);
134 return false;
135 }
136
137 if (!flags || flags > MAX_SPELL_DISABLE_TYPE)
138 {
139 LOG_ERROR("sql.sql", "Disable flags for spell {} are invalid, skipped.", entry);
140 return false;
141 }
142
143 if (flags & SPELL_DISABLE_MAP)
144 {
145 for (std::string_view mapStr : Acore::Tokenize(params_0, ',', true))
146 {
147 if (Optional<uint32> mapId = Acore::StringTo<uint32>(mapStr))
148 data.params[0].insert(*mapId);
149 else
150 LOG_ERROR("sql.sql", "Disable map '{}' for spell {} is invalid, skipped.", mapStr, entry);
151 }
152 }
153
154 if (flags & SPELL_DISABLE_AREA)
155 {
156 for (std::string_view areaStr : Acore::Tokenize(params_1, ',', true))
157 {
158 if (Optional<uint32> areaId = Acore::StringTo<uint32>(areaStr))
159 data.params[1].insert(*areaId);
160 else
161 LOG_ERROR("sql.sql", "Disable area '{}' for spell {} is invalid, skipped.", areaStr, entry);
162 }
163 }
164
165 // xinef: if spell has disabled los, add flag
166 if (flags & SPELL_DISABLE_LOS)
167 {
168 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->GetSpellInfo(entry));
170 }
171
172 break;
173 // checked later
175 break;
176 case DISABLE_TYPE_MAP:
178 {
179 MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
180 if (!mapEntry)
181 {
182 LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
183 return false;
184 }
185 bool isFlagInvalid = false;
186 switch (mapEntry->map_type)
187 {
188 case MAP_COMMON:
189 if (flags)
190 isFlagInvalid = true;
191 break;
192 case MAP_INSTANCE:
193 case MAP_RAID:
195 isFlagInvalid = true;
197 isFlagInvalid = true;
199 isFlagInvalid = true;
200 break;
201 case MAP_BATTLEGROUND:
202 case MAP_ARENA:
203 LOG_ERROR("sql.sql", "Battleground map {} specified to be disabled in map case, skipped.", entry);
204 return false;
205 }
206 if (isFlagInvalid)
207 {
208 LOG_ERROR("sql.sql", "Disable flags for map {} are invalid, skipped.", entry);
209 return false;
210 }
211 break;
212 }
214 if (!sBattlemasterListStore.LookupEntry(entry))
215 {
216 LOG_ERROR("sql.sql", "Battleground entry {} from `disables` doesn't exist in dbc, skipped.", entry);
217 return false;
218 }
219 if (flags)
220 LOG_ERROR("sql.sql", "Disable flags specified for battleground {}, useless data.", entry);
221 break;
223 if (entry > MAX_OUTDOORPVP_TYPES)
224 {
225 LOG_ERROR("sql.sql", "OutdoorPvPTypes value {} from `disables` is invalid, skipped.", entry);
226 return false;
227 }
228 if (flags)
229 LOG_ERROR("sql.sql", "Disable flags specified for outdoor PvP {}, useless data.", entry);
230 break;
232 if (!sAchievementCriteriaStore.LookupEntry(entry))
233 {
234 LOG_ERROR("sql.sql", "Achievement Criteria entry {} from `disables` doesn't exist in dbc, skipped.", entry);
235 return false;
236 }
237 if (flags)
238 LOG_ERROR("sql.sql", "Disable flags specified for Achievement Criteria {}, useless data.", entry);
239 break;
241 {
242 MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
243 if (!mapEntry)
244 {
245 LOG_ERROR("sql.sql", "Map entry {} from `disables` doesn't exist in dbc, skipped.", entry);
246 return false;
247 }
248 switch (mapEntry->map_type)
249 {
250 case MAP_COMMON:
251 if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
252 LOG_INFO("disable", "Areaflag disabled for world map {}.", entry);
254 LOG_INFO("disable", "Liquid status disabled for world map {}.", entry);
255 break;
256 case MAP_INSTANCE:
257 case MAP_RAID:
258 if (flags & VMAP::VMAP_DISABLE_HEIGHT)
259 LOG_INFO("disable", "Height disabled for instance map {}.", entry);
260 if (flags & VMAP::VMAP_DISABLE_LOS)
261 LOG_INFO("disable", "LoS disabled for instance map {}.", entry);
262 break;
263 case MAP_BATTLEGROUND:
264 if (flags & VMAP::VMAP_DISABLE_HEIGHT)
265 LOG_INFO("disable", "Height disabled for battleground map {}.", entry);
266 if (flags & VMAP::VMAP_DISABLE_LOS)
267 LOG_INFO("disable", "LoS disabled for battleground map {}.", entry);
268 break;
269 case MAP_ARENA:
270 if (flags & VMAP::VMAP_DISABLE_HEIGHT)
271 LOG_INFO("disable", "Height disabled for arena map {}.", entry);
272 if (flags & VMAP::VMAP_DISABLE_LOS)
273 LOG_INFO("disable", "LoS disabled for arena map {}.", entry);
274 break;
275 default:
276 break;
277 }
278 break;
279 }
281 {
282 GameEventMgr::ActiveEvents const& activeEvents = sGameEventMgr->GetActiveEventList();
283 if (activeEvents.find(entry) != activeEvents.end())
284 {
285 sGameEventMgr->StopEvent(entry);
286 LOG_INFO("disable", "Event entry {} was stopped because it has been disabled.", entry);
287 }
288 break;
289 }
291 break;
293 {
294 LOG_ERROR("disable", "SourceType out of range for entry {}, skipped", entry);
295 return false;
296 }
297 default:
298 return false;
299 }
300 return true;
301}
@ MAP_COMMON
Definition DBCEnums.h:346
@ MAP_BATTLEGROUND
Definition DBCEnums.h:349
@ MAP_ARENA
Definition DBCEnums.h:350
@ MAP_INSTANCE
Definition DBCEnums.h:347
@ MAP_RAID
Definition DBCEnums.h:348
@ RAID_DIFFICULTY_25MAN_HEROIC
Definition DBCEnums.h:276
@ DUNGEON_DIFFICULTY_HEROIC
Definition DBCEnums.h:270
@ RAID_DIFFICULTY_10MAN_HEROIC
Definition DBCEnums.h:275
DBCStorage< AchievementCriteriaEntry > sAchievementCriteriaStore(AchievementCriteriafmt)
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListEntryfmt)
MapDifficulty const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition DBCStores.cpp:761
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
@ SPELL_DISABLE_LOS
Definition DisableMgr.h:50
@ SPELL_DISABLE_MAP
Definition DisableMgr.h:48
@ SPELL_DISABLE_DEPRECATED_SPELL
Definition DisableMgr.h:47
@ MAX_SPELL_DISABLE_TYPE
Definition DisableMgr.h:51
@ SPELL_DISABLE_AREA
Definition DisableMgr.h:49
@ DISABLE_TYPE_SPELL
Definition DisableMgr.h:28
@ DISABLE_TYPE_VMAP
Definition DisableMgr.h:34
@ DISABLE_TYPE_MAP
Definition DisableMgr.h:30
@ DISABLE_TYPE_BATTLEGROUND
Definition DisableMgr.h:31
@ DISABLE_TYPE_ACHIEVEMENT_CRITERIA
Definition DisableMgr.h:32
@ DISABLE_TYPE_LOOT
Definition DisableMgr.h:38
@ DISABLE_TYPE_GAME_EVENT
Definition DisableMgr.h:37
@ DISABLE_TYPE_LFG_MAP
Definition DisableMgr.h:36
@ DISABLE_TYPE_GO_LOS
Definition DisableMgr.h:35
@ DISABLE_TYPE_OUTDOORPVP
Definition DisableMgr.h:33
#define sGameEventMgr
Definition GameEventMgr.h:201
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:24
#define MAX_OUTDOORPVP_TYPES
Definition OutdoorPvP.h:39
@ SPELL_ATTR2_IGNORE_LINE_OF_SIGHT
Definition SharedDefines.h:458
@ RAID_STATUSFLAG_10MAN_HEROIC
Definition SharedDefines.h:3699
@ RAID_STATUSFLAG_25MAN_HEROIC
Definition SharedDefines.h:3700
@ DUNGEON_STATUSFLAG_HEROIC
Definition SharedDefines.h:3695
#define sSpellMgr
Definition SpellMgr.h:825
std::set< uint16 > ActiveEvents
Definition GameEventMgr.h:106
Definition SpellInfo.h:316
uint32 AttributesEx2
Definition SpellInfo.h:326
Definition AsioHacksFwd.h:47
std::vector< std::string_view > Tokenize(std::string_view str, char sep, bool keepEmpty)
Definition Tokenize.cpp:20
@ VMAP_DISABLE_LIQUIDSTATUS
Definition VMapMgr2.h:72
@ VMAP_DISABLE_LOS
Definition VMapMgr2.h:71
@ VMAP_DISABLE_HEIGHT
Definition VMapMgr2.h:70
@ VMAP_DISABLE_AREAFLAG
Definition VMapMgr2.h:69
std::set< uint32 > params[2]
Definition DisableMgr.h:59
Definition DBCStructure.h:1324
uint32 map_type
Definition DBCStructure.h:1327

References SpellInfo::AttributesEx2, DISABLE_TYPE_ACHIEVEMENT_CRITERIA, DISABLE_TYPE_BATTLEGROUND, DISABLE_TYPE_GAME_EVENT, DISABLE_TYPE_GO_LOS, DISABLE_TYPE_LFG_MAP, DISABLE_TYPE_LOOT, DISABLE_TYPE_MAP, DISABLE_TYPE_OUTDOORPVP, DISABLE_TYPE_QUEST, DISABLE_TYPE_SPELL, DISABLE_TYPE_VMAP, DUNGEON_DIFFICULTY_HEROIC, DUNGEON_STATUSFLAG_HEROIC, GetMapDifficultyData(), LOG_ERROR, LOG_INFO, MAP_ARENA, MAP_BATTLEGROUND, MAP_COMMON, MAP_INSTANCE, MAP_RAID, MapEntry::map_type, MAX_DISABLE_TYPES, MAX_OUTDOORPVP_TYPES, MAX_SPELL_DISABLE_TYPE, DisableData::params, RAID_DIFFICULTY_10MAN_HEROIC, RAID_DIFFICULTY_25MAN_HEROIC, RAID_STATUSFLAG_10MAN_HEROIC, RAID_STATUSFLAG_25MAN_HEROIC, sAchievementCriteriaStore, sBattlemasterListStore, sGameEventMgr, sMapStore, sObjectMgr, SPELL_ATTR2_IGNORE_LINE_OF_SIGHT, SPELL_DISABLE_AREA, SPELL_DISABLE_DEPRECATED_SPELL, SPELL_DISABLE_LOS, SPELL_DISABLE_MAP, sSpellMgr, Acore::Tokenize(), VMAP::VMAP_DISABLE_AREAFLAG, VMAP::VMAP_DISABLE_HEIGHT, VMAP::VMAP_DISABLE_LIQUIDSTATUS, and VMAP::VMAP_DISABLE_LOS.

Referenced by AddDisable(), and LoadDisables().

◆ instance()

DisableMgr * DisableMgr::instance ( )
static
37{
38 static DisableMgr instance;
39 return &instance;
40}
Definition DisableMgr.h:63
static DisableMgr * instance()
Definition DisableMgr.cpp:36

References instance().

Referenced by instance().

◆ IsDisabledFor()

bool DisableMgr::IsDisabledFor ( DisableType  type,
uint32  entry,
Unit const *  unit,
uint8  flags = 0 
)
static
335{
336 if (type >= MAX_DISABLE_TYPES)
337 {
338 LOG_ERROR("server", "Disables::IsDisabledFor() called with unknown disable type {}! (entry {}, flags {}).", type, entry, flags);
339 return false;
340 }
341
342 if (m_DisableMap[type].empty())
343 return false;
344
345 DisableTypeMap::iterator itr = m_DisableMap[type].find(entry);
346 if (itr == m_DisableMap[type].end()) // not disabled
347 return false;
348
349 switch (type)
350 {
352 {
353 uint8 spellFlags = itr->second.flags;
354 if (unit)
355 {
356 if ((spellFlags & SPELL_DISABLE_PLAYER && unit->IsPlayer()) ||
357 (unit->IsCreature() && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
358 {
359 if (spellFlags & SPELL_DISABLE_MAP)
360 {
361 std::set<uint32> const& mapIds = itr->second.params[0];
362 if (mapIds.find(unit->GetMapId()) != mapIds.end())
363 return true; // Spell is disabled on current map
364
365 if (!(spellFlags & SPELL_DISABLE_AREA))
366 return false; // Spell is disabled on another map, but not this one, return false
367
368 // Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
369 }
370
371 if (spellFlags & SPELL_DISABLE_AREA)
372 {
373 std::set<uint32> const& areaIds = itr->second.params[1];
374 if (areaIds.find(unit->GetAreaId()) != areaIds.end())
375 return true; // Spell is disabled in this area
376 return false; // Spell is disabled in another area, but not this one, return false
377 }
378 else
379 return true; // Spell disabled for all maps
380 }
381
382 return false;
383 }
384 else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
385 return true;
386
387 break;
388 }
389 case DISABLE_TYPE_MAP:
391 if (Player const* player = unit->ToPlayer())
392 {
393 MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
394 if (mapEntry->IsDungeon())
395 {
396 uint8 disabledModes = itr->second.flags;
397 Difficulty targetDifficulty = player->GetDifficulty(mapEntry->IsRaid());
398 GetDownscaledMapDifficultyData(entry, targetDifficulty);
399 switch (targetDifficulty)
400 {
402 return disabledModes & DUNGEON_STATUSFLAG_NORMAL;
404 return disabledModes & DUNGEON_STATUSFLAG_HEROIC;
406 return disabledModes & RAID_STATUSFLAG_10MAN_HEROIC;
408 return disabledModes & RAID_STATUSFLAG_25MAN_HEROIC;
409 }
410 }
411 else if (mapEntry->map_type == MAP_COMMON)
412 return true;
413 }
414 return false;
416 return flags & itr->second.flags;
424 return true;
425 default:
426 break;
427 }
428
429 return false;
430}
Difficulty
Definition DBCEnums.h:266
@ DUNGEON_DIFFICULTY_NORMAL
Definition DBCEnums.h:269
MapDifficulty const * GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty)
Definition DBCStores.cpp:767
std::uint8_t uint8
Definition Define.h:109
@ SPELL_DISABLE_CREATURE
Definition DisableMgr.h:45
@ SPELL_DISABLE_PET
Definition DisableMgr.h:46
@ SPELL_DISABLE_PLAYER
Definition DisableMgr.h:44
@ DUNGEON_STATUSFLAG_NORMAL
Definition SharedDefines.h:3694
Player * ToPlayer()
Definition Object.h:201
Definition Player.h:1081
bool IsDungeon() const
Definition DBCStructure.h:1350
bool IsRaid() const
Definition DBCStructure.h:1353

References DISABLE_TYPE_ACHIEVEMENT_CRITERIA, DISABLE_TYPE_BATTLEGROUND, DISABLE_TYPE_GAME_EVENT, DISABLE_TYPE_GO_LOS, DISABLE_TYPE_LFG_MAP, DISABLE_TYPE_LOOT, DISABLE_TYPE_MAP, DISABLE_TYPE_OUTDOORPVP, DISABLE_TYPE_QUEST, DISABLE_TYPE_SPELL, DISABLE_TYPE_VMAP, DUNGEON_DIFFICULTY_HEROIC, DUNGEON_DIFFICULTY_NORMAL, DUNGEON_STATUSFLAG_HEROIC, DUNGEON_STATUSFLAG_NORMAL, WorldObject::GetAreaId(), GetDownscaledMapDifficultyData(), WorldLocation::GetMapId(), Object::IsCreature(), MapEntry::IsDungeon(), Unit::IsPet(), Object::IsPlayer(), MapEntry::IsRaid(), LOG_ERROR, m_DisableMap, MAP_COMMON, MapEntry::map_type, MAX_DISABLE_TYPES, RAID_DIFFICULTY_10MAN_HEROIC, RAID_DIFFICULTY_25MAN_HEROIC, RAID_STATUSFLAG_10MAN_HEROIC, RAID_STATUSFLAG_25MAN_HEROIC, sMapStore, SPELL_DISABLE_AREA, SPELL_DISABLE_CREATURE, SPELL_DISABLE_DEPRECATED_SPELL, SPELL_DISABLE_MAP, SPELL_DISABLE_PET, SPELL_DISABLE_PLAYER, and Object::ToPlayer().

Referenced by IsVMAPDisabledFor().

◆ IsPathfindingEnabled()

bool DisableMgr::IsPathfindingEnabled ( Map const *  map)
static
438{
439 if (!map)
440 return false;
441
442 return !MMAP::MMapFactory::forbiddenMaps[map->GetId()] && (sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS) ? true : map->IsBattlegroundOrArena());
443}
@ CONFIG_ENABLE_MMAPS
Definition IWorld.h:139
static bool forbiddenMaps[1000]
Definition MMapFactory.h:41
#define sWorld
Definition World.h:363

References CONFIG_ENABLE_MMAPS, MMAP::MMapFactory::forbiddenMaps, Map::GetId(), Map::IsBattlegroundOrArena(), and sWorld.

Referenced by GridTerrainLoader::LoadMMap().

◆ IsVMAPDisabledFor()

bool DisableMgr::IsVMAPDisabledFor ( uint32  entry,
uint8  flags 
)
static
433{
434 return IsDisabledFor(DISABLE_TYPE_VMAP, entry, nullptr, flags);
435}
static bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags=0)
Definition DisableMgr.cpp:334

References DISABLE_TYPE_VMAP, and IsDisabledFor().

Referenced by World::SetInitialWorldSettings().

◆ LoadDisables()

void DisableMgr::LoadDisables ( )
43{
44 uint32 oldMSTime = getMSTime();
45
46 // reload case
47 for (DisableTypeMap& disableTypeMap : m_DisableMap)
48 disableTypeMap.clear();
49
50 QueryResult result = WorldDatabase.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");
51
52 uint32 total_count = 0;
53
54 if (!result)
55 {
56 LOG_WARN("server.loading", ">> Loaded 0 disables. DB table `disables` is empty!");
57 LOG_INFO("server.loading", " ");
58 return;
59 }
60
61 Field* fields;
62 do
63 {
64 fields = result->Fetch();
65 DisableType type = DisableType(fields[0].Get<uint32>());
66 if (type >= MAX_DISABLE_TYPES)
67 {
68 LOG_ERROR("sql.sql", "Invalid type {} specified in `disables` table, skipped.", type);
69 continue;
70 }
71
72 uint32 entry = fields[1].Get<uint32>();
73 uint8 flags = fields[2].Get<uint8>();
74 std::string params_0 = fields[3].Get<std::string>();
75 std::string params_1 = fields[4].Get<std::string>();
76
77 DisableData data;
78 data.flags = flags;
79
80 if (!HandleDisableType(type, entry, flags, params_0, params_1, data))
81 continue;
82
83 m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
84 ++total_count;
85 } while (result->NextRow());
86
87 LOG_INFO("server.loading", ">> Loaded {} Disables in {} ms", total_count, GetMSTimeDiffToNow(oldMSTime));
88 LOG_INFO("server.loading", " ");
89}
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
DisableType
Definition DisableMgr.h:27
#define LOG_WARN(filterType__,...)
Definition Log.h:161
std::unordered_map< uint32, DisableData > DisableTypeMap
Definition DisableMgr.h:80
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112

References DisableData::flags, Field::Get(), getMSTime(), GetMSTimeDiffToNow(), HandleDisableType(), LOG_ERROR, LOG_INFO, LOG_WARN, m_DisableMap, MAX_DISABLE_TYPES, and WorldDatabase.

Member Data Documentation

◆ m_DisableMap

DisableMgr::DisableMap DisableMgr::m_DisableMap
staticprivate

The documentation for this class was generated from the following files: