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
847{}

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
850{
851 Clean();
852}
void Clean()
Definition ConditionMgr.cpp:2519

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1388{
1389 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1390 if (pMenuItemBounds.first != pMenuItemBounds.second)
1391 {
1392 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1393 {
1394 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1395 {
1396 (*itr).second.Conditions.push_back(cond);
1397 return true;
1398 }
1399 }
1400 }
1401
1402 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1403 return false;
1404}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define sObjectMgr
Definition ObjectMgr.h:1686
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition ObjectMgr.h:636
uint32 SourceGroup
Definition ConditionMgr.h:199
int32 SourceEntry
Definition ConditionMgr.h:200

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

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1368{
1369 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1370
1371 if (pMenuBounds.first != pMenuBounds.second)
1372 {
1373 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1374 {
1375 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1376 {
1377 (*itr).second.Conditions.push_back(cond);
1378 return true;
1379 }
1380 }
1381 }
1382
1383 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1384 return false;
1385}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition ObjectMgr.h:633

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

Referenced by LoadConditions().

◆ addToLootTemplate()

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
)
private
1353{
1354 if (!loot)
1355 {
1356 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1357 return false;
1358 }
1359
1360 if (loot->addConditionItem(cond))
1361 return true;
1362
1363 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1364 return false;
1365}
bool addConditionItem(Condition *cond)
Definition LootMgr.cpp:1893

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

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond)
private
1407{
1408 uint32 conditionEffMask = cond->SourceGroup;
1409 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1410 std::list<uint32> sharedMasks;
1411 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1412 {
1413 // check if effect is already a part of some shared mask
1414 bool found = false;
1415 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1416 {
1417 if ((1 << i) & *itr)
1418 {
1419 found = true;
1420 break;
1421 }
1422 }
1423 if (found)
1424 continue;
1425
1426 // build new shared mask with found effect
1427 uint32 sharedMask = (1 << i);
1428 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1429 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1430 {
1431 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1432 sharedMask |= 1 << effIndex;
1433 }
1434 sharedMasks.push_back(sharedMask);
1435 }
1436
1437 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1438 {
1439 // some effect indexes should have same data
1440 if (uint32 commonMask = *itr & conditionEffMask)
1441 {
1442 uint8 firstEffIndex = 0;
1443 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1444 if ((1 << firstEffIndex) & *itr)
1445 break;
1446
1447 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1448 return false;
1449
1450 // get shared data
1451 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1452
1453 // there's already data entry for that sharedMask
1454 if (sharedList)
1455 {
1456 // we have overlapping masks in db
1457 if (conditionEffMask != *itr)
1458 {
1459 LOG_ERROR("sql.sql",
1460 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1461 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1462 cond->SourceEntry, cond->SourceGroup);
1463 return false;
1464 }
1465 }
1466 // no data for shared mask, we can create new submask
1467 else
1468 {
1469 // add new list, create new shared mask
1470 sharedList = new ConditionList();
1471 bool assigned = false;
1472 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1473 {
1474 if ((1 << i) & commonMask)
1475 {
1476 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1477 assigned = true;
1478 }
1479 }
1480
1481 if (!assigned)
1482 delete sharedList;
1483 }
1484 if (sharedList)
1485 sharedList->push_back(cond);
1486 break;
1487 }
1488 }
1489 return true;
1490}
std::list< Condition * > ConditionList
Definition ConditionMgr.h:239
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1637
std::uint8_t uint8
Definition Define.h:109
#define sSpellMgr
Definition SpellMgr.h:826
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
974{
978}
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE
Definition ConditionMgr.h:127
@ CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE
Definition ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition ConditionMgr.h:143
@ CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE
Definition ConditionMgr.h:131
@ CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE
Definition ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE
Definition ConditionMgr.h:133
@ CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE
Definition ConditionMgr.h:134
@ CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE
Definition ConditionMgr.h:128
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE
Definition ConditionMgr.h:130
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE
Definition ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE
Definition ConditionMgr.h:126
@ CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE
Definition ConditionMgr.h:129
@ CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE
Definition ConditionMgr.h:153
@ CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE
Definition ConditionMgr.h:132

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
981{
982 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
983}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2520{
2521 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2522 {
2523 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2524 itr->second.clear();
2525 }
2526
2528
2529 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2530 {
2531 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2532 {
2533 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2534 it->second.clear();
2535 }
2536 itr->second.clear();
2537 }
2538
2539 ConditionStore.clear();
2540
2541 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2542 {
2543 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2544 {
2545 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2546 it->second.clear();
2547 }
2548 itr->second.clear();
2549 }
2550
2552
2553 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2554 {
2555 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2556 {
2557 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2558 it->second.clear();
2559 }
2560 itr->second.clear();
2561 }
2562
2564
2565 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2566 {
2567 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2568 {
2569 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2570 it->second.clear();
2571 }
2572 itr->second.clear();
2573 }
2574
2576
2577 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2578 {
2579 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2580 {
2581 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2582 it->second.clear();
2583 }
2584 itr->second.clear();
2585 }
2586
2588
2589 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2590 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2591
2592 AllocatedMemoryStore.clear();
2593}
SmartEventConditionContainer SmartEventConditionStore
Definition ConditionMgr.h:289
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition ConditionMgr.h:287
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition ConditionMgr.h:286
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition ConditionMgr.h:288
ConditionContainer ConditionStore
Definition ConditionMgr.h:284
ConditionReferenceContainer ConditionReferenceStore
Definition ConditionMgr.h:285
std::list< Condition * > AllocatedMemoryStore
Definition ConditionMgr.h:282

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

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

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
861{
862 ConditionList conditions;
863 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
864 if (ref != ConditionReferenceStore.end())
865 conditions = (*ref).second;
866 return conditions;
867}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
986{
987 ConditionList spellCond;
988 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
989 {
990 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
991 if (itr != ConditionStore.end())
992 {
993 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
994 if (i != (*itr).second.end())
995 {
996 spellCond = (*i).second;
997 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
998 }
999 }
1000 }
1001 return spellCond;
1002}
@ CONDITION_SOURCE_TYPE_MAX
Definition ConditionMgr.h:156
@ CONDITION_SOURCE_TYPE_NONE
Definition ConditionMgr.h:125
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170

References CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_NONE, ConditionStore, and LOG_DEBUG.

◆ GetConditionsForNpcVendorEvent()

ConditionList ConditionMgr::GetConditionsForNpcVendorEvent ( uint32  creatureId,
uint32  itemId 
)
1053{
1054 ConditionList cond;
1055 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1056 if (itr != NpcVendorConditionContainerStore.end())
1057 {
1058 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1059 if (i != (*itr).second.end())
1060 {
1061 cond = (*i).second;
1062 if (itemId)
1063 {
1064 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1065 }
1066 else
1067 {
1068 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1069 }
1070 }
1071 }
1072 return cond;
1073}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
1037{
1038 ConditionList cond;
1039 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
1040 if (itr != SmartEventConditionStore.end())
1041 {
1042 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
1043 if (i != (*itr).second.end())
1044 {
1045 cond = (*i).second;
1046 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
1047 }
1048 }
1049 return cond;
1050}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
1005{
1006 ConditionList cond;
1007 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
1008 if (itr != SpellClickEventConditionStore.end())
1009 {
1010 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
1011 if (i != (*itr).second.end())
1012 {
1013 cond = (*i).second;
1014 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
1015 }
1016 }
1017 return cond;
1018}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

ConditionList ConditionMgr::GetConditionsForVehicleSpell ( uint32  creatureId,
uint32  spellId 
)
1021{
1022 ConditionList cond;
1023 CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
1024 if (itr != VehicleSpellConditionStore.end())
1025 {
1026 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
1027 if (i != (*itr).second.end())
1028 {
1029 cond = (*i).second;
1030 LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
1031 }
1032 }
1033 return cond;
1034}

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

uint32 ConditionMgr::GetSearcherTypeMaskForConditionList ( ConditionList const &  conditions)
870{
871 if (conditions.empty())
873 // groupId, typeMask
874 std::map<uint32, uint32> ElseGroupStore;
875 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
876 {
877 // no point of having not loaded conditions in list
878 ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
879 std::map<uint32, uint32>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
880 // group not filled yet, fill with widest mask possible
881 if (itr == ElseGroupStore.end())
882 ElseGroupStore[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
883 // no point of checking anymore, empty mask
884 else if (!(*itr).second)
885 continue;
886
887 if ((*i)->ReferenceId) // handle reference
888 {
889 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
890 ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference");
891 ElseGroupStore[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
892 }
893 else // handle normal condition
894 {
895 // object will match conditions in one ElseGroupStore only when it matches all of them
896 // so, let's find a smallest possible mask which satisfies all conditions
897 ElseGroupStore[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
898 }
899 }
900 // object will match condition when one of the checks in ElseGroupStore is matching
901 // so, let's include all possible masks
902 uint32 mask = 0;
903 for (std::map<uint32, uint32>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i) mask |= i->second;
904
905 return mask;
906}
#define ASSERT
Definition Errors.h:68
@ GRID_MAP_TYPE_MASK_ALL
Definition GridDefines.h:76
uint32 GetSearcherTypeMaskForConditionList(ConditionList const &conditions)
Definition ConditionMgr.cpp:869

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
855{
856 static ConditionMgr instance;
857 return &instance;
858}
Definition ConditionMgr.h:249
static ConditionMgr * instance()
Definition ConditionMgr.cpp:854

References instance().

Referenced by instance().

◆ isConditionTypeValid()

bool ConditionMgr::isConditionTypeValid ( Condition cond)
1873{
1875 {
1876 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has an invalid ConditionType ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
1877 return false;
1878 }
1879 switch (cond->ConditionType)
1880 {
1882 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));
1883 return false;
1884 default:
1885 break;
1886 }
1887
1889 {
1890 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry);
1891 return false;
1892 }
1893
1894 switch (cond->ConditionType)
1895 {
1896 case CONDITION_AURA:
1897 {
1898 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
1899 {
1900 LOG_ERROR("sql.sql", "Aura condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
1901 return false;
1902 }
1903
1904 if (cond->ConditionValue2 > EFFECT_2)
1905 {
1906 LOG_ERROR("sql.sql", "Aura condition has non existing effect index ({}) (must be 0..2), skipped", cond->ConditionValue2);
1907 return false;
1908 }
1909 if (cond->ConditionValue3)
1910 LOG_ERROR("sql.sql", "Aura condition has useless data in value3 ({})!", cond->ConditionValue3);
1911 break;
1912 }
1913 case CONDITION_ITEM:
1914 {
1915 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1916 if (!proto)
1917 {
1918 LOG_ERROR("sql.sql", "Item condition has non existing item ({}), skipped", cond->ConditionValue1);
1919 return false;
1920 }
1921
1922 if (!cond->ConditionValue2)
1923 {
1924 LOG_ERROR("sql.sql", "Item condition has 0 set for item count in value2 ({}), skipped", cond->ConditionValue2);
1925 return false;
1926 }
1927 break;
1928 }
1930 {
1931 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1932 if (!proto)
1933 {
1934 LOG_ERROR("sql.sql", "ItemEquipped condition has non existing item ({}), skipped", cond->ConditionValue1);
1935 return false;
1936 }
1937
1938 if (cond->ConditionValue2)
1939 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value2 ({})!", cond->ConditionValue2);
1940 if (cond->ConditionValue3)
1941 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value3 ({})!", cond->ConditionValue3);
1942 break;
1943 }
1944 case CONDITION_ZONEID:
1945 {
1946 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(cond->ConditionValue1);
1947 if (!areaEntry)
1948 {
1949 LOG_ERROR("sql.sql", "ZoneID condition has non existing area ({}), skipped", cond->ConditionValue1);
1950 return false;
1951 }
1952
1953 if (areaEntry->zone != 0)
1954 {
1955 LOG_ERROR("sql.sql", "ZoneID condition requires to be in area ({}) which is a subzone but zone expected, skipped", cond->ConditionValue1);
1956 return false;
1957 }
1958
1959 if (cond->ConditionValue2)
1960 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value2 ({})!", cond->ConditionValue2);
1961 if (cond->ConditionValue3)
1962 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value3 ({})!", cond->ConditionValue3);
1963 break;
1964 }
1966 {
1967 FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
1968 if (!factionEntry)
1969 {
1970 LOG_ERROR("sql.sql", "Reputation condition has non existing faction ({}), skipped", cond->ConditionValue1);
1971 return false;
1972 }
1973 if (cond->ConditionValue3)
1974 LOG_ERROR("sql.sql", "Reputation condition has useless data in value3 ({})!", cond->ConditionValue3);
1975 break;
1976 }
1977 case CONDITION_TEAM:
1978 {
1979 if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
1980 {
1981 LOG_ERROR("sql.sql", "Team condition specifies unknown team ({}), skipped", cond->ConditionValue1);
1982 return false;
1983 }
1984
1985 if (cond->ConditionValue2)
1986 LOG_ERROR("sql.sql", "Team condition has useless data in value2 ({})!", cond->ConditionValue2);
1987 if (cond->ConditionValue3)
1988 LOG_ERROR("sql.sql", "Team condition has useless data in value3 ({})!", cond->ConditionValue3);
1989 break;
1990 }
1991 case CONDITION_SKILL:
1992 {
1993 SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
1994 if (!pSkill)
1995 {
1996 LOG_ERROR("sql.sql", "Skill condition specifies non-existing skill ({}), skipped", cond->ConditionValue1);
1997 return false;
1998 }
1999
2000 if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
2001 {
2002 LOG_ERROR("sql.sql", "Skill condition specifies invalid skill value ({}), skipped", cond->ConditionValue2);
2003 return false;
2004 }
2005 if (cond->ConditionValue3)
2006 LOG_ERROR("sql.sql", "Skill condition has useless data in value3 ({})!", cond->ConditionValue3);
2007 break;
2008 }
2015 {
2016 if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
2017 {
2018 LOG_ERROR("sql.sql", "Quest condition specifies non-existing quest ({}), skipped", cond->ConditionValue1);
2019 return false;
2020 }
2021
2022 if (cond->ConditionValue2 > 1)
2023 {
2024 LOG_ERROR("sql.sql", "Quest condition has useless data in value2 ({})!", cond->ConditionValue2);
2025 }
2026 if (cond->ConditionValue3)
2027 {
2028 LOG_ERROR("sql.sql", "Quest condition has useless data in value3 ({})!", cond->ConditionValue3);
2029 }
2030 break;
2031 }
2033 if (cond->ConditionValue2 >= (1 << MAX_QUEST_STATUS))
2034 {
2035 LOG_ERROR("sql.sql", "ConditionType ({}) has invalid state mask ({}), skipped.", cond->ConditionType, cond->ConditionValue2);
2036 return false;
2037 }
2038 break;
2040 {
2041 GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
2042 if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
2043 {
2044 LOG_ERROR("sql.sql", "ActiveEvent condition has non existing event id ({}), skipped", cond->ConditionValue1);
2045 return false;
2046 }
2047
2048 if (cond->ConditionValue2)
2049 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value2 ({})!", cond->ConditionValue2);
2050 if (cond->ConditionValue3)
2051 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value3 ({})!", cond->ConditionValue3);
2052 break;
2053 }
2055 {
2056 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2057 if (!achievement)
2058 {
2059 LOG_ERROR("sql.sql", "Achivement condition has non existing achivement id ({}), skipped", cond->ConditionValue1);
2060 return false;
2061 }
2062
2063 if (cond->ConditionValue2)
2064 LOG_ERROR("sql.sql", "Achivement condition has useless data in value2 ({})!", cond->ConditionValue2);
2065 if (cond->ConditionValue3)
2066 LOG_ERROR("sql.sql", "Achivement condition has useless data in value3 ({})!", cond->ConditionValue3);
2067 break;
2068 }
2069 case CONDITION_CLASS:
2070 {
2072 {
2073 LOG_ERROR("sql.sql", "Class condition has non existing classmask ({}), skipped", cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
2074 return false;
2075 }
2076
2077 if (cond->ConditionValue2)
2078 LOG_ERROR("sql.sql", "Class condition has useless data in value2 ({})!", cond->ConditionValue2);
2079 if (cond->ConditionValue3)
2080 LOG_ERROR("sql.sql", "Class condition has useless data in value3 ({})!", cond->ConditionValue3);
2081 break;
2082 }
2083 case CONDITION_RACE:
2084 {
2086 {
2087 LOG_ERROR("sql.sql", "Race condition has non existing racemask ({}), skipped", cond->ConditionValue1 & ~RACEMASK_ALL_PLAYABLE);
2088 return false;
2089 }
2090
2091 if (cond->ConditionValue2)
2092 LOG_ERROR("sql.sql", "Race condition has useless data in value2 ({})!", cond->ConditionValue2);
2093 if (cond->ConditionValue3)
2094 LOG_ERROR("sql.sql", "Race condition has useless data in value3 ({})!", cond->ConditionValue3);
2095 break;
2096 }
2097 case CONDITION_GENDER:
2098 {
2100 {
2101 LOG_ERROR("condition", "Gender condition has invalid gender ({}), skipped", cond->ConditionValue1);
2102 return false;
2103 }
2104
2105 if (cond->ConditionValue2)
2106 LOG_ERROR("condition", "Gender condition has useless data in value2 ({})!", cond->ConditionValue2);
2107 if (cond->ConditionValue3)
2108 LOG_ERROR("condition", "Gender condition has useless data in value3 ({})!", cond->ConditionValue3);
2109 break;
2110 }
2111 case CONDITION_MAPID:
2112 {
2113 MapEntry const* mapId = sMapStore.LookupEntry(cond->ConditionValue1);
2114 if (!mapId)
2115 {
2116 LOG_ERROR("sql.sql", "Map condition has non existing map ({}), skipped", cond->ConditionValue1);
2117 return false;
2118 }
2119
2120 if (cond->ConditionValue2)
2121 LOG_ERROR("sql.sql", "Map condition has useless data in value2 ({})!", cond->ConditionValue2);
2122 if (cond->ConditionValue3)
2123 LOG_ERROR("sql.sql", "Map condition has useless data in value3 ({})!", cond->ConditionValue3);
2124 break;
2125 }
2126 case CONDITION_SPELL:
2127 {
2128 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
2129 {
2130 LOG_ERROR("sql.sql", "Spell condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
2131 return false;
2132 }
2133
2134 if (cond->ConditionValue2)
2135 LOG_ERROR("sql.sql", "Spell condition has useless data in value2 ({})!", cond->ConditionValue2);
2136 if (cond->ConditionValue3)
2137 LOG_ERROR("sql.sql", "Spell condition has useless data in value3 ({})!", cond->ConditionValue3);
2138 break;
2139 }
2140 case CONDITION_LEVEL:
2141 {
2142 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2143 {
2144 LOG_ERROR("sql.sql", "Level condition has invalid option ({}), skipped", cond->ConditionValue2);
2145 return false;
2146 }
2147 if (cond->ConditionValue3)
2148 LOG_ERROR("sql.sql", "Level condition has useless data in value3 ({})!", cond->ConditionValue3);
2149 break;
2150 }
2152 {
2153 if (cond->ConditionValue1 > DRUNKEN_SMASHED)
2154 {
2155 LOG_ERROR("sql.sql", "DrunkState condition has invalid state ({}), skipped", cond->ConditionValue1);
2156 return false;
2157 }
2158 if (cond->ConditionValue2)
2159 {
2160 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value2 ({})!", cond->ConditionValue2);
2161 return false;
2162 }
2163 if (cond->ConditionValue3)
2164 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value3 ({})!", cond->ConditionValue3);
2165 break;
2166 }
2168 {
2169 if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
2170 {
2171 LOG_ERROR("sql.sql", "NearCreature condition has non existing creature template entry ({}), skipped", cond->ConditionValue1);
2172 return false;
2173 }
2174 break;
2175 }
2177 {
2178 if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
2179 {
2180 LOG_ERROR("sql.sql", "NearGameObject condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue1);
2181 return false;
2182 }
2183 if (cond->ConditionValue3 > 2)
2184 LOG_ERROR("sql.sql", "NearGameObject condition for gameobject ID ({}) has data over 2 for value3 ({})!", cond->ConditionValue1, cond->ConditionValue3);
2185 break;
2186 }
2188 {
2189 switch (cond->ConditionValue1)
2190 {
2191 case TYPEID_UNIT:
2192 if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
2193 {
2194 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry ({}), skipped", cond->ConditionValue2);
2195 return false;
2196 }
2197 if (cond->ConditionValue3 > 1)
2198 {
2199 if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
2200 {
2201 if (cond->ConditionValue2 && creatureData->id1 != cond->ConditionValue2)
2202 {
2203 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match creature entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2204 return false;
2205 }
2206 }
2207 else
2208 {
2209 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid ({}), skipped", cond->ConditionValue3);
2210 return false;
2211 }
2212 }
2213 break;
2214 case TYPEID_GAMEOBJECT:
2215 if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
2216 {
2217 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue2);
2218 return false;
2219 }
2220 if (cond->ConditionValue3)
2221 {
2222 if (GameObjectData const* goData = sObjectMgr->GetGameObjectData(cond->ConditionValue3))
2223 {
2224 if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
2225 {
2226 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match gameobject entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2227 return false;
2228 }
2229 }
2230 else
2231 {
2232 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid ({}), skipped", cond->ConditionValue3);
2233 return false;
2234 }
2235 }
2236 break;
2237 case TYPEID_PLAYER:
2238 case TYPEID_CORPSE:
2239 if (cond->ConditionValue2)
2240 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 ({})!", cond->ConditionValue2);
2241 if (cond->ConditionValue3)
2242 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 ({})!", cond->ConditionValue3);
2243 break;
2244 default:
2245 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set ({}), skipped", cond->ConditionValue1);
2246 return false;
2247 }
2248 break;
2249 }
2251 {
2253 {
2254 LOG_ERROR("sql.sql", "TypeMask condition has invalid typemask set ({}), skipped", cond->ConditionValue2);
2255 return false;
2256 }
2257 if (cond->ConditionValue2)
2258 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value2 ({})!", cond->ConditionValue2);
2259 if (cond->ConditionValue3)
2260 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value3 ({})!", cond->ConditionValue3);
2261 break;
2262 }
2264 {
2266 {
2267 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2268 return false;
2269 }
2270 if (cond->ConditionValue1 == cond->ConditionTarget)
2271 {
2272 LOG_ERROR("sql.sql", "RelationTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2273 return false;
2274 }
2275 if (cond->ConditionValue2 >= RELATION_MAX)
2276 {
2277 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue2(RelationType) ({}), skipped", cond->ConditionValue2);
2278 return false;
2279 }
2280 if (cond->ConditionValue3)
2281 LOG_ERROR("sql.sql", "RelationTo condition has useless data in value3 ({})!", cond->ConditionValue3);
2282 break;
2283 }
2285 {
2287 {
2288 LOG_ERROR("sql.sql", "ReactionTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2289 return false;
2290 }
2291 if (cond->ConditionValue1 == cond->ConditionTarget)
2292 {
2293 LOG_ERROR("sql.sql", "ReactionTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2294 return false;
2295 }
2296 if (!cond->ConditionValue2)
2297 {
2298 LOG_ERROR("sql.sql", "mConditionValue2 condition has invalid ConditionValue2(rankMask) ({}), skipped", cond->ConditionValue2);
2299 return false;
2300 }
2301 break;
2302 }
2304 {
2306 {
2307 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2308 return false;
2309 }
2310 if (cond->ConditionValue1 == cond->ConditionTarget)
2311 {
2312 LOG_ERROR("sql.sql", "DistanceTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2313 return false;
2314 }
2315 if (cond->ConditionValue3 >= COMP_TYPE_MAX)
2316 {
2317 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ComparisionType ({}), skipped", cond->ConditionValue3);
2318 return false;
2319 }
2320 break;
2321 }
2322 case CONDITION_ALIVE:
2323 {
2324 if (cond->ConditionValue1)
2325 LOG_ERROR("sql.sql", "Alive condition has useless data in value1 ({})!", cond->ConditionValue1);
2326 if (cond->ConditionValue2)
2327 LOG_ERROR("sql.sql", "Alive condition has useless data in value2 ({})!", cond->ConditionValue2);
2328 if (cond->ConditionValue3)
2329 LOG_ERROR("sql.sql", "Alive condition has useless data in value3 ({})!", cond->ConditionValue3);
2330 break;
2331 }
2332 case CONDITION_HP_VAL:
2333 {
2334 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2335 {
2336 LOG_ERROR("sql.sql", "HpVal condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2337 return false;
2338 }
2339 if (cond->ConditionValue3)
2340 LOG_ERROR("sql.sql", "HpVal condition has useless data in value3 ({})!", cond->ConditionValue3);
2341 break;
2342 }
2343 case CONDITION_HP_PCT:
2344 {
2345 if (cond->ConditionValue1 > 100)
2346 {
2347 LOG_ERROR("sql.sql", "HpPct condition has too big percent value ({}), skipped", cond->ConditionValue1);
2348 return false;
2349 }
2350 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2351 {
2352 LOG_ERROR("sql.sql", "HpPct condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2353 return false;
2354 }
2355 if (cond->ConditionValue3)
2356 LOG_ERROR("sql.sql", "HpPct condition has useless data in value3 ({})!", cond->ConditionValue3);
2357 break;
2358 }
2359 case CONDITION_AREAID:
2361 break;
2363 {
2364 if (cond->ConditionValue3)
2365 LOG_ERROR("sql.sql", "World state condition has useless data in value3 ({})!", cond->ConditionValue3);
2366 break;
2367 }
2369 {
2370 if (cond->ConditionValue2)
2371 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value2 ({})!", cond->ConditionValue2);
2372 if (cond->ConditionValue3)
2373 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value3 ({})!", cond->ConditionValue3);
2374 break;
2375 }
2376 case CONDITION_TITLE:
2377 {
2378 CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
2379 if (!titleEntry)
2380 {
2381 LOG_ERROR("sql.sql", "Title condition has non existing title in value1 ({}), skipped", cond->ConditionValue1);
2382 return false;
2383 }
2384 break;
2385 }
2387 {
2389 {
2390 LOG_ERROR("condition", "SpawnMask condition has non existing SpawnMask in value1 ({}), skipped", cond->ConditionValue1);
2391 return false;
2392 }
2393 break;
2394 }
2396 {
2398 {
2399 LOG_ERROR("condition", "UnitState condition has non existing UnitState in value1 ({}), skipped", cond->ConditionValue1);
2400 return false;
2401 }
2402 break;
2403 }
2405 {
2407 {
2408 LOG_ERROR("condition", "CreatureType condition has non existing CreatureType in value1 ({}), skipped", cond->ConditionValue1);
2409 return false;
2410 }
2411 break;
2412 }
2414 {
2415 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2416 if (!achievement)
2417 {
2418 LOG_ERROR("condition", "CONDITION_REALM_ACHIEVEMENT has non existing realm first achivement id ({}), skipped.", cond->ConditionValue1);
2419 return false;
2420 }
2421 break;
2422 }
2424 {
2425 const Quest* quest = sObjectMgr->GetQuestTemplate(cond->ConditionValue1);
2426 if (!quest)
2427 {
2428 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS points to non-existing quest ({}), skipped.", cond->ConditionValue1);
2429 return false;
2430 }
2431
2432 if (cond->ConditionValue2 > 3)
2433 {
2434 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);
2435 return false;
2436 }
2437
2438 if (quest->RequiredNpcOrGo[cond->ConditionValue2] == 0)
2439 {
2440 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);
2441 return false;
2442 }
2443
2444 if (cond->ConditionValue3 > quest->RequiredNpcOrGoCount[cond->ConditionValue2])
2445 {
2446 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);
2447 return false;
2448 }
2449 break;
2450 }
2452 {
2454 {
2455 LOG_ERROR("sql.sql", "Has Aura Effect condition has non existing aura ({}), skipped", cond->ConditionValue1);
2456 return false;
2457 }
2458 break;
2459 }
2461 {
2462 bool valid = false;
2463 switch (cond->ConditionValue1)
2464 {
2465 case 0:
2467 break;
2468 case 1:
2469 valid = cond->ConditionValue2 <= 1;
2470 break;
2471 default:
2472 valid = false;
2473 break;
2474 }
2475 if (!valid)
2476 {
2477 LOG_ERROR("sql.sql", "CONDITION_STAND_STATE has non-existing stand state ({},{}), skipped.", cond->ConditionValue1, cond->ConditionValue2);
2478 return false;
2479 }
2480 break;
2481 }
2483 if (cond->ConditionValue1 >= MAX_DIFFICULTY)
2484 {
2485 LOG_ERROR("sql.sql", "CONDITION_DIFFICULTY_ID has non existing difficulty in value1 ({}), skipped.", cond->ConditionValue1);
2486 return false;
2487 }
2488 break;
2490 if (cond->ConditionValue1 > 1)
2491 {
2492 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value1 ({}).", cond->ConditionValue1);
2493 return false;
2494 }
2495 if (cond->ConditionValue2 >= MAX_DIFFICULTY)
2496 {
2497 LOG_ERROR("sql.sql", "RandomDungeon condition has invalid difficulty in value2 ({}).", cond->ConditionValue1);
2498 return false;
2499 }
2500 if (cond->ConditionValue3)
2501 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value3 ({}).", cond->ConditionValue3);
2502 break;
2503 case CONDITION_PET_TYPE:
2504 if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
2505 {
2506 LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type {}, skipped.", cond->ConditionValue1);
2507 return false;
2508 }
2509 break;
2510 case CONDITION_TAXI:
2511 case CONDITION_IN_WATER:
2512 case CONDITION_CHARMED:
2513 default:
2514 break;
2515 }
2516 return true;
2517}
@ CONDITION_TAXI
Definition ConditionMgr.h:80
@ CONDITION_PLAYER_QUEUED_RANDOM_DUNGEON
Definition ConditionMgr.h:91
@ CONDITION_MAPID
Definition ConditionMgr.h:56
@ CONDITION_SKILL
Definition ConditionMgr.h:41
@ CONDITION_RACE
Definition ConditionMgr.h:50
@ CONDITION_REACTION_TO
Definition ConditionMgr.h:68
@ CONDITION_NEAR_GAMEOBJECT
Definition ConditionMgr.h:64
@ CONDITION_QUESTREWARDED
Definition ConditionMgr.h:42
@ CONDITION_REALM_ACHIEVEMENT
Definition ConditionMgr.h:73
@ CONDITION_PHASEMASK
Definition ConditionMgr.h:60
@ CONDITION_QUEST_OBJECTIVE_PROGRESS
Definition ConditionMgr.h:82
@ CONDITION_DAILY_QUEST_DONE
Definition ConditionMgr.h:77
@ CONDITION_ACTIVE_EVENT
Definition ConditionMgr.h:46
@ CONDITION_INSTANCE_INFO
Definition ConditionMgr.h:47
@ CONDITION_RELATION_TO
Definition ConditionMgr.h:67
@ CONDITION_STAND_STATE
Definition ConditionMgr.h:76
@ CONDITION_DRUNKENSTATE
Definition ConditionMgr.h:44
@ CONDITION_AURA
Definition ConditionMgr.h:35
@ CONDITION_ACHIEVEMENT
Definition ConditionMgr.h:51
@ CONDITION_TC_END
Definition ConditionMgr.h:84
@ CONDITION_OBJECT_ENTRY_GUID
Definition ConditionMgr.h:65
@ CONDITION_PET_TYPE
Definition ConditionMgr.h:79
@ CONDITION_DIFFICULTY_ID
Definition ConditionMgr.h:83
@ CONDITION_DISTANCE_TO
Definition ConditionMgr.h:69
@ CONDITION_HP_VAL
Definition ConditionMgr.h:71
@ CONDITION_GENDER
Definition ConditionMgr.h:54
@ CONDITION_TERRAIN_SWAP
Definition ConditionMgr.h:75
@ CONDITION_REPUTATION_RANK
Definition ConditionMgr.h:39
@ CONDITION_HP_PCT
Definition ConditionMgr.h:72
@ CONDITION_QUEST_COMPLETE
Definition ConditionMgr.h:62
@ CONDITION_SPELL
Definition ConditionMgr.h:59
@ CONDITION_ZONEID
Definition ConditionMgr.h:38
@ CONDITION_CHARMED
Definition ConditionMgr.h:78
@ CONDITION_AC_START
Definition ConditionMgr.h:86
@ CONDITION_TYPE_MASK
Definition ConditionMgr.h:66
@ CONDITION_AREAID
Definition ConditionMgr.h:57
@ CONDITION_IN_WATER
Definition ConditionMgr.h:74
@ CONDITION_ITEM
Definition ConditionMgr.h:36
@ CONDITION_WORLD_STATE
Definition ConditionMgr.h:45
@ CONDITION_SPAWNMASK
Definition ConditionMgr.h:53
@ CONDITION_CLASS
Definition ConditionMgr.h:49
@ CONDITION_TEAM
Definition ConditionMgr.h:40
@ CONDITION_NONE
Definition ConditionMgr.h:34
@ CONDITION_QUEST_NONE
Definition ConditionMgr.h:48
@ CONDITION_QUESTSTATE
Definition ConditionMgr.h:81
@ CONDITION_ITEM_EQUIPPED
Definition ConditionMgr.h:37
@ CONDITION_QUEST_SATISFY_EXCLUSIVE
Definition ConditionMgr.h:87
@ CONDITION_LEVEL
Definition ConditionMgr.h:61
@ CONDITION_QUESTTAKEN
Definition ConditionMgr.h:43
@ CONDITION_NEAR_CREATURE
Definition ConditionMgr.h:63
@ CONDITION_TITLE
Definition ConditionMgr.h:52
@ CONDITION_AC_END
Definition ConditionMgr.h:93
@ CONDITION_ALIVE
Definition ConditionMgr.h:70
@ CONDITION_CREATURE_TYPE
Definition ConditionMgr.h:58
@ CONDITION_UNIT_STATE
Definition ConditionMgr.h:55
@ CONDITION_HAS_AURA_TYPE
Definition ConditionMgr.h:88
@ RELATION_MAX
Definition ConditionMgr.h:167
#define MAX_DIFFICULTY
Definition DBCEnums.h:283
@ SPAWNMASK_RAID_ALL
Definition DBCEnums.h:301
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define sGameEventMgr
Definition GameEventMgr.h:201
@ 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
@ MAX_PET_TYPE
Definition PetDefines.h:34
@ DRUNKEN_SMASHED
Definition Player.h:453
@ MAX_QUEST_STATUS
Definition QuestDef.h:107
@ EFFECT_2
Definition SharedDefines.h:33
@ CREATURE_TYPE_GAS_CLOUD
Definition SharedDefines.h:2641
@ ALLIANCE
Definition SharedDefines.h:779
@ HORDE
Definition SharedDefines.h:778
#define CLASSMASK_ALL_PLAYABLE
Definition SharedDefines.h:157
#define RACEMASK_ALL_PLAYABLE
Definition SharedDefines.h:97
@ TOTAL_AURAS
Definition SpellAuraDefines.h:380
@ SPELL_AURA_NONE
Definition SpellAuraDefines.h:63
@ UNIT_STAND_STATE_SUBMERGED
Definition UnitDefines.h:41
@ UNIT_STATE_ALL_STATE_SUPPORTED
Definition UnitDefines.h:204
@ COMP_TYPE_MAX
Definition Util.h:584
events
Definition boss_sartura.cpp:43
std::vector< GameEventData > GameEventDataMap
Definition GameEventMgr.h:107
static bool IsValidGender(uint8 Gender)
Definition Player.h:1565
Definition QuestDef.h:210
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:305
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:306
#define sWorld
Definition World.h:316
ObjectData const creatureData[]
Definition instance_blackwing_lair.cpp:45
Definition DBCStructure.h:40
Definition DBCStructure.h:519
uint32 zone
Definition DBCStructure.h:522
Definition DBCStructure.h:632
ConditionTypes ConditionType
Definition ConditionMgr.h:203
ConditionSourceType SourceType
Definition ConditionMgr.h:198
uint32 ConditionValue2
Definition ConditionMgr.h:205
uint8 ConditionTarget
Definition ConditionMgr.h:211
uint32 ConditionValue3
Definition ConditionMgr.h:206
uint32 ConditionValue1
Definition ConditionMgr.h:204
uint32 GetMaxAvailableConditionTargets()
Definition ConditionMgr.cpp:822
Definition CreatureData.h:366
Definition DBCStructure.h:907
Definition GameObjectData.h:712
Definition ItemTemplate.h:619
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_PLAYER_QUEUED_RANDOM_DUNGEON, 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)

909{
910 // groupId, groupCheckPassed
911 std::map<uint32, bool> ElseGroupStore;
912 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
913 {
914 LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList condType: {} val1: {}", (*i)->ConditionType, (*i)->ConditionValue1);
915 if ((*i)->isLoaded())
916 {
918 std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
920 if (itr == ElseGroupStore.end())
921 ElseGroupStore[(*i)->ElseGroup] = true;
922 else if (!(*itr).second)
923 continue;
924
925 if ((*i)->ReferenceId) // handle reference
926 {
927 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
928 if (ref != ConditionReferenceStore.end())
929 {
930 if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second))
931 ElseGroupStore[(*i)->ElseGroup] = false;
932 }
933 else
934 {
935 LOG_DEBUG("condition", "IsPlayerMeetToConditionList: Reference template -{} not found", (*i)->ReferenceId);
936 }
937 }
938 else // handle normal condition
939 {
940 if (!(*i)->Meets(sourceInfo))
941 ElseGroupStore[(*i)->ElseGroup] = false;
942 }
943 }
944 }
945 for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
946 if (i->second)
947 return true;
948
949 return false;
950}
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionList const &conditions)
Definition ConditionMgr.cpp:908

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
965{
966 if (conditions.empty())
967 return true;
968
969 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
970 return IsObjectMeetToConditionList(sourceInfo, conditions);
971}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
953{
955 return IsObjectMeetToConditions(srcInfo, conditions);
956}
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition ConditionMgr.cpp:952
Definition ConditionMgr.h:184

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
959{
960 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
961 return IsObjectMeetToConditions(srcInfo, conditions);
962}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1493{
1495 {
1496 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1497 return false;
1498 }
1499
1500 switch (cond->SourceType)
1501 {
1505 {
1506 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1507 return false;
1508 }
1510 {
1512 {
1513 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1514 return false;
1515 }
1516
1518 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1519 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1520 {
1521 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1522 return false;
1523 }
1524 break;
1525 }
1527 {
1529 {
1530 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1531 return false;
1532 }
1533
1535 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1536 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1537 {
1538 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1539 return false;
1540 }
1541 break;
1542 }
1544 {
1546 {
1547 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1548 return false;
1549 }
1550
1552 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1553 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1554 {
1555 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1556 return false;
1557 }
1558 break;
1559 }
1561 {
1563 {
1564 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1565 return false;
1566 }
1567
1569 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1570 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1571 {
1572 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1573 return false;
1574 }
1575 break;
1576 }
1578 {
1580 {
1581 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1582 return false;
1583 }
1584
1586 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1587 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1588 {
1589 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1590 return false;
1591 }
1592 break;
1593 }
1595 {
1597 {
1598 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1599 return false;
1600 }
1601
1603 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1604 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1605 {
1606 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1607 return false;
1608 }
1609 break;
1610 }
1612 {
1614 {
1615 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1616 return false;
1617 }
1618
1620 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1621 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1622 {
1623 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1624 return false;
1625 }
1626 break;
1627 }
1629 {
1631 {
1632 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1633 return false;
1634 }
1635
1637 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1638 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1639 {
1640 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1641 return false;
1642 }
1643 break;
1644 }
1646 {
1648 {
1649 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1650 return false;
1651 }
1652
1654 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1655 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1656 {
1657 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1658 return false;
1659 }
1660 break;
1661 }
1663 {
1665 {
1666 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1667 return false;
1668 }
1669
1671 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1672 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1673 {
1674 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1675 return false;
1676 }
1677 break;
1678 }
1680 {
1682 {
1683 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1684 return false;
1685 }
1686
1688 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1689 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1690 {
1691 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1692 return false;
1693 }
1694 break;
1695 }
1697 {
1699 {
1700 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1701 return false;
1702 }
1703
1705 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1706 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1707 {
1708 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1709 return false;
1710 }
1711 break;
1712 }
1714 {
1715 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1716 if (!spellInfo)
1717 {
1718 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1719 return false;
1720 }
1721
1722 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1723 {
1724 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1725 return false;
1726 }
1727
1728 uint32 origGroup = cond->SourceGroup;
1729
1730 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1731 {
1732 if (!((1 << i) & cond->SourceGroup))
1733 continue;
1734
1735 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1736 {
1741 continue;
1742 default:
1743 break;
1744 }
1745
1746 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1747 {
1752 continue;
1753 default:
1754 break;
1755 }
1756
1757 switch (spellInfo->Effects[i].Effect)
1758 {
1766 continue;
1767 default:
1768 break;
1769 }
1770
1771 // Xinef: chain targets are treated as area targets! Apply conditions!
1772 if (spellInfo->Effects[i].ChainTarget > 1)
1773 continue;
1774
1775 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));
1776 cond->SourceGroup &= ~(1 << i);
1777 }
1778 // all effects were removed, no need to add the condition at all
1779 if (!cond->SourceGroup)
1780 return false;
1781 break;
1782 }
1784 {
1785 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1786 {
1787 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1788 return false;
1789 }
1790 break;
1791 }
1794 {
1795 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1796 if (!spellProto)
1797 {
1798 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1799 return false;
1800 }
1801 break;
1802 }
1804 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1805 {
1806 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1807 return false;
1808 }
1809 break;
1811 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1812 break;
1815 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1816 {
1817 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1818 return false;
1819 }
1820
1821 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1822 {
1823 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1824 return false;
1825 }
1826 break;
1828 {
1829 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1830 {
1831 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1832 return false;
1833 }
1834 if (cond->SourceEntry)
1835 {
1836 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1837 if (!itemTemplate)
1838 {
1839 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1840 return false;
1841 }
1842 }
1843 break;
1844 }
1846 {
1848 {
1849 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1850 return false;
1851 }
1852
1854 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1855 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1856 {
1857 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1858 return false;
1859 }
1860 break;
1861 }
1866 default:
1867 break;
1868 }
1869
1870 return true;
1871}
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition ConditionMgr.h:150
@ CONDITION_SOURCE_TYPE_PHASE
Definition ConditionMgr.h:151
@ CONDITION_SOURCE_TYPE_SPELL
Definition ConditionMgr.h:142
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition ConditionMgr.h:141
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition ConditionMgr.h:152
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_UNUSED_20
Definition ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition ConditionMgr.h:144
#define MAX_EFFECT_MASK
Definition DBCStructure.h:1638
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)
@ SPELL_EFFECT_APPLY_AREA_AURA_PARTY
Definition SharedDefines.h:824
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition SharedDefines.h:917
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition SharedDefines.h:908
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition SharedDefines.h:854
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition SharedDefines.h:816
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition SharedDefines.h:918
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition SharedDefines.h:932
@ 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
LootTemplate * GetLootForConditionFill(uint32 loot_id) const
Definition LootMgr.cpp:257
bool HaveLootFor(uint32 loot_id) const
Definition LootMgr.h:224
Definition LootMgr.h:245
bool isReference(uint32 id) const
Definition LootMgr.cpp:1951

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 ?

1076{
1077 uint32 oldMSTime = getMSTime();
1078
1079 Clean();
1080
1081 // must clear all custom handled cases (groupped types) before reload
1082 if (isReload)
1083 {
1084 LOG_INFO("server.loading", "Reseting Loot Conditions...");
1098
1099 LOG_INFO("server.loading", "Reloading `gossip_menu` Table for Conditions!");
1100 sObjectMgr->LoadGossipMenu();
1101
1102 LOG_INFO("server.loading", "Reloading `gossip_menu_option` Table for Conditions!");
1103 sObjectMgr->LoadGossipMenuItems();
1104 sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
1105 }
1106
1107 QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
1108 " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
1109
1110 if (!result)
1111 {
1112 LOG_WARN("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
1113 return;
1114 }
1115
1116 uint32 count = 0;
1117
1118 do
1119 {
1120 Field* fields = result->Fetch();
1121
1122 Condition* cond = new Condition();
1123 int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
1124 cond->SourceGroup = fields[1].Get<uint32>();
1125 cond->SourceEntry = fields[2].Get<int32>();
1126 cond->SourceId = fields[3].Get<int32>();
1127 cond->ElseGroup = fields[4].Get<uint32>();
1128 int32 iConditionTypeOrReference = fields[5].Get<int32>();
1129 cond->ConditionTarget = fields[6].Get<uint8>();
1130 cond->ConditionValue1 = fields[7].Get<uint32>();
1131 cond->ConditionValue2 = fields[8].Get<uint32>();
1132 cond->ConditionValue3 = fields[9].Get<uint32>();
1133 cond->NegativeCondition = fields[10].Get<uint8>();
1134 cond->ErrorType = fields[11].Get<uint32>();
1135 cond->ErrorTextId = fields[12].Get<uint32>();
1136 cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
1137
1138 if (iConditionTypeOrReference >= 0)
1139 cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1140
1141 if (iSourceTypeOrReferenceId >= 0)
1142 cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1143
1144 if (iConditionTypeOrReference < 0) // it has a reference
1145 {
1146 if (iConditionTypeOrReference == iSourceTypeOrReferenceId) // self referencing, skip
1147 {
1148 LOG_ERROR("sql.sql", "Condition reference {} is referencing self, skipped", iSourceTypeOrReferenceId);
1149 delete cond;
1150 continue;
1151 }
1152 cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference));
1153
1154 const char* rowType = "reference template";
1155 if (iSourceTypeOrReferenceId >= 0)
1156 rowType = "reference";
1157 // check for useless data
1158 if (cond->ConditionTarget)
1159 LOG_ERROR("sql.sql", "Condition {} {} has useless data in ConditionTarget ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1160 if (cond->ConditionValue1)
1161 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value1 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1162 if (cond->ConditionValue2)
1163 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value2 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1164 if (cond->ConditionValue3)
1165 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value3 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1166 if (cond->NegativeCondition)
1167 LOG_ERROR("sql.sql", "Condition {} {} has useless data in NegativeCondition ({})!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1168 if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1169 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceGroup ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1170 if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1171 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceEntry ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1172 }
1173 else if (!isConditionTypeValid(cond)) // doesn't have reference, validate ConditionType
1174 {
1175 delete cond;
1176 continue;
1177 }
1178
1179 if (iSourceTypeOrReferenceId < 0) // it is a reference template
1180 {
1181 uint32 uRefId = std::abs(iSourceTypeOrReferenceId);
1182 if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id
1183 {
1184 ConditionList mCondList;
1185 ConditionReferenceStore[uRefId] = mCondList;
1186 }
1187 ConditionReferenceStore[uRefId].push_back(cond); // add to reference storage
1188 count++;
1189 continue;
1190 } // end of reference templates
1191
1192 // if not a reference and SourceType is invalid, skip
1193 if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1194 {
1195 delete cond;
1196 continue;
1197 }
1198
1199 // Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1200 if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1201 {
1202 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceGroup = {}!", uint32(cond->SourceType), cond->SourceGroup);
1203 delete cond;
1204 continue;
1205 }
1206 if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1207 {
1208 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceId = {}!", uint32(cond->SourceType), cond->SourceId);
1209 delete cond;
1210 continue;
1211 }
1212
1213 if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1214 {
1215 LOG_ERROR("condition", "Condition type {} entry {} can't have ErrorType ({}), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
1216 cond->ErrorType = 0;
1217 }
1218
1219 if (cond->ErrorTextId && !cond->ErrorType)
1220 {
1221 LOG_ERROR("condition", "Condition type {} entry {} has any ErrorType, ErrorTextId ({}) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
1222 cond->ErrorTextId = 0;
1223 }
1224
1226 {
1227 bool valid = false;
1228 // handle grouped conditions
1229 switch (cond->SourceType)
1230 {
1233 break;
1236 break;
1239 break;
1242 break;
1245 break;
1248 break;
1251 break;
1254 break;
1257 break;
1260 break;
1263 break;
1266 break;
1268 valid = addToGossipMenus(cond);
1269 break;
1271 valid = addToGossipMenuItems(cond);
1272 break;
1274 {
1275 SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1276 valid = true;
1277 ++count;
1278 continue; // do not add to m_AllocatedMemory to avoid double deleting
1279 }
1282 break;
1284 {
1285 VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1286 valid = true;
1287 ++count;
1288 continue; // do not add to m_AllocatedMemory to avoid double deleting
1289 }
1291 {
1293 std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1294 SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1295 valid = true;
1296 ++count;
1297 continue;
1298 }
1300 {
1301 NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1302 valid = true;
1303 ++count;
1304 continue;
1305 }
1307 {
1309 break;
1310 }
1311 default:
1312 break;
1313 }
1314
1315 if (!valid)
1316 {
1317 LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup {}", cond->SourceGroup);
1318 delete cond;
1319 }
1320 else
1321 {
1322 AllocatedMemoryStore.push_back(cond);
1323 ++count;
1324 }
1325 continue;
1326 }
1327
1328 // handle not grouped conditions
1329 // make sure we have a storage list for our SourceType
1330 if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
1331 {
1332 ConditionTypeContainer mTypeMap;
1333 ConditionStore[cond->SourceType] = mTypeMap; // add new empty list for SourceType
1334 }
1335
1336 // make sure we have a condition list for our SourceType's entry
1337 if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
1338 {
1339 ConditionList mCondList;
1340 ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
1341 }
1342
1343 // add new Condition to storage based on Type/Entry
1344 ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1345 ++count;
1346 } while (result->NextRow());
1347
1348 LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1349 LOG_INFO("server.loading", " ");
1350}
ConditionSourceType
Definition ConditionMgr.h:124
ConditionTypes
Definition ConditionMgr.h:32
std::map< uint32, ConditionList > ConditionTypeContainer
Definition ConditionMgr.h:240
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::int32_t int32
Definition Define.h:103
#define LOG_INFO(filterType__,...)
Definition Log.h:166
#define LOG_WARN(filterType__,...)
Definition Log.h:162
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
bool isConditionTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1872
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:973
bool addToSpellImplicitTargetConditions(Condition *cond)
Definition ConditionMgr.cpp:1406
bool addToGossipMenus(Condition *cond)
Definition ConditionMgr.cpp:1367
bool addToGossipMenuItems(Condition *cond)
Definition ConditionMgr.cpp:1387
bool addToLootTemplate(Condition *cond, LootTemplate *loot)
Definition ConditionMgr.cpp:1352
bool isSourceTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1492
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:980
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
void ResetConditions()
Definition LootMgr.cpp:238
Definition ConditionMgr.h:197
uint32 ErrorType
Definition ConditionMgr.h:207
uint32 SourceId
Definition ConditionMgr.h:201
uint32 ElseGroup
Definition ConditionMgr.h:202
uint32 ScriptId
Definition ConditionMgr.h:210
bool NegativeCondition
Definition ConditionMgr.h:212
uint32 ReferenceId
Definition ConditionMgr.h:209
uint32 ErrorTextId
Definition ConditionMgr.h:208

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

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