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

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
817{
818 Clean();
819}
void Clean()
Definition: ConditionMgr.cpp:2472

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1355{
1356 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1357 if (pMenuItemBounds.first != pMenuItemBounds.second)
1358 {
1359 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1360 {
1361 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1362 {
1363 (*itr).second.Conditions.push_back(cond);
1364 return true;
1365 }
1366 }
1367 }
1368
1369 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1370 return false;
1371}
#define LOG_ERROR(filterType__,...)
Definition: Log.h:157
std::uint32_t uint32
Definition: Define.h:107
#define sObjectMgr
Definition: ObjectMgr.h:1635
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition: ObjectMgr.h:635
uint32 SourceGroup
Definition: ConditionMgr.h:197
int32 SourceEntry
Definition: ConditionMgr.h:198

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

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1335{
1336 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1337
1338 if (pMenuBounds.first != pMenuBounds.second)
1339 {
1340 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1341 {
1342 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1343 {
1344 (*itr).second.Conditions.push_back(cond);
1345 return true;
1346 }
1347 }
1348 }
1349
1350 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1351 return false;
1352}
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
1320{
1321 if (!loot)
1322 {
1323 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1324 return false;
1325 }
1326
1327 if (loot->addConditionItem(cond))
1328 return true;
1329
1330 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1331 return false;
1332}
bool addConditionItem(Condition *cond)
Definition: LootMgr.cpp:1892

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

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond)
private
1374{
1375 uint32 conditionEffMask = cond->SourceGroup;
1376 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1377 std::list<uint32> sharedMasks;
1378 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1379 {
1380 // check if effect is already a part of some shared mask
1381 bool found = false;
1382 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1383 {
1384 if ((1 << i) & *itr)
1385 {
1386 found = true;
1387 break;
1388 }
1389 }
1390 if (found)
1391 continue;
1392
1393 // build new shared mask with found effect
1394 uint32 sharedMask = (1 << i);
1395 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1396 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1397 {
1398 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1399 sharedMask |= 1 << effIndex;
1400 }
1401 sharedMasks.push_back(sharedMask);
1402 }
1403
1404 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1405 {
1406 // some effect indexes should have same data
1407 if (uint32 commonMask = *itr & conditionEffMask)
1408 {
1409 uint8 firstEffIndex = 0;
1410 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1411 if ((1 << firstEffIndex) & *itr)
1412 break;
1413
1414 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1415 return false;
1416
1417 // get shared data
1418 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1419
1420 // there's already data entry for that sharedMask
1421 if (sharedList)
1422 {
1423 // we have overlapping masks in db
1424 if (conditionEffMask != *itr)
1425 {
1426 LOG_ERROR("sql.sql",
1427 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1428 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1429 cond->SourceEntry, cond->SourceGroup);
1430 return false;
1431 }
1432 }
1433 // no data for shared mask, we can create new submask
1434 else
1435 {
1436 // add new list, create new shared mask
1437 sharedList = new ConditionList();
1438 bool assigned = false;
1439 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1440 {
1441 if ((1 << i) & commonMask)
1442 {
1443 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1444 assigned = true;
1445 }
1446 }
1447
1448 if (!assigned)
1449 delete sharedList;
1450 }
1451 if (sharedList)
1452 sharedList->push_back(cond);
1453 break;
1454 }
1455 }
1456 return true;
1457}
std::uint8_t uint8
Definition: Define.h:109
#define MAX_SPELL_EFFECTS
Definition: DBCStructure.h:1636
#define sSpellMgr
Definition: SpellMgr.h:825
std::list< Condition * > ConditionList
Definition: ConditionMgr.h:237
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
941{
945}
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition: ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE
Definition: ConditionMgr.h:125
@ CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE
Definition: ConditionMgr.h:133
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition: ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition: ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition: ConditionMgr.h:141
@ CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE
Definition: ConditionMgr.h:129
@ CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE
Definition: ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition: ConditionMgr.h:145
@ CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE
Definition: ConditionMgr.h:131
@ CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE
Definition: ConditionMgr.h:132
@ CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE
Definition: ConditionMgr.h:126
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition: ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE
Definition: ConditionMgr.h:128
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition: ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE
Definition: ConditionMgr.h:134
@ CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE
Definition: ConditionMgr.h:124
@ CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE
Definition: ConditionMgr.h:127
@ CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE
Definition: ConditionMgr.h:151
@ CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE
Definition: ConditionMgr.h:130

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
948{
949 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
950}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2473{
2474 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2475 {
2476 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2477 itr->second.clear();
2478 }
2479
2481
2482 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2483 {
2484 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2485 {
2486 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2487 it->second.clear();
2488 }
2489 itr->second.clear();
2490 }
2491
2492 ConditionStore.clear();
2493
2494 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2495 {
2496 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2497 {
2498 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2499 it->second.clear();
2500 }
2501 itr->second.clear();
2502 }
2503
2505
2506 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2507 {
2508 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2509 {
2510 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2511 it->second.clear();
2512 }
2513 itr->second.clear();
2514 }
2515
2517
2518 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2519 {
2520 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2521 {
2522 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2523 it->second.clear();
2524 }
2525 itr->second.clear();
2526 }
2527
2529
2530 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.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
2541
2542 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2543 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2544
2545 AllocatedMemoryStore.clear();
2546}
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:287
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition: ConditionMgr.h:285
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition: ConditionMgr.h:284
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition: ConditionMgr.h:286
ConditionContainer ConditionStore
Definition: ConditionMgr.h:282
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:283
std::list< Condition * > AllocatedMemoryStore
Definition: ConditionMgr.h:280

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

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

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
828{
829 ConditionList conditions;
830 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
831 if (ref != ConditionReferenceStore.end())
832 conditions = (*ref).second;
833 return conditions;
834}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
953{
954 ConditionList spellCond;
955 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
956 {
957 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
958 if (itr != ConditionStore.end())
959 {
960 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
961 if (i != (*itr).second.end())
962 {
963 spellCond = (*i).second;
964 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
965 }
966 }
967 }
968 return spellCond;
969}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:169
@ CONDITION_SOURCE_TYPE_MAX
Definition: ConditionMgr.h:154
@ CONDITION_SOURCE_TYPE_NONE
Definition: ConditionMgr.h:123

References CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_NONE, ConditionStore, and LOG_DEBUG.

◆ GetConditionsForNpcVendorEvent()

ConditionList ConditionMgr::GetConditionsForNpcVendorEvent ( uint32  creatureId,
uint32  itemId 
)
1020{
1021 ConditionList cond;
1022 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1023 if (itr != NpcVendorConditionContainerStore.end())
1024 {
1025 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1026 if (i != (*itr).second.end())
1027 {
1028 cond = (*i).second;
1029 if (itemId)
1030 {
1031 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1032 }
1033 else
1034 {
1035 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1036 }
1037 }
1038 }
1039 return cond;
1040}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
1004{
1005 ConditionList cond;
1006 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
1007 if (itr != SmartEventConditionStore.end())
1008 {
1009 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
1010 if (i != (*itr).second.end())
1011 {
1012 cond = (*i).second;
1013 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
1014 }
1015 }
1016 return cond;
1017}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
972{
973 ConditionList cond;
974 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
975 if (itr != SpellClickEventConditionStore.end())
976 {
977 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
978 if (i != (*itr).second.end())
979 {
980 cond = (*i).second;
981 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
982 }
983 }
984 return cond;
985}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

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

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

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

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
822{
823 static ConditionMgr instance;
824 return &instance;
825}
Definition: ConditionMgr.h:247
static ConditionMgr * instance()
Definition: ConditionMgr.cpp:821

References instance().

Referenced by instance().

◆ isConditionTypeValid()

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

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)

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

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
932{
933 if (conditions.empty())
934 return true;
935
936 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
937 return IsObjectMeetToConditionList(sourceInfo, conditions);
938}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
920{
922 return IsObjectMeetToConditions(srcInfo, conditions);
923}
Definition: ConditionMgr.h:182
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition: ConditionMgr.cpp:919

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
926{
927 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
928 return IsObjectMeetToConditions(srcInfo, conditions);
929}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1460{
1462 {
1463 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1464 return false;
1465 }
1466
1467 switch (cond->SourceType)
1468 {
1472 {
1473 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1474 return false;
1475 }
1477 {
1479 {
1480 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1481 return false;
1482 }
1483
1485 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1486 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1487 {
1488 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1489 return false;
1490 }
1491 break;
1492 }
1494 {
1496 {
1497 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1498 return false;
1499 }
1500
1502 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1503 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1504 {
1505 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1506 return false;
1507 }
1508 break;
1509 }
1511 {
1513 {
1514 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_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 `gameobject_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 `item_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 `mail_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 `milling_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 `pickpocketing_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 `prospecting_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 `reference_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 `skinning_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 `spell_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 {
1682 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1683 if (!spellInfo)
1684 {
1685 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1686 return false;
1687 }
1688
1689 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1690 {
1691 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1692 return false;
1693 }
1694
1695 uint32 origGroup = cond->SourceGroup;
1696
1697 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1698 {
1699 if (!((1 << i) & cond->SourceGroup))
1700 continue;
1701
1702 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1703 {
1708 continue;
1709 default:
1710 break;
1711 }
1712
1713 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1714 {
1719 continue;
1720 default:
1721 break;
1722 }
1723
1724 switch (spellInfo->Effects[i].Effect)
1725 {
1733 continue;
1734 default:
1735 break;
1736 }
1737
1738 // Xinef: chain targets are treated as area targets! Apply conditions!
1739 if (spellInfo->Effects[i].ChainTarget > 1)
1740 continue;
1741
1742 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));
1743 cond->SourceGroup &= ~(1 << i);
1744 }
1745 // all effects were removed, no need to add the condition at all
1746 if (!cond->SourceGroup)
1747 return false;
1748 break;
1749 }
1751 {
1752 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1753 {
1754 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1755 return false;
1756 }
1757 break;
1758 }
1761 {
1762 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1763 if (!spellProto)
1764 {
1765 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1766 return false;
1767 }
1768 break;
1769 }
1771 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1772 {
1773 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1774 return false;
1775 }
1776 break;
1778 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1779 break;
1782 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1783 {
1784 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1785 return false;
1786 }
1787
1788 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1789 {
1790 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1791 return false;
1792 }
1793 break;
1795 {
1796 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1797 {
1798 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1799 return false;
1800 }
1801 if (cond->SourceEntry)
1802 {
1803 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1804 if (!itemTemplate)
1805 {
1806 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1807 return false;
1808 }
1809 }
1810 break;
1811 }
1813 {
1815 {
1816 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1817 return false;
1818 }
1819
1821 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1822 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1823 {
1824 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1825 return false;
1826 }
1827 break;
1828 }
1833 default:
1834 break;
1835 }
1836
1837 return true;
1838}
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1637
@ SPELL_EFFECT_APPLY_AREA_AURA_PARTY
Definition: SharedDefines.h:813
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition: SharedDefines.h:906
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition: SharedDefines.h:897
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition: SharedDefines.h:843
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition: SharedDefines.h:805
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition: SharedDefines.h:907
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition: SharedDefines.h:921
@ 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
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)
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition: ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_PHASE
Definition: ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition: ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition: ConditionMgr.h:150
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_UNUSED_20
Definition: ConditionMgr.h:143
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition: ConditionMgr.h:142
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:1950

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 ?

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

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