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

#include "ConditionMgr.h"

Public Member Functions

void LoadConditions (bool isReload=false)
 
bool isConditionTypeValid (Condition *cond)
 
ConditionList GetConditionReferences (uint32 refId)
 
uint32 GetSearcherTypeMaskForConditionList (ConditionList const &conditions)
 
bool IsObjectMeetToConditions (WorldObject *object, ConditionList const &conditions)
 
bool IsObjectMeetToConditions (WorldObject *object1, WorldObject *object2, ConditionList const &conditions)
 
bool IsObjectMeetToConditions (ConditionSourceInfo &sourceInfo, ConditionList const &conditions)
 
bool CanHaveSourceGroupSet (ConditionSourceType sourceType) const
 
bool CanHaveSourceIdSet (ConditionSourceType sourceType) const
 
ConditionList GetConditionsForNotGroupedEntry (ConditionSourceType sourceType, uint32 entry)
 
ConditionList GetConditionsForSpellClickEvent (uint32 creatureId, uint32 spellId)
 
ConditionList GetConditionsForSmartEvent (int32 entryOrGuid, uint32 eventId, uint32 sourceType)
 
ConditionList GetConditionsForVehicleSpell (uint32 creatureId, uint32 spellId)
 
ConditionList GetConditionsForNpcVendorEvent (uint32 creatureId, uint32 itemId)
 

Static Public Member Functions

static ConditionMgrinstance ()
 

Private Member Functions

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

Private Attributes

std::list< Condition * > AllocatedMemoryStore
 
ConditionContainer ConditionStore
 
ConditionReferenceContainer ConditionReferenceStore
 
CreatureSpellConditionContainer VehicleSpellConditionStore
 
CreatureSpellConditionContainer SpellClickEventConditionStore
 
NpcVendorConditionContainer NpcVendorConditionContainerStore
 
SmartEventConditionContainer SmartEventConditionStore
 

Detailed Description

Constructor & Destructor Documentation

◆ ConditionMgr()

ConditionMgr::ConditionMgr ( )
private
805{}

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
808{
809 Clean();
810}
void Clean()
Definition: ConditionMgr.cpp:2463

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1346{
1347 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1348 if (pMenuItemBounds.first != pMenuItemBounds.second)
1349 {
1350 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1351 {
1352 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1353 {
1354 (*itr).second.Conditions.push_back(cond);
1355 return true;
1356 }
1357 }
1358 }
1359
1360 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1361 return false;
1362}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:156
std::uint32_t uint32
Definition: Define.h:107
#define sObjectMgr
Definition: ObjectMgr.h:1623
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition: ObjectMgr.h:635
uint32 SourceGroup
Definition: ConditionMgr.h:196
int32 SourceEntry
Definition: ConditionMgr.h:197

References LOG_ERROR, sObjectMgr, Condition::SourceEntry, and Condition::SourceGroup.

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1326{
1327 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1328
1329 if (pMenuBounds.first != pMenuBounds.second)
1330 {
1331 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1332 {
1333 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1334 {
1335 (*itr).second.Conditions.push_back(cond);
1336 return true;
1337 }
1338 }
1339 }
1340
1341 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1342 return false;
1343}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition: ObjectMgr.h:632

References LOG_ERROR, sObjectMgr, Condition::SourceEntry, and Condition::SourceGroup.

Referenced by LoadConditions().

◆ addToLootTemplate()

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
)
private
1311{
1312 if (!loot)
1313 {
1314 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1315 return false;
1316 }
1317
1318 if (loot->addConditionItem(cond))
1319 return true;
1320
1321 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1322 return false;
1323}
bool addConditionItem(Condition *cond)
Definition: LootMgr.cpp:1887

References LootTemplate::addConditionItem(), LOG_ERROR, Condition::SourceEntry, and Condition::SourceGroup.

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond)
private
1365{
1366 uint32 conditionEffMask = cond->SourceGroup;
1367 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1368 std::list<uint32> sharedMasks;
1369 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1370 {
1371 // check if effect is already a part of some shared mask
1372 bool found = false;
1373 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1374 {
1375 if ((1 << i) & *itr)
1376 {
1377 found = true;
1378 break;
1379 }
1380 }
1381 if (found)
1382 continue;
1383
1384 // build new shared mask with found effect
1385 uint32 sharedMask = (1 << i);
1386 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1387 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1388 {
1389 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1390 sharedMask |= 1 << effIndex;
1391 }
1392 sharedMasks.push_back(sharedMask);
1393 }
1394
1395 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1396 {
1397 // some effect indexes should have same data
1398 if (uint32 commonMask = *itr & conditionEffMask)
1399 {
1400 uint8 firstEffIndex = 0;
1401 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1402 if ((1 << firstEffIndex) & *itr)
1403 break;
1404
1405 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1406 return false;
1407
1408 // get shared data
1409 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1410
1411 // there's already data entry for that sharedMask
1412 if (sharedList)
1413 {
1414 // we have overlapping masks in db
1415 if (conditionEffMask != *itr)
1416 {
1417 LOG_ERROR("sql.sql",
1418 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1419 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1420 cond->SourceEntry, cond->SourceGroup);
1421 return false;
1422 }
1423 }
1424 // no data for shared mask, we can create new submask
1425 else
1426 {
1427 // add new list, create new shared mask
1428 sharedList = new ConditionList();
1429 bool assigned = false;
1430 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1431 {
1432 if ((1 << i) & commonMask)
1433 {
1434 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1435 assigned = true;
1436 }
1437 }
1438
1439 if (!assigned)
1440 delete sharedList;
1441 }
1442 if (sharedList)
1443 sharedList->push_back(cond);
1444 break;
1445 }
1446 }
1447 return true;
1448}
std::uint8_t uint8
Definition: Define.h:109
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:236
#define sSpellMgr
Definition: SpellMgr.h:825
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1637
Definition: SpellInfo.h:316
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition: SpellInfo.h:393

References SpellInfo::Effects, LOG_ERROR, MAX_SPELL_EFFECTS, Condition::SourceEntry, Condition::SourceGroup, and sSpellMgr.

Referenced by LoadConditions().

◆ CanHaveSourceGroupSet()

bool ConditionMgr::CanHaveSourceGroupSet ( ConditionSourceType  sourceType) const
932{
936}
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition: ConditionMgr.h:143
@ CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE
Definition: ConditionMgr.h:124
@ CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE
Definition: ConditionMgr.h:132
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition: ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition: ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition: ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE
Definition: ConditionMgr.h:128
@ CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE
Definition: ConditionMgr.h:134
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition: ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE
Definition: ConditionMgr.h:130
@ CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE
Definition: ConditionMgr.h:131
@ CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE
Definition: ConditionMgr.h:125
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition: ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE
Definition: ConditionMgr.h:127
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition: ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE
Definition: ConditionMgr.h:133
@ CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE
Definition: ConditionMgr.h:123
@ CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE
Definition: ConditionMgr.h:126
@ CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE
Definition: ConditionMgr.h:150
@ CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE
Definition: ConditionMgr.h:129

References CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GOSSIP_MENU, CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION, CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_NPC_VENDOR, CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SMART_EVENT, CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT, CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET, CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE, and CONDITION_SOURCE_TYPE_VEHICLE_SPELL.

Referenced by LoadConditions().

◆ CanHaveSourceIdSet()

bool ConditionMgr::CanHaveSourceIdSet ( ConditionSourceType  sourceType) const
939{
940 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
941}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2464{
2465 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2466 {
2467 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2468 itr->second.clear();
2469 }
2470
2472
2473 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2474 {
2475 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2476 {
2477 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2478 it->second.clear();
2479 }
2480 itr->second.clear();
2481 }
2482
2483 ConditionStore.clear();
2484
2485 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2486 {
2487 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2488 {
2489 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2490 it->second.clear();
2491 }
2492 itr->second.clear();
2493 }
2494
2496
2497 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2498 {
2499 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2500 {
2501 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2502 it->second.clear();
2503 }
2504 itr->second.clear();
2505 }
2506
2508
2509 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2510 {
2511 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2512 {
2513 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2514 it->second.clear();
2515 }
2516 itr->second.clear();
2517 }
2518
2520
2521 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2522 {
2523 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2524 {
2525 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2526 it->second.clear();
2527 }
2528 itr->second.clear();
2529 }
2530
2532
2533 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2534 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2535
2536 AllocatedMemoryStore.clear();
2537}
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:286
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition: ConditionMgr.h:284
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition: ConditionMgr.h:283
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition: ConditionMgr.h:285
ConditionContainer ConditionStore
Definition: ConditionMgr.h:281
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:282
std::list< Condition * > AllocatedMemoryStore
Definition: ConditionMgr.h:279

References AllocatedMemoryStore, ConditionReferenceStore, ConditionStore, NpcVendorConditionContainerStore, SmartEventConditionStore, SpellClickEventConditionStore, and VehicleSpellConditionStore.

Referenced by LoadConditions(), and ~ConditionMgr().

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
819{
820 ConditionList conditions;
821 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
822 if (ref != ConditionReferenceStore.end())
823 conditions = (*ref).second;
824 return conditions;
825}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
944{
945 ConditionList spellCond;
946 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
947 {
948 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
949 if (itr != ConditionStore.end())
950 {
951 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
952 if (i != (*itr).second.end())
953 {
954 spellCond = (*i).second;
955 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
956 }
957 }
958 }
959 return spellCond;
960}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
@ CONDITION_SOURCE_TYPE_MAX
Definition: ConditionMgr.h:153
@ CONDITION_SOURCE_TYPE_NONE
Definition: ConditionMgr.h:122

References CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_NONE, ConditionStore, and LOG_DEBUG.

◆ GetConditionsForNpcVendorEvent()

ConditionList ConditionMgr::GetConditionsForNpcVendorEvent ( uint32  creatureId,
uint32  itemId 
)
1011{
1012 ConditionList cond;
1013 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1014 if (itr != NpcVendorConditionContainerStore.end())
1015 {
1016 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1017 if (i != (*itr).second.end())
1018 {
1019 cond = (*i).second;
1020 if (itemId)
1021 {
1022 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1023 }
1024 else
1025 {
1026 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1027 }
1028 }
1029 }
1030 return cond;
1031}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
995{
996 ConditionList cond;
997 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
998 if (itr != SmartEventConditionStore.end())
999 {
1000 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
1001 if (i != (*itr).second.end())
1002 {
1003 cond = (*i).second;
1004 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
1005 }
1006 }
1007 return cond;
1008}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
963{
964 ConditionList cond;
965 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
966 if (itr != SpellClickEventConditionStore.end())
967 {
968 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
969 if (i != (*itr).second.end())
970 {
971 cond = (*i).second;
972 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
973 }
974 }
975 return cond;
976}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

ConditionList ConditionMgr::GetConditionsForVehicleSpell ( uint32  creatureId,
uint32  spellId 
)
979{
980 ConditionList cond;
981 CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
982 if (itr != VehicleSpellConditionStore.end())
983 {
984 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
985 if (i != (*itr).second.end())
986 {
987 cond = (*i).second;
988 LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
989 }
990 }
991 return cond;
992}

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

uint32 ConditionMgr::GetSearcherTypeMaskForConditionList ( ConditionList const &  conditions)
828{
829 if (conditions.empty())
831 // groupId, typeMask
832 std::map<uint32, uint32> ElseGroupStore;
833 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
834 {
835 // no point of having not loaded conditions in list
836 ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
837 std::map<uint32, uint32>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
838 // group not filled yet, fill with widest mask possible
839 if (itr == ElseGroupStore.end())
840 ElseGroupStore[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
841 // no point of checking anymore, empty mask
842 else if (!(*itr).second)
843 continue;
844
845 if ((*i)->ReferenceId) // handle reference
846 {
847 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
848 ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference");
849 ElseGroupStore[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
850 }
851 else // handle normal condition
852 {
853 // object will match conditions in one ElseGroupStore only when it matches all of them
854 // so, let's find a smallest possible mask which satisfies all conditions
855 ElseGroupStore[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
856 }
857 }
858 // object will match condition when one of the checks in ElseGroupStore is matching
859 // so, let's include all possible masks
860 uint32 mask = 0;
861 for (std::map<uint32, uint32>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i) mask |= i->second;
862
863 return mask;
864}
#define ASSERT
Definition: Errors.h:68
@ GRID_MAP_TYPE_MASK_ALL
Definition: GridDefines.h:74
uint32 GetSearcherTypeMaskForConditionList(ConditionList const &conditions)
Definition: ConditionMgr.cpp:827

References ASSERT, ConditionReferenceStore, GetSearcherTypeMaskForConditionList(), and GRID_MAP_TYPE_MASK_ALL.

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
813{
814 static ConditionMgr instance;
815 return &instance;
816}
Definition: ConditionMgr.h:246
static ConditionMgr * instance()
Definition: ConditionMgr.cpp:812

References instance().

Referenced by instance().

◆ isConditionTypeValid()

bool ConditionMgr::isConditionTypeValid ( Condition cond)
1831{
1833 {
1834 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has an invalid ConditionType ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
1835 return false;
1836 }
1837 switch (cond->ConditionType)
1838 {
1840 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has a ConditionType that is not supported on 3.3.5a ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
1841 return false;
1842 default:
1843 break;
1844 }
1845
1847 {
1848 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry);
1849 return false;
1850 }
1851
1852 switch (cond->ConditionType)
1853 {
1854 case CONDITION_AURA:
1855 {
1856 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
1857 {
1858 LOG_ERROR("sql.sql", "Aura condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
1859 return false;
1860 }
1861
1862 if (cond->ConditionValue2 > EFFECT_2)
1863 {
1864 LOG_ERROR("sql.sql", "Aura condition has non existing effect index ({}) (must be 0..2), skipped", cond->ConditionValue2);
1865 return false;
1866 }
1867 if (cond->ConditionValue3)
1868 LOG_ERROR("sql.sql", "Aura condition has useless data in value3 ({})!", cond->ConditionValue3);
1869 break;
1870 }
1871 case CONDITION_ITEM:
1872 {
1873 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1874 if (!proto)
1875 {
1876 LOG_ERROR("sql.sql", "Item condition has non existing item ({}), skipped", cond->ConditionValue1);
1877 return false;
1878 }
1879
1880 if (!cond->ConditionValue2)
1881 {
1882 LOG_ERROR("sql.sql", "Item condition has 0 set for item count in value2 ({}), skipped", cond->ConditionValue2);
1883 return false;
1884 }
1885 break;
1886 }
1888 {
1889 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1890 if (!proto)
1891 {
1892 LOG_ERROR("sql.sql", "ItemEquipped condition has non existing item ({}), skipped", cond->ConditionValue1);
1893 return false;
1894 }
1895
1896 if (cond->ConditionValue2)
1897 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value2 ({})!", cond->ConditionValue2);
1898 if (cond->ConditionValue3)
1899 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value3 ({})!", cond->ConditionValue3);
1900 break;
1901 }
1902 case CONDITION_ZONEID:
1903 {
1904 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(cond->ConditionValue1);
1905 if (!areaEntry)
1906 {
1907 LOG_ERROR("sql.sql", "ZoneID condition has non existing area ({}), skipped", cond->ConditionValue1);
1908 return false;
1909 }
1910
1911 if (areaEntry->zone != 0)
1912 {
1913 LOG_ERROR("sql.sql", "ZoneID condition requires to be in area ({}) which is a subzone but zone expected, skipped", cond->ConditionValue1);
1914 return false;
1915 }
1916
1917 if (cond->ConditionValue2)
1918 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value2 ({})!", cond->ConditionValue2);
1919 if (cond->ConditionValue3)
1920 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value3 ({})!", cond->ConditionValue3);
1921 break;
1922 }
1924 {
1925 FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
1926 if (!factionEntry)
1927 {
1928 LOG_ERROR("sql.sql", "Reputation condition has non existing faction ({}), skipped", cond->ConditionValue1);
1929 return false;
1930 }
1931 if (cond->ConditionValue3)
1932 LOG_ERROR("sql.sql", "Reputation condition has useless data in value3 ({})!", cond->ConditionValue3);
1933 break;
1934 }
1935 case CONDITION_TEAM:
1936 {
1937 if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
1938 {
1939 LOG_ERROR("sql.sql", "Team condition specifies unknown team ({}), skipped", cond->ConditionValue1);
1940 return false;
1941 }
1942
1943 if (cond->ConditionValue2)
1944 LOG_ERROR("sql.sql", "Team condition has useless data in value2 ({})!", cond->ConditionValue2);
1945 if (cond->ConditionValue3)
1946 LOG_ERROR("sql.sql", "Team condition has useless data in value3 ({})!", cond->ConditionValue3);
1947 break;
1948 }
1949 case CONDITION_SKILL:
1950 {
1951 SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
1952 if (!pSkill)
1953 {
1954 LOG_ERROR("sql.sql", "Skill condition specifies non-existing skill ({}), skipped", cond->ConditionValue1);
1955 return false;
1956 }
1957
1958 if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
1959 {
1960 LOG_ERROR("sql.sql", "Skill condition specifies invalid skill value ({}), skipped", cond->ConditionValue2);
1961 return false;
1962 }
1963 if (cond->ConditionValue3)
1964 LOG_ERROR("sql.sql", "Skill condition has useless data in value3 ({})!", cond->ConditionValue3);
1965 break;
1966 }
1973 {
1974 if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
1975 {
1976 LOG_ERROR("sql.sql", "Quest condition specifies non-existing quest ({}), skipped", cond->ConditionValue1);
1977 return false;
1978 }
1979
1980 if (cond->ConditionValue2 > 1)
1981 {
1982 LOG_ERROR("sql.sql", "Quest condition has useless data in value2 ({})!", cond->ConditionValue2);
1983 }
1984 if (cond->ConditionValue3)
1985 {
1986 LOG_ERROR("sql.sql", "Quest condition has useless data in value3 ({})!", cond->ConditionValue3);
1987 }
1988 break;
1989 }
1991 if (cond->ConditionValue2 >= (1 << MAX_QUEST_STATUS))
1992 {
1993 LOG_ERROR("sql.sql", "ConditionType ({}) has invalid state mask ({}), skipped.", cond->ConditionType, cond->ConditionValue2);
1994 return false;
1995 }
1996 break;
1998 {
1999 GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
2000 if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
2001 {
2002 LOG_ERROR("sql.sql", "ActiveEvent condition has non existing event id ({}), skipped", cond->ConditionValue1);
2003 return false;
2004 }
2005
2006 if (cond->ConditionValue2)
2007 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value2 ({})!", cond->ConditionValue2);
2008 if (cond->ConditionValue3)
2009 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value3 ({})!", cond->ConditionValue3);
2010 break;
2011 }
2013 {
2014 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2015 if (!achievement)
2016 {
2017 LOG_ERROR("sql.sql", "Achivement condition has non existing achivement id ({}), skipped", cond->ConditionValue1);
2018 return false;
2019 }
2020
2021 if (cond->ConditionValue2)
2022 LOG_ERROR("sql.sql", "Achivement condition has useless data in value2 ({})!", cond->ConditionValue2);
2023 if (cond->ConditionValue3)
2024 LOG_ERROR("sql.sql", "Achivement condition has useless data in value3 ({})!", cond->ConditionValue3);
2025 break;
2026 }
2027 case CONDITION_CLASS:
2028 {
2030 {
2031 LOG_ERROR("sql.sql", "Class condition has non existing classmask ({}), skipped", cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
2032 return false;
2033 }
2034
2035 if (cond->ConditionValue2)
2036 LOG_ERROR("sql.sql", "Class condition has useless data in value2 ({})!", cond->ConditionValue2);
2037 if (cond->ConditionValue3)
2038 LOG_ERROR("sql.sql", "Class condition has useless data in value3 ({})!", cond->ConditionValue3);
2039 break;
2040 }
2041 case CONDITION_RACE:
2042 {
2044 {
2045 LOG_ERROR("sql.sql", "Race condition has non existing racemask ({}), skipped", cond->ConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
2046 return false;
2047 }
2048
2049 if (cond->ConditionValue2)
2050 LOG_ERROR("sql.sql", "Race condition has useless data in value2 ({})!", cond->ConditionValue2);
2051 if (cond->ConditionValue3)
2052 LOG_ERROR("sql.sql", "Race condition has useless data in value3 ({})!", cond->ConditionValue3);
2053 break;
2054 }
2055 case CONDITION_GENDER:
2056 {
2058 {
2059 LOG_ERROR("condition", "Gender condition has invalid gender ({}), skipped", cond->ConditionValue1);
2060 return false;
2061 }
2062
2063 if (cond->ConditionValue2)
2064 LOG_ERROR("condition", "Gender condition has useless data in value2 ({})!", cond->ConditionValue2);
2065 if (cond->ConditionValue3)
2066 LOG_ERROR("condition", "Gender condition has useless data in value3 ({})!", cond->ConditionValue3);
2067 break;
2068 }
2069 case CONDITION_MAPID:
2070 {
2071 MapEntry const* mapId = sMapStore.LookupEntry(cond->ConditionValue1);
2072 if (!mapId)
2073 {
2074 LOG_ERROR("sql.sql", "Map condition has non existing map ({}), skipped", cond->ConditionValue1);
2075 return false;
2076 }
2077
2078 if (cond->ConditionValue2)
2079 LOG_ERROR("sql.sql", "Map condition has useless data in value2 ({})!", cond->ConditionValue2);
2080 if (cond->ConditionValue3)
2081 LOG_ERROR("sql.sql", "Map condition has useless data in value3 ({})!", cond->ConditionValue3);
2082 break;
2083 }
2084 case CONDITION_SPELL:
2085 {
2086 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
2087 {
2088 LOG_ERROR("sql.sql", "Spell condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
2089 return false;
2090 }
2091
2092 if (cond->ConditionValue2)
2093 LOG_ERROR("sql.sql", "Spell condition has useless data in value2 ({})!", cond->ConditionValue2);
2094 if (cond->ConditionValue3)
2095 LOG_ERROR("sql.sql", "Spell condition has useless data in value3 ({})!", cond->ConditionValue3);
2096 break;
2097 }
2098 case CONDITION_LEVEL:
2099 {
2100 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2101 {
2102 LOG_ERROR("sql.sql", "Level condition has invalid option ({}), skipped", cond->ConditionValue2);
2103 return false;
2104 }
2105 if (cond->ConditionValue3)
2106 LOG_ERROR("sql.sql", "Level condition has useless data in value3 ({})!", cond->ConditionValue3);
2107 break;
2108 }
2110 {
2111 if (cond->ConditionValue1 > DRUNKEN_SMASHED)
2112 {
2113 LOG_ERROR("sql.sql", "DrunkState condition has invalid state ({}), skipped", cond->ConditionValue1);
2114 return false;
2115 }
2116 if (cond->ConditionValue2)
2117 {
2118 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value2 ({})!", cond->ConditionValue2);
2119 return false;
2120 }
2121 if (cond->ConditionValue3)
2122 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value3 ({})!", cond->ConditionValue3);
2123 break;
2124 }
2126 {
2127 if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
2128 {
2129 LOG_ERROR("sql.sql", "NearCreature condition has non existing creature template entry ({}), skipped", cond->ConditionValue1);
2130 return false;
2131 }
2132 break;
2133 }
2135 {
2136 if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
2137 {
2138 LOG_ERROR("sql.sql", "NearGameObject condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue1);
2139 return false;
2140 }
2141 if (cond->ConditionValue3 > 2)
2142 LOG_ERROR("sql.sql", "NearGameObject condition for gameobject ID ({}) has data over 2 for value3 ({})!", cond->ConditionValue1, cond->ConditionValue3);
2143 break;
2144 }
2146 {
2147 switch (cond->ConditionValue1)
2148 {
2149 case TYPEID_UNIT:
2150 if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
2151 {
2152 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry ({}), skipped", cond->ConditionValue2);
2153 return false;
2154 }
2155 if (cond->ConditionValue3 > 1)
2156 {
2157 if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
2158 {
2159 if (cond->ConditionValue2 && creatureData->id1 != cond->ConditionValue2)
2160 {
2161 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match creature entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2162 return false;
2163 }
2164 }
2165 else
2166 {
2167 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid ({}), skipped", cond->ConditionValue3);
2168 return false;
2169 }
2170 }
2171 break;
2172 case TYPEID_GAMEOBJECT:
2173 if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
2174 {
2175 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue2);
2176 return false;
2177 }
2178 if (cond->ConditionValue3)
2179 {
2180 if (GameObjectData const* goData = sObjectMgr->GetGameObjectData(cond->ConditionValue3))
2181 {
2182 if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
2183 {
2184 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match gameobject entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2185 return false;
2186 }
2187 }
2188 else
2189 {
2190 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid ({}), skipped", cond->ConditionValue3);
2191 return false;
2192 }
2193 }
2194 break;
2195 case TYPEID_PLAYER:
2196 case TYPEID_CORPSE:
2197 if (cond->ConditionValue2)
2198 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 ({})!", cond->ConditionValue2);
2199 if (cond->ConditionValue3)
2200 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 ({})!", cond->ConditionValue3);
2201 break;
2202 default:
2203 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set ({}), skipped", cond->ConditionValue1);
2204 return false;
2205 }
2206 break;
2207 }
2209 {
2211 {
2212 LOG_ERROR("sql.sql", "TypeMask condition has invalid typemask set ({}), skipped", cond->ConditionValue2);
2213 return false;
2214 }
2215 if (cond->ConditionValue2)
2216 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value2 ({})!", cond->ConditionValue2);
2217 if (cond->ConditionValue3)
2218 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value3 ({})!", cond->ConditionValue3);
2219 break;
2220 }
2222 {
2224 {
2225 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2226 return false;
2227 }
2228 if (cond->ConditionValue1 == cond->ConditionTarget)
2229 {
2230 LOG_ERROR("sql.sql", "RelationTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2231 return false;
2232 }
2233 if (cond->ConditionValue2 >= RELATION_MAX)
2234 {
2235 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue2(RelationType) ({}), skipped", cond->ConditionValue2);
2236 return false;
2237 }
2238 if (cond->ConditionValue3)
2239 LOG_ERROR("sql.sql", "RelationTo condition has useless data in value3 ({})!", cond->ConditionValue3);
2240 break;
2241 }
2243 {
2245 {
2246 LOG_ERROR("sql.sql", "ReactionTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2247 return false;
2248 }
2249 if (cond->ConditionValue1 == cond->ConditionTarget)
2250 {
2251 LOG_ERROR("sql.sql", "ReactionTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2252 return false;
2253 }
2254 if (!cond->ConditionValue2)
2255 {
2256 LOG_ERROR("sql.sql", "mConditionValue2 condition has invalid ConditionValue2(rankMask) ({}), skipped", cond->ConditionValue2);
2257 return false;
2258 }
2259 break;
2260 }
2262 {
2264 {
2265 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2266 return false;
2267 }
2268 if (cond->ConditionValue1 == cond->ConditionTarget)
2269 {
2270 LOG_ERROR("sql.sql", "DistanceTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2271 return false;
2272 }
2273 if (cond->ConditionValue3 >= COMP_TYPE_MAX)
2274 {
2275 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ComparisionType ({}), skipped", cond->ConditionValue3);
2276 return false;
2277 }
2278 break;
2279 }
2280 case CONDITION_ALIVE:
2281 {
2282 if (cond->ConditionValue1)
2283 LOG_ERROR("sql.sql", "Alive condition has useless data in value1 ({})!", cond->ConditionValue1);
2284 if (cond->ConditionValue2)
2285 LOG_ERROR("sql.sql", "Alive condition has useless data in value2 ({})!", cond->ConditionValue2);
2286 if (cond->ConditionValue3)
2287 LOG_ERROR("sql.sql", "Alive condition has useless data in value3 ({})!", cond->ConditionValue3);
2288 break;
2289 }
2290 case CONDITION_HP_VAL:
2291 {
2292 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2293 {
2294 LOG_ERROR("sql.sql", "HpVal condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2295 return false;
2296 }
2297 if (cond->ConditionValue3)
2298 LOG_ERROR("sql.sql", "HpVal condition has useless data in value3 ({})!", cond->ConditionValue3);
2299 break;
2300 }
2301 case CONDITION_HP_PCT:
2302 {
2303 if (cond->ConditionValue1 > 100)
2304 {
2305 LOG_ERROR("sql.sql", "HpPct condition has too big percent value ({}), skipped", cond->ConditionValue1);
2306 return false;
2307 }
2308 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2309 {
2310 LOG_ERROR("sql.sql", "HpPct condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2311 return false;
2312 }
2313 if (cond->ConditionValue3)
2314 LOG_ERROR("sql.sql", "HpPct condition has useless data in value3 ({})!", cond->ConditionValue3);
2315 break;
2316 }
2317 case CONDITION_AREAID:
2319 break;
2321 {
2322 if (cond->ConditionValue3)
2323 LOG_ERROR("sql.sql", "World state condition has useless data in value3 ({})!", cond->ConditionValue3);
2324 break;
2325 }
2327 {
2328 if (cond->ConditionValue2)
2329 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value2 ({})!", cond->ConditionValue2);
2330 if (cond->ConditionValue3)
2331 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value3 ({})!", cond->ConditionValue3);
2332 break;
2333 }
2334 case CONDITION_TITLE:
2335 {
2336 CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
2337 if (!titleEntry)
2338 {
2339 LOG_ERROR("sql.sql", "Title condition has non existing title in value1 ({}), skipped", cond->ConditionValue1);
2340 return false;
2341 }
2342 break;
2343 }
2345 {
2347 {
2348 LOG_ERROR("condition", "SpawnMask condition has non existing SpawnMask in value1 ({}), skipped", cond->ConditionValue1);
2349 return false;
2350 }
2351 break;
2352 }
2354 {
2356 {
2357 LOG_ERROR("condition", "UnitState condition has non existing UnitState in value1 ({}), skipped", cond->ConditionValue1);
2358 return false;
2359 }
2360 break;
2361 }
2363 {
2365 {
2366 LOG_ERROR("condition", "CreatureType condition has non existing CreatureType in value1 ({}), skipped", cond->ConditionValue1);
2367 return false;
2368 }
2369 break;
2370 }
2372 {
2373 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2374 if (!achievement)
2375 {
2376 LOG_ERROR("condition", "CONDITION_REALM_ACHIEVEMENT has non existing realm first achivement id ({}), skipped.", cond->ConditionValue1);
2377 return false;
2378 }
2379 break;
2380 }
2382 {
2383 const Quest* quest = sObjectMgr->GetQuestTemplate(cond->ConditionValue1);
2384 if (!quest)
2385 {
2386 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS points to non-existing quest ({}), skipped.", cond->ConditionValue1);
2387 return false;
2388 }
2389
2390 if (cond->ConditionValue2 > 3)
2391 {
2392 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS has out-of-range quest objective index specified ({}), it must be a number between 0 and 3. skipped.", cond->ConditionValue2);
2393 return false;
2394 }
2395
2396 if (quest->RequiredNpcOrGo[cond->ConditionValue2] == 0)
2397 {
2398 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS has quest objective {} for quest {}, but the field RequiredNPCOrGo{} is 0, skipped.", cond->ConditionValue2, cond->ConditionValue1, cond->ConditionValue2);
2399 return false;
2400 }
2401
2402 if (cond->ConditionValue3 > quest->RequiredNpcOrGoCount[cond->ConditionValue2])
2403 {
2404 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS has quest objective count {} in value3, but quest {} has a maximum objective count of {} in RequiredNPCOrGOCount{}, skipped.", cond->ConditionValue3, cond->ConditionValue2, quest->RequiredNpcOrGoCount[cond->ConditionValue2], cond->ConditionValue2);
2405 return false;
2406 }
2407 break;
2408 }
2410 {
2412 {
2413 LOG_ERROR("sql.sql", "Has Aura Effect condition has non existing aura ({}), skipped", cond->ConditionValue1);
2414 return false;
2415 }
2416 break;
2417 }
2419 {
2420 bool valid = false;
2421 switch (cond->ConditionValue1)
2422 {
2423 case 0:
2425 break;
2426 case 1:
2427 valid = cond->ConditionValue2 <= 1;
2428 break;
2429 default:
2430 valid = false;
2431 break;
2432 }
2433 if (!valid)
2434 {
2435 LOG_ERROR("sql.sql", "CONDITION_STAND_STATE has non-existing stand state ({},{}), skipped.", cond->ConditionValue1, cond->ConditionValue2);
2436 return false;
2437 }
2438 break;
2439 }
2441 if (cond->ConditionValue1 >= MAX_DIFFICULTY)
2442 {
2443 LOG_ERROR("sql.sql", "CONDITION_DIFFICULTY_ID has non existing difficulty in value1 ({}), skipped.", cond->ConditionValue1);
2444 return false;
2445 }
2446 break;
2447 case CONDITION_PET_TYPE:
2448 if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
2449 {
2450 LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type {}, skipped.", cond->ConditionValue1);
2451 return false;
2452 }
2453 break;
2454 case CONDITION_TAXI:
2455 case CONDITION_IN_WATER:
2456 case CONDITION_CHARMED:
2457 default:
2458 break;
2459 }
2460 return true;
2461}
@ COMP_TYPE_MAX
Definition: Util.h:593
@ CONDITION_TAXI
Definition: ConditionMgr.h:81
@ CONDITION_MAPID
Definition: ConditionMgr.h:57
@ CONDITION_SKILL
Definition: ConditionMgr.h:42
@ CONDITION_RACE
Definition: ConditionMgr.h:51
@ CONDITION_REACTION_TO
Definition: ConditionMgr.h:69
@ CONDITION_NEAR_GAMEOBJECT
Definition: ConditionMgr.h:65
@ CONDITION_QUESTREWARDED
Definition: ConditionMgr.h:43
@ CONDITION_REALM_ACHIEVEMENT
Definition: ConditionMgr.h:74
@ CONDITION_PHASEMASK
Definition: ConditionMgr.h:61
@ CONDITION_QUEST_OBJECTIVE_PROGRESS
Definition: ConditionMgr.h:83
@ CONDITION_DAILY_QUEST_DONE
Definition: ConditionMgr.h:78
@ CONDITION_ACTIVE_EVENT
Definition: ConditionMgr.h:47
@ CONDITION_INSTANCE_INFO
Definition: ConditionMgr.h:48
@ CONDITION_RELATION_TO
Definition: ConditionMgr.h:68
@ CONDITION_STAND_STATE
Definition: ConditionMgr.h:77
@ CONDITION_DRUNKENSTATE
Definition: ConditionMgr.h:45
@ CONDITION_AURA
Definition: ConditionMgr.h:36
@ CONDITION_ACHIEVEMENT
Definition: ConditionMgr.h:52
@ CONDITION_TC_END
Definition: ConditionMgr.h:85
@ CONDITION_OBJECT_ENTRY_GUID
Definition: ConditionMgr.h:66
@ CONDITION_PET_TYPE
Definition: ConditionMgr.h:80
@ CONDITION_DIFFICULTY_ID
Definition: ConditionMgr.h:84
@ CONDITION_DISTANCE_TO
Definition: ConditionMgr.h:70
@ CONDITION_HP_VAL
Definition: ConditionMgr.h:72
@ CONDITION_GENDER
Definition: ConditionMgr.h:55
@ CONDITION_TERRAIN_SWAP
Definition: ConditionMgr.h:76
@ CONDITION_REPUTATION_RANK
Definition: ConditionMgr.h:40
@ CONDITION_HP_PCT
Definition: ConditionMgr.h:73
@ CONDITION_QUEST_COMPLETE
Definition: ConditionMgr.h:63
@ CONDITION_SPELL
Definition: ConditionMgr.h:60
@ CONDITION_ZONEID
Definition: ConditionMgr.h:39
@ CONDITION_CHARMED
Definition: ConditionMgr.h:79
@ CONDITION_AC_START
Definition: ConditionMgr.h:87
@ CONDITION_TYPE_MASK
Definition: ConditionMgr.h:67
@ CONDITION_AREAID
Definition: ConditionMgr.h:58
@ CONDITION_IN_WATER
Definition: ConditionMgr.h:75
@ CONDITION_ITEM
Definition: ConditionMgr.h:37
@ CONDITION_WORLD_STATE
Definition: ConditionMgr.h:46
@ CONDITION_SPAWNMASK
Definition: ConditionMgr.h:54
@ CONDITION_CLASS
Definition: ConditionMgr.h:50
@ CONDITION_TEAM
Definition: ConditionMgr.h:41
@ CONDITION_NONE
Definition: ConditionMgr.h:35
@ CONDITION_QUEST_NONE
Definition: ConditionMgr.h:49
@ CONDITION_QUESTSTATE
Definition: ConditionMgr.h:82
@ CONDITION_ITEM_EQUIPPED
Definition: ConditionMgr.h:38
@ CONDITION_QUEST_SATISFY_EXCLUSIVE
Definition: ConditionMgr.h:88
@ CONDITION_LEVEL
Definition: ConditionMgr.h:62
@ CONDITION_QUESTTAKEN
Definition: ConditionMgr.h:44
@ CONDITION_NEAR_CREATURE
Definition: ConditionMgr.h:64
@ CONDITION_TITLE
Definition: ConditionMgr.h:53
@ CONDITION_AC_END
Definition: ConditionMgr.h:90
@ CONDITION_ALIVE
Definition: ConditionMgr.h:71
@ CONDITION_CREATURE_TYPE
Definition: ConditionMgr.h:59
@ CONDITION_UNIT_STATE
Definition: ConditionMgr.h:56
@ CONDITION_HAS_AURA_TYPE
Definition: ConditionMgr.h:89
@ RELATION_MAX
Definition: ConditionMgr.h:164
@ MAX_QUEST_STATUS
Definition: QuestDef.h:107
#define sGameEventMgr
Definition: GameEventMgr.h:186
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
@ UNIT_STAND_STATE_SUBMERGED
Definition: UnitDefines.h:41
@ UNIT_STATE_ALL_STATE_SUPPORTED
Definition: UnitDefines.h:179
@ TYPEID_GAMEOBJECT
Definition: ObjectGuid.h:37
@ TYPEID_UNIT
Definition: ObjectGuid.h:35
@ TYPEID_CORPSE
Definition: ObjectGuid.h:39
@ TYPEID_PLAYER
Definition: ObjectGuid.h:36
@ TYPEMASK_UNIT
Definition: ObjectGuid.h:49
@ TYPEMASK_CORPSE
Definition: ObjectGuid.h:53
@ TYPEMASK_GAMEOBJECT
Definition: ObjectGuid.h:51
@ TYPEMASK_PLAYER
Definition: ObjectGuid.h:50
@ DRUNKEN_SMASHED
Definition: Player.h:467
@ MAX_PET_TYPE
Definition: PetDefines.h:33
@ TOTAL_AURAS
Definition: SpellAuraDefines.h:380
@ SPELL_AURA_NONE
Definition: SpellAuraDefines.h:63
ObjectData const creatureData[]
Definition: instance_blackwing_lair.cpp:45
events
Definition: boss_sartura.cpp:43
@ EFFECT_2
Definition: SharedDefines.h:33
@ CREATURE_TYPE_GAS_CLOUD
Definition: SharedDefines.h:2640
@ ALLIANCE
Definition: SharedDefines.h:768
@ HORDE
Definition: SharedDefines.h:767
#define CLASSMASK_ALL_PLAYABLE
Definition: SharedDefines.h:157
#define RACEMASK_ALL_PLAYABLE
Definition: SharedDefines.h:97
#define MAX_DIFFICULTY
Definition: DBCEnums.h:283
@ SPAWNMASK_RAID_ALL
Definition: DBCEnums.h:301
#define sWorld
Definition: World.h:444
ConditionTypes ConditionType
Definition: ConditionMgr.h:200
ConditionSourceType SourceType
Definition: ConditionMgr.h:195
uint32 ConditionValue2
Definition: ConditionMgr.h:202
uint8 ConditionTarget
Definition: ConditionMgr.h:208
uint32 ConditionValue3
Definition: ConditionMgr.h:203
uint32 ConditionValue1
Definition: ConditionMgr.h:201
uint32 GetMaxAvailableConditionTargets()
Definition: ConditionMgr.cpp:780
Definition: CreatureData.h:373
Definition: GameObjectData.h:697
Definition: ItemTemplate.h:619
static bool IsValidGender(uint8 Gender)
Definition: Player.h:1561
std::vector< GameEventData > GameEventDataMap
Definition: GameEventMgr.h:107
Definition: QuestDef.h:210
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:304
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition: QuestDef.h:305
Definition: DBCStructure.h:40
Definition: DBCStructure.h:519
uint32 zone
Definition: DBCStructure.h:522
Definition: DBCStructure.h:632
Definition: DBCStructure.h:907
Definition: DBCStructure.h:1325
Definition: DBCStructure.h:1583

References ALLIANCE, CLASSMASK_ALL_PLAYABLE, COMP_TYPE_MAX, CONDITION_AC_END, CONDITION_AC_START, CONDITION_ACHIEVEMENT, CONDITION_ACTIVE_EVENT, CONDITION_ALIVE, CONDITION_AREAID, CONDITION_AURA, CONDITION_CHARMED, CONDITION_CLASS, CONDITION_CREATURE_TYPE, CONDITION_DAILY_QUEST_DONE, CONDITION_DIFFICULTY_ID, CONDITION_DISTANCE_TO, CONDITION_DRUNKENSTATE, CONDITION_GENDER, CONDITION_HAS_AURA_TYPE, CONDITION_HP_PCT, CONDITION_HP_VAL, CONDITION_IN_WATER, CONDITION_INSTANCE_INFO, CONDITION_ITEM, CONDITION_ITEM_EQUIPPED, CONDITION_LEVEL, CONDITION_MAPID, CONDITION_NEAR_CREATURE, CONDITION_NEAR_GAMEOBJECT, CONDITION_NONE, CONDITION_OBJECT_ENTRY_GUID, CONDITION_PET_TYPE, CONDITION_PHASEMASK, CONDITION_QUEST_COMPLETE, CONDITION_QUEST_NONE, CONDITION_QUEST_OBJECTIVE_PROGRESS, CONDITION_QUEST_SATISFY_EXCLUSIVE, CONDITION_QUESTREWARDED, CONDITION_QUESTSTATE, CONDITION_QUESTTAKEN, CONDITION_RACE, CONDITION_REACTION_TO, CONDITION_REALM_ACHIEVEMENT, CONDITION_RELATION_TO, CONDITION_REPUTATION_RANK, CONDITION_SKILL, CONDITION_SPAWNMASK, CONDITION_SPELL, CONDITION_STAND_STATE, CONDITION_TAXI, CONDITION_TC_END, CONDITION_TEAM, CONDITION_TERRAIN_SWAP, CONDITION_TITLE, CONDITION_TYPE_MASK, CONDITION_UNIT_STATE, CONDITION_WORLD_STATE, CONDITION_ZONEID, Condition::ConditionTarget, Condition::ConditionType, Condition::ConditionValue1, Condition::ConditionValue2, Condition::ConditionValue3, CREATURE_TYPE_GAS_CLOUD, creatureData, DRUNKEN_SMASHED, EFFECT_2, Condition::GetMaxAvailableConditionTargets(), HORDE, Player::IsValidGender(), LOG_ERROR, MAX_DIFFICULTY, MAX_PET_TYPE, MAX_QUEST_STATUS, RACEMASK_ALL_PLAYABLE, RELATION_MAX, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, sAchievementStore, sAreaTableStore, sCharTitlesStore, sFactionStore, sGameEventMgr, sMapStore, sObjectMgr, Condition::SourceEntry, Condition::SourceType, SPAWNMASK_RAID_ALL, SPELL_AURA_NONE, sSkillLineStore, sSpellMgr, sWorld, TOTAL_AURAS, TYPEID_CORPSE, TYPEID_GAMEOBJECT, TYPEID_PLAYER, TYPEID_UNIT, TYPEMASK_CORPSE, TYPEMASK_GAMEOBJECT, TYPEMASK_PLAYER, TYPEMASK_UNIT, UNIT_STAND_STATE_SUBMERGED, UNIT_STATE_ALL_STATE_SUPPORTED, and AreaTableEntry::zone.

Referenced by LoadConditions().

◆ IsObjectMeetToConditionList()

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

Find ElseGroup in ElseGroupStore

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

867{
868 // groupId, groupCheckPassed
869 std::map<uint32, bool> ElseGroupStore;
870 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
871 {
872 LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList condType: {} val1: {}", (*i)->ConditionType, (*i)->ConditionValue1);
873 if ((*i)->isLoaded())
874 {
876 std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
878 if (itr == ElseGroupStore.end())
879 ElseGroupStore[(*i)->ElseGroup] = true;
880 else if (!(*itr).second)
881 continue;
882
883 if ((*i)->ReferenceId) // handle reference
884 {
885 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
886 if (ref != ConditionReferenceStore.end())
887 {
888 if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second))
889 ElseGroupStore[(*i)->ElseGroup] = false;
890 }
891 else
892 {
893 LOG_DEBUG("condition", "IsPlayerMeetToConditionList: Reference template -{} not found", (*i)->ReferenceId);
894 }
895 }
896 else // handle normal condition
897 {
898 if (!(*i)->Meets(sourceInfo))
899 ElseGroupStore[(*i)->ElseGroup] = false;
900 }
901 }
902 }
903 for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
904 if (i->second)
905 return true;
906
907 return false;
908}
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionList const &conditions)
Definition: ConditionMgr.cpp:866

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
923{
924 if (conditions.empty())
925 return true;
926
927 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
928 return IsObjectMeetToConditionList(sourceInfo, conditions);
929}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
911{
913 return IsObjectMeetToConditions(srcInfo, conditions);
914}
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition: ConditionMgr.cpp:910

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
917{
918 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
919 return IsObjectMeetToConditions(srcInfo, conditions);
920}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1451{
1453 {
1454 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1455 return false;
1456 }
1457
1458 switch (cond->SourceType)
1459 {
1463 {
1464 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1465 return false;
1466 }
1468 {
1470 {
1471 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1472 return false;
1473 }
1474
1476 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1477 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1478 {
1479 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1480 return false;
1481 }
1482 break;
1483 }
1485 {
1487 {
1488 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1489 return false;
1490 }
1491
1493 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1494 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1495 {
1496 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1497 return false;
1498 }
1499 break;
1500 }
1502 {
1504 {
1505 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1506 return false;
1507 }
1508
1510 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1511 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1512 {
1513 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1514 return false;
1515 }
1516 break;
1517 }
1519 {
1521 {
1522 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1523 return false;
1524 }
1525
1527 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1528 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1529 {
1530 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1531 return false;
1532 }
1533 break;
1534 }
1536 {
1538 {
1539 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1540 return false;
1541 }
1542
1544 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1545 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1546 {
1547 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1548 return false;
1549 }
1550 break;
1551 }
1553 {
1555 {
1556 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1557 return false;
1558 }
1559
1561 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1562 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1563 {
1564 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1565 return false;
1566 }
1567 break;
1568 }
1570 {
1572 {
1573 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1574 return false;
1575 }
1576
1578 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1579 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1580 {
1581 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1582 return false;
1583 }
1584 break;
1585 }
1587 {
1589 {
1590 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1591 return false;
1592 }
1593
1595 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1596 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1597 {
1598 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1599 return false;
1600 }
1601 break;
1602 }
1604 {
1606 {
1607 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1608 return false;
1609 }
1610
1612 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1613 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1614 {
1615 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1616 return false;
1617 }
1618 break;
1619 }
1621 {
1623 {
1624 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1625 return false;
1626 }
1627
1629 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1630 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1631 {
1632 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1633 return false;
1634 }
1635 break;
1636 }
1638 {
1640 {
1641 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1642 return false;
1643 }
1644
1646 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1647 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1648 {
1649 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1650 return false;
1651 }
1652 break;
1653 }
1655 {
1657 {
1658 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1659 return false;
1660 }
1661
1663 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1664 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1665 {
1666 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1667 return false;
1668 }
1669 break;
1670 }
1672 {
1673 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1674 if (!spellInfo)
1675 {
1676 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1677 return false;
1678 }
1679
1680 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1681 {
1682 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1683 return false;
1684 }
1685
1686 uint32 origGroup = cond->SourceGroup;
1687
1688 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1689 {
1690 if (!((1 << i) & cond->SourceGroup))
1691 continue;
1692
1693 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1694 {
1699 continue;
1700 default:
1701 break;
1702 }
1703
1704 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1705 {
1710 continue;
1711 default:
1712 break;
1713 }
1714
1715 switch (spellInfo->Effects[i].Effect)
1716 {
1724 continue;
1725 default:
1726 break;
1727 }
1728
1729 // Xinef: chain targets are treated as area targets! Apply conditions!
1730 if (spellInfo->Effects[i].ChainTarget > 1)
1731 continue;
1732
1733 LOG_ERROR("sql.sql", "SourceEntry {} SourceGroup {} in `condition` table - spell {} does not have implicit targets of types: _AREA_, _CONE_, _NEARBY_ for effect {}, SourceGroup needs correction, ignoring.", cond->SourceEntry, origGroup, cond->SourceEntry, uint32(i));
1734 cond->SourceGroup &= ~(1 << i);
1735 }
1736 // all effects were removed, no need to add the condition at all
1737 if (!cond->SourceGroup)
1738 return false;
1739 break;
1740 }
1742 {
1743 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1744 {
1745 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1746 return false;
1747 }
1748 break;
1749 }
1752 {
1753 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1754 if (!spellProto)
1755 {
1756 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1757 return false;
1758 }
1759 break;
1760 }
1762 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1763 {
1764 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1765 return false;
1766 }
1767 break;
1769 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1770 break;
1773 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1774 {
1775 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1776 return false;
1777 }
1778
1779 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1780 {
1781 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1782 return false;
1783 }
1784 break;
1786 {
1787 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1788 {
1789 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1790 return false;
1791 }
1792 if (cond->SourceEntry)
1793 {
1794 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1795 if (!itemTemplate)
1796 {
1797 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1798 return false;
1799 }
1800 }
1801 break;
1802 }
1804 {
1806 {
1807 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1808 return false;
1809 }
1810
1812 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1813 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1814 {
1815 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1816 return false;
1817 }
1818 break;
1819 }
1824 default:
1825 break;
1826 }
1827
1828 return true;
1829}
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition: ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_PHASE
Definition: ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition: ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition: ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_UNUSED_20
Definition: ConditionMgr.h:142
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition: ConditionMgr.h:141
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false)
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)
LootStore LootTemplates_Reference("reference_loot_template", "reference id", false)
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true)
LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false)
LootStore LootTemplates_Player("player_loot_template", "team id", true)
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
@ TARGET_SELECT_CATEGORY_CONE
Definition: SpellInfo.h:81
@ TARGET_SELECT_CATEGORY_AREA
Definition: SpellInfo.h:82
@ TARGET_SELECT_CATEGORY_NEARBY
Definition: SpellInfo.h:80
@ TARGET_SELECT_CATEGORY_TRAJ
Definition: SpellInfo.h:83
@ SPELL_EFFECT_APPLY_AREA_AURA_PARTY
Definition: SharedDefines.h:813
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition: SharedDefines.h:906
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition: SharedDefines.h:897
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition: SharedDefines.h:843
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition: SharedDefines.h:805
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition: SharedDefines.h:907
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition: SharedDefines.h:921
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1638
LootTemplate * GetLootForConditionFill(uint32 loot_id) const
Definition: LootMgr.cpp:256
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:224
Definition: LootMgr.h:245
bool isReference(uint32 id) const
Definition: LootMgr.cpp:1945

References CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GOSSIP_MENU, CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION, CONDITION_SOURCE_TYPE_GRAVEYARD, CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_NONE, CONDITION_SOURCE_TYPE_NPC_VENDOR, CONDITION_SOURCE_TYPE_PHASE, CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_QUEST_AVAILABLE, CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SMART_EVENT, CONDITION_SOURCE_TYPE_SPELL, CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT, CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET, CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SPELL_PROC, CONDITION_SOURCE_TYPE_TERRAIN_SWAP, CONDITION_SOURCE_TYPE_UNUSED_20, CONDITION_SOURCE_TYPE_VEHICLE_SPELL, SpellInfo::Effects, LootStore::GetLootForConditionFill(), LootStore::HaveLootFor(), LootTemplate::isReference(), LOG_ERROR, LootTemplates_Creature, LootTemplates_Disenchant, LootTemplates_Fishing, LootTemplates_Gameobject, LootTemplates_Item, LootTemplates_Mail, LootTemplates_Milling, LootTemplates_Pickpocketing, LootTemplates_Player, LootTemplates_Prospecting, LootTemplates_Reference, LootTemplates_Skinning, LootTemplates_Spell, MAX_EFFECT_MASK, MAX_SPELL_EFFECTS, sObjectMgr, Condition::SourceEntry, Condition::SourceGroup, Condition::SourceType, SPELL_EFFECT_APPLY_AREA_AURA_ENEMY, SPELL_EFFECT_APPLY_AREA_AURA_FRIEND, SPELL_EFFECT_APPLY_AREA_AURA_OWNER, SPELL_EFFECT_APPLY_AREA_AURA_PARTY, SPELL_EFFECT_APPLY_AREA_AURA_PET, SPELL_EFFECT_APPLY_AREA_AURA_RAID, SPELL_EFFECT_PERSISTENT_AREA_AURA, sSpellMgr, TARGET_SELECT_CATEGORY_AREA, TARGET_SELECT_CATEGORY_CONE, TARGET_SELECT_CATEGORY_NEARBY, and TARGET_SELECT_CATEGORY_TRAJ.

Referenced by LoadConditions().

◆ LoadConditions()

void ConditionMgr::LoadConditions ( bool  isReload = false)

TODO: PAIR_32 ?

1034{
1035 uint32 oldMSTime = getMSTime();
1036
1037 Clean();
1038
1039 // must clear all custom handled cases (groupped types) before reload
1040 if (isReload)
1041 {
1042 LOG_INFO("server.loading", "Reseting Loot Conditions...");
1056
1057 LOG_INFO("server.loading", "Reloading `gossip_menu` Table for Conditions!");
1058 sObjectMgr->LoadGossipMenu();
1059
1060 LOG_INFO("server.loading", "Reloading `gossip_menu_option` Table for Conditions!");
1061 sObjectMgr->LoadGossipMenuItems();
1062 sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
1063 }
1064
1065 QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
1066 " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
1067
1068 if (!result)
1069 {
1070 LOG_WARN("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
1071 return;
1072 }
1073
1074 uint32 count = 0;
1075
1076 do
1077 {
1078 Field* fields = result->Fetch();
1079
1080 Condition* cond = new Condition();
1081 int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
1082 cond->SourceGroup = fields[1].Get<uint32>();
1083 cond->SourceEntry = fields[2].Get<int32>();
1084 cond->SourceId = fields[3].Get<int32>();
1085 cond->ElseGroup = fields[4].Get<uint32>();
1086 int32 iConditionTypeOrReference = fields[5].Get<int32>();
1087 cond->ConditionTarget = fields[6].Get<uint8>();
1088 cond->ConditionValue1 = fields[7].Get<uint32>();
1089 cond->ConditionValue2 = fields[8].Get<uint32>();
1090 cond->ConditionValue3 = fields[9].Get<uint32>();
1091 cond->NegativeCondition = fields[10].Get<uint8>();
1092 cond->ErrorType = fields[11].Get<uint32>();
1093 cond->ErrorTextId = fields[12].Get<uint32>();
1094 cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
1095
1096 if (iConditionTypeOrReference >= 0)
1097 cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1098
1099 if (iSourceTypeOrReferenceId >= 0)
1100 cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1101
1102 if (iConditionTypeOrReference < 0) // it has a reference
1103 {
1104 if (iConditionTypeOrReference == iSourceTypeOrReferenceId) // self referencing, skip
1105 {
1106 LOG_ERROR("sql.sql", "Condition reference {} is referencing self, skipped", iSourceTypeOrReferenceId);
1107 delete cond;
1108 continue;
1109 }
1110 cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference));
1111
1112 const char* rowType = "reference template";
1113 if (iSourceTypeOrReferenceId >= 0)
1114 rowType = "reference";
1115 // check for useless data
1116 if (cond->ConditionTarget)
1117 LOG_ERROR("sql.sql", "Condition {} {} has useless data in ConditionTarget ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1118 if (cond->ConditionValue1)
1119 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value1 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1120 if (cond->ConditionValue2)
1121 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value2 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1122 if (cond->ConditionValue3)
1123 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value3 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1124 if (cond->NegativeCondition)
1125 LOG_ERROR("sql.sql", "Condition {} {} has useless data in NegativeCondition ({})!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1126 if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1127 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceGroup ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1128 if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1129 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceEntry ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1130 }
1131 else if (!isConditionTypeValid(cond)) // doesn't have reference, validate ConditionType
1132 {
1133 delete cond;
1134 continue;
1135 }
1136
1137 if (iSourceTypeOrReferenceId < 0) // it is a reference template
1138 {
1139 uint32 uRefId = std::abs(iSourceTypeOrReferenceId);
1140 if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id
1141 {
1142 ConditionList mCondList;
1143 ConditionReferenceStore[uRefId] = mCondList;
1144 }
1145 ConditionReferenceStore[uRefId].push_back(cond); // add to reference storage
1146 count++;
1147 continue;
1148 } // end of reference templates
1149
1150 // if not a reference and SourceType is invalid, skip
1151 if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1152 {
1153 delete cond;
1154 continue;
1155 }
1156
1157 // Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1158 if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1159 {
1160 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceGroup = {}!", uint32(cond->SourceType), cond->SourceGroup);
1161 delete cond;
1162 continue;
1163 }
1164 if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1165 {
1166 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceId = {}!", uint32(cond->SourceType), cond->SourceId);
1167 delete cond;
1168 continue;
1169 }
1170
1171 if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1172 {
1173 LOG_ERROR("condition", "Condition type {} entry {} can't have ErrorType ({}), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
1174 cond->ErrorType = 0;
1175 }
1176
1177 if (cond->ErrorTextId && !cond->ErrorType)
1178 {
1179 LOG_ERROR("condition", "Condition type {} entry {} has any ErrorType, ErrorTextId ({}) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
1180 cond->ErrorTextId = 0;
1181 }
1182
1184 {
1185 bool valid = false;
1186 // handle grouped conditions
1187 switch (cond->SourceType)
1188 {
1191 break;
1194 break;
1197 break;
1200 break;
1203 break;
1206 break;
1209 break;
1212 break;
1215 break;
1218 break;
1221 break;
1224 break;
1226 valid = addToGossipMenus(cond);
1227 break;
1229 valid = addToGossipMenuItems(cond);
1230 break;
1232 {
1233 SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1234 valid = true;
1235 ++count;
1236 continue; // do not add to m_AllocatedMemory to avoid double deleting
1237 }
1240 break;
1242 {
1243 VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1244 valid = true;
1245 ++count;
1246 continue; // do not add to m_AllocatedMemory to avoid double deleting
1247 }
1249 {
1251 std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1252 SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1253 valid = true;
1254 ++count;
1255 continue;
1256 }
1258 {
1259 NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1260 valid = true;
1261 ++count;
1262 continue;
1263 }
1265 {
1267 break;
1268 }
1269 default:
1270 break;
1271 }
1272
1273 if (!valid)
1274 {
1275 LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup {}", cond->SourceGroup);
1276 delete cond;
1277 }
1278 else
1279 {
1280 AllocatedMemoryStore.push_back(cond);
1281 ++count;
1282 }
1283 continue;
1284 }
1285
1286 // handle not grouped conditions
1287 // make sure we have a storage list for our SourceType
1288 if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
1289 {
1290 ConditionTypeContainer mTypeMap;
1291 ConditionStore[cond->SourceType] = mTypeMap; // add new empty list for SourceType
1292 }
1293
1294 // make sure we have a condition list for our SourceType's entry
1295 if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
1296 {
1297 ConditionList mCondList;
1298 ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
1299 }
1300
1301 // add new Condition to storage based on Type/Entry
1302 ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1303 ++count;
1304 } while (result->NextRow());
1305
1306 LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1307 LOG_INFO("server.loading", " ");
1308}
#define LOG_INFO(filterType__,...)
Definition: Log.h:164
#define LOG_WARN(filterType__,...)
Definition: Log.h:160
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition: Timer.h:131
uint32 getMSTime()
Definition: Timer.h:103
std::int32_t int32
Definition: Define.h:103
ConditionSourceType
Definition: ConditionMgr.h:121
ConditionTypes
Definition: ConditionMgr.h:33
std::map< uint32, ConditionList > ConditionTypeContainer
Definition: ConditionMgr.h:237
std::shared_ptr< ResultSet > QueryResult
Definition: DatabaseEnvFwd.h:28
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition: DatabaseEnv.cpp:20
Class used to access individual fields of database query result.
Definition: Field.h:99
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:113
Definition: ConditionMgr.h:194
uint32 ErrorType
Definition: ConditionMgr.h:204
uint32 SourceId
Definition: ConditionMgr.h:198
uint32 ElseGroup
Definition: ConditionMgr.h:199
uint32 ScriptId
Definition: ConditionMgr.h:207
bool NegativeCondition
Definition: ConditionMgr.h:209
uint32 ReferenceId
Definition: ConditionMgr.h:206
uint32 ErrorTextId
Definition: ConditionMgr.h:205
bool isConditionTypeValid(Condition *cond)
Definition: ConditionMgr.cpp:1830
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const
Definition: ConditionMgr.cpp:931
bool addToSpellImplicitTargetConditions(Condition *cond)
Definition: ConditionMgr.cpp:1364
bool addToGossipMenus(Condition *cond)
Definition: ConditionMgr.cpp:1325
bool addToGossipMenuItems(Condition *cond)
Definition: ConditionMgr.cpp:1345
bool addToLootTemplate(Condition *cond, LootTemplate *loot)
Definition: ConditionMgr.cpp:1310
bool isSourceTypeValid(Condition *cond)
Definition: ConditionMgr.cpp:1450
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const
Definition: ConditionMgr.cpp:938
void ResetConditions()
Definition: LootMgr.cpp:237

References addToGossipMenuItems(), addToGossipMenus(), addToLootTemplate(), addToSpellImplicitTargetConditions(), AllocatedMemoryStore, CanHaveSourceGroupSet(), CanHaveSourceIdSet(), Clean(), CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_GOSSIP_MENU, CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION, CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_NPC_VENDOR, CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_SMART_EVENT, CONDITION_SOURCE_TYPE_SPELL, CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT, CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET, CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE, CONDITION_SOURCE_TYPE_VEHICLE_SPELL, ConditionReferenceStore, ConditionStore, Condition::ConditionTarget, Condition::ConditionType, Condition::ConditionValue1, Condition::ConditionValue2, Condition::ConditionValue3, Condition::ElseGroup, Condition::ErrorTextId, Condition::ErrorType, Field::Get(), LootStore::GetLootForConditionFill(), getMSTime(), GetMSTimeDiffToNow(), isConditionTypeValid(), isSourceTypeValid(), LOG_ERROR, LOG_INFO, LOG_WARN, LootTemplates_Creature, LootTemplates_Disenchant, LootTemplates_Fishing, LootTemplates_Gameobject, LootTemplates_Item, LootTemplates_Mail, LootTemplates_Milling, LootTemplates_Pickpocketing, LootTemplates_Player, LootTemplates_Prospecting, LootTemplates_Reference, LootTemplates_Skinning, LootTemplates_Spell, Condition::NegativeCondition, NpcVendorConditionContainerStore, Condition::ReferenceId, LootStore::ResetConditions(), Condition::ScriptId, SmartEventConditionStore, sObjectMgr, Condition::SourceEntry, Condition::SourceGroup, Condition::SourceId, Condition::SourceType, SpellClickEventConditionStore, sSpellMgr, VehicleSpellConditionStore, and WorldDatabase.

Member Data Documentation

◆ AllocatedMemoryStore

std::list<Condition*> ConditionMgr::AllocatedMemoryStore
private

Referenced by Clean(), and LoadConditions().

◆ ConditionReferenceStore

◆ ConditionStore

ConditionContainer ConditionMgr::ConditionStore
private

◆ NpcVendorConditionContainerStore

NpcVendorConditionContainer ConditionMgr::NpcVendorConditionContainerStore
private

◆ SmartEventConditionStore

SmartEventConditionContainer ConditionMgr::SmartEventConditionStore
private

◆ SpellClickEventConditionStore

CreatureSpellConditionContainer ConditionMgr::SpellClickEventConditionStore
private

◆ VehicleSpellConditionStore

CreatureSpellConditionContainer ConditionMgr::VehicleSpellConditionStore
private