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

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
794{
795 Clean();
796}
void Clean()
Definition: ConditionMgr.cpp:2449

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1332{
1333 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1334 if (pMenuItemBounds.first != pMenuItemBounds.second)
1335 {
1336 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1337 {
1338 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1339 {
1340 (*itr).second.Conditions.push_back(cond);
1341 return true;
1342 }
1343 }
1344 }
1345
1346 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1347 return false;
1348}
std::uint32_t uint32
Definition: Define.h:108
#define LOG_ERROR(filterType__,...)
Definition: Log.h:159
#define sObjectMgr
Definition: ObjectMgr.h:1640
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition: ObjectMgr.h:640
uint32 SourceGroup
Definition: ConditionMgr.h:196
int32 SourceEntry
Definition: ConditionMgr.h:197

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

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1312{
1313 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1314
1315 if (pMenuBounds.first != pMenuBounds.second)
1316 {
1317 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1318 {
1319 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1320 {
1321 (*itr).second.Conditions.push_back(cond);
1322 return true;
1323 }
1324 }
1325 }
1326
1327 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1328 return false;
1329}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition: ObjectMgr.h:637

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

Referenced by LoadConditions().

◆ addToLootTemplate()

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
)
private
1297{
1298 if (!loot)
1299 {
1300 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1301 return false;
1302 }
1303
1304 if (loot->addConditionItem(cond))
1305 return true;
1306
1307 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1308 return false;
1309}
bool addConditionItem(Condition *cond)
Definition: LootMgr.cpp:1843

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

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

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

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

Referenced by LoadConditions().

◆ CanHaveSourceGroupSet()

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

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

Referenced by LoadConditions().

◆ CanHaveSourceIdSet()

bool ConditionMgr::CanHaveSourceIdSet ( ConditionSourceType  sourceType) const
925{
926 return (sourceType == CONDITION_SOURCE_TYPE_SMART_EVENT);
927}

References CONDITION_SOURCE_TYPE_SMART_EVENT.

Referenced by LoadConditions().

◆ Clean()

void ConditionMgr::Clean ( )
private
2450{
2451 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2452 {
2453 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2454 itr->second.clear();
2455 }
2456
2458
2459 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2460 {
2461 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2462 {
2463 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2464 it->second.clear();
2465 }
2466 itr->second.clear();
2467 }
2468
2469 ConditionStore.clear();
2470
2471 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2472 {
2473 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2474 {
2475 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2476 it->second.clear();
2477 }
2478 itr->second.clear();
2479 }
2480
2482
2483 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2484 {
2485 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2486 {
2487 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2488 it->second.clear();
2489 }
2490 itr->second.clear();
2491 }
2492
2494
2495 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.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
2506
2507 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.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 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2520 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2521
2522 AllocatedMemoryStore.clear();
2523}
SmartEventConditionContainer SmartEventConditionStore
Definition: ConditionMgr.h:286
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition: ConditionMgr.h:284
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition: ConditionMgr.h:283
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition: ConditionMgr.h:285
ConditionContainer ConditionStore
Definition: ConditionMgr.h:281
ConditionReferenceContainer ConditionReferenceStore
Definition: ConditionMgr.h:282
std::list< Condition * > AllocatedMemoryStore
Definition: ConditionMgr.h:279

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

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

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
805{
806 ConditionList conditions;
807 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
808 if (ref != ConditionReferenceStore.end())
809 conditions = (*ref).second;
810 return conditions;
811}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
930{
931 ConditionList spellCond;
932 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
933 {
934 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
935 if (itr != ConditionStore.end())
936 {
937 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
938 if (i != (*itr).second.end())
939 {
940 spellCond = (*i).second;
941 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
942 }
943 }
944 }
945 return spellCond;
946}
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
@ CONDITION_SOURCE_TYPE_MAX
Definition: ConditionMgr.h:153
@ CONDITION_SOURCE_TYPE_NONE
Definition: ConditionMgr.h:122

References CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_NONE, ConditionStore, and LOG_DEBUG.

◆ GetConditionsForNpcVendorEvent()

ConditionList ConditionMgr::GetConditionsForNpcVendorEvent ( uint32  creatureId,
uint32  itemId 
)
997{
998 ConditionList cond;
999 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1000 if (itr != NpcVendorConditionContainerStore.end())
1001 {
1002 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1003 if (i != (*itr).second.end())
1004 {
1005 cond = (*i).second;
1006 if (itemId)
1007 {
1008 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1009 }
1010 else
1011 {
1012 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1013 }
1014 }
1015 }
1016 return cond;
1017}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
981{
982 ConditionList cond;
983 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
984 if (itr != SmartEventConditionStore.end())
985 {
986 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
987 if (i != (*itr).second.end())
988 {
989 cond = (*i).second;
990 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
991 }
992 }
993 return cond;
994}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
949{
950 ConditionList cond;
951 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
952 if (itr != SpellClickEventConditionStore.end())
953 {
954 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
955 if (i != (*itr).second.end())
956 {
957 cond = (*i).second;
958 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
959 }
960 }
961 return cond;
962}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

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

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

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

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
799{
800 static ConditionMgr instance;
801 return &instance;
802}
Definition: ConditionMgr.h:246
static ConditionMgr * instance()
Definition: ConditionMgr.cpp:798

References instance().

Referenced by instance().

◆ isConditionTypeValid()

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

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)

853{
854 // groupId, groupCheckPassed
855 std::map<uint32, bool> ElseGroupStore;
856 for (ConditionList::const_iterator i = conditions.begin(); i != conditions.end(); ++i)
857 {
858 LOG_DEBUG("condition", "ConditionMgr::IsPlayerMeetToConditionList condType: {} val1: {}", (*i)->ConditionType, (*i)->ConditionValue1);
859 if ((*i)->isLoaded())
860 {
862 std::map<uint32, bool>::const_iterator itr = ElseGroupStore.find((*i)->ElseGroup);
864 if (itr == ElseGroupStore.end())
865 ElseGroupStore[(*i)->ElseGroup] = true;
866 else if (!(*itr).second)
867 continue;
868
869 if ((*i)->ReferenceId) // handle reference
870 {
871 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find((*i)->ReferenceId);
872 if (ref != ConditionReferenceStore.end())
873 {
874 if (!IsObjectMeetToConditionList(sourceInfo, (*ref).second))
875 ElseGroupStore[(*i)->ElseGroup] = false;
876 }
877 else
878 {
879 LOG_DEBUG("condition", "IsPlayerMeetToConditionList: Reference template -{} not found", (*i)->ReferenceId);
880 }
881 }
882 else // handle normal condition
883 {
884 if (!(*i)->Meets(sourceInfo))
885 ElseGroupStore[(*i)->ElseGroup] = false;
886 }
887 }
888 }
889 for (std::map<uint32, bool>::const_iterator i = ElseGroupStore.begin(); i != ElseGroupStore.end(); ++i)
890 if (i->second)
891 return true;
892
893 return false;
894}
bool IsObjectMeetToConditionList(ConditionSourceInfo &sourceInfo, ConditionList const &conditions)
Definition: ConditionMgr.cpp:852

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
909{
910 if (conditions.empty())
911 return true;
912
913 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
914 return IsObjectMeetToConditionList(sourceInfo, conditions);
915}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
897{
899 return IsObjectMeetToConditions(srcInfo, conditions);
900}
Definition: ConditionMgr.h:181
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition: ConditionMgr.cpp:896

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
903{
904 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
905 return IsObjectMeetToConditions(srcInfo, conditions);
906}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1437{
1439 {
1440 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1441 return false;
1442 }
1443
1444 switch (cond->SourceType)
1445 {
1449 {
1450 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1451 return false;
1452 }
1454 {
1456 {
1457 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1458 return false;
1459 }
1460
1462 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1463 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1464 {
1465 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1466 return false;
1467 }
1468 break;
1469 }
1471 {
1473 {
1474 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1475 return false;
1476 }
1477
1479 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1480 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1481 {
1482 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1483 return false;
1484 }
1485 break;
1486 }
1488 {
1490 {
1491 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1492 return false;
1493 }
1494
1496 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1497 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1498 {
1499 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1500 return false;
1501 }
1502 break;
1503 }
1505 {
1507 {
1508 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1509 return false;
1510 }
1511
1513 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1514 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1515 {
1516 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1517 return false;
1518 }
1519 break;
1520 }
1522 {
1524 {
1525 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1526 return false;
1527 }
1528
1530 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1531 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1532 {
1533 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1534 return false;
1535 }
1536 break;
1537 }
1539 {
1541 {
1542 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1543 return false;
1544 }
1545
1547 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1548 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1549 {
1550 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1551 return false;
1552 }
1553 break;
1554 }
1556 {
1558 {
1559 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1560 return false;
1561 }
1562
1564 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1565 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1566 {
1567 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1568 return false;
1569 }
1570 break;
1571 }
1573 {
1575 {
1576 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1577 return false;
1578 }
1579
1581 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1582 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1583 {
1584 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1585 return false;
1586 }
1587 break;
1588 }
1590 {
1592 {
1593 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1594 return false;
1595 }
1596
1598 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1599 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1600 {
1601 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1602 return false;
1603 }
1604 break;
1605 }
1607 {
1609 {
1610 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1611 return false;
1612 }
1613
1615 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1616 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1617 {
1618 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1619 return false;
1620 }
1621 break;
1622 }
1624 {
1626 {
1627 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1628 return false;
1629 }
1630
1632 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1633 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1634 {
1635 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1636 return false;
1637 }
1638 break;
1639 }
1641 {
1643 {
1644 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1645 return false;
1646 }
1647
1649 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1650 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1651 {
1652 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1653 return false;
1654 }
1655 break;
1656 }
1658 {
1659 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1660 if (!spellInfo)
1661 {
1662 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1663 return false;
1664 }
1665
1666 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1667 {
1668 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1669 return false;
1670 }
1671
1672 uint32 origGroup = cond->SourceGroup;
1673
1674 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1675 {
1676 if (!((1 << i) & cond->SourceGroup))
1677 continue;
1678
1679 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1680 {
1685 continue;
1686 default:
1687 break;
1688 }
1689
1690 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1691 {
1696 continue;
1697 default:
1698 break;
1699 }
1700
1701 switch (spellInfo->Effects[i].Effect)
1702 {
1710 continue;
1711 default:
1712 break;
1713 }
1714
1715 // Xinef: chain targets are treated as area targets! Apply conditions!
1716 if (spellInfo->Effects[i].ChainTarget > 1)
1717 continue;
1718
1719 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));
1720 cond->SourceGroup &= ~(1 << i);
1721 }
1722 // all effects were removed, no need to add the condition at all
1723 if (!cond->SourceGroup)
1724 return false;
1725 break;
1726 }
1728 {
1729 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1730 {
1731 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1732 return false;
1733 }
1734 break;
1735 }
1738 {
1739 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1740 if (!spellProto)
1741 {
1742 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1743 return false;
1744 }
1745 break;
1746 }
1748 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1749 {
1750 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1751 return false;
1752 }
1753 break;
1755 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_UNUSED_20 is not in use. SourceEntry = ({}), skipped", cond->SourceEntry);
1756 break;
1759 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1760 {
1761 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1762 return false;
1763 }
1764
1765 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1766 {
1767 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1768 return false;
1769 }
1770 break;
1772 {
1773 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1774 {
1775 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1776 return false;
1777 }
1778 if (cond->SourceEntry)
1779 {
1780 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1781 if (!itemTemplate)
1782 {
1783 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1784 return false;
1785 }
1786 }
1787 break;
1788 }
1790 {
1792 {
1793 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1794 return false;
1795 }
1796
1798 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1799 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1800 {
1801 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1802 return false;
1803 }
1804 break;
1805 }
1810 default:
1811 break;
1812 }
1813
1814 return true;
1815}
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition: ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_PHASE
Definition: ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_SPELL
Definition: ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition: ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition: ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition: ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_UNUSED_20
Definition: ConditionMgr.h:142
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition: ConditionMgr.h:141
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false)
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)
LootStore LootTemplates_Reference("reference_loot_template", "reference id", false)
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true)
LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false)
LootStore LootTemplates_Player("player_loot_template", "team id", true)
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
@ TARGET_SELECT_CATEGORY_CONE
Definition: SpellInfo.h:81
@ TARGET_SELECT_CATEGORY_AREA
Definition: SpellInfo.h:82
@ TARGET_SELECT_CATEGORY_NEARBY
Definition: SpellInfo.h:80
@ TARGET_SELECT_CATEGORY_TRAJ
Definition: SpellInfo.h:83
#define MAX_EFFECT_MASK
Definition: DBCStructure.h:1611
@ SPELL_EFFECT_APPLY_AREA_AURA_PARTY
Definition: SharedDefines.h:785
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition: SharedDefines.h:878
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition: SharedDefines.h:869
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition: SharedDefines.h:815
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition: SharedDefines.h:777
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition: SharedDefines.h:879
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition: SharedDefines.h:893
LootTemplate * GetLootForConditionFill(uint32 loot_id) const
Definition: LootMgr.cpp:256
bool HaveLootFor(uint32 loot_id) const
Definition: LootMgr.h:224
Definition: LootMgr.h:245
bool isReference(uint32 id) const
Definition: LootMgr.cpp:1901

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 ?

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

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

Member Data Documentation

◆ AllocatedMemoryStore

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

Referenced by Clean(), and LoadConditions().

◆ ConditionReferenceStore

◆ ConditionStore

ConditionContainer ConditionMgr::ConditionStore
private

◆ NpcVendorConditionContainerStore

NpcVendorConditionContainer ConditionMgr::NpcVendorConditionContainerStore
private

◆ SmartEventConditionStore

SmartEventConditionContainer ConditionMgr::SmartEventConditionStore
private

◆ SpellClickEventConditionStore

CreatureSpellConditionContainer ConditionMgr::SpellClickEventConditionStore
private

◆ VehicleSpellConditionStore

CreatureSpellConditionContainer ConditionMgr::VehicleSpellConditionStore
private