TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
DisableMgr Namespace Reference

Functions

void LoadDisables ()
 
void CheckQuestDisables ()
 
bool IsDisabledFor (DisableType type, uint32 entry, Unit const *unit, uint8 flags)
 
bool IsVMAPDisabledFor (uint32 entry, uint8 flags)
 
bool IsPathfindingEnabled (uint32 mapId)
 

Variables

char constMapTypeNames []
 

Function Documentation

TC_GAME_API void DisableMgr::CheckQuestDisables ( )
249 {
250  uint32 oldMSTime = getMSTime();
251 
252  uint32 count = m_DisableMap[DISABLE_TYPE_QUEST].size();
253  if (!count)
254  {
255  TC_LOG_INFO("server.loading", ">> Checked 0 quest disables.");
256  return;
257  }
258 
259  // check only quests, rest already done at startup
260  for (DisableTypeMap::iterator itr = m_DisableMap[DISABLE_TYPE_QUEST].begin(); itr != m_DisableMap[DISABLE_TYPE_QUEST].end();)
261  {
262  const uint32 entry = itr->first;
263  if (!sObjectMgr->GetQuestTemplate(entry))
264  {
265  TC_LOG_ERROR("sql.sql", "Quest entry %u from `disables` doesn't exist, skipped.", entry);
266  m_DisableMap[DISABLE_TYPE_QUEST].erase(itr++);
267  continue;
268  }
269  if (itr->second.flags)
270  TC_LOG_ERROR("sql.sql", "Disable flags specified for quest %u, useless data.", entry);
271  ++itr;
272  }
273 
274  TC_LOG_INFO("server.loading", ">> Checked %u quest disables in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
275 }
uint32 getMSTime()
Definition: Timer.h:24
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32_t uint32
Definition: Define.h:150
Definition: DisableMgr.h:30
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_GAME_API bool DisableMgr::IsDisabledFor ( DisableType  type,
uint32  entry,
Unit const unit,
uint8  flags 
)
278 {
279  ASSERT(type < MAX_DISABLE_TYPES);
280  if (m_DisableMap[type].empty())
281  return false;
282 
283  DisableTypeMap::iterator itr = m_DisableMap[type].find(entry);
284  if (itr == m_DisableMap[type].end()) // not disabled
285  return false;
286 
287  switch (type)
288  {
289  case DISABLE_TYPE_SPELL:
290  {
291  uint8 spellFlags = itr->second.flags;
292  if (unit)
293  {
294  if ((spellFlags & SPELL_DISABLE_PLAYER && unit->GetTypeId() == TYPEID_PLAYER) ||
295  (unit->GetTypeId() == TYPEID_UNIT && ((unit->IsPet() && spellFlags & SPELL_DISABLE_PET) || spellFlags & SPELL_DISABLE_CREATURE)))
296  {
297  if (spellFlags & SPELL_DISABLE_MAP)
298  {
299  std::set<uint32> const& mapIds = itr->second.params[0];
300  if (mapIds.find(unit->GetMapId()) != mapIds.end())
301  return true; // Spell is disabled on current map
302 
303  if (!(spellFlags & SPELL_DISABLE_AREA))
304  return false; // Spell is disabled on another map, but not this one, return false
305 
306  // Spell is disabled in an area, but not explicitly our current mapId. Continue processing.
307  }
308 
309  if (spellFlags & SPELL_DISABLE_AREA)
310  {
311  std::set<uint32> const& areaIds = itr->second.params[1];
312  if (areaIds.find(unit->GetAreaId()) != areaIds.end())
313  return true; // Spell is disabled in this area
314  return false; // Spell is disabled in another area, but not this one, return false
315  }
316  else
317  return true; // Spell disabled for all maps
318  }
319 
320  return false;
321  }
322  else if (spellFlags & SPELL_DISABLE_DEPRECATED_SPELL) // call not from spellcast
323  return true;
324  else if (flags & SPELL_DISABLE_LOS)
325  return (spellFlags & SPELL_DISABLE_LOS) != 0;
326 
327  break;
328  }
329  case DISABLE_TYPE_MAP:
330  if (Player const* player = unit->ToPlayer())
331  {
332  MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
333  if (mapEntry->IsDungeon())
334  {
335  uint8 disabledModes = itr->second.flags;
336  Difficulty targetDifficulty = player->GetDifficultyID(mapEntry);
337  GetDownscaledMapDifficultyData(entry, targetDifficulty);
338  switch (targetDifficulty)
339  {
340  case DIFFICULTY_NORMAL:
341  return (disabledModes & DUNGEON_STATUSFLAG_NORMAL) != 0;
342  case DIFFICULTY_HEROIC:
343  return (disabledModes & DUNGEON_STATUSFLAG_HEROIC) != 0;
344  case DIFFICULTY_10_HC:
345  return (disabledModes & RAID_STATUSFLAG_10MAN_HEROIC) != 0;
346  case DIFFICULTY_25_HC:
347  return (disabledModes & RAID_STATUSFLAG_25MAN_HEROIC) != 0;
348  default:
349  return false;
350  }
351  }
352  else if (mapEntry->InstanceType == MAP_COMMON)
353  return true;
354  }
355  return false;
356  case DISABLE_TYPE_QUEST:
357  if (!unit)
358  return true;
359  if (Player const* player = unit->ToPlayer())
360  if (player->IsGameMaster())
361  return false;
362  return true;
366  case DISABLE_TYPE_MMAP:
367  return true;
368  case DISABLE_TYPE_VMAP:
369  return (flags & itr->second.flags) != 0;
370  }
371 
372  return false;
373 }
Definition: DBCEnums.h:406
Difficulty
Definition: DBCEnums.h:402
Definition: DBCStructure.h:830
Definition: ObjectGuid.h:32
Definition: DisableMgr.h:47
Definition: SharedDefines.h:4813
MapDifficultyEntry const * GetDownscaledMapDifficultyData(uint32 mapId, Difficulty &difficulty)
Definition: DBCStores.cpp:737
Definition: DisableMgr.h:43
Definition: DisableMgr.h:45
uint32 InstanceType
Definition: DBCStructure.h:834
Definition: DisableMgr.h:46
Definition: DisableMgr.h:36
Definition: DisableMgr.h:42
Definition: SharedDefines.h:4808
Definition: DisableMgr.h:32
Definition: DisableMgr.h:35
Definition: DBCEnums.h:409
Definition: DisableMgr.h:29
bool IsDungeon() const
Definition: DBCStructure.h:857
Definition: DBCEnums.h:410
Definition: SharedDefines.h:4807
Definition: DisableMgr.h:41
Definition: DisableMgr.h:30
Definition: DisableMgr.h:33
Definition: ObjectGuid.h:33
Definition: DBCEnums.h:478
DBCStorage< MapEntry > sMapStore(Mapfmt)
Definition: DisableMgr.h:31
Definition: SharedDefines.h:4812
uint8_t uint8
Definition: Define.h:152
#define ASSERT
Definition: Errors.h:55
Definition: DisableMgr.h:34
uint8 flags
Definition: DisableMgr.cpp:44
Definition: DisableMgr.h:44
Definition: DBCEnums.h:405

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_GAME_API bool DisableMgr::IsPathfindingEnabled ( uint32  mapId)
381 {
382  return sWorld->getBoolConfig(CONFIG_ENABLE_MMAPS)
384 }
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
arena_t NULL
Definition: jemalloc_internal.h:624
#define sWorld
Definition: World.h:887
Definition: DisableMgr.h:36
Definition: World.h:167
Definition: DisableMgr.h:55

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_GAME_API bool DisableMgr::IsVMAPDisabledFor ( uint32  entry,
uint8  flags 
)
376 {
377  return IsDisabledFor(DISABLE_TYPE_VMAP, entry, NULL, flags);
378 }
bool IsDisabledFor(DisableType type, uint32 entry, Unit const *unit, uint8 flags)
Definition: DisableMgr.cpp:277
arena_t NULL
Definition: jemalloc_internal.h:624
Definition: DisableMgr.h:35
uint8 flags
Definition: DisableMgr.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

TC_GAME_API void DisableMgr::LoadDisables ( )
59 {
60  uint32 oldMSTime = getMSTime();
61 
62  // reload case
63  for (DisableMap::iterator itr = m_DisableMap.begin(); itr != m_DisableMap.end(); ++itr)
64  itr->second.clear();
65 
66  m_DisableMap.clear();
67 
68  QueryResult result = WorldDatabase.Query("SELECT sourceType, entry, flags, params_0, params_1 FROM disables");
69 
70  uint32 total_count = 0;
71 
72  if (!result)
73  {
74  TC_LOG_INFO("server.loading", ">> Loaded 0 disables. DB table `disables` is empty!");
75  return;
76  }
77 
78  Field* fields;
79  do
80  {
81  fields = result->Fetch();
82  DisableType type = DisableType(fields[0].GetUInt32());
83  if (type >= MAX_DISABLE_TYPES)
84  {
85  TC_LOG_ERROR("sql.sql", "Invalid type %u specified in `disables` table, skipped.", type);
86  continue;
87  }
88 
89  uint32 entry = fields[1].GetUInt32();
90  uint8 flags = fields[2].GetUInt8();
91  std::string params_0 = fields[3].GetString();
92  std::string params_1 = fields[4].GetString();
93 
94  DisableData data;
95  data.flags = flags;
96 
97  switch (type)
98  {
99  case DISABLE_TYPE_SPELL:
100  if (!(sSpellMgr->GetSpellInfo(entry) || flags & SPELL_DISABLE_DEPRECATED_SPELL))
101  {
102  TC_LOG_ERROR("sql.sql", "Spell entry %u from `disables` doesn't exist in dbc, skipped.", entry);
103  continue;
104  }
105 
106  if (!flags || flags > MAX_SPELL_DISABLE_TYPE)
107  {
108  TC_LOG_ERROR("sql.sql", "Disable flags for spell %u are invalid, skipped.", entry);
109  continue;
110  }
111 
112  if (flags & SPELL_DISABLE_MAP)
113  {
114  Tokenizer tokens(params_0, ',');
115  for (uint8 i = 0; i < tokens.size(); )
116  data.params[0].insert(atoi(tokens[i++]));
117  }
118 
119  if (flags & SPELL_DISABLE_AREA)
120  {
121  Tokenizer tokens(params_1, ',');
122  for (uint8 i = 0; i < tokens.size(); )
123  data.params[1].insert(atoi(tokens[i++]));
124  }
125 
126  break;
127  // checked later
128  case DISABLE_TYPE_QUEST:
129  break;
130  case DISABLE_TYPE_MAP:
131  {
132  MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
133  if (!mapEntry)
134  {
135  TC_LOG_ERROR("sql.sql", "Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
136  continue;
137  }
138  bool isFlagInvalid = false;
139  switch (mapEntry->InstanceType)
140  {
141  case MAP_COMMON:
142  if (flags)
143  isFlagInvalid = true;
144  break;
145  case MAP_INSTANCE:
146  case MAP_RAID:
148  flags -= DUNGEON_STATUSFLAG_HEROIC;
153  if (!flags)
154  isFlagInvalid = true;
155  break;
156  case MAP_BATTLEGROUND:
157  case MAP_ARENA:
158  TC_LOG_ERROR("sql.sql", "Battleground map %u specified to be disabled in map case, skipped.", entry);
159  continue;
160  }
161  if (isFlagInvalid)
162  {
163  TC_LOG_ERROR("sql.sql", "Disable flags for map %u are invalid, skipped.", entry);
164  continue;
165  }
166  break;
167  }
169  if (!sBattlemasterListStore.LookupEntry(entry))
170  {
171  TC_LOG_ERROR("sql.sql", "Battleground entry %u from `disables` doesn't exist in dbc, skipped.", entry);
172  continue;
173  }
174  if (flags)
175  TC_LOG_ERROR("sql.sql", "Disable flags specified for battleground %u, useless data.", entry);
176  break;
178  if (entry > MAX_OUTDOORPVP_TYPES)
179  {
180  TC_LOG_ERROR("sql.sql", "OutdoorPvPTypes value %u from `disables` is invalid, skipped.", entry);
181  continue;
182  }
183  if (flags)
184  TC_LOG_ERROR("sql.sql", "Disable flags specified for outdoor PvP %u, useless data.", entry);
185  break;
187  if (!sAchievementMgr->GetAchievementCriteria(entry))
188  {
189  TC_LOG_ERROR("sql.sql", "Achievement Criteria entry %u from `disables` doesn't exist in dbc, skipped.", entry);
190  continue;
191  }
192  if (flags)
193  TC_LOG_ERROR("sql.sql", "Disable flags specified for Achievement Criteria %u, useless data.", entry);
194  break;
195  case DISABLE_TYPE_VMAP:
196  {
197  MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
198  if (!mapEntry)
199  {
200  TC_LOG_ERROR("sql.sql", "Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
201  continue;
202  }
203  switch (mapEntry->InstanceType)
204  {
205  case MAP_COMMON:
206  if (flags & VMAP::VMAP_DISABLE_AREAFLAG)
207  TC_LOG_INFO("misc", "Areaflag disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
209  TC_LOG_INFO("misc", "Liquid status disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
210  break;
211  case MAP_INSTANCE:
212  case MAP_RAID:
213  case MAP_BATTLEGROUND:
214  case MAP_ARENA:
215  case MAP_SCENARIO:
216  if (flags & VMAP::VMAP_DISABLE_HEIGHT)
217  TC_LOG_INFO("misc", "Height disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
218  if (flags & VMAP::VMAP_DISABLE_LOS)
219  TC_LOG_INFO("misc", "LoS disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
220  break;
221  }
222  break;
223  }
224  case DISABLE_TYPE_MMAP:
225  {
226  MapEntry const* mapEntry = sMapStore.LookupEntry(entry);
227  if (!mapEntry)
228  {
229  TC_LOG_ERROR("sql.sql", "Map entry %u from `disables` doesn't exist in dbc, skipped.", entry);
230  continue;
231  }
232  if (mapEntry->InstanceType <= MAP_SCENARIO)
233  TC_LOG_INFO("misc", "Pathfinding disabled for %s map %u.", MapTypeNames[mapEntry->InstanceType], entry);
234  break;
235  }
236  default:
237  break;
238  }
239 
240  m_DisableMap[type].insert(DisableTypeMap::value_type(entry, data));
241  ++total_count;
242  }
243  while (result->NextRow());
244 
245  TC_LOG_INFO("server.loading", ">> Loaded %u disables in %u ms", total_count, GetMSTimeDiffToNow(oldMSTime));
246 }
char const * MapTypeNames[]
Definition: DisableMgr.cpp:30
Definition: DBCEnums.h:406
Definition: VMapManager2.h:73
MapDifficultyEntry const * GetMapDifficultyData(uint32 mapId, Difficulty difficulty)
Definition: DBCStores.cpp:724
Definition: Util.h:45
Class used to access individual fields of database query result.
Definition: Field.h:56
DBCStorage< BattlemasterListEntry > sBattlemasterListStore(BattlemasterListfmt)
Definition: VMapManager2.h:75
Definition: DBCEnums.h:482
DisableType
Definition: DisableMgr.h:27
uint32 getMSTime()
Definition: Timer.h:24
Definition: DBCStructure.h:830
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Definition: DBCEnums.h:480
Definition: SharedDefines.h:4813
uint8 GetUInt8() const
Definition: Field.h:70
Definition: DisableMgr.h:45
uint32 InstanceType
Definition: DBCStructure.h:834
Definition: DBCEnums.h:481
Definition: DisableMgr.h:46
Definition: DisableMgr.h:36
#define MAX_OUTDOORPVP_TYPES
Definition: OutdoorPvP.h:37
Definition: SharedDefines.h:4808
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: DisableMgr.h:32
uint32_t uint32
Definition: Define.h:150
Definition: DisableMgr.h:35
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
Definition: DBCEnums.h:409
Definition: DisableMgr.h:29
Definition: DBCEnums.h:410
Definition: DisableMgr.h:30
Definition: DisableMgr.h:33
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
Definition: DBCEnums.h:478
DBCStorage< MapEntry > sMapStore(Mapfmt)
Definition: DisableMgr.h:31
Definition: SharedDefines.h:4812
uint32 GetUInt32() const
Definition: Field.h:146
uint8_t uint8
Definition: Define.h:152
Definition: VMapManager2.h:74
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: DisableMgr.h:34
uint8 flags
Definition: DisableMgr.cpp:44
Definition: DBCEnums.h:483
Definition: DisableMgr.h:48
Definition: DisableMgr.h:44
std::string GetString() const
Definition: Field.h:276
Definition: DBCEnums.h:479
Definition: VMapManager2.h:72
#define sAchievementMgr
Definition: AchievementMgr.h:501

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Variable Documentation

char const* DisableMgr::MapTypeNames[]
Initial value:
=
{
"World",
"Dungeon",
"Raid",
"Battleground",
"Arena",
"Scenario"
}