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

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
830{
831 Clean();
832}
void Clean()
Definition ConditionMgr.cpp:2485

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1368{
1369 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1370 if (pMenuItemBounds.first != pMenuItemBounds.second)
1371 {
1372 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1373 {
1374 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1375 {
1376 (*itr).second.Conditions.push_back(cond);
1377 return true;
1378 }
1379 }
1380 }
1381
1382 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1383 return false;
1384}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
#define sObjectMgr
Definition ObjectMgr.h:1650
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition ObjectMgr.h:635
uint32 SourceGroup
Definition ConditionMgr.h:198
int32 SourceEntry
Definition ConditionMgr.h:199

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

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1348{
1349 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1350
1351 if (pMenuBounds.first != pMenuBounds.second)
1352 {
1353 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1354 {
1355 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1356 {
1357 (*itr).second.Conditions.push_back(cond);
1358 return true;
1359 }
1360 }
1361 }
1362
1363 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1364 return false;
1365}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition ObjectMgr.h:632

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

Referenced by LoadConditions().

◆ addToLootTemplate()

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
)
private
1333{
1334 if (!loot)
1335 {
1336 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1337 return false;
1338 }
1339
1340 if (loot->addConditionItem(cond))
1341 return true;
1342
1343 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1344 return false;
1345}
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
1387{
1388 uint32 conditionEffMask = cond->SourceGroup;
1389 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1390 std::list<uint32> sharedMasks;
1391 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1392 {
1393 // check if effect is already a part of some shared mask
1394 bool found = false;
1395 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1396 {
1397 if ((1 << i) & *itr)
1398 {
1399 found = true;
1400 break;
1401 }
1402 }
1403 if (found)
1404 continue;
1405
1406 // build new shared mask with found effect
1407 uint32 sharedMask = (1 << i);
1408 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1409 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1410 {
1411 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1412 sharedMask |= 1 << effIndex;
1413 }
1414 sharedMasks.push_back(sharedMask);
1415 }
1416
1417 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1418 {
1419 // some effect indexes should have same data
1420 if (uint32 commonMask = *itr & conditionEffMask)
1421 {
1422 uint8 firstEffIndex = 0;
1423 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1424 if ((1 << firstEffIndex) & *itr)
1425 break;
1426
1427 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1428 return false;
1429
1430 // get shared data
1431 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1432
1433 // there's already data entry for that sharedMask
1434 if (sharedList)
1435 {
1436 // we have overlapping masks in db
1437 if (conditionEffMask != *itr)
1438 {
1439 LOG_ERROR("sql.sql",
1440 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1441 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1442 cond->SourceEntry, cond->SourceGroup);
1443 return false;
1444 }
1445 }
1446 // no data for shared mask, we can create new submask
1447 else
1448 {
1449 // add new list, create new shared mask
1450 sharedList = new ConditionList();
1451 bool assigned = false;
1452 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1453 {
1454 if ((1 << i) & commonMask)
1455 {
1456 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1457 assigned = true;
1458 }
1459 }
1460
1461 if (!assigned)
1462 delete sharedList;
1463 }
1464 if (sharedList)
1465 sharedList->push_back(cond);
1466 break;
1467 }
1468 }
1469 return true;
1470}
std::list< Condition * > ConditionList
Definition ConditionMgr.h:238
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1638
std::uint8_t uint8
Definition Define.h:109
#define sSpellMgr
Definition SpellMgr.h:825
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
954{
958}
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE
Definition ConditionMgr.h:126
@ CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE
Definition ConditionMgr.h:134
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition ConditionMgr.h:142
@ CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE
Definition ConditionMgr.h:130
@ CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE
Definition ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE
Definition ConditionMgr.h:132
@ CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE
Definition ConditionMgr.h:133
@ CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE
Definition ConditionMgr.h:127
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE
Definition ConditionMgr.h:129
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE
Definition ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE
Definition ConditionMgr.h:125
@ CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE
Definition ConditionMgr.h:128
@ CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE
Definition ConditionMgr.h:152
@ CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE
Definition ConditionMgr.h:131

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
961{
962 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
963}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2486{
2487 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2488 {
2489 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2490 itr->second.clear();
2491 }
2492
2494
2495 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2496 {
2497 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2498 {
2499 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2500 it->second.clear();
2501 }
2502 itr->second.clear();
2503 }
2504
2505 ConditionStore.clear();
2506
2507 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2508 {
2509 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2510 {
2511 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2512 it->second.clear();
2513 }
2514 itr->second.clear();
2515 }
2516
2518
2519 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2520 {
2521 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2522 {
2523 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2524 it->second.clear();
2525 }
2526 itr->second.clear();
2527 }
2528
2530
2531 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2532 {
2533 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2534 {
2535 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2536 it->second.clear();
2537 }
2538 itr->second.clear();
2539 }
2540
2542
2543 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2544 {
2545 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2546 {
2547 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2548 it->second.clear();
2549 }
2550 itr->second.clear();
2551 }
2552
2554
2555 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2556 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2557
2558 AllocatedMemoryStore.clear();
2559}
SmartEventConditionContainer SmartEventConditionStore
Definition ConditionMgr.h:288
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition ConditionMgr.h:286
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition ConditionMgr.h:285
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition ConditionMgr.h:287
ConditionContainer ConditionStore
Definition ConditionMgr.h:283
ConditionReferenceContainer ConditionReferenceStore
Definition ConditionMgr.h:284
std::list< Condition * > AllocatedMemoryStore
Definition ConditionMgr.h:281

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

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

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
841{
842 ConditionList conditions;
843 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
844 if (ref != ConditionReferenceStore.end())
845 conditions = (*ref).second;
846 return conditions;
847}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
966{
967 ConditionList spellCond;
968 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
969 {
970 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
971 if (itr != ConditionStore.end())
972 {
973 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
974 if (i != (*itr).second.end())
975 {
976 spellCond = (*i).second;
977 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
978 }
979 }
980 }
981 return spellCond;
982}
@ CONDITION_SOURCE_TYPE_MAX
Definition ConditionMgr.h:155
@ CONDITION_SOURCE_TYPE_NONE
Definition ConditionMgr.h:124
#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 
)
1033{
1034 ConditionList cond;
1035 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1036 if (itr != NpcVendorConditionContainerStore.end())
1037 {
1038 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1039 if (i != (*itr).second.end())
1040 {
1041 cond = (*i).second;
1042 if (itemId)
1043 {
1044 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1045 }
1046 else
1047 {
1048 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1049 }
1050 }
1051 }
1052 return cond;
1053}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
1017{
1018 ConditionList cond;
1019 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
1020 if (itr != SmartEventConditionStore.end())
1021 {
1022 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
1023 if (i != (*itr).second.end())
1024 {
1025 cond = (*i).second;
1026 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
1027 }
1028 }
1029 return cond;
1030}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
985{
986 ConditionList cond;
987 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
988 if (itr != SpellClickEventConditionStore.end())
989 {
990 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
991 if (i != (*itr).second.end())
992 {
993 cond = (*i).second;
994 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
995 }
996 }
997 return cond;
998}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

ConditionList ConditionMgr::GetConditionsForVehicleSpell ( uint32  creatureId,
uint32  spellId 
)
1001{
1002 ConditionList cond;
1003 CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
1004 if (itr != VehicleSpellConditionStore.end())
1005 {
1006 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
1007 if (i != (*itr).second.end())
1008 {
1009 cond = (*i).second;
1010 LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
1011 }
1012 }
1013 return cond;
1014}

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

uint32 ConditionMgr::GetSearcherTypeMaskForConditionList ( ConditionList const &  conditions)
850{
851 if (conditions.empty())
853 // groupId, typeMask
854 std::map<uint32, uint32> ElseGroupStore;
855 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
856 {
857 // no point of having not loaded conditions in list
858 ASSERT((*i)->isLoaded() && "ConditionMgr::GetSearcherTypeMaskForConditionList - not yet loaded condition found in list");
859 std::map<uint32, uint32>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
860 // group not filled yet, fill with widest mask possible
861 if (itr == ElseGroupStore.end())
862 ElseGroupStore[(*i)->ElseGroup] = GRID_MAP_TYPE_MASK_ALL;
863 // no point of checking anymore, empty mask
864 else if (!(*itr).second)
865 continue;
866
867 if ((*i)->ReferenceId) // handle reference
868 {
869 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
870 ASSERT(ref != ConditionReferenceStore.end() && "ConditionMgr::GetSearcherTypeMaskForConditionList - incorrect reference");
871 ElseGroupStore[(*i)->ElseGroup] &= GetSearcherTypeMaskForConditionList((*ref).second);
872 }
873 else // handle normal condition
874 {
875 // object will match conditions in one ElseGroupStore only when it matches all of them
876 // so, let's find a smallest possible mask which satisfies all conditions
877 ElseGroupStore[(*i)->ElseGroup] &= (*i)->GetSearcherTypeMaskForCondition();
878 }
879 }
880 // object will match condition when one of the checks in ElseGroupStore is matching
881 // so, let's include all possible masks
882 uint32 mask = 0;
883 for (std::map<uint32, uint32>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i) mask |= i->second;
884
885 return mask;
886}
#define ASSERT
Definition Errors.h:68
@ GRID_MAP_TYPE_MASK_ALL
Definition GridDefines.h:76
uint32 GetSearcherTypeMaskForConditionList(ConditionList const &conditions)
Definition ConditionMgr.cpp:849

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
835{
836 static ConditionMgr instance;
837 return &instance;
838}
Definition ConditionMgr.h:248
static ConditionMgr * instance()
Definition ConditionMgr.cpp:834

References instance().

Referenced by instance().

◆ isConditionTypeValid()

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

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

Referenced by LoadConditions().

◆ IsObjectMeetToConditionList()

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

Find ElseGroup in ElseGroupStore

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

889{
890 // groupId, groupCheckPassed
891 std::map<uint32, bool> ElseGroupStore;
892 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
893 {
894 LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList condType: {} val1: {}", (*i)->ConditionType, (*i)->ConditionValue1);
895 if ((*i)->isLoaded())
896 {
898 std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
900 if (itr == ElseGroupStore.end())
901 ElseGroupStore[(*i)->ElseGroup] = true;
902 else if (!(*itr).second)
903 continue;
904
905 if ((*i)->ReferenceId) // handle reference
906 {
907 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
908 if (ref != ConditionReferenceStore.end())
909 {
910 if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second))
911 ElseGroupStore[(*i)->ElseGroup] = false;
912 }
913 else
914 {
915 LOG_DEBUG("condition", "IsPlayerMeetToConditionList: Reference template -{} not found", (*i)->ReferenceId);
916 }
917 }
918 else // handle normal condition
919 {
920 if (!(*i)->Meets(sourceInfo))
921 ElseGroupStore[(*i)->ElseGroup] = false;
922 }
923 }
924 }
925 for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
926 if (i->second)
927 return true;
928
929 return false;
930}
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionList const &conditions)
Definition ConditionMgr.cpp:888

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
945{
946 if (conditions.empty())
947 return true;
948
949 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
950 return IsObjectMeetToConditionList(sourceInfo, conditions);
951}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
933{
935 return IsObjectMeetToConditions(srcInfo, conditions);
936}
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition ConditionMgr.cpp:932
Definition ConditionMgr.h:183

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
939{
940 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
941 return IsObjectMeetToConditions(srcInfo, conditions);
942}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1473{
1475 {
1476 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1477 return false;
1478 }
1479
1480 switch (cond->SourceType)
1481 {
1485 {
1486 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1487 return false;
1488 }
1490 {
1492 {
1493 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1494 return false;
1495 }
1496
1498 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1499 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1500 {
1501 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1502 return false;
1503 }
1504 break;
1505 }
1507 {
1509 {
1510 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1511 return false;
1512 }
1513
1515 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1516 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1517 {
1518 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1519 return false;
1520 }
1521 break;
1522 }
1524 {
1526 {
1527 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1528 return false;
1529 }
1530
1532 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1533 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1534 {
1535 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1536 return false;
1537 }
1538 break;
1539 }
1541 {
1543 {
1544 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1545 return false;
1546 }
1547
1549 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1550 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1551 {
1552 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1553 return false;
1554 }
1555 break;
1556 }
1558 {
1560 {
1561 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1562 return false;
1563 }
1564
1566 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1567 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1568 {
1569 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1570 return false;
1571 }
1572 break;
1573 }
1575 {
1577 {
1578 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1579 return false;
1580 }
1581
1583 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1584 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1585 {
1586 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1587 return false;
1588 }
1589 break;
1590 }
1592 {
1594 {
1595 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1596 return false;
1597 }
1598
1600 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1601 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1602 {
1603 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1604 return false;
1605 }
1606 break;
1607 }
1609 {
1611 {
1612 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1613 return false;
1614 }
1615
1617 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1618 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1619 {
1620 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1621 return false;
1622 }
1623 break;
1624 }
1626 {
1628 {
1629 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1630 return false;
1631 }
1632
1634 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1635 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1636 {
1637 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1638 return false;
1639 }
1640 break;
1641 }
1643 {
1645 {
1646 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1647 return false;
1648 }
1649
1651 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1652 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1653 {
1654 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1655 return false;
1656 }
1657 break;
1658 }
1660 {
1662 {
1663 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1664 return false;
1665 }
1666
1668 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1669 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1670 {
1671 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1672 return false;
1673 }
1674 break;
1675 }
1677 {
1679 {
1680 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1681 return false;
1682 }
1683
1685 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1686 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1687 {
1688 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1689 return false;
1690 }
1691 break;
1692 }
1694 {
1695 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1696 if (!spellInfo)
1697 {
1698 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1699 return false;
1700 }
1701
1702 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1703 {
1704 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1705 return false;
1706 }
1707
1708 uint32 origGroup = cond->SourceGroup;
1709
1710 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1711 {
1712 if (!((1 << i) & cond->SourceGroup))
1713 continue;
1714
1715 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1716 {
1721 continue;
1722 default:
1723 break;
1724 }
1725
1726 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1727 {
1732 continue;
1733 default:
1734 break;
1735 }
1736
1737 switch (spellInfo->Effects[i].Effect)
1738 {
1746 continue;
1747 default:
1748 break;
1749 }
1750
1751 // Xinef: chain targets are treated as area targets! Apply conditions!
1752 if (spellInfo->Effects[i].ChainTarget > 1)
1753 continue;
1754
1755 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));
1756 cond->SourceGroup &= ~(1 << i);
1757 }
1758 // all effects were removed, no need to add the condition at all
1759 if (!cond->SourceGroup)
1760 return false;
1761 break;
1762 }
1764 {
1765 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1766 {
1767 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1768 return false;
1769 }
1770 break;
1771 }
1774 {
1775 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1776 if (!spellProto)
1777 {
1778 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1779 return false;
1780 }
1781 break;
1782 }
1784 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1785 {
1786 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1787 return false;
1788 }
1789 break;
1791 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1792 break;
1795 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1796 {
1797 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1798 return false;
1799 }
1800
1801 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1802 {
1803 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1804 return false;
1805 }
1806 break;
1808 {
1809 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1810 {
1811 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1812 return false;
1813 }
1814 if (cond->SourceEntry)
1815 {
1816 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1817 if (!itemTemplate)
1818 {
1819 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1820 return false;
1821 }
1822 }
1823 break;
1824 }
1826 {
1828 {
1829 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1830 return false;
1831 }
1832
1834 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1835 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1836 {
1837 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1838 return false;
1839 }
1840 break;
1841 }
1846 default:
1847 break;
1848 }
1849
1850 return true;
1851}
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_PHASE
Definition ConditionMgr.h:150
@ CONDITION_SOURCE_TYPE_SPELL
Definition ConditionMgr.h:141
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition ConditionMgr.h:151
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_UNUSED_20
Definition ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition ConditionMgr.h:143
#define MAX_EFFECT_MASK
Definition DBCStructure.h:1639
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 ?

1056{
1057 uint32 oldMSTime = getMSTime();
1058
1059 Clean();
1060
1061 // must clear all custom handled cases (groupped types) before reload
1062 if (isReload)
1063 {
1064 LOG_INFO("server.loading", "Reseting Loot Conditions...");
1078
1079 LOG_INFO("server.loading", "Reloading `gossip_menu` Table for Conditions!");
1080 sObjectMgr->LoadGossipMenu();
1081
1082 LOG_INFO("server.loading", "Reloading `gossip_menu_option` Table for Conditions!");
1083 sObjectMgr->LoadGossipMenuItems();
1084 sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
1085 }
1086
1087 QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
1088 " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
1089
1090 if (!result)
1091 {
1092 LOG_WARN("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
1093 return;
1094 }
1095
1096 uint32 count = 0;
1097
1098 do
1099 {
1100 Field* fields = result->Fetch();
1101
1102 Condition* cond = new Condition();
1103 int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
1104 cond->SourceGroup = fields[1].Get<uint32>();
1105 cond->SourceEntry = fields[2].Get<int32>();
1106 cond->SourceId = fields[3].Get<int32>();
1107 cond->ElseGroup = fields[4].Get<uint32>();
1108 int32 iConditionTypeOrReference = fields[5].Get<int32>();
1109 cond->ConditionTarget = fields[6].Get<uint8>();
1110 cond->ConditionValue1 = fields[7].Get<uint32>();
1111 cond->ConditionValue2 = fields[8].Get<uint32>();
1112 cond->ConditionValue3 = fields[9].Get<uint32>();
1113 cond->NegativeCondition = fields[10].Get<uint8>();
1114 cond->ErrorType = fields[11].Get<uint32>();
1115 cond->ErrorTextId = fields[12].Get<uint32>();
1116 cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
1117
1118 if (iConditionTypeOrReference >= 0)
1119 cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1120
1121 if (iSourceTypeOrReferenceId >= 0)
1122 cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1123
1124 if (iConditionTypeOrReference < 0) // it has a reference
1125 {
1126 if (iConditionTypeOrReference == iSourceTypeOrReferenceId) // self referencing, skip
1127 {
1128 LOG_ERROR("sql.sql", "Condition reference {} is referencing self, skipped", iSourceTypeOrReferenceId);
1129 delete cond;
1130 continue;
1131 }
1132 cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference));
1133
1134 const char* rowType = "reference template";
1135 if (iSourceTypeOrReferenceId >= 0)
1136 rowType = "reference";
1137 // check for useless data
1138 if (cond->ConditionTarget)
1139 LOG_ERROR("sql.sql", "Condition {} {} has useless data in ConditionTarget ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1140 if (cond->ConditionValue1)
1141 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value1 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1142 if (cond->ConditionValue2)
1143 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value2 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1144 if (cond->ConditionValue3)
1145 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value3 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1146 if (cond->NegativeCondition)
1147 LOG_ERROR("sql.sql", "Condition {} {} has useless data in NegativeCondition ({})!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1148 if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1149 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceGroup ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1150 if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1151 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceEntry ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1152 }
1153 else if (!isConditionTypeValid(cond)) // doesn't have reference, validate ConditionType
1154 {
1155 delete cond;
1156 continue;
1157 }
1158
1159 if (iSourceTypeOrReferenceId < 0) // it is a reference template
1160 {
1161 uint32 uRefId = std::abs(iSourceTypeOrReferenceId);
1162 if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id
1163 {
1164 ConditionList mCondList;
1165 ConditionReferenceStore[uRefId] = mCondList;
1166 }
1167 ConditionReferenceStore[uRefId].push_back(cond); // add to reference storage
1168 count++;
1169 continue;
1170 } // end of reference templates
1171
1172 // if not a reference and SourceType is invalid, skip
1173 if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1174 {
1175 delete cond;
1176 continue;
1177 }
1178
1179 // Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1180 if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1181 {
1182 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceGroup = {}!", uint32(cond->SourceType), cond->SourceGroup);
1183 delete cond;
1184 continue;
1185 }
1186 if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1187 {
1188 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceId = {}!", uint32(cond->SourceType), cond->SourceId);
1189 delete cond;
1190 continue;
1191 }
1192
1193 if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1194 {
1195 LOG_ERROR("condition", "Condition type {} entry {} can't have ErrorType ({}), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
1196 cond->ErrorType = 0;
1197 }
1198
1199 if (cond->ErrorTextId && !cond->ErrorType)
1200 {
1201 LOG_ERROR("condition", "Condition type {} entry {} has any ErrorType, ErrorTextId ({}) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
1202 cond->ErrorTextId = 0;
1203 }
1204
1206 {
1207 bool valid = false;
1208 // handle grouped conditions
1209 switch (cond->SourceType)
1210 {
1213 break;
1216 break;
1219 break;
1222 break;
1225 break;
1228 break;
1231 break;
1234 break;
1237 break;
1240 break;
1243 break;
1246 break;
1248 valid = addToGossipMenus(cond);
1249 break;
1251 valid = addToGossipMenuItems(cond);
1252 break;
1254 {
1255 SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1256 valid = true;
1257 ++count;
1258 continue; // do not add to m_AllocatedMemory to avoid double deleting
1259 }
1262 break;
1264 {
1265 VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1266 valid = true;
1267 ++count;
1268 continue; // do not add to m_AllocatedMemory to avoid double deleting
1269 }
1271 {
1273 std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1274 SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1275 valid = true;
1276 ++count;
1277 continue;
1278 }
1280 {
1281 NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1282 valid = true;
1283 ++count;
1284 continue;
1285 }
1287 {
1289 break;
1290 }
1291 default:
1292 break;
1293 }
1294
1295 if (!valid)
1296 {
1297 LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup {}", cond->SourceGroup);
1298 delete cond;
1299 }
1300 else
1301 {
1302 AllocatedMemoryStore.push_back(cond);
1303 ++count;
1304 }
1305 continue;
1306 }
1307
1308 // handle not grouped conditions
1309 // make sure we have a storage list for our SourceType
1310 if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
1311 {
1312 ConditionTypeContainer mTypeMap;
1313 ConditionStore[cond->SourceType] = mTypeMap; // add new empty list for SourceType
1314 }
1315
1316 // make sure we have a condition list for our SourceType's entry
1317 if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
1318 {
1319 ConditionList mCondList;
1320 ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
1321 }
1322
1323 // add new Condition to storage based on Type/Entry
1324 ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1325 ++count;
1326 } while (result->NextRow());
1327
1328 LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1329 LOG_INFO("server.loading", " ");
1330}
ConditionSourceType
Definition ConditionMgr.h:123
ConditionTypes
Definition ConditionMgr.h:32
std::map< uint32, ConditionList > ConditionTypeContainer
Definition ConditionMgr.h:239
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:1852
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:953
bool addToSpellImplicitTargetConditions(Condition *cond)
Definition ConditionMgr.cpp:1386
bool addToGossipMenus(Condition *cond)
Definition ConditionMgr.cpp:1347
bool addToGossipMenuItems(Condition *cond)
Definition ConditionMgr.cpp:1367
bool addToLootTemplate(Condition *cond, LootTemplate *loot)
Definition ConditionMgr.cpp:1332
bool isSourceTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1472
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:960
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:196
uint32 ErrorType
Definition ConditionMgr.h:206
uint32 SourceId
Definition ConditionMgr.h:200
uint32 ElseGroup
Definition ConditionMgr.h:201
uint32 ScriptId
Definition ConditionMgr.h:209
bool NegativeCondition
Definition ConditionMgr.h:211
uint32 ReferenceId
Definition ConditionMgr.h:208
uint32 ErrorTextId
Definition ConditionMgr.h:207

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: