TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
ConditionMgr Class Reference

#include <ConditionMgr.h>

Classes

struct  ConditionTypeInfo
 

Public Member Functions

void LoadConditions (bool isReload=false)
 
bool isConditionTypeValid (Condition *cond) const
 
uint32 GetSearcherTypeMaskForConditionList (ConditionContainer const &conditions) const
 
bool IsObjectMeetToConditions (WorldObject *object, ConditionContainer const &conditions) const
 
bool IsObjectMeetToConditions (WorldObject *object1, WorldObject *object2, ConditionContainer const &conditions) const
 
bool IsObjectMeetToConditions (ConditionSourceInfo &sourceInfo, ConditionContainer const &conditions) const
 
bool IsObjectMeetingNotGroupedConditions (ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo &sourceInfo) const
 
bool IsObjectMeetingNotGroupedConditions (ConditionSourceType sourceType, uint32 entry, WorldObject *target0, WorldObject *target1=nullptr, WorldObject *target2=nullptr) const
 
bool HasConditionsForNotGroupedEntry (ConditionSourceType sourceType, uint32 entry) const
 
bool IsObjectMeetingSpellClickConditions (uint32 creatureId, uint32 spellId, WorldObject *clicker, WorldObject *target) const
 
ConditionContainer constGetConditionsForSpellClickEvent (uint32 creatureId, uint32 spellId) const
 
bool IsObjectMeetingVehicleSpellConditions (uint32 creatureId, uint32 spellId, Player *player, Unit *vehicle) const
 
bool IsObjectMeetingSmartEventConditions (int64 entryOrGuid, uint32 eventId, uint32 sourceType, Unit *unit, WorldObject *baseObject) const
 
bool IsObjectMeetingVendorItemConditions (uint32 creatureId, uint32 itemId, Player *player, Creature *vendor) const
 

Static Public Member Functions

static ConditionMgrinstance ()
 
static bool CanHaveSourceGroupSet (ConditionSourceType sourceType)
 
static bool CanHaveSourceIdSet (ConditionSourceType sourceType)
 
static bool IsPlayerMeetingCondition (Player *player, PlayerConditionEntry const *condition)
 

Static Public Attributes

static char const *const StaticSourceTypeData [CONDITION_SOURCE_TYPE_MAX]
 
static ConditionTypeInfo const StaticConditionTypeData [CONDITION_MAX]
 

Private Member Functions

 ConditionMgr ()
 
 ~ConditionMgr ()
 
bool isSourceTypeValid (Condition *cond) const
 
bool addToLootTemplate (Condition *cond, LootTemplate *loot) const
 
bool addToGossipMenus (Condition *cond) const
 
bool addToGossipMenuItems (Condition *cond) const
 
bool addToSpellImplicitTargetConditions (Condition *cond) const
 
bool addToPhases (Condition *cond) const
 
bool IsObjectMeetToConditionList (ConditionSourceInfo &sourceInfo, ConditionContainer const &conditions) const
 
void Clean ()
 

Static Private Member Functions

static void LogUselessConditionValue (Condition *cond, uint8 index, uint32 value)
 

Private Attributes

std::vector< Condition * > AllocatedMemoryStore
 
ConditionEntriesByTypeArray ConditionStore
 
ConditionReferenceContainer ConditionReferenceStore
 
ConditionEntriesByCreatureIdMap VehicleSpellConditionStore
 
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore
 
ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore
 
SmartEventConditionContainer SmartEventConditionStore
 

Constructor & Destructor Documentation

ConditionMgr::ConditionMgr ( )
private
677 { }
ConditionMgr::~ConditionMgr ( )
private
680 {
681  Clean();
682 }
void Clean()
Definition: ConditionMgr.cpp:2226

+ Here is the call graph for this function:

Member Function Documentation

bool ConditionMgr::addToGossipMenuItems ( Condition cond) const
private
1238 {
1239  GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1240  if (pMenuItemBounds.first != pMenuItemBounds.second)
1241  {
1242  for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1243  {
1244  if ((*itr).second.MenuId == cond->SourceGroup && (*itr).second.OptionIndex == uint32(cond->SourceEntry))
1245  {
1246  (*itr).second.Conditions.push_back(cond);
1247  return true;
1248  }
1249  }
1250  }
1251 
1252  TC_LOG_ERROR("sql.sql", "%s GossipMenuId %u Item %u not found.", cond->ToString().c_str(), cond->SourceGroup, cond->SourceEntry);
1253  return false;
1254 }
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition: ObjectMgr.h:540
int32 SourceEntry
Definition: ConditionMgr.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 SourceGroup
Definition: ConditionMgr.h:197
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
uint32_t uint32
Definition: Define.h:150
#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:

bool ConditionMgr::addToGossipMenus ( Condition cond) const
private
1218 {
1219  GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1220 
1221  if (pMenuBounds.first != pMenuBounds.second)
1222  {
1223  for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1224  {
1225  if ((*itr).second.entry == cond->SourceGroup && (*itr).second.text_id == uint32(cond->SourceEntry))
1226  {
1227  (*itr).second.conditions.push_back(cond);
1228  return true;
1229  }
1230  }
1231  }
1232 
1233  TC_LOG_ERROR("sql.sql", "%s GossipMenu %u not found.", cond->ToString().c_str(), cond->SourceGroup);
1234  return false;
1235 }
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition: ObjectMgr.h:537
int32 SourceEntry
Definition: ConditionMgr.h:198
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 SourceGroup
Definition: ConditionMgr.h:197
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
uint32_t uint32
Definition: Define.h:150
#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:

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
) const
private
1203 {
1204  if (!loot)
1205  {
1206  TC_LOG_ERROR("sql.sql", "%s LootTemplate %u not found.", cond->ToString().c_str(), cond->SourceGroup);
1207  return false;
1208  }
1209 
1210  if (loot->addConditionItem(cond))
1211  return true;
1212 
1213  TC_LOG_ERROR("sql.sql", "%s Item %u not found in LootTemplate %u.", cond->ToString().c_str(), cond->SourceEntry, cond->SourceGroup);
1214  return false;
1215 }
int32 SourceEntry
Definition: ConditionMgr.h:198
uint32 SourceGroup
Definition: ConditionMgr.h:197
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
bool addConditionItem(Condition *cond)
Definition: LootMgr.cpp:1444

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConditionMgr::addToPhases ( Condition cond) const
private
1361 {
1362  if (!cond->SourceEntry)
1363  {
1364  PhaseInfo& p = sObjectMgr->GetAreaPhasesForLoading();
1365  for (auto phaseItr = p.begin(); phaseItr != p.end(); ++phaseItr)
1366  {
1367  for (PhaseInfoStruct& phase : phaseItr->second)
1368  {
1369  if (phase.Id == cond->SourceGroup)
1370  {
1371  phase.Conditions.push_back(cond);
1372  return true;
1373  }
1374  }
1375  }
1376  }
1377  else if (std::vector<PhaseInfoStruct>* phases = sObjectMgr->GetPhasesForAreaForLoading(cond->SourceEntry))
1378  {
1379  for (PhaseInfoStruct& phase : *phases)
1380  {
1381  if (phase.Id == cond->SourceGroup)
1382  {
1383  phase.Conditions.push_back(cond);
1384  return true;
1385  }
1386  }
1387  }
1388 
1389  TC_LOG_ERROR("sql.sql", "%s Area %u does not have phase %u.", cond->ToString().c_str(), cond->SourceGroup, cond->SourceEntry);
1390  return false;
1391 }
std::unordered_map< uint32, std::vector< PhaseInfoStruct > > PhaseInfo
Definition: ObjectMgr.h:698
Definition: ObjectMgr.h:690
int32 SourceEntry
Definition: ConditionMgr.h:198
uint32 Id
Definition: ObjectMgr.h:692
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 SourceGroup
Definition: ConditionMgr.h:197
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
ConditionContainer Conditions
Definition: ObjectMgr.h:693
#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:

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond) const
private
1257 {
1258  uint32 conditionEffMask = cond->SourceGroup;
1259  SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1260  std::list<uint32> sharedMasks;
1261  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1262  {
1263  SpellEffectInfo const* effect = spellInfo->GetEffect(DIFFICULTY_NONE, i);
1264  if (!effect)
1265  continue;
1266 
1267  // check if effect is already a part of some shared mask
1268  bool found = false;
1269  for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1270  {
1271  if ((1 << i) & *itr)
1272  {
1273  found = true;
1274  break;
1275  }
1276  }
1277 
1278  if (found)
1279  continue;
1280 
1281  // build new shared mask with found effect
1282  uint32 sharedMask = 1 << i;
1284  for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1285  {
1286  SpellEffectInfo const* inner = spellInfo->GetEffect(DIFFICULTY_NONE, effIndex);
1287  if (!inner)
1288  continue;
1289 
1290  if (inner->ImplicitTargetConditions == cmp)
1291  sharedMask |= 1 << effIndex;
1292  }
1293 
1294  sharedMasks.push_back(sharedMask);
1295  }
1296 
1297  for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1298  {
1299  // some effect indexes should have same data
1300  if (uint32 commonMask = *itr & conditionEffMask)
1301  {
1302  uint8 firstEffIndex = 0;
1303  for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1304  if ((1<<firstEffIndex) & *itr)
1305  break;
1306 
1307  if (firstEffIndex >= MAX_SPELL_EFFECTS)
1308  return false;
1309 
1310  SpellEffectInfo const* effect = spellInfo->GetEffect(DIFFICULTY_NONE, firstEffIndex);
1311  if (!effect)
1312  continue;
1313 
1314  // get shared data
1315  ConditionContainer* sharedList = effect->ImplicitTargetConditions;
1316 
1317  // there's already data entry for that sharedMask
1318  if (sharedList)
1319  {
1320  // we have overlapping masks in db
1321  if (conditionEffMask != *itr)
1322  {
1323  TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect SourceGroup %u (spell effectMask) set - "
1324  "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.", cond->ToString().c_str(), cond->SourceGroup);
1325  return false;
1326  }
1327  }
1328  // no data for shared mask, we can create new submask
1329  else
1330  {
1331  // add new list, create new shared mask
1332  sharedList = new ConditionContainer();
1333  bool assigned = false;
1334  for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1335  {
1336  SpellEffectInfo const* eff = spellInfo->GetEffect(DIFFICULTY_NONE, i);
1337  if (!eff)
1338  continue;
1339 
1340  if ((1 << i) & commonMask)
1341  {
1342  const_cast<SpellEffectInfo*>(eff)->ImplicitTargetConditions = sharedList;
1343  assigned = true;
1344  }
1345  }
1346 
1347  if (!assigned)
1348  {
1349  delete sharedList;
1350  break;
1351  }
1352  }
1353  sharedList->push_back(cond);
1354  break;
1355  }
1356  }
1357  return true;
1358 }
Definition: DBCEnums.h:404
Definition: SpellInfo.h:326
int32 SourceEntry
Definition: ConditionMgr.h:198
std::vector< Condition * > * ImplicitTargetConditions
Definition: SpellInfo.h:266
uint32 SourceGroup
Definition: ConditionMgr.h:197
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348
uint8_t uint8
Definition: Define.h:152
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
std::vector< Condition * > ConditionContainer
Definition: ConditionMgr.h:239

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConditionMgr::CanHaveSourceGroupSet ( ConditionSourceType  sourceType)
static
792 {
793  return (sourceType == CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE ||
805  sourceType == CONDITION_SOURCE_TYPE_GOSSIP_MENU ||
807  sourceType == CONDITION_SOURCE_TYPE_VEHICLE_SPELL ||
810  sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT ||
811  sourceType == CONDITION_SOURCE_TYPE_NPC_VENDOR ||
812  sourceType == CONDITION_SOURCE_TYPE_PHASE);
813 }
Definition: ConditionMgr.h:132
Definition: ConditionMgr.h:134
Definition: ConditionMgr.h:139
Definition: ConditionMgr.h:150
Definition: ConditionMgr.h:128
Definition: ConditionMgr.h:138
Definition: ConditionMgr.h:145
Definition: ConditionMgr.h:137
Definition: ConditionMgr.h:142
Definition: ConditionMgr.h:133
Definition: ConditionMgr.h:149
Definition: ConditionMgr.h:141
Definition: ConditionMgr.h:153
Definition: ConditionMgr.h:140
Definition: ConditionMgr.h:148
Definition: ConditionMgr.h:130

+ Here is the caller graph for this function:

bool ConditionMgr::CanHaveSourceIdSet ( ConditionSourceType  sourceType)
static
816 {
817  return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
818 }
Definition: ConditionMgr.h:149

+ Here is the caller graph for this function:

void ConditionMgr::Clean ( )
private
2227 {
2228  for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2229  for (ConditionContainer::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2230  delete *it;
2231 
2232  ConditionReferenceStore.clear();
2233 
2234  for (uint32 i = 0; i < CONDITION_SOURCE_TYPE_MAX; ++i)
2235  {
2236  for (ConditionsByEntryMap::iterator it = ConditionStore[i].begin(); it != ConditionStore[i].end(); ++it)
2237  for (ConditionContainer::const_iterator itr = it->second.begin(); itr != it->second.end(); ++itr)
2238  delete *itr;
2239 
2240  ConditionStore[i].clear();
2241  }
2242 
2243  for (ConditionEntriesByCreatureIdMap::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2244  for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2245  for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
2246  delete *i;
2247 
2249 
2250  for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2251  for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2252  for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
2253  delete *i;
2254 
2255  SmartEventConditionStore.clear();
2256 
2257  for (ConditionEntriesByCreatureIdMap::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2258  for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2259  for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
2260  delete *i;
2261 
2263 
2264  for (ConditionEntriesByCreatureIdMap::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2265  for (ConditionsByEntryMap::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2266  for (ConditionContainer::const_iterator i = it->second.begin(); i != it->second.end(); ++i)
2267  delete *i;
2268 
2270 
2271  // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2272  for (std::vector<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr)
2273  delete *itr;
2274 
2275  AllocatedMemoryStore.clear();
2276 }
ConditionEntriesByTypeArray ConditionStore
Definition: ConditionMgr.h:299
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore
Definition: ConditionMgr.h:302
std::vector< Condition * > AllocatedMemoryStore
Definition: ConditionMgr.h:297
ConditionEntriesByCreatureIdMap VehicleSpellConditionStore
Definition: ConditionMgr.h:301
uint32_t uint32
Definition: Define.h:150
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:304
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:300
Definition: ConditionMgr.h:154
ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore
Definition: ConditionMgr.h:303

+ Here is the caller graph for this function:

ConditionContainer const * ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
) const
867 {
868  ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
869  if (itr != SpellClickEventConditionStore.end())
870  {
871  ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
872  if (i != itr->second.end())
873  {
874  TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId);
875  return &i->second;
876  }
877  }
878  return nullptr;
879 }
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore
Definition: ConditionMgr.h:302
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
uint32 ConditionMgr::GetSearcherTypeMaskForConditionList ( ConditionContainer const conditions) const
685 {
686  if (conditions.empty())
687  return GRID_MAP_TYPE_MASK_ALL;
688  // groupId, typeMask
689  std::map<uint32, uint32> elseGroupSearcherTypeMasks;
690  for (ConditionContainer::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
691  {
692  // no point of having not loaded conditions in list
693  ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
694  std::map<uint32, uint32>::const_iterator itr = elseGroupSearcherTypeMasks.find((*i)->ElseGroup);
695  // group not filled yet, fill with widest mask possible
696  if (itr == elseGroupSearcherTypeMasks.end())
697  elseGroupSearcherTypeMasks[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
698  // no point of checking anymore, empty mask
699  else if (!itr->second)
700  continue;
701 
702  if ((*i)->ReferenceId) // handle reference
703  {
704  ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
705  ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference");
706  elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
707  }
708  else // handle normal condition
709  {
710  // object will match conditions in one ElseGroupStore only when it matches all of them
711  // so, let's find a smallest possible mask which satisfies all conditions
712  elseGroupSearcherTypeMasks[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
713  }
714  }
715  // object will match condition when one of the checks in ElseGroupStore is matching
716  // so, let's include all possible masks
717  uint32 mask = 0;
718  for (std::map<uint32, uint32>::const_iterator i = elseGroupSearcherTypeMasks.begin(); i != elseGroupSearcherTypeMasks.end(); ++i)
719  mask |= i->second;
720 
721  return mask;
722 }
Definition: GridDefines.h:79
uint32 GetSearcherTypeMaskForConditionList(ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:684
uint32_t uint32
Definition: Define.h:150
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:300
#define ASSERT
Definition: Errors.h:55
bool ConditionMgr::HasConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
) const
842 {
843  if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
844  if (ConditionStore[sourceType].find(entry) != ConditionStore[sourceType].end())
845  return true;
846 
847  return false;
848 }
ConditionEntriesByTypeArray ConditionStore
Definition: ConditionMgr.h:299
Definition: ConditionMgr.h:154
Definition: ConditionMgr.h:127
ConditionMgr * ConditionMgr::instance ( )
static
930 {
931  static ConditionMgr instance;
932  return &instance;
933 }
static ConditionMgr * instance()
Definition: ConditionMgr.cpp:929
Definition: ConditionMgr.h:246
bool ConditionMgr::isConditionTypeValid ( Condition cond) const
1763 {
1764  if (cond->ConditionType == CONDITION_NONE || cond->ConditionType >= CONDITION_MAX)
1765  {
1766  TC_LOG_ERROR("sql.sql", "%s Invalid ConditionType in `condition` table, ignoring.", cond->ToString().c_str());
1767  return false;
1768  }
1769 
1770  if (cond->ConditionTarget >= cond->GetMaxAvailableConditionTargets())
1771  {
1772  TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->ToString(true).c_str());
1773  return false;
1774  }
1775 
1776  switch (cond->ConditionType)
1777  {
1778  case CONDITION_AURA:
1779  {
1780  if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
1781  {
1782  TC_LOG_ERROR("sql.sql", "%s has non existing spell (Id: %d), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1783  return false;
1784  }
1785 
1786  if (cond->ConditionValue2 > EFFECT_2)
1787  {
1788  TC_LOG_ERROR("sql.sql", "%s has non existing effect index (%u) (must be 0..2), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
1789  return false;
1790  }
1791  break;
1792  }
1793  case CONDITION_ITEM:
1794  {
1795  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1796  if (!proto)
1797  {
1798  TC_LOG_ERROR("sql.sql", "%s Item (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1799  return false;
1800  }
1801 
1802  if (!cond->ConditionValue2)
1803  {
1804  TC_LOG_ERROR("sql.sql", "%s Zero item count in ConditionValue2, skipped.", cond->ToString(true).c_str());
1805  return false;
1806  }
1807  break;
1808  }
1810  {
1811  ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1812  if (!proto)
1813  {
1814  TC_LOG_ERROR("sql.sql", "%s Item (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1815  return false;
1816  }
1817  break;
1818  }
1819  case CONDITION_ZONEID:
1820  {
1821  AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(cond->ConditionValue1);
1822  if (!areaEntry)
1823  {
1824  TC_LOG_ERROR("sql.sql", "%s Area (%u) does not exist, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1825  return false;
1826  }
1827 
1828  if (areaEntry->ParentAreaID != 0)
1829  {
1830  TC_LOG_ERROR("sql.sql", "%s requires to be in area (%u) which is a subzone but zone expected, skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1831  return false;
1832  }
1833  break;
1834  }
1836  {
1837  FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
1838  if (!factionEntry)
1839  {
1840  TC_LOG_ERROR("sql.sql", "%s has non existing faction (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1841  return false;
1842  }
1843  break;
1844  }
1845  case CONDITION_TEAM:
1846  {
1847  if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
1848  {
1849  TC_LOG_ERROR("sql.sql", "%s specifies unknown team (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1850  return false;
1851  }
1852  break;
1853  }
1854  case CONDITION_SKILL:
1855  {
1856  SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
1857  if (!pSkill)
1858  {
1859  TC_LOG_ERROR("sql.sql", "%s specifies non-existing skill (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1860  return false;
1861  }
1862 
1863  if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
1864  {
1865  TC_LOG_ERROR("sql.sql", "%s specifies skill (%u) with invalid value (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1, cond->ConditionValue2);
1866  return false;
1867  }
1868  break;
1869  }
1871  case CONDITION_QUESTTAKEN:
1872  case CONDITION_QUEST_NONE:
1874  {
1875  if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
1876  {
1877  TC_LOG_ERROR("sql.sql", "%s points to non-existing quest (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1878  return false;
1879  }
1880  break;
1881  }
1883  {
1884  GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
1885  if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
1886  {
1887  TC_LOG_ERROR("sql.sql", "%s has non existing event id (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1888  return false;
1889  }
1890  break;
1891  }
1892  case CONDITION_ACHIEVEMENT:
1893  {
1894  AchievementEntry const* achievement = sAchievementMgr->GetAchievement(cond->ConditionValue1);
1895  if (!achievement)
1896  {
1897  TC_LOG_ERROR("sql.sql", "%s has non existing achivement id (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1898  return false;
1899  }
1900  break;
1901  }
1902  case CONDITION_CLASS:
1903  {
1904  if (!(cond->ConditionValue1 & CLASSMASK_ALL_PLAYABLE))
1905  {
1906  TC_LOG_ERROR("sql.sql", "%s has non existing classmask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
1907  return false;
1908  }
1909  break;
1910  }
1911  case CONDITION_RACE:
1912  {
1913  if (!(cond->ConditionValue1 & RACEMASK_ALL_PLAYABLE))
1914  {
1915  TC_LOG_ERROR("sql.sql", "%s has non existing racemask (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
1916  return false;
1917  }
1918  break;
1919  }
1920  case CONDITION_GENDER:
1921  {
1922  if (!Player::IsValidGender(uint8(cond->ConditionValue1)))
1923  {
1924  TC_LOG_ERROR("sql.sql", "%s has invalid gender (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1925  return false;
1926  }
1927  break;
1928  }
1929  case CONDITION_MAPID:
1930  {
1931  MapEntry const* me = sMapStore.LookupEntry(cond->ConditionValue1);
1932  if (!me)
1933  {
1934  TC_LOG_ERROR("sql.sql", "%s has non existing map (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
1935  return false;
1936  }
1937  break;
1938  }
1939  case CONDITION_SPELL:
1940  {
1941  if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
1942  {
1943  TC_LOG_ERROR("sql.sql", "%s has non existing spell (Id: %d), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
1944  return false;
1945  }
1946  break;
1947  }
1948  case CONDITION_LEVEL:
1949  {
1950  if (cond->ConditionValue2 >= COMP_TYPE_MAX)
1951  {
1952  TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
1953  return false;
1954  }
1955  break;
1956  }
1958  {
1959  if (cond->ConditionValue1 > DRUNKEN_SMASHED)
1960  {
1961  TC_LOG_ERROR("sql.sql", "%s has invalid state (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
1962  return false;
1963  }
1964  break;
1965  }
1967  {
1968  if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
1969  {
1970  TC_LOG_ERROR("sql.sql", "%s has non existing creature template entry (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
1971  return false;
1972  }
1973  break;
1974  }
1976  {
1977  if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
1978  {
1979  TC_LOG_ERROR("sql.sql", "%s has non existing gameobject template entry (%u), skipped.", cond->ToString().c_str(), cond->ConditionValue1);
1980  return false;
1981  }
1982  break;
1983  }
1985  {
1986  switch (cond->ConditionValue1)
1987  {
1988  case TYPEID_UNIT:
1989  if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
1990  {
1991  TC_LOG_ERROR("sql.sql", "%s has non existing creature template entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
1992  return false;
1993  }
1994  if (cond->ConditionValue3)
1995  {
1996  if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
1997  {
1998  if (cond->ConditionValue2 && creatureData->id != cond->ConditionValue2)
1999  {
2000  TC_LOG_ERROR("sql.sql", "%s has guid %u set but does not match creature entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3, cond->ConditionValue2);
2001  return false;
2002  }
2003  }
2004  else
2005  {
2006  TC_LOG_ERROR("sql.sql", "%s has non existing creature guid (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
2007  return false;
2008  }
2009  }
2010  break;
2011  case TYPEID_GAMEOBJECT:
2012  if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
2013  {
2014  TC_LOG_ERROR("sql.sql", "%s has non existing gameobject template entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2015  return false;
2016  }
2017  if (cond->ConditionValue3)
2018  {
2019  if (GameObjectData const* goData = sObjectMgr->GetGOData(cond->ConditionValue3))
2020  {
2021  if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
2022  {
2023  TC_LOG_ERROR("sql.sql", "%s has guid %u set but does not match gameobject entry (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3, cond->ConditionValue2);
2024  return false;
2025  }
2026  }
2027  else
2028  {
2029  TC_LOG_ERROR("sql.sql", "%s has non existing gameobject guid (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
2030  return false;
2031  }
2032  }
2033  break;
2034  case TYPEID_PLAYER:
2035  case TYPEID_CORPSE:
2036  if (cond->ConditionValue2)
2037  LogUselessConditionValue(cond, 2, cond->ConditionValue2);
2038  if (cond->ConditionValue3)
2039  LogUselessConditionValue(cond, 3, cond->ConditionValue3);
2040  break;
2041  default:
2042  TC_LOG_ERROR("sql.sql", "%s has wrong typeid set (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
2043  return false;
2044  }
2045  break;
2046  }
2047  case CONDITION_TYPE_MASK:
2048  {
2050  {
2051  TC_LOG_ERROR("sql.sql", "%s has invalid typemask set (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2052  return false;
2053  }
2054  break;
2055  }
2056  case CONDITION_RELATION_TO:
2057  {
2058  if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
2059  {
2060  TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2061  return false;
2062  }
2063  if (cond->ConditionValue1 == cond->ConditionTarget)
2064  {
2065  TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2066  return false;
2067  }
2068  if (cond->ConditionValue2 >= RELATION_MAX)
2069  {
2070  TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue2(RelationType) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2071  return false;
2072  }
2073  break;
2074  }
2075  case CONDITION_REACTION_TO:
2076  {
2077  if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
2078  {
2079  TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2080  return false;
2081  }
2082  if (cond->ConditionValue1 == cond->ConditionTarget)
2083  {
2084  TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2085  return false;
2086  }
2087  if (!cond->ConditionValue2)
2088  {
2089  TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue2(rankMask) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2090  return false;
2091  }
2092  break;
2093  }
2094  case CONDITION_DISTANCE_TO:
2095  {
2096  if (cond->ConditionValue1 >= cond->GetMaxAvailableConditionTargets())
2097  {
2098  TC_LOG_ERROR("sql.sql", "%s has invalid ConditionValue1(ConditionTarget selection) (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2099  return false;
2100  }
2101  if (cond->ConditionValue1 == cond->ConditionTarget)
2102  {
2103  TC_LOG_ERROR("sql.sql", "%s has ConditionValue1(ConditionTarget selection) set to self (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2104  return false;
2105  }
2106  if (cond->ConditionValue3 >= COMP_TYPE_MAX)
2107  {
2108  TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue3);
2109  return false;
2110  }
2111  break;
2112  }
2113  case CONDITION_HP_VAL:
2114  {
2115  if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2116  {
2117  TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2118  return false;
2119  }
2120  break;
2121  }
2122  case CONDITION_HP_PCT:
2123  {
2124  if (cond->ConditionValue1 > 100)
2125  {
2126  TC_LOG_ERROR("sql.sql", "%s has too big percent value (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2127  return false;
2128  }
2129  if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2130  {
2131  TC_LOG_ERROR("sql.sql", "%s has invalid ComparisionType (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue2);
2132  return false;
2133  }
2134  break;
2135  }
2136  case CONDITION_WORLD_STATE:
2137  {
2138  if (!sWorld->getWorldState(cond->ConditionValue1))
2139  {
2140  TC_LOG_ERROR("sql.sql", "%s has non existing world state in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2141  return false;
2142  }
2143  break;
2144  }
2145  case CONDITION_PHASEID:
2146  {
2147  if (!sPhaseStore.LookupEntry(cond->ConditionValue1))
2148  {
2149  TC_LOG_ERROR("sql.sql", "%s has nonexistent phaseid in value1 (%u), skipped", cond->ToString(true).c_str(), cond->ConditionValue1);
2150  return false;
2151  }
2152  break;
2153  }
2154  case CONDITION_TITLE:
2155  {
2156  CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
2157  if (!titleEntry)
2158  {
2159  TC_LOG_ERROR("sql.sql", "%s has non existing title in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2160  return false;
2161  }
2162  break;
2163  }
2164  case CONDITION_SPAWNMASK:
2165  {
2166  if (cond->ConditionValue1 > SPAWNMASK_RAID_ALL)
2167  {
2168  TC_LOG_ERROR("sql.sql", "%s has non existing SpawnMask in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2169  return false;
2170  }
2171  break;
2172  }
2173  case CONDITION_UNIT_STATE:
2174  {
2176  {
2177  TC_LOG_ERROR("sql.sql", "%s has non existing UnitState in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2178  return false;
2179  }
2180  break;
2181  }
2183  {
2185  {
2186  TC_LOG_ERROR("sql.sql", "%s has non existing CreatureType in value1 (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2187  return false;
2188  }
2189  break;
2190  }
2192  case CONDITION_AREAID:
2193  case CONDITION_ALIVE:
2194  break;
2196  {
2197  AchievementEntry const* achievement = sAchievementMgr->GetAchievement(cond->ConditionValue1);
2198  if (!achievement)
2199  {
2200  TC_LOG_ERROR("sql.sql", "%s has non existing realm first achivement id (%u), skipped.", cond->ToString(true).c_str(), cond->ConditionValue1);
2201  return false;
2202  }
2203  break;
2204  }
2205  case CONDITION_IN_WATER:
2206  break;
2207  default:
2208  break;
2209  }
2210 
2212  LogUselessConditionValue(cond, 1, cond->ConditionValue1);
2214  LogUselessConditionValue(cond, 2, cond->ConditionValue2);
2216  LogUselessConditionValue(cond, 3, cond->ConditionValue3);
2217 
2218  return true;
2219 }
Definition: ConditionMgr.h:67
Definition: Creature.h:287
Definition: DBCStructure.h:37
bool HasConditionValue2
Definition: ConditionMgr.h:279
Definition: DBCStructure.h:952
Definition: ConditionMgr.h:55
Definition: ConditionMgr.h:81
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
Definition: ObjectGuid.h:50
bool HasConditionValue3
Definition: ConditionMgr.h:280
Definition: ConditionMgr.h:52
Definition: ConditionMgr.h:83
Definition: ObjectGuid.h:36
Definition: ConditionMgr.h:69
static ConditionTypeInfo const StaticConditionTypeData[CONDITION_MAX]
Definition: ConditionMgr.h:283
Definition: Util.h:509
Definition: ConditionMgr.h:75
Definition: DBCStructure.h:162
Definition: ConditionMgr.h:59
Definition: ConditionMgr.h:85
Definition: ConditionMgr.h:91
Definition: ConditionMgr.h:62
Definition: ConditionMgr.h:72
Definition: ConditionMgr.h:76
Definition: Player.h:510
Definition: DBCStructure.h:830
Definition: ObjectGuid.h:32
ObjectData const creatureData[]
Definition: instance_blackrock_caverns.cpp:22
#define sWorld
Definition: World.h:887
Definition: ConditionMgr.h:56
#define sObjectMgr
Definition: ObjectMgr.h:1567
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesfmt)
Definition: ConditionMgr.h:80
uint32 GetMaxAvailableConditionTargets() const
Definition: ConditionMgr.cpp:628
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
Definition: SharedDefines.h:1000
Definition: ObjectGuid.h:49
Definition: ObjectGuid.h:51
Definition: ConditionMgr.h:93
Definition: ConditionMgr.h:70
Definition: ConditionMgr.h:54
Definition: DB2Structure.h:27
Definition: ConditionMgr.h:61
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
Definition: ConditionMgr.h:73
Definition: ObjectGuid.h:34
#define sSpellMgr
Definition: SpellMgr.h:756
uint8 ConditionTarget
Definition: ConditionMgr.h:209
Definition: ConditionMgr.h:64
#define CLASSMASK_ALL_PLAYABLE
Definition: SharedDefines.h:183
Definition: ConditionMgr.h:66
Definition: ConditionMgr.h:51
Definition: ConditionMgr.h:78
Definition: ConditionMgr.h:58
Definition: ConditionMgr.h:165
DBCStorage< PhaseEntry > sPhaseStore(Phasefmt)
uint32 ConditionValue3
Definition: ConditionMgr.h:204
Definition: ConditionMgr.h:57
Definition: SharedDefines.h:3566
bool HasConditionValue1
Definition: ConditionMgr.h:278
uint32 ParentAreaID
Definition: DBCStructure.h:41
Definition: ConditionMgr.h:90
Definition: SharedDefines.h:999
uint32 ConditionValue2
Definition: ConditionMgr.h:203
Definition: DBCStructure.h:405
Definition: ConditionMgr.h:87
Definition: GameObject.h:833
uint8_t uint8
Definition: g3dmath.h:164
#define sGameEventMgr
Definition: GameEventMgr.h:184
Definition: ObjectGuid.h:33
Definition: ItemTemplate.h:647
uint32 ConditionValue1
Definition: ConditionMgr.h:202
DBCStorage< MapEntry > sMapStore(Mapfmt)
Definition: ConditionMgr.h:77
Definition: ConditionMgr.h:71
#define RACEMASK_ALL_PLAYABLE
Definition: SharedDefines.h:133
Definition: DBCEnums.h:457
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
Definition: ConditionMgr.h:86
Definition: ConditionMgr.h:79
DBCStorage< FactionEntry > sFactionStore(Factionfmt)
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: SharedDefines.h:30
Definition: ConditionMgr.h:63
Definition: ObjectGuid.h:53
Definition: ConditionMgr.h:88
static void LogUselessConditionValue(Condition *cond, uint8 index, uint32 value)
Definition: ConditionMgr.cpp:2221
Definition: Unit.h:578
Definition: ConditionMgr.h:74
ConditionTypes ConditionType
Definition: ConditionMgr.h:201
Definition: ConditionMgr.h:84
#define sAchievementMgr
Definition: AchievementMgr.h:501
Definition: ConditionMgr.h:89
Definition: ConditionMgr.h:60
Definition: ConditionMgr.h:53
Definition: ConditionMgr.h:68
Definition: ConditionMgr.h:82
Definition: ConditionMgr.h:65

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConditionMgr::IsObjectMeetingNotGroupedConditions ( ConditionSourceType  sourceType,
uint32  entry,
ConditionSourceInfo sourceInfo 
) const
821 {
822  if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
823  {
824  ConditionsByEntryMap::const_iterator i = ConditionStore[sourceType].find(entry);
825  if (i != ConditionStore[sourceType].end())
826  {
827  TC_LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type %u and entry %u", uint32(sourceType), entry);
828  return IsObjectMeetToConditions(sourceInfo, i->second);
829  }
830  }
831 
832  return true;
833 }
ConditionEntriesByTypeArray ConditionStore
Definition: ConditionMgr.h:299
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: ConditionMgr.h:154
Definition: ConditionMgr.h:127
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770
uint32_t uint32
Definition: g3dmath.h:168

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool ConditionMgr::IsObjectMeetingNotGroupedConditions ( ConditionSourceType  sourceType,
uint32  entry,
WorldObject target0,
WorldObject target1 = nullptr,
WorldObject target2 = nullptr 
) const
836 {
837  ConditionSourceInfo conditionSource(target0, target1, target2);
838  return IsObjectMeetingNotGroupedConditions(sourceType, entry, conditionSource);
839 }
bool IsObjectMeetingNotGroupedConditions(ConditionSourceType sourceType, uint32 entry, ConditionSourceInfo &sourceInfo) const
Definition: ConditionMgr.cpp:820
Definition: ConditionMgr.h:181

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetingSmartEventConditions ( int64  entryOrGuid,
uint32  eventId,
uint32  sourceType,
Unit unit,
WorldObject baseObject 
) const
898 {
899  SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
900  if (itr != SmartEventConditionStore.end())
901  {
902  ConditionsByEntryMap::const_iterator i = itr->second.find(eventId + 1);
903  if (i != itr->second.end())
904  {
905  TC_LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid " SI64FMTD " eventId %u", entryOrGuid, eventId);
906  ConditionSourceInfo sourceInfo(unit, baseObject);
907  return IsObjectMeetToConditions(sourceInfo, i->second);
908  }
909  }
910  return true;
911 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
#define SI64FMTD
Definition: Define.h:140
Definition: ConditionMgr.h:181
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:304
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetingSpellClickConditions ( uint32  creatureId,
uint32  spellId,
WorldObject clicker,
WorldObject target 
) const
851 {
852  ConditionEntriesByCreatureIdMap::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
853  if (itr != SpellClickEventConditionStore.end())
854  {
855  ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
856  if (i != itr->second.end())
857  {
858  TC_LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for SpellClickEvent entry %u spell %u", creatureId, spellId);
859  ConditionSourceInfo sourceInfo(clicker, target);
860  return IsObjectMeetToConditions(sourceInfo, i->second);
861  }
862  }
863  return true;
864 }
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore
Definition: ConditionMgr.h:302
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetingVehicleSpellConditions ( uint32  creatureId,
uint32  spellId,
Player player,
Unit vehicle 
) const
882 {
883  ConditionEntriesByCreatureIdMap::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
884  if (itr != VehicleSpellConditionStore.end())
885  {
886  ConditionsByEntryMap::const_iterator i = itr->second.find(spellId);
887  if (i != itr->second.end())
888  {
889  TC_LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry %u spell %u", creatureId, spellId);
890  ConditionSourceInfo sourceInfo(player, vehicle);
891  return IsObjectMeetToConditions(sourceInfo, i->second);
892  }
893  }
894  return true;
895 }
ConditionEntriesByCreatureIdMap VehicleSpellConditionStore
Definition: ConditionMgr.h:301
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetingVendorItemConditions ( uint32  creatureId,
uint32  itemId,
Player player,
Creature vendor 
) const
914 {
915  ConditionEntriesByCreatureIdMap::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
916  if (itr != NpcVendorConditionContainerStore.end())
917  {
918  ConditionsByEntryMap::const_iterator i = (*itr).second.find(itemId);
919  if (i != (*itr).second.end())
920  {
921  TC_LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry %u item %u", creatureId, itemId);
922  ConditionSourceInfo sourceInfo(player, vendor);
923  return IsObjectMeetToConditions(sourceInfo, i->second);
924  }
925  }
926  return true;
927 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770
ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore
Definition: ConditionMgr.h:303

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetToConditionList ( ConditionSourceInfo sourceInfo,
ConditionContainer const conditions 
) const
private

Find ElseGroup in ElseGroupStore

If not found, add an entry in the store and set to true (placeholder)

725 {
726  // groupId, groupCheckPassed
727  std::map<uint32, bool> elseGroupStore;
728  for (Condition const* condition : conditions)
729  {
730  TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s val1: %u", condition->ToString().c_str(), condition->ConditionValue1);
731  if (condition->isLoaded())
732  {
734  std::map<uint32, bool>::const_iterator itr = elseGroupStore.find(condition->ElseGroup);
736  if (itr == elseGroupStore.end())
737  elseGroupStore[condition->ElseGroup] = true;
738  else if (!(*itr).second)
739  continue;
740 
741  if (condition->ReferenceId)//handle reference
742  {
743  ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(condition->ReferenceId);
744  if (ref != ConditionReferenceStore.end())
745  {
746  if (!IsObjectMeetToConditionList(sourceInfo, ref->second))
747  elseGroupStore[condition->ElseGroup] = false;
748  }
749  else
750  {
751  TC_LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList %s Reference template -%u not found",
752  condition->ToString().c_str(), condition->ReferenceId); // checked at loading, should never happen
753  }
754 
755  }
756  else //handle normal condition
757  {
758  if (!condition->Meets(sourceInfo))
759  elseGroupStore[condition->ElseGroup] = false;
760  }
761  }
762  }
763  for (std::map<uint32, bool>::const_iterator i = elseGroupStore.begin(); i != elseGroupStore.end(); ++i)
764  if (i->second)
765  return true;
766 
767  return false;
768 }
Definition: ConditionMgr.h:194
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:724
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:300

+ Here is the caller graph for this function:

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionContainer const conditions 
) const
771 {
772  ConditionSourceInfo srcInfo = ConditionSourceInfo(object);
773  return IsObjectMeetToConditions(srcInfo, conditions);
774 }
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770

+ Here is the caller graph for this function:

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionContainer const conditions 
) const
777 {
778  ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
779  return IsObjectMeetToConditions(srcInfo, conditions);
780 }
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:770

+ Here is the call graph for this function:

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionContainer const conditions 
) const
783 {
784  if (conditions.empty())
785  return true;
786 
787  TC_LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
788  return IsObjectMeetToConditionList(sourceInfo, conditions);
789 }
#define TC_LOG_DEBUG(filterType__,...)
Definition: Log.h:198
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionContainer const &conditions) const
Definition: ConditionMgr.cpp:724

+ Here is the call graph for this function:

bool ConditionMgr::IsPlayerMeetingCondition ( Player player,
PlayerConditionEntry const condition 
)
static
2329 {
2330  if (condition->MinLevel && player->getLevel() < condition->MinLevel)
2331  return false;
2332 
2333  if (condition->MaxLevel && player->getLevel() > condition->MaxLevel)
2334  return false;
2335 
2336  if (condition->RaceMask && !(player->getRaceMask() & condition->RaceMask))
2337  return false;
2338 
2339  if (condition->ClassMask && !(player->getClassMask() & condition->ClassMask))
2340  return false;
2341 
2342  if (condition->Gender >= 0 && player->getGender() != condition->Gender)
2343  return false;
2344 
2345  if (condition->NativeGender >= 0 && player->GetByteValue(PLAYER_BYTES_3, PLAYER_BYTES_3_OFFSET_GENDER) != condition->NativeGender)
2346  return false;
2347 
2348  if (condition->PowerType != -1 && condition->PowerTypeComp)
2349  {
2350  int32 requiredPowerValue = condition->Flags & 4 ? player->GetMaxPower(Powers(condition->PowerType)) : condition->PowerTypeValue;
2351  if (!PlayerConditionCompare(condition->PowerTypeComp, player->GetPower(Powers(condition->PowerType)), requiredPowerValue))
2352  return false;
2353  }
2354 
2355  if (condition->ChrSpecializationIndex >= 0 || condition->ChrSpecializationRole >= 0)
2356  {
2357  if (ChrSpecializationEntry const* spec = sChrSpecializationStore.LookupEntry(player->GetSpecId(player->GetActiveTalentGroup())))
2358  {
2359  if (condition->ChrSpecializationIndex >= 0 && spec->OrderIndex != uint32(condition->ChrSpecializationIndex))
2360  return false;
2361 
2362  if (condition->ChrSpecializationRole >= 0 && spec->Role != uint32(condition->ChrSpecializationRole))
2363  return false;
2364  }
2365  }
2366 
2367  if (condition->SkillID[0] || condition->SkillID[1] || condition->SkillID[2] || condition->SkillID[3])
2368  {
2369  using SkillCount = std::extent<decltype(condition->SkillID)>;
2370 
2371  std::array<bool, SkillCount::value> results;
2372  results.fill(true);
2373  for (std::size_t i = 0; i < SkillCount::value; ++i)
2374  {
2375  if (condition->SkillID[i])
2376  {
2377  uint16 skillValue = player->GetSkillValue(condition->SkillID[i]);
2378  results[i] = skillValue != 0 && skillValue > condition->MinSkill[i] && skillValue < condition->MaxSkill[i];
2379  }
2380  }
2381 
2382  if (!PlayerConditionLogic(condition->SkillLogic, results))
2383  return false;
2384  }
2385 
2386  if (condition->LanguageID)
2387  {
2388  if (LanguageDesc const* lang = GetLanguageDescByID(condition->LanguageID))
2389  {
2390  uint32 languageSkill = player->GetSkillValue(lang->skill_id);
2391  if (!languageSkill && player->HasAuraTypeWithMiscvalue(SPELL_AURA_COMPREHEND_LANGUAGE, condition->LanguageID))
2392  languageSkill = 300;
2393 
2394  if (condition->MinLanguage && languageSkill < condition->MinLanguage)
2395  return false;
2396 
2397  if (condition->MaxLanguage && languageSkill > condition->MaxLanguage)
2398  return false;
2399  }
2400  }
2401 
2402  if (condition->MinFactionID[0] && condition->MinFactionID[1] && condition->MinFactionID[2] && condition->MaxFactionID)
2403  {
2404  if (!condition->MinFactionID[0] && !condition->MinFactionID[1] && !condition->MinFactionID[2])
2405  {
2406  if (ReputationRank const* forcedRank = player->GetReputationMgr().GetForcedRankIfAny(condition->MaxFactionID))
2407  {
2408  if (*forcedRank > ReputationRank(condition->MaxReputation))
2409  return false;
2410  }
2411  else if (player->GetReputationRank(condition->MaxFactionID) > ReputationRank(condition->MaxReputation))
2412  return false;
2413  }
2414  else
2415  {
2416  using FactionCount = std::extent<decltype(condition->MinFactionID)>;
2417 
2418  std::array<bool, FactionCount::value + 1> results;
2419  results.fill(true);
2420  for (std::size_t i = 0; i < FactionCount::value; ++i)
2421  {
2422  if (condition->MinFactionID[i])
2423  {
2424  if (ReputationRank const* forcedRank = player->GetReputationMgr().GetForcedRankIfAny(condition->MinFactionID[i]))
2425  results[i] = *forcedRank >= ReputationRank(condition->MinReputation[i]);
2426  else
2427  results[i] = player->GetReputationRank(condition->MinFactionID[i]) >= ReputationRank(condition->MinReputation[i]);
2428  }
2429  }
2430 
2431  if (ReputationRank const* forcedRank = player->GetReputationMgr().GetForcedRankIfAny(condition->MaxFactionID))
2432  results[3] = *forcedRank <= ReputationRank(condition->MaxReputation);
2433  else
2434  results[3] = player->GetReputationRank(condition->MaxFactionID) <= ReputationRank(condition->MaxReputation);
2435 
2436  if (!PlayerConditionLogic(condition->ReputationLogic, results))
2437  return false;
2438  }
2439  }
2440 
2441  if (condition->PvpMedal && !((1 << (condition->PvpMedal - 1)) & player->GetUInt32Value(PLAYER_FIELD_PVP_MEDALS)))
2442  return false;
2443 
2444  if (condition->LifetimeMaxPVPRank && player->GetByteValue(PLAYER_FIELD_BYTES, PLAYER_FIELD_BYTES_OFFSET_LIFETIME_MAX_PVP_RANK) != condition->LifetimeMaxPVPRank)
2445  return false;
2446 
2447  if (condition->PartyStatus)
2448  {
2449  Group* group = player->GetGroup();
2450  switch (condition->PartyStatus)
2451  {
2452  case 1:
2453  if (group)
2454  return false;
2455  break;
2456  case 2:
2457  if (!group)
2458  return false;
2459  break;
2460  case 3:
2461  if (!group || group->isRaidGroup())
2462  return false;
2463  break;
2464  case 4:
2465  if (!group || !group->isRaidGroup())
2466  return false;
2467  break;
2468  case 5:
2469  if (group && group->isRaidGroup())
2470  return false;
2471  break;
2472  default:
2473  break;
2474  }
2475  }
2476 
2477  if (condition->PrevQuestID[0])
2478  {
2479  using PrevQuestCount = std::extent<decltype(condition->PrevQuestID)>;
2480 
2481  std::array<bool, PrevQuestCount::value> results;
2482  results.fill(true);
2483  for (std::size_t i = 0; i < PrevQuestCount::value; ++i)
2484  if (uint32 questBit = sDB2Manager.GetQuestUniqueBitFlag(condition->PrevQuestID[i]))
2485  results[i] = (player->GetUInt32Value(PLAYER_FIELD_QUEST_COMPLETED + ((questBit - 1) >> 5)) & (1 << ((questBit - 1) & 31))) != 0;
2486 
2487  if (!PlayerConditionLogic(condition->PrevQuestLogic, results))
2488  return false;
2489  }
2490 
2491  if (condition->CurrQuestID[0])
2492  {
2493  using CurrQuestCount = std::extent<decltype(condition->CurrQuestID)>;
2494 
2495  std::array<bool, CurrQuestCount::value> results;
2496  results.fill(true);
2497  for (std::size_t i = 0; i < CurrQuestCount::value; ++i)
2498  if (condition->CurrQuestID[i])
2499  results[i] = player->FindQuestSlot(condition->CurrQuestID[i]) != MAX_QUEST_LOG_SIZE;
2500 
2501  if (!PlayerConditionLogic(condition->CurrQuestLogic, results))
2502  return false;
2503  }
2504 
2505  if (condition->CurrentCompletedQuestID[0])
2506  {
2507  using CurrentCompletedQuestCount = std::extent<decltype(condition->CurrentCompletedQuestID)>;
2508 
2509  std::array<bool, CurrentCompletedQuestCount::value> results;
2510  results.fill(true);
2511  for (std::size_t i = 0; i < CurrentCompletedQuestCount::value; ++i)
2512  if (condition->CurrentCompletedQuestID[i])
2513  results[i] = player->GetQuestStatus(condition->CurrentCompletedQuestID[i]) == QUEST_STATUS_COMPLETE;
2514 
2515  if (!PlayerConditionLogic(condition->CurrentCompletedQuestLogic, results))
2516  return false;
2517  }
2518 
2519 
2520  if (condition->SpellID[0])
2521  {
2522  using SpellCount = std::extent<decltype(condition->SpellID)>;
2523 
2524  std::array<bool, SpellCount::value> results;
2525  results.fill(true);
2526  for (std::size_t i = 0; i < SpellCount::value; ++i)
2527  if (condition->SpellID[i])
2528  results[i] = player->HasSpell(condition->SpellID[i]);
2529 
2530  if (!PlayerConditionLogic(condition->SpellLogic, results))
2531  return false;
2532  }
2533 
2534  if (condition->ItemID[0])
2535  {
2536  using ItemCount = std::extent<decltype(condition->ItemID)>;
2537 
2538  std::array<bool, ItemCount::value> results;
2539  results.fill(true);
2540  for (std::size_t i = 0; i < ItemCount::value; ++i)
2541  if (condition->ItemID[i])
2542  results[i] = player->GetItemCount(condition->ItemID[i], condition->ItemFlags != 0) >= condition->ItemCount[i];
2543 
2544  if (!PlayerConditionLogic(condition->ItemLogic, results))
2545  return false;
2546  }
2547 
2548  if (condition->CurrencyID[0])
2549  {
2550  using CurrencyCount = std::extent<decltype(condition->CurrencyID)>;
2551 
2552  std::array<bool, CurrencyCount::value> results;
2553  results.fill(true);
2554  for (std::size_t i = 0; i < CurrencyCount::value; ++i)
2555  if (condition->CurrencyID[i])
2556  results[i] = player->GetCurrency(condition->CurrencyID[i]) >= condition->CurrencyCount[i];
2557 
2558  if (!PlayerConditionLogic(condition->CurrencyLogic, results))
2559  return false;
2560  }
2561 
2562  if (condition->Explored[0] || condition->Explored[1])
2563  {
2564  using ExploredCount = std::extent<decltype(condition->Explored)>;
2565 
2566  for (std::size_t i = 0; i < ExploredCount::value; ++i)
2567  {
2568  if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(condition->Explored[i]))
2569  if (area->AreaBit != -1 && !(player->GetUInt32Value(PLAYER_EXPLORED_ZONES_1 + area->AreaBit / 32) & (1 << (uint32(area->AreaBit) % 32))))
2570  return false;
2571  }
2572  }
2573 
2574  if (condition->AuraSpellID[0])
2575  {
2576  using AuraCount = std::extent<decltype(condition->AuraSpellID)>;
2577 
2578  std::array<bool, AuraCount::value> results;
2579  results.fill(true);
2580  for (std::size_t i = 0; i < AuraCount::value; ++i)
2581  if (condition->AuraSpellID[i])
2582  results[i] = player->HasAura(condition->AuraSpellID[i]);
2583 
2584  if (!PlayerConditionLogic(condition->AuraSpellLogic, results))
2585  return false;
2586  }
2587 
2588  // TODO: time condition
2589  // TODO (or not): world state expression condition
2590  // TODO: weather condition
2591 
2592  if (condition->Achievement[0])
2593  {
2594  using AchievementCount = std::extent<decltype(condition->Achievement)>;
2595 
2596  std::array<bool, AchievementCount::value> results;
2597  results.fill(true);
2598  for (std::size_t i = 0; i < AchievementCount::value; ++i)
2599  {
2600  if (condition->Achievement[i])
2601  {
2602  // if (condition->Flags & 2) { any character on account completed it } else { current character only }
2603  // TODO: part of accountwide achievements
2604  results[i] = player->HasAchieved(condition->Achievement[i]);
2605  }
2606  }
2607 
2608  if (!PlayerConditionLogic(condition->AchievementLogic, results))
2609  return false;
2610  }
2611 
2612  // TODO: research lfg status for player conditions
2613 
2614  if (condition->AreaID[0])
2615  {
2616  using AreaCount = std::extent<decltype(condition->AreaID)>;
2617 
2618  std::array<bool, AreaCount::value> results;
2619  results.fill(true);
2620  for (std::size_t i = 0; i < AreaCount::value; ++i)
2621  if (condition->AreaID[i])
2622  results[i] = player->GetAreaId() == condition->AreaID[i] || player->GetZoneId() == condition->AreaID[i];
2623 
2624  if (!PlayerConditionLogic(condition->AreaLogic, results))
2625  return false;
2626  }
2627 
2628  if (condition->MinExpansionLevel != -1 && player->GetSession()->GetExpansion() < condition->MinExpansionLevel)
2629  return false;
2630 
2631  if (condition->MaxExpansionLevel != -1 && player->GetSession()->GetExpansion() > condition->MaxExpansionLevel)
2632  return false;
2633 
2634  if (condition->MinExpansionLevel != -1 && condition->MinExpansionTier != -1 && !player->IsGameMaster()
2635  && ((condition->MinExpansionLevel == int32(sWorld->getIntConfig(CONFIG_EXPANSION)) && condition->MinExpansionTier > 0) /*TODO: implement tier*/
2636  || condition->MinExpansionLevel > int32(sWorld->getIntConfig(CONFIG_EXPANSION))))
2637  return false;
2638 
2639  if (condition->PhaseID && !player->IsInPhase(condition->PhaseID))
2640  return false;
2641 
2642  if (condition->PhaseGroupID)
2643  {
2644  std::set<uint32> phases = sDB2Manager.GetPhasesForGroup(condition->PhaseGroupID);
2645  if (!Trinity::Containers::Intersects(phases.begin(), phases.end(), player->GetPhases().begin(), player->GetPhases().end()))
2646  return false;
2647  }
2648 
2649  if (condition->QuestKillID)
2650  {
2651  Quest const* quest = sObjectMgr->GetQuestTemplate(condition->QuestKillID);
2652  if (quest && player->GetQuestStatus(condition->QuestKillID) != QUEST_STATUS_COMPLETE)
2653  {
2654  using QuestKillCount = std::extent<decltype(condition->QuestKillMonster)>;
2655 
2656  std::array<bool, QuestKillCount::value> results;
2657  results.fill(true);
2658  for (std::size_t i = 0; i < QuestKillCount::value; ++i)
2659  {
2660  if (condition->QuestKillMonster[i])
2661  {
2662  auto objectiveItr = std::find_if(quest->GetObjectives().begin(), quest->GetObjectives().end(), [condition, i](QuestObjective const& objective) -> bool
2663  {
2664  return objective.Type == QUEST_OBJECTIVE_MONSTER && uint32(objective.ObjectID) == condition->QuestKillMonster[i];
2665  });
2666  if (objectiveItr != quest->GetObjectives().end())
2667  results[i] = player->GetQuestObjectiveData(quest, objectiveItr->StorageIndex) >= objectiveItr->Amount;
2668  }
2669  }
2670 
2671  if (!PlayerConditionLogic(condition->QuestKillLogic, results))
2672  return false;
2673  }
2674  }
2675 
2676  if (condition->MinAvgItemLevel && uint32(std::floor(player->GetFloatValue(PLAYER_FIELD_AVG_ITEM_LEVEL))) < condition->MinAvgItemLevel)
2677  return false;
2678 
2679  if (condition->MaxAvgItemLevel && uint32(std::floor(player->GetFloatValue(PLAYER_FIELD_AVG_ITEM_LEVEL))) > condition->MaxAvgItemLevel)
2680  return false;
2681 
2682  if (condition->MinAvgEquippedItemLevel && uint32(std::floor(player->GetFloatValue(PLAYER_FIELD_AVG_ITEM_LEVEL + 1))) < condition->MinAvgEquippedItemLevel)
2683  return false;
2684 
2685  if (condition->MaxAvgEquippedItemLevel && uint32(std::floor(player->GetFloatValue(PLAYER_FIELD_AVG_ITEM_LEVEL + 1))) > condition->MaxAvgEquippedItemLevel)
2686  return false;
2687 
2688  return true;
2689 }
static uint16 const FactionCount
Definition: ReputationPackets.h:27
Definition: DBCStructure.h:37
Definition: Player.h:587
Definition: QuestDef.h:111
#define sDB2Manager
Definition: DB2Stores.h:224
Definition: QuestDef.h:279
ReputationRank
Definition: SharedDefines.h:211
#define MAX_QUEST_LOG_SIZE
Definition: QuestDef.h:43
Definition: UpdateFields.h:269
bool isRaidGroup() const
Definition: Group.cpp:2509
Definition: QuestDef.h:261
static Vector3int16 floor(const Vector3 &v)
Definition: UpdateFields.h:208
QuestObjectives const & GetObjectives() const
Definition: QuestDef.h:345
Definition: SpellAuraDefines.h:304
#define sWorld
Definition: World.h:887
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: ObjectMgr.h:660
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
Definition: UpdateFields.h:198
bool PlayerConditionLogic(uint32 logic, std::array< bool, N > &results)
Definition: ConditionMgr.cpp:2301
Powers
Definition: SharedDefines.h:246
Definition: DBCStructure.h:245
Definition: QuestDef.h:220
bool PlayerConditionCompare(int32 comparisonType, int32 value1, int32 value2)
Definition: ConditionMgr.cpp:2278
int32_t int32
Definition: Define.h:146
uint32_t uint32
Definition: Define.h:150
uint16_t uint16
Definition: Define.h:151
Definition: UpdateFields.h:267
bool Intersects(Iterator1 first1, Iterator1 last1, Iterator2 first2, Iterator2 last2)
Definition: Containers.h:133
Definition: World.h:278
LanguageDesc const * GetLanguageDescByID(uint32 lang)
Definition: ObjectMgr.cpp:192
DBCStorage< ChrSpecializationEntry > sChrSpecializationStore(ChrSpecializationfmt)
int32_t int32
Definition: g3dmath.h:167
Definition: UpdateFields.h:299
const FieldDescriptor value
Definition: descriptor.h:1522
uint32_t uint32
Definition: g3dmath.h:168
Definition: UpdateFields.h:249
Definition: Group.h:191

+ Here is the call graph for this function:

bool ConditionMgr::isSourceTypeValid ( Condition cond) const
private
1394 {
1396  {
1397  TC_LOG_ERROR("sql.sql", "%s Invalid ConditionSourceType in `condition` table, ignoring.", cond->ToString().c_str());
1398  return false;
1399  }
1400 
1401  switch (cond->SourceType)
1402  {
1404  {
1406  {
1407  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->ToString().c_str());
1408  return false;
1409  }
1410 
1412  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1413  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1414  {
1415  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1416  return false;
1417  }
1418  break;
1419  }
1421  {
1423  {
1424  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->ToString().c_str());
1425  return false;
1426  }
1427 
1429  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1430  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1431  {
1432  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1433  return false;
1434  }
1435  break;
1436  }
1438  {
1440  {
1441  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->ToString().c_str());
1442  return false;
1443  }
1444 
1446  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1447  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1448  {
1449  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1450  return false;
1451  }
1452  break;
1453  }
1455  {
1457  {
1458  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->ToString().c_str());
1459  return false;
1460  }
1461 
1463  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1464  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1465  {
1466  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1467  return false;
1468  }
1469  break;
1470  }
1472  {
1474  {
1475  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->ToString().c_str());
1476  return false;
1477  }
1478 
1480  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1481  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1482  {
1483  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1484  return false;
1485  }
1486  break;
1487  }
1489  {
1491  {
1492  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->ToString().c_str());
1493  return false;
1494  }
1495 
1497  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1498  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1499  {
1500  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1501  return false;
1502  }
1503  break;
1504  }
1506  {
1508  {
1509  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->ToString().c_str());
1510  return false;
1511  }
1512 
1514  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1515  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1516  {
1517  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1518  return false;
1519  }
1520  break;
1521  }
1523  {
1525  {
1526  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->ToString().c_str());
1527  return false;
1528  }
1529 
1531  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1532  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1533  {
1534  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1535  return false;
1536  }
1537  break;
1538  }
1540  {
1542  {
1543  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->ToString().c_str());
1544  return false;
1545  }
1546 
1548  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1549  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1550  {
1551  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1552  return false;
1553  }
1554  break;
1555  }
1557  {
1559  {
1560  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->ToString().c_str());
1561  return false;
1562  }
1563 
1565  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1566  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1567  {
1568  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1569  return false;
1570  }
1571  break;
1572  }
1574  {
1576  {
1577  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->ToString().c_str());
1578  return false;
1579  }
1580 
1582  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1583  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1584  {
1585  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1586  return false;
1587  }
1588  break;
1589  }
1591  {
1593  {
1594  TC_LOG_ERROR("sql.sql", "%s SourceGroup in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->ToString().c_str());
1595  return false;
1596  }
1597 
1599  ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1600  if (!pItemProto && !loot->isReference(cond->SourceEntry))
1601  {
1602  TC_LOG_ERROR("sql.sql", "%s SourceType, SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1603  return false;
1604  }
1605  break;
1606  }
1608  {
1609  SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1610  if (!spellInfo)
1611  {
1612  TC_LOG_ERROR("sql.sql", "%s in `condition` table, SourceEntry does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
1613  return false;
1614  }
1615 
1616  if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1617  {
1618  TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect SourceGroup (spell effectMask) set, ignoring.", cond->ToString().c_str());
1619  return false;
1620  }
1621 
1622  uint32 origGroup = cond->SourceGroup;
1623 
1624  for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1625  {
1626  if (!((1 << i) & cond->SourceGroup))
1627  continue;
1628 
1629  SpellEffectInfo const* effect = spellInfo->GetEffect(DIFFICULTY_NONE, i);
1630  if (!effect)
1631  continue;
1632 
1633  if (effect->ChainTargets > 0)
1634  continue;
1635 
1636  switch (effect->TargetA.GetSelectionCategory())
1637  {
1641  continue;
1642  default:
1643  break;
1644  }
1645 
1646  switch (effect->TargetB.GetSelectionCategory())
1647  {
1651  continue;
1652  default:
1653  break;
1654  }
1655 
1656  TC_LOG_ERROR("sql.sql", "SourceEntry %u SourceGroup %u in `condition` table - spell %u does not have implicit targets of types: _AREA_, _CONE_, _NEARBY_, __CHAIN__ for effect %u, SourceGroup needs correction, ignoring.", cond->SourceEntry, origGroup, cond->SourceEntry, uint32(i));
1657  cond->SourceGroup &= ~(1 << i);
1658  }
1659  // all effects were removed, no need to add the condition at all
1660  if (!cond->SourceGroup)
1661  return false;
1662  break;
1663  }
1665  {
1666  if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1667  {
1668  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
1669  return false;
1670  }
1671  break;
1672  }
1675  {
1676  SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1677  if (!spellProto)
1678  {
1679  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
1680  return false;
1681  }
1682  break;
1683  }
1686  if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1687  {
1688  TC_LOG_ERROR("sql.sql", "%s SourceEntry specifies non-existing quest, skipped.", cond->ToString().c_str());
1689  return false;
1690  }
1691  break;
1693  if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1694  {
1695  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
1696  return false;
1697  }
1698 
1699  if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1700  {
1701  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
1702  return false;
1703  }
1704  break;
1706  if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1707  {
1708  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
1709  return false;
1710  }
1711 
1712  if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1713  {
1714  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->ToString().c_str());
1715  return false;
1716  }
1717  break;
1719  {
1720  if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1721  {
1722  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `creature_template`, ignoring.", cond->ToString().c_str());
1723  return false;
1724  }
1725  ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1726  if (!itemTemplate)
1727  {
1728  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in `item_template`, ignoring.", cond->ToString().c_str());
1729  return false;
1730  }
1731  break;
1732  }
1734  {
1735  if (!sMapStore.LookupEntry(cond->SourceEntry))
1736  {
1737  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in Map.dbc, ignoring.", cond->ToString().c_str());
1738  return false;
1739  }
1740  break;
1741  }
1743  {
1744  if (cond->SourceEntry && !sAreaTableStore.LookupEntry(cond->SourceEntry))
1745  {
1746  TC_LOG_ERROR("sql.sql", "%s SourceEntry in `condition` table, does not exist in AreaTable.dbc, ignoring.", cond->ToString().c_str());
1747  return false;
1748  }
1749  break;
1750  }
1755  default:
1756  break;
1757  }
1758 
1759  return true;
1760 }
LootStore LootTemplates_Disenchant("disenchant_loot_template","item disenchant id", true)
Definition: DBCEnums.h:404
LootStore LootTemplates_Creature("creature_loot_template","creature entry", true)
LootStore LootTemplates_Prospecting("prospecting_loot_template","item entry (ore)", true)
Definition: ConditionMgr.h:132
bool isReference(uint32 id)
Definition: LootMgr.cpp:1502
LootStore LootTemplates_Item("item_loot_template","item entry", true)
Definition: SpellInfo.h:326
LootStore LootTemplates_Skinning("skinning_loot_template","creature skinning id", true)
Definition: ConditionMgr.h:134
LootTemplate * GetLootForConditionFill(uint32 loot_id)
Definition: LootMgr.cpp:237
Definition: ConditionMgr.h:139
int32 SourceEntry
Definition: ConditionMgr.h:198
SpellTargetSelectionCategories GetSelectionCategory() const
Definition: SpellInfo.cpp:69
Definition: ConditionMgr.h:152
Definition: ConditionMgr.h:150
Definition: ConditionMgr.h:151
#define sObjectMgr
Definition: ObjectMgr.h:1567
LootStore LootTemplates_Milling("milling_loot_template","item entry (herb)", true)
Definition: ConditionMgr.h:128
Definition: ConditionMgr.h:146
LootStore LootTemplates_Fishing("fishing_loot_template","area id", true)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTablefmt)
LootStore LootTemplates_Gameobject("gameobject_loot_template","gameobject entry", true)
SpellImplicitTargetInfo TargetA
Definition: SpellInfo.h:257
uint32 ChainTargets
Definition: SpellInfo.h:261
uint32 SourceGroup
Definition: ConditionMgr.h:197
Definition: ConditionMgr.h:138
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
Definition: ConditionMgr.h:145
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: ConditionMgr.h:137
Definition: SpellInfo.h:238
uint32_t uint32
Definition: Define.h:150
Definition: SpellInfo.h:88
Definition: ConditionMgr.h:142
Definition: SpellInfo.h:87
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:229
Definition: ConditionMgr.h:133
SpellEffectInfo const * GetEffect(uint32 difficulty, uint32 index) const
Definition: SpellInfo.cpp:3348
Definition: ConditionMgr.h:154
Definition: ConditionMgr.h:149
Definition: ConditionMgr.h:127
Definition: SpellInfo.h:89
Definition: LootMgr.h:250
Definition: ItemTemplate.h:647
DBCStorage< MapEntry > sMapStore(Mapfmt)
LootStore LootTemplates_Spell("spell_loot_template","spell id (random item creating)", false)
SpellImplicitTargetInfo TargetB
Definition: SpellInfo.h:258
uint8_t uint8
Definition: Define.h:152
LootStore LootTemplates_Mail("mail_loot_template","mail template id", false)
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1026
Definition: ConditionMgr.h:141
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true)
Definition: ConditionMgr.h:147
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ConditionMgr.h:153
Definition: ConditionMgr.h:144
Definition: ConditionMgr.h:140
Definition: ConditionMgr.h:148
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1027
Definition: ConditionMgr.h:130
ConditionSourceType SourceType
Definition: ConditionMgr.h:196
LootStore LootTemplates_Reference("reference_loot_template","reference id", false)

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void ConditionMgr::LoadConditions ( bool  isReload = false)

TODO: PAIR_32 ?

936 {
937  uint32 oldMSTime = getMSTime();
938 
939  Clean();
940 
941  //must clear all custom handled cases (groupped types) before reload
942  if (isReload)
943  {
944  TC_LOG_INFO("misc", "Reseting Loot Conditions...");
957 
958  TC_LOG_INFO("misc", "Re-Loading `gossip_menu` Table for Conditions!");
959  sObjectMgr->LoadGossipMenu();
960 
961  TC_LOG_INFO("misc", "Re-Loading `gossip_menu_option` Table for Conditions!");
962  sObjectMgr->LoadGossipMenuItems();
963 
964  sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
965 
966  TC_LOG_INFO("misc", "Re-Loading `terrain_phase_info` Table for Conditions!");
967  sObjectMgr->LoadTerrainPhaseInfo();
968 
969  TC_LOG_INFO("misc", "Re-Loading `terrain_swap_defaults` Table for Conditions!");
970  sObjectMgr->LoadTerrainSwapDefaults();
971 
972  TC_LOG_INFO("misc", "Re-Loading `terrain_worldmap` Table for Conditions!");
973  sObjectMgr->LoadTerrainWorldMaps();
974 
975  TC_LOG_INFO("misc", "Re-Loading `phase_area` Table for Conditions!");
976  sObjectMgr->LoadAreaPhases();
977  }
978 
979  QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
980  " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
981 
982  if (!result)
983  {
984  TC_LOG_ERROR("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
985  return;
986  }
987 
988  uint32 count = 0;
989 
990  do
991  {
992  Field* fields = result->Fetch();
993 
994  Condition* cond = new Condition();
995  int32 iSourceTypeOrReferenceId = fields[0].GetInt32();
996  cond->SourceGroup = fields[1].GetUInt32();
997  cond->SourceEntry = fields[2].GetInt32();
998  cond->SourceId = fields[3].GetInt32();
999  cond->ElseGroup = fields[4].GetUInt32();
1000  int32 iConditionTypeOrReference = fields[5].GetInt32();
1001  cond->ConditionTarget = fields[6].GetUInt8();
1002  cond->ConditionValue1 = fields[7].GetUInt32();
1003  cond->ConditionValue2 = fields[8].GetUInt32();
1004  cond->ConditionValue3 = fields[9].GetUInt32();
1005  cond->NegativeCondition = fields[10].GetBool();
1006  cond->ErrorType = fields[11].GetUInt32();
1007  cond->ErrorTextId = fields[12].GetUInt32();
1008  cond->ScriptId = sObjectMgr->GetScriptId(fields[13].GetString());
1009 
1010  if (iConditionTypeOrReference >= 0)
1011  cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1012 
1013  if (iSourceTypeOrReferenceId >= 0)
1014  cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1015 
1016  if (iConditionTypeOrReference < 0)//it has a reference
1017  {
1018  if (iConditionTypeOrReference == iSourceTypeOrReferenceId)//self referencing, skip
1019  {
1020  TC_LOG_ERROR("sql.sql", "Condition reference %i is referencing self, skipped", iSourceTypeOrReferenceId);
1021  delete cond;
1022  continue;
1023  }
1024  cond->ReferenceId = uint32(abs(iConditionTypeOrReference));
1025 
1026  const char* rowType = "reference template";
1027  if (iSourceTypeOrReferenceId >= 0)
1028  rowType = "reference";
1029  //check for useless data
1030  if (cond->ConditionTarget)
1031  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in ConditionTarget (%u)!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1032  if (cond->ConditionValue1)
1033  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in value1 (%u)!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1034  if (cond->ConditionValue2)
1035  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in value2 (%u)!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1036  if (cond->ConditionValue3)
1037  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in value3 (%u)!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1038  if (cond->NegativeCondition)
1039  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in NegativeCondition (%u)!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1040  if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1041  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in SourceGroup (%u)!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1042  if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1043  TC_LOG_ERROR("sql.sql", "Condition %s %i has useless data in SourceEntry (%u)!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1044  }
1045  else if (!isConditionTypeValid(cond))//doesn't have reference, validate ConditionType
1046  {
1047  delete cond;
1048  continue;
1049  }
1050 
1051  if (iSourceTypeOrReferenceId < 0)//it is a reference template
1052  {
1053  ConditionReferenceStore[std::abs(iSourceTypeOrReferenceId)].push_back(cond);//add to reference storage
1054  ++count;
1055  continue;
1056  }//end of reference templates
1057 
1058  //if not a reference and SourceType is invalid, skip
1059  if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1060  {
1061  delete cond;
1062  continue;
1063  }
1064 
1065  //Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1066  if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1067  {
1068  TC_LOG_ERROR("sql.sql", "%s has not allowed value of SourceGroup = %u!", cond->ToString().c_str(), cond->SourceGroup);
1069  delete cond;
1070  continue;
1071  }
1072  if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1073  {
1074  TC_LOG_ERROR("sql.sql", "%s has not allowed value of SourceId = %u!", cond->ToString().c_str(), cond->SourceId);
1075  delete cond;
1076  continue;
1077  }
1078 
1079  if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1080  {
1081  TC_LOG_ERROR("sql.sql", "%s can't have ErrorType (%u), set to 0!", cond->ToString().c_str(), cond->ErrorType);
1082  cond->ErrorType = 0;
1083  }
1084 
1085  if (cond->ErrorTextId && !cond->ErrorType)
1086  {
1087  TC_LOG_ERROR("sql.sql", "%s has any ErrorType, ErrorTextId (%u) is set, set to 0!", cond->ToString().c_str(), cond->ErrorTextId);
1088  cond->ErrorTextId = 0;
1089  }
1090 
1091  if (cond->SourceGroup)
1092  {
1093  bool valid = false;
1094  // handle grouped conditions
1095  switch (cond->SourceType)
1096  {
1099  break;
1102  break;
1105  break;
1108  break;
1111  break;
1114  break;
1117  break;
1120  break;
1123  break;
1126  break;
1129  break;
1132  break;
1134  valid = addToGossipMenus(cond);
1135  break;
1137  valid = addToGossipMenuItems(cond);
1138  break;
1140  {
1141  SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1142  valid = true;
1143  ++count;
1144  continue; // do not add to m_AllocatedMemory to avoid double deleting
1145  }
1147  valid = addToSpellImplicitTargetConditions(cond);
1148  break;
1150  {
1151  VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1152  valid = true;
1153  ++count;
1154  continue; // do not add to m_AllocatedMemory to avoid double deleting
1155  }
1157  {
1159  std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1160  SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1161  valid = true;
1162  ++count;
1163  continue;
1164  }
1166  {
1167  NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1168  valid = true;
1169  ++count;
1170  continue;
1171  }
1173  valid = addToPhases(cond);
1174  break;
1175  default:
1176  break;
1177  }
1178 
1179  if (!valid)
1180  {
1181  TC_LOG_ERROR("sql.sql", "%s Not handled grouped condition.", cond->ToString().c_str());
1182  delete cond;
1183  }
1184  else
1185  {
1186  AllocatedMemoryStore.push_back(cond);
1187  ++count;
1188  }
1189  continue;
1190  }
1191 
1192  //handle not grouped conditions
1193  //add new Condition to storage based on Type/Entry
1194  ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1195  ++count;
1196  }
1197  while (result->NextRow());
1198 
1199  TC_LOG_INFO("server.loading", ">> Loaded %u conditions in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
1200 }
LootStore LootTemplates_Disenchant("disenchant_loot_template","item disenchant id", true)
G3D::Matrix abs(const G3D::Matrix &M)
Definition: Matrix.h:632
void ResetConditions()
Definition: LootMgr.cpp:218
uint32 ElseGroup
Definition: ConditionMgr.h:200
ConditionEntriesByTypeArray ConditionStore
Definition: ConditionMgr.h:299
LootStore LootTemplates_Creature("creature_loot_template","creature entry", true)
ConditionSourceType
Definition: ConditionMgr.h:125
LootStore LootTemplates_Prospecting("prospecting_loot_template","item entry (ore)", true)
Definition: ConditionMgr.h:132
ConditionEntriesByCreatureIdMap SpellClickEventConditionStore
Definition: ConditionMgr.h:302
Definition: ConditionMgr.h:194
LootStore LootTemplates_Item("item_loot_template","item entry", true)
LootStore LootTemplates_Skinning("skinning_loot_template","creature skinning id", true)
std::vector< Condition * > AllocatedMemoryStore
Definition: ConditionMgr.h:297
bool isConditionTypeValid(Condition *cond) const
Definition: ConditionMgr.cpp:1762
Definition: ConditionMgr.h:134
Class used to access individual fields of database query result.
Definition: Field.h:56
ConditionEntriesByCreatureIdMap VehicleSpellConditionStore
Definition: ConditionMgr.h:301
uint32 getMSTime()
Definition: Timer.h:24
LootTemplate * GetLootForConditionFill(uint32 loot_id)
Definition: LootMgr.cpp:237
Definition: ConditionMgr.h:139
WorldDatabaseWorkerPool WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
int32 SourceEntry
Definition: ConditionMgr.h:198
bool addToLootTemplate(Condition *cond, LootTemplate *loot) const
Definition: ConditionMgr.cpp:1202
Definition: ConditionMgr.h:150
ConditionTypes
Definition: ConditionMgr.h:49
uint32 SourceId
Definition: ConditionMgr.h:199
#define sObjectMgr
Definition: ObjectMgr.h:1567
uint32 ErrorTextId
Definition: ConditionMgr.h:206
LootStore LootTemplates_Milling("milling_loot_template","item entry (herb)", true)
Definition: ConditionMgr.h:128
LootStore LootTemplates_Fishing("fishing_loot_template","area id", true)
bool addToGossipMenus(Condition *cond) const
Definition: ConditionMgr.cpp:1217
LootStore LootTemplates_Gameobject("gameobject_loot_template","gameobject entry", true)
uint8 GetUInt8() const
Definition: Field.h:70
void Clean()
Definition: ConditionMgr.cpp:2226
uint32 ErrorType
Definition: ConditionMgr.h:205
bool addToPhases(Condition *cond) const
Definition: ConditionMgr.cpp:1360
uint32 SourceGroup
Definition: ConditionMgr.h:197
Definition: ConditionMgr.h:138
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
Definition: ConditionMgr.h:145
#define sSpellMgr
Definition: SpellMgr.h:756
Definition: ConditionMgr.h:137
int32_t int32
Definition: Define.h:146
uint8 ConditionTarget
Definition: ConditionMgr.h:209
uint32_t uint32
Definition: Define.h:150
std::shared_ptr< ResultSet > QueryResult
Definition: QueryResult.h:61
uint32 ConditionValue3
Definition: ConditionMgr.h:204
bool addToSpellImplicitTargetConditions(Condition *cond) const
Definition: ConditionMgr.cpp:1256
Definition: ConditionMgr.h:142
bool addToGossipMenuItems(Condition *cond) const
Definition: ConditionMgr.cpp:1237
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:304
bool NegativeCondition
Definition: ConditionMgr.h:210
Definition: ConditionMgr.h:133
uint32 ConditionValue2
Definition: ConditionMgr.h:203
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:300
Definition: ConditionMgr.h:149
int32 GetInt32() const
Definition: Field.h:165
static bool CanHaveSourceGroupSet(ConditionSourceType sourceType)
Definition: ConditionMgr.cpp:791
static bool CanHaveSourceIdSet(ConditionSourceType sourceType)
Definition: ConditionMgr.cpp:815
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:42
uint32 ScriptId
Definition: ConditionMgr.h:208
QueryResult Query(const char *sql, T *connection=nullptr)
Definition: DatabaseWorkerPool.cpp:113
uint32 ConditionValue1
Definition: ConditionMgr.h:202
LootStore LootTemplates_Spell("spell_loot_template","spell id (random item creating)", false)
bool isSourceTypeValid(Condition *cond) const
Definition: ConditionMgr.cpp:1393
uint32 GetUInt32() const
Definition: Field.h:146
LootStore LootTemplates_Mail("mail_loot_template","mail template id", false)
Definition: ConditionMgr.h:141
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template","creature pickpocket lootid", true)
#define TC_LOG_INFO(filterType__,...)
Definition: Log.h:201
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: ConditionMgr.h:153
Definition: ConditionMgr.h:144
uint32_t uint32
Definition: g3dmath.h:168
bool GetBool() const
Definition: Field.h:65
uint32 ReferenceId
Definition: ConditionMgr.h:207
Definition: ConditionMgr.h:140
Definition: ConditionMgr.h:148
ConditionEntriesByCreatureIdMap NpcVendorConditionContainerStore
Definition: ConditionMgr.h:303
Definition: ConditionMgr.h:130
ConditionTypes ConditionType
Definition: ConditionMgr.h:201
ConditionSourceType SourceType
Definition: ConditionMgr.h:196
LootStore LootTemplates_Reference("reference_loot_template","reference id", false)

+ Here is the call graph for this function:

void ConditionMgr::LogUselessConditionValue ( Condition cond,
uint8  index,
uint32  value 
)
staticprivate
2222 {
2223  TC_LOG_ERROR("sql.sql", "%s has useless data in ConditionValue%u (%u)!", cond->ToString(true).c_str(), index, value);
2224 }
std::string ToString(bool ext=false) const
Definition: ConditionMgr.cpp:649
const FieldDescriptor value
Definition: descriptor.h:1522
#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:

Member Data Documentation

std::vector<Condition*> ConditionMgr::AllocatedMemoryStore
private
ConditionReferenceContainer ConditionMgr::ConditionReferenceStore
private
ConditionEntriesByTypeArray ConditionMgr::ConditionStore
private
ConditionEntriesByCreatureIdMap ConditionMgr::NpcVendorConditionContainerStore
private
SmartEventConditionContainer ConditionMgr::SmartEventConditionStore
private
ConditionEntriesByCreatureIdMap ConditionMgr::SpellClickEventConditionStore
private
ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData
static
char const *const ConditionMgr::StaticSourceTypeData
static
Initial value:
=
{
"None",
"Creature Loot",
"Disenchant Loot",
"Fishing Loot",
"GameObject Loot",
"Item Loot",
"Mail Loot",
"Milling Loot",
"Pickpocketing Loot",
"Prospecting Loot",
"Reference Loot",
"Skinning Loot",
"Spell Loot",
"Spell Impl. Target",
"Gossip Menu",
"Gossip Menu Option",
"Creature Vehicle",
"Spell Expl. Target",
"Spell Click Event",
"Quest Accept",
"Quest Show Mark",
"Vehicle Spell",
"SmartScript",
"Npc Vendor",
"Spell Proc",
"Terrain Swap",
"Phase"
}
ConditionEntriesByCreatureIdMap ConditionMgr::VehicleSpellConditionStore
private

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