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

◆ ~ConditionMgr()

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

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1389{
1390 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1391 if (pMenuItemBounds.first != pMenuItemBounds.second)
1392 {
1393 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1394 {
1395 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1396 {
1397 (*itr).second.Conditions.push_back(cond);
1398 return true;
1399 }
1400 }
1401 }
1402
1403 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1404 return false;
1405}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define sObjectMgr
Definition ObjectMgr.h:1712
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition ObjectMgr.h:638
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
1369{
1370 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1371
1372 if (pMenuBounds.first != pMenuBounds.second)
1373 {
1374 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1375 {
1376 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1377 {
1378 (*itr).second.Conditions.push_back(cond);
1379 return true;
1380 }
1381 }
1382 }
1383
1384 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1385 return false;
1386}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition ObjectMgr.h:635

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

Referenced by LoadConditions().

◆ addToLootTemplate()

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

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

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond)
private
1408{
1409 uint32 conditionEffMask = cond->SourceGroup;
1410 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1411 std::list<uint32> sharedMasks;
1412 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1413 {
1414 // check if effect is already a part of some shared mask
1415 bool found = false;
1416 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1417 {
1418 if ((1 << i) & *itr)
1419 {
1420 found = true;
1421 break;
1422 }
1423 }
1424 if (found)
1425 continue;
1426
1427 // build new shared mask with found effect
1428 uint32 sharedMask = (1 << i);
1429 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1430 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1431 {
1432 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1433 sharedMask |= 1 << effIndex;
1434 }
1435 sharedMasks.push_back(sharedMask);
1436 }
1437
1438 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1439 {
1440 // some effect indexes should have same data
1441 if (uint32 commonMask = *itr & conditionEffMask)
1442 {
1443 uint8 firstEffIndex = 0;
1444 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1445 if ((1 << firstEffIndex) & *itr)
1446 break;
1447
1448 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1449 return false;
1450
1451 // get shared data
1452 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1453
1454 // there's already data entry for that sharedMask
1455 if (sharedList)
1456 {
1457 // we have overlapping masks in db
1458 if (conditionEffMask != *itr)
1459 {
1460 LOG_ERROR("sql.sql",
1461 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1462 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1463 cond->SourceEntry, cond->SourceGroup);
1464 return false;
1465 }
1466 }
1467 // no data for shared mask, we can create new submask
1468 else
1469 {
1470 // add new list, create new shared mask
1471 sharedList = new ConditionList();
1472 bool assigned = false;
1473 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1474 {
1475 if ((1 << i) & commonMask)
1476 {
1477 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1478 assigned = true;
1479 }
1480 }
1481
1482 if (!assigned)
1483 delete sharedList;
1484 }
1485 if (sharedList)
1486 sharedList->push_back(cond);
1487 break;
1488 }
1489 }
1490 return true;
1491}
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:836
Definition SpellInfo.h:340
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417

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

Referenced by LoadConditions().

◆ CanHaveSourceGroupSet()

bool ConditionMgr::CanHaveSourceGroupSet ( ConditionSourceType  sourceType) const
975{
979}
@ 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
982{
983 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
984}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2521{
2522 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2523 {
2524 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2525 itr->second.clear();
2526 }
2527
2529
2530 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2531 {
2532 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2533 {
2534 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2535 it->second.clear();
2536 }
2537 itr->second.clear();
2538 }
2539
2540 ConditionStore.clear();
2541
2542 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2543 {
2544 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2545 {
2546 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2547 it->second.clear();
2548 }
2549 itr->second.clear();
2550 }
2551
2553
2554 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2555 {
2556 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2557 {
2558 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2559 it->second.clear();
2560 }
2561 itr->second.clear();
2562 }
2563
2565
2566 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2567 {
2568 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2569 {
2570 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2571 it->second.clear();
2572 }
2573 itr->second.clear();
2574 }
2575
2577
2578 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2579 {
2580 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2581 {
2582 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2583 it->second.clear();
2584 }
2585 itr->second.clear();
2586 }
2587
2589
2590 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2591 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2592
2593 AllocatedMemoryStore.clear();
2594}
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)
862{
863 ConditionList conditions;
864 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
865 if (ref != ConditionReferenceStore.end())
866 conditions = (*ref).second;
867 return conditions;
868}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
987{
988 ConditionList spellCond;
989 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
990 {
991 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
992 if (itr != ConditionStore.end())
993 {
994 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
995 if (i != (*itr).second.end())
996 {
997 spellCond = (*i).second;
998 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
999 }
1000 }
1001 }
1002 return spellCond;
1003}
@ 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 
)
1054{
1055 ConditionList cond;
1056 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1057 if (itr != NpcVendorConditionContainerStore.end())
1058 {
1059 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1060 if (i != (*itr).second.end())
1061 {
1062 cond = (*i).second;
1063 if (itemId)
1064 {
1065 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1066 }
1067 else
1068 {
1069 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1070 }
1071 }
1072 }
1073 return cond;
1074}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

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

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

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

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

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

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

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

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

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

References instance().

Referenced by instance().

◆ isConditionTypeValid()

bool ConditionMgr::isConditionTypeValid ( Condition cond)
1874{
1876 {
1877 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has an invalid ConditionType ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
1878 return false;
1879 }
1880 switch (cond->ConditionType)
1881 {
1883 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));
1884 return false;
1885 default:
1886 break;
1887 }
1888
1890 {
1891 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry);
1892 return false;
1893 }
1894
1895 switch (cond->ConditionType)
1896 {
1897 case CONDITION_AURA:
1898 {
1899 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
1900 {
1901 LOG_ERROR("sql.sql", "Aura condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
1902 return false;
1903 }
1904
1905 if (cond->ConditionValue2 > EFFECT_2)
1906 {
1907 LOG_ERROR("sql.sql", "Aura condition has non existing effect index ({}) (must be 0..2), skipped", cond->ConditionValue2);
1908 return false;
1909 }
1910 if (cond->ConditionValue3)
1911 LOG_ERROR("sql.sql", "Aura condition has useless data in value3 ({})!", cond->ConditionValue3);
1912 break;
1913 }
1914 case CONDITION_ITEM:
1915 {
1916 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1917 if (!proto)
1918 {
1919 LOG_ERROR("sql.sql", "Item condition has non existing item ({}), skipped", cond->ConditionValue1);
1920 return false;
1921 }
1922
1923 if (!cond->ConditionValue2)
1924 {
1925 LOG_ERROR("sql.sql", "Item condition has 0 set for item count in value2 ({}), skipped", cond->ConditionValue2);
1926 return false;
1927 }
1928 break;
1929 }
1931 {
1932 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
1933 if (!proto)
1934 {
1935 LOG_ERROR("sql.sql", "ItemEquipped condition has non existing item ({}), skipped", cond->ConditionValue1);
1936 return false;
1937 }
1938
1939 if (cond->ConditionValue2)
1940 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value2 ({})!", cond->ConditionValue2);
1941 if (cond->ConditionValue3)
1942 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value3 ({})!", cond->ConditionValue3);
1943 break;
1944 }
1945 case CONDITION_ZONEID:
1946 {
1947 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(cond->ConditionValue1);
1948 if (!areaEntry)
1949 {
1950 LOG_ERROR("sql.sql", "ZoneID condition has non existing area ({}), skipped", cond->ConditionValue1);
1951 return false;
1952 }
1953
1954 if (areaEntry->zone != 0)
1955 {
1956 LOG_ERROR("sql.sql", "ZoneID condition requires to be in area ({}) which is a subzone but zone expected, skipped", cond->ConditionValue1);
1957 return false;
1958 }
1959
1960 if (cond->ConditionValue2)
1961 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value2 ({})!", cond->ConditionValue2);
1962 if (cond->ConditionValue3)
1963 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value3 ({})!", cond->ConditionValue3);
1964 break;
1965 }
1967 {
1968 FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
1969 if (!factionEntry)
1970 {
1971 LOG_ERROR("sql.sql", "Reputation condition has non existing faction ({}), skipped", cond->ConditionValue1);
1972 return false;
1973 }
1974 if (cond->ConditionValue3)
1975 LOG_ERROR("sql.sql", "Reputation condition has useless data in value3 ({})!", cond->ConditionValue3);
1976 break;
1977 }
1978 case CONDITION_TEAM:
1979 {
1980 if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
1981 {
1982 LOG_ERROR("sql.sql", "Team condition specifies unknown team ({}), skipped", cond->ConditionValue1);
1983 return false;
1984 }
1985
1986 if (cond->ConditionValue2)
1987 LOG_ERROR("sql.sql", "Team condition has useless data in value2 ({})!", cond->ConditionValue2);
1988 if (cond->ConditionValue3)
1989 LOG_ERROR("sql.sql", "Team condition has useless data in value3 ({})!", cond->ConditionValue3);
1990 break;
1991 }
1992 case CONDITION_SKILL:
1993 {
1994 SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
1995 if (!pSkill)
1996 {
1997 LOG_ERROR("sql.sql", "Skill condition specifies non-existing skill ({}), skipped", cond->ConditionValue1);
1998 return false;
1999 }
2000
2001 if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
2002 {
2003 LOG_ERROR("sql.sql", "Skill condition specifies invalid skill value ({}), skipped", cond->ConditionValue2);
2004 return false;
2005 }
2006 if (cond->ConditionValue3)
2007 LOG_ERROR("sql.sql", "Skill condition has useless data in value3 ({})!", cond->ConditionValue3);
2008 break;
2009 }
2016 {
2017 if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
2018 {
2019 LOG_ERROR("sql.sql", "Quest condition specifies non-existing quest ({}), skipped", cond->ConditionValue1);
2020 return false;
2021 }
2022
2023 if (cond->ConditionValue2 > 1)
2024 {
2025 LOG_ERROR("sql.sql", "Quest condition has useless data in value2 ({})!", cond->ConditionValue2);
2026 }
2027 if (cond->ConditionValue3)
2028 {
2029 LOG_ERROR("sql.sql", "Quest condition has useless data in value3 ({})!", cond->ConditionValue3);
2030 }
2031 break;
2032 }
2034 if (cond->ConditionValue2 >= (1 << MAX_QUEST_STATUS))
2035 {
2036 LOG_ERROR("sql.sql", "ConditionType ({}) has invalid state mask ({}), skipped.", cond->ConditionType, cond->ConditionValue2);
2037 return false;
2038 }
2039 break;
2041 {
2042 GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
2043 if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
2044 {
2045 LOG_ERROR("sql.sql", "ActiveEvent condition has non existing event id ({}), skipped", cond->ConditionValue1);
2046 return false;
2047 }
2048
2049 if (cond->ConditionValue2)
2050 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value2 ({})!", cond->ConditionValue2);
2051 if (cond->ConditionValue3)
2052 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value3 ({})!", cond->ConditionValue3);
2053 break;
2054 }
2056 {
2057 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2058 if (!achievement)
2059 {
2060 LOG_ERROR("sql.sql", "Achivement condition has non existing achivement id ({}), skipped", cond->ConditionValue1);
2061 return false;
2062 }
2063
2064 if (cond->ConditionValue2)
2065 LOG_ERROR("sql.sql", "Achivement condition has useless data in value2 ({})!", cond->ConditionValue2);
2066 if (cond->ConditionValue3)
2067 LOG_ERROR("sql.sql", "Achivement condition has useless data in value3 ({})!", cond->ConditionValue3);
2068 break;
2069 }
2070 case CONDITION_CLASS:
2071 {
2073 {
2074 LOG_ERROR("sql.sql", "Class condition has non existing classmask ({}), skipped", cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
2075 return false;
2076 }
2077
2078 if (cond->ConditionValue2)
2079 LOG_ERROR("sql.sql", "Class condition has useless data in value2 ({})!", cond->ConditionValue2);
2080 if (cond->ConditionValue3)
2081 LOG_ERROR("sql.sql", "Class condition has useless data in value3 ({})!", cond->ConditionValue3);
2082 break;
2083 }
2084 case CONDITION_RACE:
2085 {
2086 if (!(cond->ConditionValue1 & sRaceMgr->GetPlayableRaceMask()))
2087 {
2088 LOG_ERROR("sql.sql", "Race condition has non existing racemask ({}), skipped", cond->ConditionValue1 & ~sRaceMgr->GetPlayableRaceMask());
2089 return false;
2090 }
2091
2092 if (cond->ConditionValue2)
2093 LOG_ERROR("sql.sql", "Race condition has useless data in value2 ({})!", cond->ConditionValue2);
2094 if (cond->ConditionValue3)
2095 LOG_ERROR("sql.sql", "Race condition has useless data in value3 ({})!", cond->ConditionValue3);
2096 break;
2097 }
2098 case CONDITION_GENDER:
2099 {
2101 {
2102 LOG_ERROR("condition", "Gender condition has invalid gender ({}), skipped", cond->ConditionValue1);
2103 return false;
2104 }
2105
2106 if (cond->ConditionValue2)
2107 LOG_ERROR("condition", "Gender condition has useless data in value2 ({})!", cond->ConditionValue2);
2108 if (cond->ConditionValue3)
2109 LOG_ERROR("condition", "Gender condition has useless data in value3 ({})!", cond->ConditionValue3);
2110 break;
2111 }
2112 case CONDITION_MAPID:
2113 {
2114 MapEntry const* mapId = sMapStore.LookupEntry(cond->ConditionValue1);
2115 if (!mapId)
2116 {
2117 LOG_ERROR("sql.sql", "Map condition has non existing map ({}), skipped", cond->ConditionValue1);
2118 return false;
2119 }
2120
2121 if (cond->ConditionValue2)
2122 LOG_ERROR("sql.sql", "Map condition has useless data in value2 ({})!", cond->ConditionValue2);
2123 if (cond->ConditionValue3)
2124 LOG_ERROR("sql.sql", "Map condition has useless data in value3 ({})!", cond->ConditionValue3);
2125 break;
2126 }
2127 case CONDITION_SPELL:
2128 {
2129 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
2130 {
2131 LOG_ERROR("sql.sql", "Spell condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
2132 return false;
2133 }
2134
2135 if (cond->ConditionValue2)
2136 LOG_ERROR("sql.sql", "Spell condition has useless data in value2 ({})!", cond->ConditionValue2);
2137 if (cond->ConditionValue3)
2138 LOG_ERROR("sql.sql", "Spell condition has useless data in value3 ({})!", cond->ConditionValue3);
2139 break;
2140 }
2141 case CONDITION_LEVEL:
2142 {
2143 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2144 {
2145 LOG_ERROR("sql.sql", "Level condition has invalid option ({}), skipped", cond->ConditionValue2);
2146 return false;
2147 }
2148 if (cond->ConditionValue3)
2149 LOG_ERROR("sql.sql", "Level condition has useless data in value3 ({})!", cond->ConditionValue3);
2150 break;
2151 }
2153 {
2154 if (cond->ConditionValue1 > DRUNKEN_SMASHED)
2155 {
2156 LOG_ERROR("sql.sql", "DrunkState condition has invalid state ({}), skipped", cond->ConditionValue1);
2157 return false;
2158 }
2159 if (cond->ConditionValue2)
2160 {
2161 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value2 ({})!", cond->ConditionValue2);
2162 return false;
2163 }
2164 if (cond->ConditionValue3)
2165 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value3 ({})!", cond->ConditionValue3);
2166 break;
2167 }
2169 {
2170 if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
2171 {
2172 LOG_ERROR("sql.sql", "NearCreature condition has non existing creature template entry ({}), skipped", cond->ConditionValue1);
2173 return false;
2174 }
2175 break;
2176 }
2178 {
2179 if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
2180 {
2181 LOG_ERROR("sql.sql", "NearGameObject condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue1);
2182 return false;
2183 }
2184 if (cond->ConditionValue3 > 2)
2185 LOG_ERROR("sql.sql", "NearGameObject condition for gameobject ID ({}) has data over 2 for value3 ({})!", cond->ConditionValue1, cond->ConditionValue3);
2186 break;
2187 }
2189 {
2190 switch (cond->ConditionValue1)
2191 {
2192 case TYPEID_UNIT:
2193 if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
2194 {
2195 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry ({}), skipped", cond->ConditionValue2);
2196 return false;
2197 }
2198 if (cond->ConditionValue3 > 1)
2199 {
2200 if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
2201 {
2202 if (cond->ConditionValue2 && creatureData->id1 != cond->ConditionValue2)
2203 {
2204 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match creature entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2205 return false;
2206 }
2207 }
2208 else
2209 {
2210 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid ({}), skipped", cond->ConditionValue3);
2211 return false;
2212 }
2213 }
2214 break;
2215 case TYPEID_GAMEOBJECT:
2216 if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
2217 {
2218 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue2);
2219 return false;
2220 }
2221 if (cond->ConditionValue3)
2222 {
2223 if (GameObjectData const* goData = sObjectMgr->GetGameObjectData(cond->ConditionValue3))
2224 {
2225 if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
2226 {
2227 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match gameobject entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2228 return false;
2229 }
2230 }
2231 else
2232 {
2233 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid ({}), skipped", cond->ConditionValue3);
2234 return false;
2235 }
2236 }
2237 break;
2238 case TYPEID_PLAYER:
2239 case TYPEID_CORPSE:
2240 if (cond->ConditionValue2)
2241 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 ({})!", cond->ConditionValue2);
2242 if (cond->ConditionValue3)
2243 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 ({})!", cond->ConditionValue3);
2244 break;
2245 default:
2246 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set ({}), skipped", cond->ConditionValue1);
2247 return false;
2248 }
2249 break;
2250 }
2252 {
2254 {
2255 LOG_ERROR("sql.sql", "TypeMask condition has invalid typemask set ({}), skipped", cond->ConditionValue2);
2256 return false;
2257 }
2258 if (cond->ConditionValue2)
2259 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value2 ({})!", cond->ConditionValue2);
2260 if (cond->ConditionValue3)
2261 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value3 ({})!", cond->ConditionValue3);
2262 break;
2263 }
2265 {
2267 {
2268 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2269 return false;
2270 }
2271 if (cond->ConditionValue1 == cond->ConditionTarget)
2272 {
2273 LOG_ERROR("sql.sql", "RelationTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2274 return false;
2275 }
2276 if (cond->ConditionValue2 >= RELATION_MAX)
2277 {
2278 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue2(RelationType) ({}), skipped", cond->ConditionValue2);
2279 return false;
2280 }
2281 if (cond->ConditionValue3)
2282 LOG_ERROR("sql.sql", "RelationTo condition has useless data in value3 ({})!", cond->ConditionValue3);
2283 break;
2284 }
2286 {
2288 {
2289 LOG_ERROR("sql.sql", "ReactionTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2290 return false;
2291 }
2292 if (cond->ConditionValue1 == cond->ConditionTarget)
2293 {
2294 LOG_ERROR("sql.sql", "ReactionTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2295 return false;
2296 }
2297 if (!cond->ConditionValue2)
2298 {
2299 LOG_ERROR("sql.sql", "mConditionValue2 condition has invalid ConditionValue2(rankMask) ({}), skipped", cond->ConditionValue2);
2300 return false;
2301 }
2302 break;
2303 }
2305 {
2307 {
2308 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2309 return false;
2310 }
2311 if (cond->ConditionValue1 == cond->ConditionTarget)
2312 {
2313 LOG_ERROR("sql.sql", "DistanceTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2314 return false;
2315 }
2316 if (cond->ConditionValue3 >= COMP_TYPE_MAX)
2317 {
2318 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ComparisionType ({}), skipped", cond->ConditionValue3);
2319 return false;
2320 }
2321 break;
2322 }
2323 case CONDITION_ALIVE:
2324 {
2325 if (cond->ConditionValue1)
2326 LOG_ERROR("sql.sql", "Alive condition has useless data in value1 ({})!", cond->ConditionValue1);
2327 if (cond->ConditionValue2)
2328 LOG_ERROR("sql.sql", "Alive condition has useless data in value2 ({})!", cond->ConditionValue2);
2329 if (cond->ConditionValue3)
2330 LOG_ERROR("sql.sql", "Alive condition has useless data in value3 ({})!", cond->ConditionValue3);
2331 break;
2332 }
2333 case CONDITION_HP_VAL:
2334 {
2335 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2336 {
2337 LOG_ERROR("sql.sql", "HpVal condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2338 return false;
2339 }
2340 if (cond->ConditionValue3)
2341 LOG_ERROR("sql.sql", "HpVal condition has useless data in value3 ({})!", cond->ConditionValue3);
2342 break;
2343 }
2344 case CONDITION_HP_PCT:
2345 {
2346 if (cond->ConditionValue1 > 100)
2347 {
2348 LOG_ERROR("sql.sql", "HpPct condition has too big percent value ({}), skipped", cond->ConditionValue1);
2349 return false;
2350 }
2351 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2352 {
2353 LOG_ERROR("sql.sql", "HpPct condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2354 return false;
2355 }
2356 if (cond->ConditionValue3)
2357 LOG_ERROR("sql.sql", "HpPct condition has useless data in value3 ({})!", cond->ConditionValue3);
2358 break;
2359 }
2360 case CONDITION_AREAID:
2362 break;
2364 {
2365 if (cond->ConditionValue3)
2366 LOG_ERROR("sql.sql", "World state condition has useless data in value3 ({})!", cond->ConditionValue3);
2367 break;
2368 }
2370 {
2371 if (cond->ConditionValue2)
2372 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value2 ({})!", cond->ConditionValue2);
2373 if (cond->ConditionValue3)
2374 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value3 ({})!", cond->ConditionValue3);
2375 break;
2376 }
2377 case CONDITION_TITLE:
2378 {
2379 CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
2380 if (!titleEntry)
2381 {
2382 LOG_ERROR("sql.sql", "Title condition has non existing title in value1 ({}), skipped", cond->ConditionValue1);
2383 return false;
2384 }
2385 break;
2386 }
2388 {
2390 {
2391 LOG_ERROR("condition", "SpawnMask condition has non existing SpawnMask in value1 ({}), skipped", cond->ConditionValue1);
2392 return false;
2393 }
2394 break;
2395 }
2397 {
2399 {
2400 LOG_ERROR("condition", "UnitState condition has non existing UnitState in value1 ({}), skipped", cond->ConditionValue1);
2401 return false;
2402 }
2403 break;
2404 }
2406 {
2408 {
2409 LOG_ERROR("condition", "CreatureType condition has non existing CreatureType in value1 ({}), skipped", cond->ConditionValue1);
2410 return false;
2411 }
2412 break;
2413 }
2415 {
2416 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2417 if (!achievement)
2418 {
2419 LOG_ERROR("condition", "CONDITION_REALM_ACHIEVEMENT has non existing realm first achivement id ({}), skipped.", cond->ConditionValue1);
2420 return false;
2421 }
2422 break;
2423 }
2425 {
2426 const Quest* quest = sObjectMgr->GetQuestTemplate(cond->ConditionValue1);
2427 if (!quest)
2428 {
2429 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS points to non-existing quest ({}), skipped.", cond->ConditionValue1);
2430 return false;
2431 }
2432
2433 if (cond->ConditionValue2 > 3)
2434 {
2435 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);
2436 return false;
2437 }
2438
2439 if (quest->RequiredNpcOrGo[cond->ConditionValue2] == 0)
2440 {
2441 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);
2442 return false;
2443 }
2444
2445 if (cond->ConditionValue3 > quest->RequiredNpcOrGoCount[cond->ConditionValue2])
2446 {
2447 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);
2448 return false;
2449 }
2450 break;
2451 }
2453 {
2455 {
2456 LOG_ERROR("sql.sql", "Has Aura Effect condition has non existing aura ({}), skipped", cond->ConditionValue1);
2457 return false;
2458 }
2459 break;
2460 }
2462 {
2463 bool valid = false;
2464 switch (cond->ConditionValue1)
2465 {
2466 case 0:
2468 break;
2469 case 1:
2470 valid = cond->ConditionValue2 <= 1;
2471 break;
2472 default:
2473 valid = false;
2474 break;
2475 }
2476 if (!valid)
2477 {
2478 LOG_ERROR("sql.sql", "CONDITION_STAND_STATE has non-existing stand state ({},{}), skipped.", cond->ConditionValue1, cond->ConditionValue2);
2479 return false;
2480 }
2481 break;
2482 }
2484 if (cond->ConditionValue1 >= MAX_DIFFICULTY)
2485 {
2486 LOG_ERROR("sql.sql", "CONDITION_DIFFICULTY_ID has non existing difficulty in value1 ({}), skipped.", cond->ConditionValue1);
2487 return false;
2488 }
2489 break;
2491 if (cond->ConditionValue1 > 1)
2492 {
2493 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value1 ({}).", cond->ConditionValue1);
2494 return false;
2495 }
2496 if (cond->ConditionValue2 >= MAX_DIFFICULTY)
2497 {
2498 LOG_ERROR("sql.sql", "RandomDungeon condition has invalid difficulty in value2 ({}).", cond->ConditionValue1);
2499 return false;
2500 }
2501 if (cond->ConditionValue3)
2502 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value3 ({}).", cond->ConditionValue3);
2503 break;
2504 case CONDITION_PET_TYPE:
2505 if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
2506 {
2507 LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type {}, skipped.", cond->ConditionValue1);
2508 return false;
2509 }
2510 break;
2511 case CONDITION_TAXI:
2512 case CONDITION_IN_WATER:
2513 case CONDITION_CHARMED:
2514 default:
2515 break;
2516 }
2517 return true;
2518}
@ 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:452
@ MAX_QUEST_STATUS
Definition QuestDef.h:107
#define sRaceMgr
Definition RaceMgr.h:52
@ EFFECT_2
Definition SharedDefines.h:33
@ CREATURE_TYPE_GAS_CLOUD
Definition SharedDefines.h:2636
@ ALLIANCE
Definition SharedDefines.h:756
@ HORDE
Definition SharedDefines.h:755
#define CLASSMASK_ALL_PLAYABLE
Definition SharedDefines.h:142
@ TOTAL_AURAS
Definition SpellAuraDefines.h:380
@ SPELL_AURA_NONE
Definition SpellAuraDefines.h:63
@ UNIT_STAND_STATE_SUBMERGED
Definition UnitDefines.h:44
@ UNIT_STATE_ALL_STATE_SUPPORTED
Definition UnitDefines.h:207
@ 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:1589
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:823
Definition CreatureData.h:370
Definition DBCStructure.h:907
Definition GameObjectData.h:715
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, RELATION_MAX, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, sAchievementStore, sAreaTableStore, sCharTitlesStore, sFactionStore, sGameEventMgr, sMapStore, sObjectMgr, Condition::SourceEntry, Condition::SourceType, SPAWNMASK_RAID_ALL, SPELL_AURA_NONE, sRaceMgr, 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)

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

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

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

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

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

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

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

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1494{
1496 {
1497 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1498 return false;
1499 }
1500
1501 switch (cond->SourceType)
1502 {
1506 {
1507 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1508 return false;
1509 }
1511 {
1513 {
1514 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1515 return false;
1516 }
1517
1519 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1520 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1521 {
1522 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1523 return false;
1524 }
1525 break;
1526 }
1528 {
1530 {
1531 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1532 return false;
1533 }
1534
1536 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1537 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1538 {
1539 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1540 return false;
1541 }
1542 break;
1543 }
1545 {
1547 {
1548 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1549 return false;
1550 }
1551
1553 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1554 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1555 {
1556 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1557 return false;
1558 }
1559 break;
1560 }
1562 {
1564 {
1565 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1566 return false;
1567 }
1568
1570 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1571 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1572 {
1573 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1574 return false;
1575 }
1576 break;
1577 }
1579 {
1581 {
1582 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1583 return false;
1584 }
1585
1587 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1588 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1589 {
1590 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1591 return false;
1592 }
1593 break;
1594 }
1596 {
1598 {
1599 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1600 return false;
1601 }
1602
1604 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1605 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1606 {
1607 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1608 return false;
1609 }
1610 break;
1611 }
1613 {
1615 {
1616 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1617 return false;
1618 }
1619
1621 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1622 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1623 {
1624 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1625 return false;
1626 }
1627 break;
1628 }
1630 {
1632 {
1633 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1634 return false;
1635 }
1636
1638 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1639 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1640 {
1641 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1642 return false;
1643 }
1644 break;
1645 }
1647 {
1649 {
1650 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1651 return false;
1652 }
1653
1655 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1656 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1657 {
1658 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1659 return false;
1660 }
1661 break;
1662 }
1664 {
1666 {
1667 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1668 return false;
1669 }
1670
1672 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1673 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1674 {
1675 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1676 return false;
1677 }
1678 break;
1679 }
1681 {
1683 {
1684 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1685 return false;
1686 }
1687
1689 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1690 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1691 {
1692 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1693 return false;
1694 }
1695 break;
1696 }
1698 {
1700 {
1701 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1702 return false;
1703 }
1704
1706 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1707 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1708 {
1709 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1710 return false;
1711 }
1712 break;
1713 }
1715 {
1716 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1717 if (!spellInfo)
1718 {
1719 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1720 return false;
1721 }
1722
1723 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1724 {
1725 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1726 return false;
1727 }
1728
1729 uint32 origGroup = cond->SourceGroup;
1730
1731 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1732 {
1733 if (!((1 << i) & cond->SourceGroup))
1734 continue;
1735
1736 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1737 {
1742 continue;
1743 default:
1744 break;
1745 }
1746
1747 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1748 {
1753 continue;
1754 default:
1755 break;
1756 }
1757
1758 switch (spellInfo->Effects[i].Effect)
1759 {
1767 continue;
1768 default:
1769 break;
1770 }
1771
1772 // Xinef: chain targets are treated as area targets! Apply conditions!
1773 if (spellInfo->Effects[i].ChainTarget > 1)
1774 continue;
1775
1776 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));
1777 cond->SourceGroup &= ~(1 << i);
1778 }
1779 // all effects were removed, no need to add the condition at all
1780 if (!cond->SourceGroup)
1781 return false;
1782 break;
1783 }
1785 {
1786 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1787 {
1788 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1789 return false;
1790 }
1791 break;
1792 }
1795 {
1796 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1797 if (!spellProto)
1798 {
1799 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1800 return false;
1801 }
1802 break;
1803 }
1805 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1806 {
1807 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1808 return false;
1809 }
1810 break;
1812 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1813 break;
1816 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1817 {
1818 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1819 return false;
1820 }
1821
1822 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1823 {
1824 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1825 return false;
1826 }
1827 break;
1829 {
1830 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1831 {
1832 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1833 return false;
1834 }
1835 if (cond->SourceEntry)
1836 {
1837 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1838 if (!itemTemplate)
1839 {
1840 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1841 return false;
1842 }
1843 }
1844 break;
1845 }
1847 {
1849 {
1850 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1851 return false;
1852 }
1853
1855 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1856 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1857 {
1858 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1859 return false;
1860 }
1861 break;
1862 }
1867 default:
1868 break;
1869 }
1870
1871 return true;
1872}
@ 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:801
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition SharedDefines.h:894
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition SharedDefines.h:885
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition SharedDefines.h:831
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition SharedDefines.h:793
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition SharedDefines.h:895
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition SharedDefines.h:909
@ TARGET_SELECT_CATEGORY_CONE
Definition SpellInfo.h:82
@ TARGET_SELECT_CATEGORY_AREA
Definition SpellInfo.h:83
@ TARGET_SELECT_CATEGORY_NEARBY
Definition SpellInfo.h:81
@ TARGET_SELECT_CATEGORY_TRAJ
Definition SpellInfo.h:84
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:1879

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 ?

1077{
1078 uint32 oldMSTime = getMSTime();
1079
1080 Clean();
1081
1082 // must clear all custom handled cases (groupped types) before reload
1083 if (isReload)
1084 {
1085 LOG_INFO("server.loading", "Reseting Loot Conditions...");
1099
1100 LOG_INFO("server.loading", "Reloading `gossip_menu` Table for Conditions!");
1101 sObjectMgr->LoadGossipMenu();
1102
1103 LOG_INFO("server.loading", "Reloading `gossip_menu_option` Table for Conditions!");
1104 sObjectMgr->LoadGossipMenuItems();
1105 sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
1106 }
1107
1108 QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
1109 " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
1110
1111 if (!result)
1112 {
1113 LOG_WARN("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
1114 return;
1115 }
1116
1117 uint32 count = 0;
1118
1119 do
1120 {
1121 Field* fields = result->Fetch();
1122
1123 Condition* cond = new Condition();
1124 int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
1125 cond->SourceGroup = fields[1].Get<uint32>();
1126 cond->SourceEntry = fields[2].Get<int32>();
1127 cond->SourceId = fields[3].Get<int32>();
1128 cond->ElseGroup = fields[4].Get<uint32>();
1129 int32 iConditionTypeOrReference = fields[5].Get<int32>();
1130 cond->ConditionTarget = fields[6].Get<uint8>();
1131 cond->ConditionValue1 = fields[7].Get<uint32>();
1132 cond->ConditionValue2 = fields[8].Get<uint32>();
1133 cond->ConditionValue3 = fields[9].Get<uint32>();
1134 cond->NegativeCondition = fields[10].Get<uint8>();
1135 cond->ErrorType = fields[11].Get<uint32>();
1136 cond->ErrorTextId = fields[12].Get<uint32>();
1137 cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
1138
1139 if (iConditionTypeOrReference >= 0)
1140 cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1141
1142 if (iSourceTypeOrReferenceId >= 0)
1143 cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1144
1145 if (iConditionTypeOrReference < 0) // it has a reference
1146 {
1147 if (iConditionTypeOrReference == iSourceTypeOrReferenceId) // self referencing, skip
1148 {
1149 LOG_ERROR("sql.sql", "Condition reference {} is referencing self, skipped", iSourceTypeOrReferenceId);
1150 delete cond;
1151 continue;
1152 }
1153 cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference));
1154
1155 const char* rowType = "reference template";
1156 if (iSourceTypeOrReferenceId >= 0)
1157 rowType = "reference";
1158 // check for useless data
1159 if (cond->ConditionTarget)
1160 LOG_ERROR("sql.sql", "Condition {} {} has useless data in ConditionTarget ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1161 if (cond->ConditionValue1)
1162 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value1 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1163 if (cond->ConditionValue2)
1164 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value2 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1165 if (cond->ConditionValue3)
1166 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value3 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1167 if (cond->NegativeCondition)
1168 LOG_ERROR("sql.sql", "Condition {} {} has useless data in NegativeCondition ({})!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1169 if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1170 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceGroup ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1171 if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1172 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceEntry ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1173 }
1174 else if (!isConditionTypeValid(cond)) // doesn't have reference, validate ConditionType
1175 {
1176 delete cond;
1177 continue;
1178 }
1179
1180 if (iSourceTypeOrReferenceId < 0) // it is a reference template
1181 {
1182 uint32 uRefId = std::abs(iSourceTypeOrReferenceId);
1183 if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id
1184 {
1185 ConditionList mCondList;
1186 ConditionReferenceStore[uRefId] = mCondList;
1187 }
1188 ConditionReferenceStore[uRefId].push_back(cond); // add to reference storage
1189 count++;
1190 continue;
1191 } // end of reference templates
1192
1193 // if not a reference and SourceType is invalid, skip
1194 if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1195 {
1196 delete cond;
1197 continue;
1198 }
1199
1200 // Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1201 if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1202 {
1203 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceGroup = {}!", uint32(cond->SourceType), cond->SourceGroup);
1204 delete cond;
1205 continue;
1206 }
1207 if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1208 {
1209 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceId = {}!", uint32(cond->SourceType), cond->SourceId);
1210 delete cond;
1211 continue;
1212 }
1213
1214 if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1215 {
1216 LOG_ERROR("condition", "Condition type {} entry {} can't have ErrorType ({}), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
1217 cond->ErrorType = 0;
1218 }
1219
1220 if (cond->ErrorTextId && !cond->ErrorType)
1221 {
1222 LOG_ERROR("condition", "Condition type {} entry {} has any ErrorType, ErrorTextId ({}) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
1223 cond->ErrorTextId = 0;
1224 }
1225
1227 {
1228 bool valid = false;
1229 // handle grouped conditions
1230 switch (cond->SourceType)
1231 {
1234 break;
1237 break;
1240 break;
1243 break;
1246 break;
1249 break;
1252 break;
1255 break;
1258 break;
1261 break;
1264 break;
1267 break;
1269 valid = addToGossipMenus(cond);
1270 break;
1272 valid = addToGossipMenuItems(cond);
1273 break;
1275 {
1276 SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1277 valid = true;
1278 ++count;
1279 continue; // do not add to m_AllocatedMemory to avoid double deleting
1280 }
1283 break;
1285 {
1286 VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1287 valid = true;
1288 ++count;
1289 continue; // do not add to m_AllocatedMemory to avoid double deleting
1290 }
1292 {
1294 std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1295 SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1296 valid = true;
1297 ++count;
1298 continue;
1299 }
1301 {
1302 NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1303 valid = true;
1304 ++count;
1305 continue;
1306 }
1308 {
1310 break;
1311 }
1312 default:
1313 break;
1314 }
1315
1316 if (!valid)
1317 {
1318 LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup {}", cond->SourceGroup);
1319 delete cond;
1320 }
1321 else
1322 {
1323 AllocatedMemoryStore.push_back(cond);
1324 ++count;
1325 }
1326 continue;
1327 }
1328
1329 // handle not grouped conditions
1330 // make sure we have a storage list for our SourceType
1331 if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
1332 {
1333 ConditionTypeContainer mTypeMap;
1334 ConditionStore[cond->SourceType] = mTypeMap; // add new empty list for SourceType
1335 }
1336
1337 // make sure we have a condition list for our SourceType's entry
1338 if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
1339 {
1340 ConditionList mCondList;
1341 ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
1342 }
1343
1344 // add new Condition to storage based on Type/Entry
1345 ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1346 ++count;
1347 } while (result->NextRow());
1348
1349 LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1350 LOG_INFO("server.loading", " ");
1351}
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:1873
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:974
bool addToSpellImplicitTargetConditions(Condition *cond)
Definition ConditionMgr.cpp:1407
bool addToGossipMenus(Condition *cond)
Definition ConditionMgr.cpp:1368
bool addToGossipMenuItems(Condition *cond)
Definition ConditionMgr.cpp:1388
bool addToLootTemplate(Condition *cond, LootTemplate *loot)
Definition ConditionMgr.cpp:1353
bool isSourceTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1493
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:981
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: