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)
 
ConditionList GetConditionsForObjectVisibility (const WorldObject *object) const
 

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
 
ObjectVisibilityConditionContainer ObjectVisibilityConditionStore
 

Detailed Description

Constructor & Destructor Documentation

◆ ConditionMgr()

ConditionMgr::ConditionMgr ( )
private
858{}

◆ ~ConditionMgr()

ConditionMgr::~ConditionMgr ( )
private
861{
862 Clean();
863}
void Clean()
Definition ConditionMgr.cpp:2644

References Clean().

Member Function Documentation

◆ addToGossipMenuItems()

bool ConditionMgr::addToGossipMenuItems ( Condition cond)
private
1444{
1445 GossipMenuItemsMapBoundsNonConst pMenuItemBounds = sObjectMgr->GetGossipMenuItemsMapBoundsNonConst(cond->SourceGroup);
1446 if (pMenuItemBounds.first != pMenuItemBounds.second)
1447 {
1448 for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
1449 {
1450 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.OptionID == uint32(cond->SourceEntry))
1451 {
1452 (*itr).second.Conditions.push_back(cond);
1453 return true;
1454 }
1455 }
1456 }
1457
1458 LOG_ERROR("sql.sql", "addToGossipMenuItems: GossipMenuId {} Item {} not found", cond->SourceGroup, cond->SourceEntry);
1459 return false;
1460}
std::uint32_t uint32
Definition Define.h:107
#define LOG_ERROR(filterType__,...)
Definition Log.h:145
#define sObjectMgr
Definition ObjectMgr.h:1723
std::pair< GossipMenuItemsContainer::iterator, GossipMenuItemsContainer::iterator > GossipMenuItemsMapBoundsNonConst
Definition ObjectMgr.h:639
uint32 SourceGroup
Definition ConditionMgr.h:200
int32 SourceEntry
Definition ConditionMgr.h:201

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

Referenced by LoadConditions().

◆ addToGossipMenus()

bool ConditionMgr::addToGossipMenus ( Condition cond)
private
1424{
1425 GossipMenusMapBoundsNonConst pMenuBounds = sObjectMgr->GetGossipMenusMapBoundsNonConst(cond->SourceGroup);
1426
1427 if (pMenuBounds.first != pMenuBounds.second)
1428 {
1429 for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
1430 {
1431 if ((*itr).second.MenuID == cond->SourceGroup && (*itr).second.TextID == uint32(cond->SourceEntry))
1432 {
1433 (*itr).second.Conditions.push_back(cond);
1434 return true;
1435 }
1436 }
1437 }
1438
1439 LOG_ERROR("sql.sql", "addToGossipMenus: GossipMenu {} not found", cond->SourceGroup);
1440 return false;
1441}
std::pair< GossipMenusContainer::iterator, GossipMenusContainer::iterator > GossipMenusMapBoundsNonConst
Definition ObjectMgr.h:636

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

Referenced by LoadConditions().

◆ addToLootTemplate()

bool ConditionMgr::addToLootTemplate ( Condition cond,
LootTemplate loot 
)
private
1409{
1410 if (!loot)
1411 {
1412 LOG_ERROR("sql.sql", "ConditionMgr: LootTemplate {} not found", cond->SourceGroup);
1413 return false;
1414 }
1415
1416 if (loot->addConditionItem(cond))
1417 return true;
1418
1419 LOG_ERROR("sql.sql", "ConditionMgr: Item {} not found in LootTemplate {}", cond->SourceEntry, cond->SourceGroup);
1420 return false;
1421}
bool addConditionItem(Condition *cond)
Definition LootMgr.cpp:1839

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

Referenced by LoadConditions().

◆ addToSpellImplicitTargetConditions()

bool ConditionMgr::addToSpellImplicitTargetConditions ( Condition cond)
private
1463{
1464 uint32 conditionEffMask = cond->SourceGroup;
1465 SpellInfo* spellInfo = const_cast<SpellInfo*>(sSpellMgr->AssertSpellInfo(cond->SourceEntry));
1466 std::list<uint32> sharedMasks;
1467 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1468 {
1469 // check if effect is already a part of some shared mask
1470 bool found = false;
1471 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1472 {
1473 if ((1 << i) & *itr)
1474 {
1475 found = true;
1476 break;
1477 }
1478 }
1479 if (found)
1480 continue;
1481
1482 // build new shared mask with found effect
1483 uint32 sharedMask = (1 << i);
1484 ConditionList* cmp = spellInfo->Effects[i].ImplicitTargetConditions;
1485 for (uint8 effIndex = i + 1; effIndex < MAX_SPELL_EFFECTS; ++effIndex)
1486 {
1487 if (spellInfo->Effects[effIndex].ImplicitTargetConditions == cmp)
1488 sharedMask |= 1 << effIndex;
1489 }
1490 sharedMasks.push_back(sharedMask);
1491 }
1492
1493 for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr)
1494 {
1495 // some effect indexes should have same data
1496 if (uint32 commonMask = *itr & conditionEffMask)
1497 {
1498 uint8 firstEffIndex = 0;
1499 for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex)
1500 if ((1 << firstEffIndex) & *itr)
1501 break;
1502
1503 if (firstEffIndex >= MAX_SPELL_EFFECTS)
1504 return false;
1505
1506 // get shared data
1507 ConditionList* sharedList = spellInfo->Effects[firstEffIndex].ImplicitTargetConditions;
1508
1509 // there's already data entry for that sharedMask
1510 if (sharedList)
1511 {
1512 // we have overlapping masks in db
1513 if (conditionEffMask != *itr)
1514 {
1515 LOG_ERROR("sql.sql",
1516 "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set - "
1517 "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.",
1518 cond->SourceEntry, cond->SourceGroup);
1519 return false;
1520 }
1521 }
1522 // no data for shared mask, we can create new submask
1523 else
1524 {
1525 // add new list, create new shared mask
1526 sharedList = new ConditionList();
1527 bool assigned = false;
1528 for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)
1529 {
1530 if ((1 << i) & commonMask)
1531 {
1532 spellInfo->Effects[i].ImplicitTargetConditions = sharedList;
1533 assigned = true;
1534 }
1535 }
1536
1537 if (!assigned)
1538 delete sharedList;
1539 }
1540 if (sharedList)
1541 sharedList->push_back(cond);
1542 break;
1543 }
1544 }
1545 return true;
1546}
std::list< Condition * > ConditionList
Definition ConditionMgr.h:240
#define MAX_SPELL_EFFECTS
Definition DBCStructure.h:1637
std::uint8_t uint8
Definition Define.h:109
#define sSpellMgr
Definition SpellMgr.h:836
Definition SpellInfo.h:340
std::array< SpellEffectInfo, MAX_SPELL_EFFECTS > Effects
Definition SpellInfo.h:417

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

Referenced by LoadConditions().

◆ CanHaveSourceGroupSet()

bool ConditionMgr::CanHaveSourceGroupSet ( ConditionSourceType  sourceType) const
985{
989}
@ CONDITION_SOURCE_TYPE_VEHICLE_SPELL
Definition ConditionMgr.h:147
@ CONDITION_SOURCE_TYPE_DISENCHANT_LOOT_TEMPLATE
Definition ConditionMgr.h:128
@ CONDITION_SOURCE_TYPE_REFERENCE_LOOT_TEMPLATE
Definition ConditionMgr.h:136
@ CONDITION_SOURCE_TYPE_NPC_VENDOR
Definition ConditionMgr.h:149
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION
Definition ConditionMgr.h:141
@ CONDITION_SOURCE_TYPE_SPELL_CLICK_EVENT
Definition ConditionMgr.h:144
@ CONDITION_SOURCE_TYPE_MAIL_LOOT_TEMPLATE
Definition ConditionMgr.h:132
@ CONDITION_SOURCE_TYPE_SPELL_LOOT_TEMPLATE
Definition ConditionMgr.h:138
@ CONDITION_SOURCE_TYPE_SMART_EVENT
Definition ConditionMgr.h:148
@ CONDITION_SOURCE_TYPE_PICKPOCKETING_LOOT_TEMPLATE
Definition ConditionMgr.h:134
@ CONDITION_SOURCE_TYPE_PROSPECTING_LOOT_TEMPLATE
Definition ConditionMgr.h:135
@ CONDITION_SOURCE_TYPE_GOSSIP_HELLO
Definition ConditionMgr.h:146
@ CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY
Definition ConditionMgr.h:156
@ CONDITION_SOURCE_TYPE_FISHING_LOOT_TEMPLATE
Definition ConditionMgr.h:129
@ CONDITION_SOURCE_TYPE_GOSSIP_MENU
Definition ConditionMgr.h:140
@ CONDITION_SOURCE_TYPE_ITEM_LOOT_TEMPLATE
Definition ConditionMgr.h:131
@ CONDITION_SOURCE_TYPE_SPELL_IMPLICIT_TARGET
Definition ConditionMgr.h:139
@ CONDITION_SOURCE_TYPE_SKINNING_LOOT_TEMPLATE
Definition ConditionMgr.h:137
@ CONDITION_SOURCE_TYPE_CREATURE_LOOT_TEMPLATE
Definition ConditionMgr.h:127
@ CONDITION_SOURCE_TYPE_GAMEOBJECT_LOOT_TEMPLATE
Definition ConditionMgr.h:130
@ CONDITION_SOURCE_TYPE_PLAYER_LOOT_TEMPLATE
Definition ConditionMgr.h:154
@ CONDITION_SOURCE_TYPE_MILLING_LOOT_TEMPLATE
Definition ConditionMgr.h:133

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_HELLO, 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_OBJECT_VISIBILITY, 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

◆ Clean()

void ConditionMgr::Clean ( )
private
2645{
2646 for (ConditionReferenceContainer::iterator itr = ConditionReferenceStore.begin(); itr != ConditionReferenceStore.end(); ++itr)
2647 {
2648 for (ConditionList::const_iterator it = itr->second.begin(); it != itr->second.end(); ++it) delete *it;
2649 itr->second.clear();
2650 }
2651
2653
2654 for (ConditionContainer::iterator itr = ConditionStore.begin(); itr != ConditionStore.end(); ++itr)
2655 {
2656 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2657 {
2658 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2659 it->second.clear();
2660 }
2661 itr->second.clear();
2662 }
2663
2664 ConditionStore.clear();
2665
2666 for (CreatureSpellConditionContainer::iterator itr = VehicleSpellConditionStore.begin(); itr != VehicleSpellConditionStore.end(); ++itr)
2667 {
2668 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2669 {
2670 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2671 it->second.clear();
2672 }
2673 itr->second.clear();
2674 }
2675
2677
2678 for (SmartEventConditionContainer::iterator itr = SmartEventConditionStore.begin(); itr != SmartEventConditionStore.end(); ++itr)
2679 {
2680 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2681 {
2682 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2683 it->second.clear();
2684 }
2685 itr->second.clear();
2686 }
2687
2689
2690 for (CreatureSpellConditionContainer::iterator itr = SpellClickEventConditionStore.begin(); itr != SpellClickEventConditionStore.end(); ++itr)
2691 {
2692 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2693 {
2694 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2695 it->second.clear();
2696 }
2697 itr->second.clear();
2698 }
2699
2701
2702 for (NpcVendorConditionContainer::iterator itr = NpcVendorConditionContainerStore.begin(); itr != NpcVendorConditionContainerStore.end(); ++itr)
2703 {
2704 for (ConditionTypeContainer::iterator it = itr->second.begin(); it != itr->second.end(); ++it)
2705 {
2706 for (ConditionList::const_iterator i = it->second.begin(); i != it->second.end(); ++i) delete *i;
2707 it->second.clear();
2708 }
2709 itr->second.clear();
2710 }
2711
2713
2714 for (auto& itr : ObjectVisibilityConditionStore)
2715 {
2716 for (auto& sourceIdConds : itr.second)
2717 {
2718 for (Condition* cond : sourceIdConds.second)
2719 delete cond;
2720
2721 sourceIdConds.second.clear();
2722 }
2723
2724 itr.second.clear();
2725 }
2726
2728
2729 // this is a BIG hack, feel free to fix it if you can figure out the ConditionMgr ;)
2730 for (std::list<Condition*>::const_iterator itr = AllocatedMemoryStore.begin(); itr != AllocatedMemoryStore.end(); ++itr) delete *itr;
2731
2732 AllocatedMemoryStore.clear();
2733}
SmartEventConditionContainer SmartEventConditionStore
Definition ConditionMgr.h:292
CreatureSpellConditionContainer SpellClickEventConditionStore
Definition ConditionMgr.h:290
CreatureSpellConditionContainer VehicleSpellConditionStore
Definition ConditionMgr.h:289
ObjectVisibilityConditionContainer ObjectVisibilityConditionStore
Definition ConditionMgr.h:293
NpcVendorConditionContainer NpcVendorConditionContainerStore
Definition ConditionMgr.h:291
ConditionContainer ConditionStore
Definition ConditionMgr.h:287
ConditionReferenceContainer ConditionReferenceStore
Definition ConditionMgr.h:288
std::list< Condition * > AllocatedMemoryStore
Definition ConditionMgr.h:285
Definition ConditionMgr.h:198

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

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

◆ GetConditionReferences()

ConditionList ConditionMgr::GetConditionReferences ( uint32  refId)
872{
873 ConditionList conditions;
874 ConditionReferenceContainer::const_iterator ref = ConditionReferenceStore.find(refId);
875 if (ref != ConditionReferenceStore.end())
876 conditions = (*ref).second;
877 return conditions;
878}

References ConditionReferenceStore.

◆ GetConditionsForNotGroupedEntry()

ConditionList ConditionMgr::GetConditionsForNotGroupedEntry ( ConditionSourceType  sourceType,
uint32  entry 
)
997{
998 ConditionList spellCond;
999 if (sourceType > CONDITION_SOURCE_TYPE_NONE && sourceType < CONDITION_SOURCE_TYPE_MAX)
1000 {
1001 ConditionContainer::const_iterator itr = ConditionStore.find(sourceType);
1002 if (itr != ConditionStore.end())
1003 {
1004 ConditionTypeContainer::const_iterator i = (*itr).second.find(entry);
1005 if (i != (*itr).second.end())
1006 {
1007 spellCond = (*i).second;
1008 LOG_DEBUG("condition", "GetConditionsForNotGroupedEntry: found conditions for type {} and entry {}", uint32(sourceType), entry);
1009 }
1010 }
1011 }
1012 return spellCond;
1013}
@ CONDITION_SOURCE_TYPE_MAX
Definition ConditionMgr.h:157
@ CONDITION_SOURCE_TYPE_NONE
Definition ConditionMgr.h:126
#define LOG_DEBUG(filterType__,...)
Definition Log.h:157

References CONDITION_SOURCE_TYPE_MAX, CONDITION_SOURCE_TYPE_NONE, ConditionStore, and LOG_DEBUG.

◆ GetConditionsForNpcVendorEvent()

ConditionList ConditionMgr::GetConditionsForNpcVendorEvent ( uint32  creatureId,
uint32  itemId 
)
1064{
1065 ConditionList cond;
1066 NpcVendorConditionContainer::const_iterator itr = NpcVendorConditionContainerStore.find(creatureId);
1067 if (itr != NpcVendorConditionContainerStore.end())
1068 {
1069 ConditionTypeContainer::const_iterator i = (*itr).second.find(itemId);
1070 if (i != (*itr).second.end())
1071 {
1072 cond = (*i).second;
1073 if (itemId)
1074 {
1075 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {} item {}", creatureId, itemId);
1076 }
1077 else
1078 {
1079 LOG_DEBUG("condition", "GetConditionsForNpcVendorEvent: found conditions for creature entry {}", creatureId);
1080 }
1081 }
1082 }
1083 return cond;
1084}

References LOG_DEBUG, and NpcVendorConditionContainerStore.

◆ GetConditionsForObjectVisibility()

ConditionList ConditionMgr::GetConditionsForObjectVisibility ( const WorldObject object) const
1087{
1088 ConditionList cond;
1089
1090 if (!object->IsCreature() && !object->IsGameObject())
1091 return cond;
1092
1093 uint32 entry = object->GetEntry();
1094 uint32 sourceGroup = object->IsGameObject() ? 1 : 0;
1095
1096 auto itrBucket = ObjectVisibilityConditionStore.find(std::make_pair(entry, sourceGroup));
1097 if (itrBucket == ObjectVisibilityConditionStore.end())
1098 return cond;
1099
1100 uint32 guid = object->IsGameObject() ? object->ToGameObject()->GetSpawnId() : object->ToCreature()->GetSpawnId();
1101
1102 auto const& sourceIdConditions = itrBucket->second;
1103
1104 auto itrGuid = sourceIdConditions.find(guid);
1105 if (itrGuid != sourceIdConditions.end())
1106 {
1107 cond.insert(cond.end(), itrGuid->second.begin(), itrGuid->second.end());
1108 LOG_DEBUG("condition", "GetConditionsForObjectVisibility: found guid-level conditions for sourceGroup {} entry {} guid {}", sourceGroup, entry, guid);
1109 }
1110 else
1111 {
1112 auto itrEntry = sourceIdConditions.find(0);
1113 if (itrEntry != sourceIdConditions.end())
1114 {
1115 cond.insert(cond.end(), itrEntry->second.begin(), itrEntry->second.end());
1116 LOG_DEBUG("condition", "GetConditionsForObjectVisibility: found entry-level conditions for sourceGroup {} entry {}", sourceGroup, entry);
1117 }
1118 }
1119
1120 return cond;
1121}
bool IsGameObject() const
Definition Object.h:213
bool IsCreature() const
Definition Object.h:205

References Object::IsCreature(), Object::IsGameObject(), LOG_DEBUG, and ObjectVisibilityConditionStore.

◆ GetConditionsForSmartEvent()

ConditionList ConditionMgr::GetConditionsForSmartEvent ( int32  entryOrGuid,
uint32  eventId,
uint32  sourceType 
)
1048{
1049 ConditionList cond;
1050 SmartEventConditionContainer::const_iterator itr = SmartEventConditionStore.find(std::make_pair(entryOrGuid, sourceType));
1051 if (itr != SmartEventConditionStore.end())
1052 {
1053 ConditionTypeContainer::const_iterator i = (*itr).second.find(eventId + 1);
1054 if (i != (*itr).second.end())
1055 {
1056 cond = (*i).second;
1057 LOG_DEBUG("condition", "GetConditionsForSmartEvent: found conditions for Smart Event entry or guid {} event_id {}", entryOrGuid, eventId);
1058 }
1059 }
1060 return cond;
1061}

References LOG_DEBUG, and SmartEventConditionStore.

◆ GetConditionsForSpellClickEvent()

ConditionList ConditionMgr::GetConditionsForSpellClickEvent ( uint32  creatureId,
uint32  spellId 
)
1016{
1017 ConditionList cond;
1018 CreatureSpellConditionContainer::const_iterator itr = SpellClickEventConditionStore.find(creatureId);
1019 if (itr != SpellClickEventConditionStore.end())
1020 {
1021 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
1022 if (i != (*itr).second.end())
1023 {
1024 cond = (*i).second;
1025 LOG_DEBUG("condition", "GetConditionsForSpellClickEvent: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
1026 }
1027 }
1028 return cond;
1029}

References LOG_DEBUG, and SpellClickEventConditionStore.

◆ GetConditionsForVehicleSpell()

ConditionList ConditionMgr::GetConditionsForVehicleSpell ( uint32  creatureId,
uint32  spellId 
)
1032{
1033 ConditionList cond;
1034 CreatureSpellConditionContainer::const_iterator itr = VehicleSpellConditionStore.find(creatureId);
1035 if (itr != VehicleSpellConditionStore.end())
1036 {
1037 ConditionTypeContainer::const_iterator i = (*itr).second.find(spellId);
1038 if (i != (*itr).second.end())
1039 {
1040 cond = (*i).second;
1041 LOG_DEBUG("condition", "GetConditionsForVehicleSpell: found conditions for Vehicle entry {} spell {}", creatureId, spellId);
1042 }
1043 }
1044 return cond;
1045}

References LOG_DEBUG, and VehicleSpellConditionStore.

◆ GetSearcherTypeMaskForConditionList()

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

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

Referenced by GetSearcherTypeMaskForConditionList().

◆ instance()

ConditionMgr * ConditionMgr::instance ( )
static
866{
867 static ConditionMgr instance;
868 return &instance;
869}
Definition ConditionMgr.h:251
static ConditionMgr * instance()
Definition ConditionMgr.cpp:865

References instance().

Referenced by instance().

◆ isConditionTypeValid()

bool ConditionMgr::isConditionTypeValid ( Condition cond)
1997{
1999 {
2000 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table has an invalid ConditionType ({}), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
2001 return false;
2002 }
2003 switch (cond->ConditionType)
2004 {
2006 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));
2007 return false;
2008 default:
2009 break;
2010 }
2011
2013 {
2014 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, has incorrect ConditionTarget set, ignoring.", cond->SourceType, cond->SourceEntry);
2015 return false;
2016 }
2017
2018 switch (cond->ConditionType)
2019 {
2020 case CONDITION_AURA:
2021 {
2022 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
2023 {
2024 LOG_ERROR("sql.sql", "Aura condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
2025 return false;
2026 }
2027
2028 if (cond->ConditionValue2 > EFFECT_2)
2029 {
2030 LOG_ERROR("sql.sql", "Aura condition has non existing effect index ({}) (must be 0..2), skipped", cond->ConditionValue2);
2031 return false;
2032 }
2033 if (cond->ConditionValue3)
2034 LOG_ERROR("sql.sql", "Aura condition has useless data in value3 ({})!", cond->ConditionValue3);
2035 break;
2036 }
2037 case CONDITION_ITEM:
2038 {
2039 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
2040 if (!proto)
2041 {
2042 LOG_ERROR("sql.sql", "Item condition has non existing item ({}), skipped", cond->ConditionValue1);
2043 return false;
2044 }
2045
2046 if (!cond->ConditionValue2)
2047 {
2048 LOG_ERROR("sql.sql", "Item condition has 0 set for item count in value2 ({}), skipped", cond->ConditionValue2);
2049 return false;
2050 }
2051 break;
2052 }
2054 {
2055 ItemTemplate const* proto = sObjectMgr->GetItemTemplate(cond->ConditionValue1);
2056 if (!proto)
2057 {
2058 LOG_ERROR("sql.sql", "ItemEquipped condition has non existing item ({}), skipped", cond->ConditionValue1);
2059 return false;
2060 }
2061
2062 if (cond->ConditionValue2)
2063 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value2 ({})!", cond->ConditionValue2);
2064 if (cond->ConditionValue3)
2065 LOG_ERROR("sql.sql", "ItemEquipped condition has useless data in value3 ({})!", cond->ConditionValue3);
2066 break;
2067 }
2068 case CONDITION_ZONEID:
2069 {
2070 AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(cond->ConditionValue1);
2071 if (!areaEntry)
2072 {
2073 LOG_ERROR("sql.sql", "ZoneID condition has non existing area ({}), skipped", cond->ConditionValue1);
2074 return false;
2075 }
2076
2077 if (areaEntry->zone != 0)
2078 {
2079 LOG_ERROR("sql.sql", "ZoneID condition requires to be in area ({}) which is a subzone but zone expected, skipped", cond->ConditionValue1);
2080 return false;
2081 }
2082
2083 if (cond->ConditionValue2)
2084 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value2 ({})!", cond->ConditionValue2);
2085 if (cond->ConditionValue3)
2086 LOG_ERROR("sql.sql", "ZoneID condition has useless data in value3 ({})!", cond->ConditionValue3);
2087 break;
2088 }
2090 {
2091 FactionEntry const* factionEntry = sFactionStore.LookupEntry(cond->ConditionValue1);
2092 if (!factionEntry)
2093 {
2094 LOG_ERROR("sql.sql", "Reputation condition has non existing faction ({}), skipped", cond->ConditionValue1);
2095 return false;
2096 }
2097 if (cond->ConditionValue3)
2098 LOG_ERROR("sql.sql", "Reputation condition has useless data in value3 ({})!", cond->ConditionValue3);
2099 break;
2100 }
2101 case CONDITION_TEAM:
2102 {
2103 if (cond->ConditionValue1 != ALLIANCE && cond->ConditionValue1 != HORDE)
2104 {
2105 LOG_ERROR("sql.sql", "Team condition specifies unknown team ({}), skipped", cond->ConditionValue1);
2106 return false;
2107 }
2108
2109 if (cond->ConditionValue2)
2110 LOG_ERROR("sql.sql", "Team condition has useless data in value2 ({})!", cond->ConditionValue2);
2111 if (cond->ConditionValue3)
2112 LOG_ERROR("sql.sql", "Team condition has useless data in value3 ({})!", cond->ConditionValue3);
2113 break;
2114 }
2115 case CONDITION_SKILL:
2116 {
2117 SkillLineEntry const* pSkill = sSkillLineStore.LookupEntry(cond->ConditionValue1);
2118 if (!pSkill)
2119 {
2120 LOG_ERROR("sql.sql", "Skill condition specifies non-existing skill ({}), skipped", cond->ConditionValue1);
2121 return false;
2122 }
2123
2124 if (cond->ConditionValue2 < 1 || cond->ConditionValue2 > sWorld->GetConfigMaxSkillValue())
2125 {
2126 LOG_ERROR("sql.sql", "Skill condition specifies invalid skill value ({}), skipped", cond->ConditionValue2);
2127 return false;
2128 }
2129 if (cond->ConditionValue3)
2130 LOG_ERROR("sql.sql", "Skill condition has useless data in value3 ({})!", cond->ConditionValue3);
2131 break;
2132 }
2139 {
2140 if (!sObjectMgr->GetQuestTemplate(cond->ConditionValue1))
2141 {
2142 LOG_ERROR("sql.sql", "Quest condition specifies non-existing quest ({}), skipped", cond->ConditionValue1);
2143 return false;
2144 }
2145
2146 if (cond->ConditionValue2 > 1)
2147 {
2148 LOG_ERROR("sql.sql", "Quest condition has useless data in value2 ({})!", cond->ConditionValue2);
2149 }
2150 if (cond->ConditionValue3)
2151 {
2152 LOG_ERROR("sql.sql", "Quest condition has useless data in value3 ({})!", cond->ConditionValue3);
2153 }
2154 break;
2155 }
2157 if (cond->ConditionValue2 >= (1 << MAX_QUEST_STATUS))
2158 {
2159 LOG_ERROR("sql.sql", "ConditionType ({}) has invalid state mask ({}), skipped.", cond->ConditionType, cond->ConditionValue2);
2160 return false;
2161 }
2162 break;
2164 {
2165 GameEventMgr::GameEventDataMap const& events = sGameEventMgr->GetEventMap();
2166 if (cond->ConditionValue1 >= events.size() || !events[cond->ConditionValue1].isValid())
2167 {
2168 LOG_ERROR("sql.sql", "ActiveEvent condition has non existing event id ({}), skipped", cond->ConditionValue1);
2169 return false;
2170 }
2171
2172 if (cond->ConditionValue2)
2173 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value2 ({})!", cond->ConditionValue2);
2174 if (cond->ConditionValue3)
2175 LOG_ERROR("sql.sql", "ActiveEvent condition has useless data in value3 ({})!", cond->ConditionValue3);
2176 break;
2177 }
2179 {
2180 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2181 if (!achievement)
2182 {
2183 LOG_ERROR("sql.sql", "Achivement condition has non existing achivement id ({}), skipped", cond->ConditionValue1);
2184 return false;
2185 }
2186
2187 if (cond->ConditionValue2)
2188 LOG_ERROR("sql.sql", "Achivement condition has useless data in value2 ({})!", cond->ConditionValue2);
2189 if (cond->ConditionValue3)
2190 LOG_ERROR("sql.sql", "Achivement condition has useless data in value3 ({})!", cond->ConditionValue3);
2191 break;
2192 }
2193 case CONDITION_CLASS:
2194 {
2196 {
2197 LOG_ERROR("sql.sql", "Class condition has non existing classmask ({}), skipped", cond->ConditionValue1 & ~CLASSMASK_ALL_PLAYABLE);
2198 return false;
2199 }
2200
2201 if (cond->ConditionValue2)
2202 LOG_ERROR("sql.sql", "Class condition has useless data in value2 ({})!", cond->ConditionValue2);
2203 if (cond->ConditionValue3)
2204 LOG_ERROR("sql.sql", "Class condition has useless data in value3 ({})!", cond->ConditionValue3);
2205 break;
2206 }
2207 case CONDITION_RACE:
2208 {
2209 if (!(cond->ConditionValue1 & sRaceMgr->GetPlayableRaceMask()))
2210 {
2211 LOG_ERROR("sql.sql", "Race condition has non existing racemask ({}), skipped", cond->ConditionValue1 & ~sRaceMgr->GetPlayableRaceMask());
2212 return false;
2213 }
2214
2215 if (cond->ConditionValue2)
2216 LOG_ERROR("sql.sql", "Race condition has useless data in value2 ({})!", cond->ConditionValue2);
2217 if (cond->ConditionValue3)
2218 LOG_ERROR("sql.sql", "Race condition has useless data in value3 ({})!", cond->ConditionValue3);
2219 break;
2220 }
2221 case CONDITION_GENDER:
2222 {
2224 {
2225 LOG_ERROR("condition", "Gender condition has invalid gender ({}), skipped", cond->ConditionValue1);
2226 return false;
2227 }
2228
2229 if (cond->ConditionValue2)
2230 LOG_ERROR("condition", "Gender condition has useless data in value2 ({})!", cond->ConditionValue2);
2231 if (cond->ConditionValue3)
2232 LOG_ERROR("condition", "Gender condition has useless data in value3 ({})!", cond->ConditionValue3);
2233 break;
2234 }
2235 case CONDITION_MAPID:
2236 {
2237 MapEntry const* mapId = sMapStore.LookupEntry(cond->ConditionValue1);
2238 if (!mapId)
2239 {
2240 LOG_ERROR("sql.sql", "Map condition has non existing map ({}), skipped", cond->ConditionValue1);
2241 return false;
2242 }
2243
2244 if (cond->ConditionValue2)
2245 LOG_ERROR("sql.sql", "Map condition has useless data in value2 ({})!", cond->ConditionValue2);
2246 if (cond->ConditionValue3)
2247 LOG_ERROR("sql.sql", "Map condition has useless data in value3 ({})!", cond->ConditionValue3);
2248 break;
2249 }
2250 case CONDITION_SPELL:
2251 {
2252 if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
2253 {
2254 LOG_ERROR("sql.sql", "Spell condition has non existing spell (Id: {}), skipped", cond->ConditionValue1);
2255 return false;
2256 }
2257
2258 if (cond->ConditionValue2)
2259 LOG_ERROR("sql.sql", "Spell condition has useless data in value2 ({})!", cond->ConditionValue2);
2260 if (cond->ConditionValue3)
2261 LOG_ERROR("sql.sql", "Spell condition has useless data in value3 ({})!", cond->ConditionValue3);
2262 break;
2263 }
2264 case CONDITION_LEVEL:
2265 {
2266 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2267 {
2268 LOG_ERROR("sql.sql", "Level condition has invalid option ({}), skipped", cond->ConditionValue2);
2269 return false;
2270 }
2271 if (cond->ConditionValue3)
2272 LOG_ERROR("sql.sql", "Level condition has useless data in value3 ({})!", cond->ConditionValue3);
2273 break;
2274 }
2276 {
2277 if (cond->ConditionValue1 > DRUNKEN_SMASHED)
2278 {
2279 LOG_ERROR("sql.sql", "DrunkState condition has invalid state ({}), skipped", cond->ConditionValue1);
2280 return false;
2281 }
2282 if (cond->ConditionValue2)
2283 {
2284 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value2 ({})!", cond->ConditionValue2);
2285 return false;
2286 }
2287 if (cond->ConditionValue3)
2288 LOG_ERROR("sql.sql", "DrunkState condition has useless data in value3 ({})!", cond->ConditionValue3);
2289 break;
2290 }
2292 {
2293 if (!sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
2294 {
2295 LOG_ERROR("sql.sql", "NearCreature condition has non existing creature template entry ({}), skipped", cond->ConditionValue1);
2296 return false;
2297 }
2298 break;
2299 }
2301 {
2302 if (!sObjectMgr->GetGameObjectTemplate(cond->ConditionValue1))
2303 {
2304 LOG_ERROR("sql.sql", "NearGameObject condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue1);
2305 return false;
2306 }
2307 if (cond->ConditionValue3 > 2)
2308 LOG_ERROR("sql.sql", "NearGameObject condition for gameobject ID ({}) has data over 2 for value3 ({})!", cond->ConditionValue1, cond->ConditionValue3);
2309 break;
2310 }
2312 {
2313 switch (cond->ConditionValue1)
2314 {
2315 case TYPEID_UNIT:
2316 if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
2317 {
2318 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry ({}), skipped", cond->ConditionValue2);
2319 return false;
2320 }
2321 if (cond->ConditionValue3 > 1)
2322 {
2323 if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3))
2324 {
2325 if (cond->ConditionValue2 && creatureData->id1 != cond->ConditionValue2)
2326 {
2327 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match creature entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2328 return false;
2329 }
2330 }
2331 else
2332 {
2333 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid ({}), skipped", cond->ConditionValue3);
2334 return false;
2335 }
2336 }
2337 break;
2338 case TYPEID_GAMEOBJECT:
2339 if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2))
2340 {
2341 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry ({}), skipped", cond->ConditionValue2);
2342 return false;
2343 }
2344 if (cond->ConditionValue3)
2345 {
2346 if (GameObjectData const* goData = sObjectMgr->GetGameObjectData(cond->ConditionValue3))
2347 {
2348 if (cond->ConditionValue2 && goData->id != cond->ConditionValue2)
2349 {
2350 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid {} set but does not match gameobject entry ({}), skipped", cond->ConditionValue3, cond->ConditionValue2);
2351 return false;
2352 }
2353 }
2354 else
2355 {
2356 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid ({}), skipped", cond->ConditionValue3);
2357 return false;
2358 }
2359 }
2360 break;
2361 case TYPEID_PLAYER:
2362 case TYPEID_CORPSE:
2363 if (cond->ConditionValue2)
2364 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 ({})!", cond->ConditionValue2);
2365 if (cond->ConditionValue3)
2366 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 ({})!", cond->ConditionValue3);
2367 break;
2368 default:
2369 LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set ({}), skipped", cond->ConditionValue1);
2370 return false;
2371 }
2372 break;
2373 }
2375 {
2377 {
2378 LOG_ERROR("sql.sql", "TypeMask condition has invalid typemask set ({}), skipped", cond->ConditionValue2);
2379 return false;
2380 }
2381 if (cond->ConditionValue2)
2382 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value2 ({})!", cond->ConditionValue2);
2383 if (cond->ConditionValue3)
2384 LOG_ERROR("sql.sql", "TypeMask condition has useless data in value3 ({})!", cond->ConditionValue3);
2385 break;
2386 }
2388 {
2390 {
2391 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2392 return false;
2393 }
2394 if (cond->ConditionValue1 == cond->ConditionTarget)
2395 {
2396 LOG_ERROR("sql.sql", "RelationTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2397 return false;
2398 }
2399 if (cond->ConditionValue2 >= RELATION_MAX)
2400 {
2401 LOG_ERROR("sql.sql", "RelationTo condition has invalid ConditionValue2(RelationType) ({}), skipped", cond->ConditionValue2);
2402 return false;
2403 }
2404 if (cond->ConditionValue3)
2405 LOG_ERROR("sql.sql", "RelationTo condition has useless data in value3 ({})!", cond->ConditionValue3);
2406 break;
2407 }
2409 {
2411 {
2412 LOG_ERROR("sql.sql", "ReactionTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2413 return false;
2414 }
2415 if (cond->ConditionValue1 == cond->ConditionTarget)
2416 {
2417 LOG_ERROR("sql.sql", "ReactionTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2418 return false;
2419 }
2420 if (!cond->ConditionValue2)
2421 {
2422 LOG_ERROR("sql.sql", "mConditionValue2 condition has invalid ConditionValue2(rankMask) ({}), skipped", cond->ConditionValue2);
2423 return false;
2424 }
2425 break;
2426 }
2428 {
2430 {
2431 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ConditionValue1(ConditionTarget selection) ({}), skipped", cond->ConditionValue1);
2432 return false;
2433 }
2434 if (cond->ConditionValue1 == cond->ConditionTarget)
2435 {
2436 LOG_ERROR("sql.sql", "DistanceTo condition has ConditionValue1(ConditionTarget selection) set to self ({}), skipped", cond->ConditionValue1);
2437 return false;
2438 }
2439 if (cond->ConditionValue3 >= COMP_TYPE_MAX)
2440 {
2441 LOG_ERROR("sql.sql", "DistanceTo condition has invalid ComparisionType ({}), skipped", cond->ConditionValue3);
2442 return false;
2443 }
2444 break;
2445 }
2446 case CONDITION_ALIVE:
2447 {
2448 if (cond->ConditionValue1)
2449 LOG_ERROR("sql.sql", "Alive condition has useless data in value1 ({})!", cond->ConditionValue1);
2450 if (cond->ConditionValue2)
2451 LOG_ERROR("sql.sql", "Alive condition has useless data in value2 ({})!", cond->ConditionValue2);
2452 if (cond->ConditionValue3)
2453 LOG_ERROR("sql.sql", "Alive condition has useless data in value3 ({})!", cond->ConditionValue3);
2454 break;
2455 }
2456 case CONDITION_HP_VAL:
2457 {
2458 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2459 {
2460 LOG_ERROR("sql.sql", "HpVal condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2461 return false;
2462 }
2463 if (cond->ConditionValue3)
2464 LOG_ERROR("sql.sql", "HpVal condition has useless data in value3 ({})!", cond->ConditionValue3);
2465 break;
2466 }
2467 case CONDITION_HP_PCT:
2468 {
2469 if (cond->ConditionValue1 > 100)
2470 {
2471 LOG_ERROR("sql.sql", "HpPct condition has too big percent value ({}), skipped", cond->ConditionValue1);
2472 return false;
2473 }
2474 if (cond->ConditionValue2 >= COMP_TYPE_MAX)
2475 {
2476 LOG_ERROR("sql.sql", "HpPct condition has invalid ComparisionType ({}), skipped", cond->ConditionValue2);
2477 return false;
2478 }
2479 if (cond->ConditionValue3)
2480 LOG_ERROR("sql.sql", "HpPct condition has useless data in value3 ({})!", cond->ConditionValue3);
2481 break;
2482 }
2483 case CONDITION_AREAID:
2485 break;
2487 {
2488 if (cond->ConditionValue3)
2489 LOG_ERROR("sql.sql", "World state condition has useless data in value3 ({})!", cond->ConditionValue3);
2490 break;
2491 }
2493 {
2494 if (cond->ConditionValue2)
2495 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value2 ({})!", cond->ConditionValue2);
2496 if (cond->ConditionValue3)
2497 LOG_ERROR("sql.sql", "Phasemask condition has useless data in value3 ({})!", cond->ConditionValue3);
2498 break;
2499 }
2500 case CONDITION_TITLE:
2501 {
2502 CharTitlesEntry const* titleEntry = sCharTitlesStore.LookupEntry(cond->ConditionValue1);
2503 if (!titleEntry)
2504 {
2505 LOG_ERROR("sql.sql", "Title condition has non existing title in value1 ({}), skipped", cond->ConditionValue1);
2506 return false;
2507 }
2508 break;
2509 }
2511 {
2513 {
2514 LOG_ERROR("condition", "SpawnMask condition has non existing SpawnMask in value1 ({}), skipped", cond->ConditionValue1);
2515 return false;
2516 }
2517 break;
2518 }
2520 {
2522 {
2523 LOG_ERROR("condition", "UnitState condition has non existing UnitState in value1 ({}), skipped", cond->ConditionValue1);
2524 return false;
2525 }
2526 break;
2527 }
2529 {
2531 {
2532 LOG_ERROR("condition", "CreatureType condition has non existing CreatureType in value1 ({}), skipped", cond->ConditionValue1);
2533 return false;
2534 }
2535 break;
2536 }
2538 {
2539 AchievementEntry const* achievement = sAchievementStore.LookupEntry(cond->ConditionValue1);
2540 if (!achievement)
2541 {
2542 LOG_ERROR("condition", "CONDITION_REALM_ACHIEVEMENT has non existing realm first achivement id ({}), skipped.", cond->ConditionValue1);
2543 return false;
2544 }
2545 break;
2546 }
2548 {
2549 const Quest* quest = sObjectMgr->GetQuestTemplate(cond->ConditionValue1);
2550 if (!quest)
2551 {
2552 LOG_ERROR("sql.sql", "CONDITION_QUEST_OBJECTIVE_PROGRESS points to non-existing quest ({}), skipped.", cond->ConditionValue1);
2553 return false;
2554 }
2555
2556 if (cond->ConditionValue2 > 3)
2557 {
2558 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);
2559 return false;
2560 }
2561
2562 if (quest->RequiredNpcOrGo[cond->ConditionValue2] == 0)
2563 {
2564 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);
2565 return false;
2566 }
2567
2568 if (cond->ConditionValue3 > quest->RequiredNpcOrGoCount[cond->ConditionValue2])
2569 {
2570 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);
2571 return false;
2572 }
2573 break;
2574 }
2576 {
2578 {
2579 LOG_ERROR("sql.sql", "Has Aura Effect condition has non existing aura ({}), skipped", cond->ConditionValue1);
2580 return false;
2581 }
2582 break;
2583 }
2585 {
2586 bool valid = false;
2587 switch (cond->ConditionValue1)
2588 {
2589 case 0:
2591 break;
2592 case 1:
2593 valid = cond->ConditionValue2 <= 1;
2594 break;
2595 default:
2596 valid = false;
2597 break;
2598 }
2599 if (!valid)
2600 {
2601 LOG_ERROR("sql.sql", "CONDITION_STAND_STATE has non-existing stand state ({},{}), skipped.", cond->ConditionValue1, cond->ConditionValue2);
2602 return false;
2603 }
2604 break;
2605 }
2607 if (cond->ConditionValue1 >= MAX_DIFFICULTY)
2608 {
2609 LOG_ERROR("sql.sql", "CONDITION_DIFFICULTY_ID has non existing difficulty in value1 ({}), skipped.", cond->ConditionValue1);
2610 return false;
2611 }
2612 break;
2614 if (cond->ConditionValue1 > 1)
2615 {
2616 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value1 ({}).", cond->ConditionValue1);
2617 return false;
2618 }
2619 if (cond->ConditionValue2 >= MAX_DIFFICULTY)
2620 {
2621 LOG_ERROR("sql.sql", "RandomDungeon condition has invalid difficulty in value2 ({}).", cond->ConditionValue1);
2622 return false;
2623 }
2624 if (cond->ConditionValue3)
2625 LOG_ERROR("sql.sql", "RandomDungeon condition has useless data in value3 ({}).", cond->ConditionValue3);
2626 break;
2627 case CONDITION_PET_TYPE:
2628 if (cond->ConditionValue1 >= (1 << MAX_PET_TYPE))
2629 {
2630 LOG_ERROR("sql.sql", "CONDITION_PET_TYPE has non-existing pet type {}, skipped.", cond->ConditionValue1);
2631 return false;
2632 }
2633 break;
2634 case CONDITION_TAXI:
2635 case CONDITION_IN_WATER:
2636 case CONDITION_CHARMED:
2638 default:
2639 break;
2640 }
2641 return true;
2642}
@ CONDITION_TAXI
Definition ConditionMgr.h:80
@ CONDITION_PLAYER_QUEUED_RANDOM_DUNGEON
Definition ConditionMgr.h:91
@ CONDITION_MAPID
Definition ConditionMgr.h:56
@ CONDITION_SKILL
Definition ConditionMgr.h:41
@ CONDITION_RACE
Definition ConditionMgr.h:50
@ CONDITION_REACTION_TO
Definition ConditionMgr.h:68
@ CONDITION_NEAR_GAMEOBJECT
Definition ConditionMgr.h:64
@ CONDITION_QUESTREWARDED
Definition ConditionMgr.h:42
@ CONDITION_REALM_ACHIEVEMENT
Definition ConditionMgr.h:73
@ CONDITION_PHASEMASK
Definition ConditionMgr.h:60
@ CONDITION_QUEST_OBJECTIVE_PROGRESS
Definition ConditionMgr.h:82
@ CONDITION_DAILY_QUEST_DONE
Definition ConditionMgr.h:77
@ CONDITION_ACTIVE_EVENT
Definition ConditionMgr.h:46
@ CONDITION_INSTANCE_INFO
Definition ConditionMgr.h:47
@ CONDITION_RELATION_TO
Definition ConditionMgr.h:67
@ CONDITION_STAND_STATE
Definition ConditionMgr.h:76
@ CONDITION_UNIT_IN_COMBAT
Definition ConditionMgr.h:92
@ 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:94
@ 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:168
#define MAX_DIFFICULTY
Definition DBCEnums.h:283
@ SPAWNMASK_RAID_ALL
Definition DBCEnums.h:301
DBCStorage< CharTitlesEntry > sCharTitlesStore(CharTitlesEntryfmt)
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
DBCStorage< AchievementEntry > sAchievementStore(Achievementfmt)
DBCStorage< SkillLineEntry > sSkillLineStore(SkillLinefmt)
DBCStorage< MapEntry > sMapStore(MapEntryfmt)
DBCStorage< AreaTableEntry > sAreaTableStore(AreaTableEntryfmt)
#define sGameEventMgr
Definition GameEventMgr.h:201
@ TYPEID_GAMEOBJECT
Definition ObjectGuid.h:37
@ TYPEID_UNIT
Definition ObjectGuid.h:35
@ TYPEID_CORPSE
Definition ObjectGuid.h:39
@ TYPEID_PLAYER
Definition ObjectGuid.h:36
@ TYPEMASK_UNIT
Definition ObjectGuid.h:49
@ TYPEMASK_CORPSE
Definition ObjectGuid.h:53
@ TYPEMASK_GAMEOBJECT
Definition ObjectGuid.h:51
@ TYPEMASK_PLAYER
Definition ObjectGuid.h:50
@ MAX_PET_TYPE
Definition PetDefines.h:34
@ DRUNKEN_SMASHED
Definition Player.h:452
@ MAX_QUEST_STATUS
Definition QuestDef.h:107
#define sRaceMgr
Definition RaceMgr.h:52
@ EFFECT_2
Definition SharedDefines.h:33
@ CREATURE_TYPE_GAS_CLOUD
Definition SharedDefines.h:2634
@ ALLIANCE
Definition SharedDefines.h:756
@ HORDE
Definition SharedDefines.h:755
#define CLASSMASK_ALL_PLAYABLE
Definition SharedDefines.h:142
@ TOTAL_AURAS
Definition SpellAuraDefines.h:380
@ SPELL_AURA_NONE
Definition SpellAuraDefines.h:63
@ UNIT_STAND_STATE_SUBMERGED
Definition UnitDefines.h:44
@ UNIT_STATE_ALL_STATE_SUPPORTED
Definition UnitDefines.h:207
@ COMP_TYPE_MAX
Definition Util.h:584
events
Definition boss_sartura.cpp:43
std::vector< GameEventData > GameEventDataMap
Definition GameEventMgr.h:107
static bool IsValidGender(uint8 Gender)
Definition Player.h:1590
Definition QuestDef.h:210
int32 RequiredNpcOrGo[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:305
uint32 RequiredNpcOrGoCount[QUEST_OBJECTIVES_COUNT]
Definition QuestDef.h:306
#define sWorld
Definition World.h:317
ObjectData const creatureData[]
Definition instance_blackwing_lair.cpp:45
ObjectData const goData[]
Definition instance_violet_hold.cpp:48
Definition DBCStructure.h:40
Definition DBCStructure.h:519
uint32 zone
Definition DBCStructure.h:522
Definition DBCStructure.h:632
ConditionTypes ConditionType
Definition ConditionMgr.h:204
ConditionSourceType SourceType
Definition ConditionMgr.h:199
uint32 ConditionValue2
Definition ConditionMgr.h:206
uint8 ConditionTarget
Definition ConditionMgr.h:212
uint32 ConditionValue3
Definition ConditionMgr.h:207
uint32 ConditionValue1
Definition ConditionMgr.h:205
uint32 GetMaxAvailableConditionTargets()
Definition ConditionMgr.cpp:832
Definition CreatureData.h:370
Definition DBCStructure.h:907
Definition GameObjectData.h:715
Definition ItemTemplate.h:619
Definition DBCStructure.h:1325
Definition DBCStructure.h:1583

References ALLIANCE, CLASSMASK_ALL_PLAYABLE, COMP_TYPE_MAX, CONDITION_AC_END, CONDITION_AC_START, CONDITION_ACHIEVEMENT, CONDITION_ACTIVE_EVENT, CONDITION_ALIVE, CONDITION_AREAID, CONDITION_AURA, CONDITION_CHARMED, CONDITION_CLASS, CONDITION_CREATURE_TYPE, CONDITION_DAILY_QUEST_DONE, CONDITION_DIFFICULTY_ID, CONDITION_DISTANCE_TO, CONDITION_DRUNKENSTATE, CONDITION_GENDER, CONDITION_HAS_AURA_TYPE, CONDITION_HP_PCT, CONDITION_HP_VAL, CONDITION_IN_WATER, CONDITION_INSTANCE_INFO, CONDITION_ITEM, CONDITION_ITEM_EQUIPPED, CONDITION_LEVEL, CONDITION_MAPID, CONDITION_NEAR_CREATURE, CONDITION_NEAR_GAMEOBJECT, CONDITION_NONE, CONDITION_OBJECT_ENTRY_GUID, CONDITION_PET_TYPE, CONDITION_PHASEMASK, CONDITION_PLAYER_QUEUED_RANDOM_DUNGEON, CONDITION_QUEST_COMPLETE, CONDITION_QUEST_NONE, CONDITION_QUEST_OBJECTIVE_PROGRESS, CONDITION_QUEST_SATISFY_EXCLUSIVE, CONDITION_QUESTREWARDED, CONDITION_QUESTSTATE, CONDITION_QUESTTAKEN, CONDITION_RACE, CONDITION_REACTION_TO, CONDITION_REALM_ACHIEVEMENT, CONDITION_RELATION_TO, CONDITION_REPUTATION_RANK, CONDITION_SKILL, CONDITION_SPAWNMASK, CONDITION_SPELL, CONDITION_STAND_STATE, CONDITION_TAXI, CONDITION_TC_END, CONDITION_TEAM, CONDITION_TERRAIN_SWAP, CONDITION_TITLE, CONDITION_TYPE_MASK, CONDITION_UNIT_IN_COMBAT, 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(), goData, HORDE, Player::IsValidGender(), LOG_ERROR, MAX_DIFFICULTY, MAX_PET_TYPE, MAX_QUEST_STATUS, RELATION_MAX, Quest::RequiredNpcOrGo, Quest::RequiredNpcOrGoCount, sAchievementStore, sAreaTableStore, sCharTitlesStore, sFactionStore, sGameEventMgr, sMapStore, sObjectMgr, Condition::SourceEntry, Condition::SourceType, SPAWNMASK_RAID_ALL, SPELL_AURA_NONE, sRaceMgr, sSkillLineStore, sSpellMgr, sWorld, TOTAL_AURAS, TYPEID_CORPSE, TYPEID_GAMEOBJECT, TYPEID_PLAYER, TYPEID_UNIT, TYPEMASK_CORPSE, TYPEMASK_GAMEOBJECT, TYPEMASK_PLAYER, TYPEMASK_UNIT, UNIT_STAND_STATE_SUBMERGED, UNIT_STATE_ALL_STATE_SUPPORTED, and AreaTableEntry::zone.

Referenced by LoadConditions().

◆ IsObjectMeetToConditionList()

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

Find ElseGroup in ElseGroupStore

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

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

References ConditionReferenceStore, IsObjectMeetToConditionList(), and LOG_DEBUG.

Referenced by IsObjectMeetToConditionList(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [1/3]

bool ConditionMgr::IsObjectMeetToConditions ( ConditionSourceInfo sourceInfo,
ConditionList const &  conditions 
)
976{
977 if (conditions.empty())
978 return true;
979
980 LOG_DEBUG("condition", "ConditionMgr::IsObjectMeetToConditions");
981 return IsObjectMeetToConditionList(sourceInfo, conditions);
982}

References IsObjectMeetToConditionList(), and LOG_DEBUG.

◆ IsObjectMeetToConditions() [2/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object,
ConditionList const &  conditions 
)
964{
966 return IsObjectMeetToConditions(srcInfo, conditions);
967}
bool IsObjectMeetToConditions(WorldObject *object, ConditionList const &conditions)
Definition ConditionMgr.cpp:963
Definition ConditionMgr.h:185

References IsObjectMeetToConditions().

Referenced by IsObjectMeetToConditions(), and IsObjectMeetToConditions().

◆ IsObjectMeetToConditions() [3/3]

bool ConditionMgr::IsObjectMeetToConditions ( WorldObject object1,
WorldObject object2,
ConditionList const &  conditions 
)
970{
971 ConditionSourceInfo srcInfo = ConditionSourceInfo(object1, object2);
972 return IsObjectMeetToConditions(srcInfo, conditions);
973}

References IsObjectMeetToConditions().

◆ isSourceTypeValid()

bool ConditionMgr::isSourceTypeValid ( Condition cond)
private
1549{
1551 {
1552 LOG_ERROR("sql.sql", "Invalid ConditionSourceType {} in `condition` table, ignoring.", uint32(cond->SourceType));
1553 return false;
1554 }
1555
1556 switch (cond->SourceType)
1557 {
1561 {
1562 LOG_ERROR("sql.sql", "ConditionSourceType {} in `condition` table is not supported on 3.3.5a, ignoring.", uint32(cond->SourceType));
1563 return false;
1564 }
1566 {
1568 {
1569 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `creature_loot_template`, ignoring.", cond->SourceGroup);
1570 return false;
1571 }
1572
1574 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1575 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1576 {
1577 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1578 return false;
1579 }
1580 break;
1581 }
1583 {
1585 {
1586 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `disenchant_loot_template`, ignoring.", cond->SourceGroup);
1587 return false;
1588 }
1589
1591 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1592 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1593 {
1594 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1595 return false;
1596 }
1597 break;
1598 }
1600 {
1602 {
1603 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `fishing_loot_template`, ignoring.", cond->SourceGroup);
1604 return false;
1605 }
1606
1608 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1609 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1610 {
1611 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1612 return false;
1613 }
1614 break;
1615 }
1617 {
1619 {
1620 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `gameobject_loot_template`, ignoring.", cond->SourceGroup);
1621 return false;
1622 }
1623
1625 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1626 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1627 {
1628 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1629 return false;
1630 }
1631 break;
1632 }
1634 {
1636 {
1637 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `item_loot_template`, ignoring.", cond->SourceGroup);
1638 return false;
1639 }
1640
1642 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1643 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1644 {
1645 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1646 return false;
1647 }
1648 break;
1649 }
1651 {
1653 {
1654 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `mail_loot_template`, ignoring.", cond->SourceGroup);
1655 return false;
1656 }
1657
1659 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1660 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1661 {
1662 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1663 return false;
1664 }
1665 break;
1666 }
1668 {
1670 {
1671 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `milling_loot_template`, ignoring.", cond->SourceGroup);
1672 return false;
1673 }
1674
1676 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1677 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1678 {
1679 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1680 return false;
1681 }
1682 break;
1683 }
1685 {
1687 {
1688 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `pickpocketing_loot_template`, ignoring.", cond->SourceGroup);
1689 return false;
1690 }
1691
1693 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1694 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1695 {
1696 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1697 return false;
1698 }
1699 break;
1700 }
1702 {
1704 {
1705 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `prospecting_loot_template`, ignoring.", cond->SourceGroup);
1706 return false;
1707 }
1708
1710 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1711 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1712 {
1713 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1714 return false;
1715 }
1716 break;
1717 }
1719 {
1721 {
1722 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `reference_loot_template`, ignoring.", cond->SourceGroup);
1723 return false;
1724 }
1725
1727 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1728 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1729 {
1730 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1731 return false;
1732 }
1733 break;
1734 }
1736 {
1738 {
1739 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `skinning_loot_template`, ignoring.", cond->SourceGroup);
1740 return false;
1741 }
1742
1744 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1745 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1746 {
1747 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1748 return false;
1749 }
1750 break;
1751 }
1753 {
1755 {
1756 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `spell_loot_template`, ignoring.", cond->SourceGroup);
1757 return false;
1758 }
1759
1761 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1762 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1763 {
1764 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1765 return false;
1766 }
1767 break;
1768 }
1770 {
1771 SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1772 if (!spellInfo)
1773 {
1774 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1775 return false;
1776 }
1777
1778 if ((cond->SourceGroup > MAX_EFFECT_MASK) || !cond->SourceGroup)
1779 {
1780 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, has incorrect SourceGroup {} (spell effectMask) set , ignoring.", cond->SourceEntry, cond->SourceGroup);
1781 return false;
1782 }
1783
1784 uint32 origGroup = cond->SourceGroup;
1785
1786 for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
1787 {
1788 if (!((1 << i) & cond->SourceGroup))
1789 continue;
1790
1791 switch (spellInfo->Effects[i].TargetA.GetSelectionCategory())
1792 {
1797 continue;
1798 default:
1799 break;
1800 }
1801
1802 switch (spellInfo->Effects[i].TargetB.GetSelectionCategory())
1803 {
1808 continue;
1809 default:
1810 break;
1811 }
1812
1813 switch (spellInfo->Effects[i].Effect)
1814 {
1822 continue;
1823 default:
1824 break;
1825 }
1826
1827 // Xinef: chain targets are treated as area targets! Apply conditions!
1828 if (spellInfo->Effects[i].ChainTarget > 1)
1829 continue;
1830
1831 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));
1832 cond->SourceGroup &= ~(1 << i);
1833 }
1834 // all effects were removed, no need to add the condition at all
1835 if (!cond->SourceGroup)
1836 return false;
1837 break;
1838 }
1840 {
1841 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1842 {
1843 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1844 return false;
1845 }
1846 break;
1847 }
1850 {
1851 SpellInfo const* spellProto = sSpellMgr->GetSpellInfo(cond->SourceEntry);
1852 if (!spellProto)
1853 {
1854 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1855 return false;
1856 }
1857 break;
1858 }
1860 if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
1861 {
1862 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_QUEST_AVAILABLE specifies non-existing quest ({}), skipped", cond->SourceEntry);
1863 return false;
1864 }
1865 break;
1867 {
1868 if (!sObjectMgr->GetCreatureTemplate(cond->SourceEntry))
1869 {
1870 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_GOSSIP_HELLO: creature entry {} in `condition` table does not exist in `creature_template`, ignoring.", cond->SourceEntry);
1871 return false;
1872 }
1873 break;
1874 }
1877 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1878 {
1879 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1880 return false;
1881 }
1882
1883 if (!sSpellMgr->GetSpellInfo(cond->SourceEntry))
1884 {
1885 LOG_ERROR("sql.sql", "SourceEntry {} in `condition` table, does not exist in `spell.dbc`, ignoring.", cond->SourceEntry);
1886 return false;
1887 }
1888 break;
1890 {
1891 if (!sObjectMgr->GetCreatureTemplate(cond->SourceGroup))
1892 {
1893 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `creature_template`, ignoring.", cond->SourceGroup);
1894 return false;
1895 }
1896 if (cond->SourceEntry)
1897 {
1898 ItemTemplate const* itemTemplate = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1899 if (!itemTemplate)
1900 {
1901 LOG_ERROR("condition", "SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceEntry);
1902 return false;
1903 }
1904 }
1905 break;
1906 }
1908 {
1910 {
1911 LOG_ERROR("sql.sql", "SourceGroup {} in `condition` table, does not exist in `player_loot_template`, ignoring.", cond->SourceGroup);
1912 return false;
1913 }
1914
1916 ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
1917 if (!pItemProto && !loot->isReference(cond->SourceEntry))
1918 {
1919 LOG_ERROR("sql.sql", "SourceType {}, SourceEntry {} in `condition` table, does not exist in `item_template`, ignoring.", cond->SourceType, cond->SourceEntry);
1920 return false;
1921 }
1922 break;
1923 }
1925 {
1926 if (cond->SourceGroup > 1)
1927 {
1928 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY has invalid SourceGroup {} for SourceEntry {}, expected 0 (creature) or 1 (gameobject)", cond->SourceGroup, cond->SourceEntry);
1929 return false;
1930 }
1931
1932 if (cond->SourceEntry <= 0)
1933 {
1934 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY has invalid SourceEntry {}, expected a positive entry id.", cond->SourceEntry);
1935 return false;
1936 }
1937
1938 if (cond->SourceGroup == 0 && !sObjectMgr->GetCreatureTemplate(uint32(cond->SourceEntry)))
1939 {
1940 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY points to non-existing creature entry {}, skipped.", cond->SourceEntry);
1941 return false;
1942 }
1943
1944 if (cond->SourceGroup == 1 && !sObjectMgr->GetGameObjectTemplate(uint32(cond->SourceEntry)))
1945 {
1946 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY points to non-existing gameobject entry {}, skipped.", cond->SourceEntry);
1947 return false;
1948 }
1949
1950 if (cond->SourceId)
1951 {
1952 if (cond->SourceGroup == 0)
1953 {
1954 CreatureData const* data = sObjectMgr->GetCreatureData(cond->SourceId);
1955 if (!data)
1956 {
1957 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY points to non-existing creature guid {}, skipped.", cond->SourceId);
1958 return false;
1959 }
1960
1961 if (data->id1 != uint32(cond->SourceEntry))
1962 {
1963 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY has creature guid {} that does not match SourceEntry {}, skipped.", cond->SourceId, cond->SourceEntry);
1964 return false;
1965 }
1966 }
1967 else
1968 {
1969 GameObjectData const* data = sObjectMgr->GetGameObjectData(cond->SourceId);
1970 if (!data)
1971 {
1972 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY points to non-existing gameobject guid {}, skipped.", cond->SourceId);
1973 return false;
1974 }
1975
1976 if (data->id != uint32(cond->SourceEntry))
1977 {
1978 LOG_ERROR("sql.sql", "CONDITION_SOURCE_TYPE_OBJECT_VISIBILITY has gameobject guid {} that does not match SourceEntry {}, skipped.", cond->SourceId, cond->SourceEntry);
1979 return false;
1980 }
1981 }
1982 }
1983
1984 break;
1985 }
1990 default:
1991 break;
1992 }
1993
1994 return true;
1995}
@ CONDITION_SOURCE_TYPE_TERRAIN_SWAP
Definition ConditionMgr.h:151
@ CONDITION_SOURCE_TYPE_PHASE
Definition ConditionMgr.h:152
@ CONDITION_SOURCE_TYPE_SPELL
Definition ConditionMgr.h:143
@ CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE
Definition ConditionMgr.h:142
@ CONDITION_SOURCE_TYPE_GRAVEYARD
Definition ConditionMgr.h:153
@ CONDITION_SOURCE_TYPE_SPELL_PROC
Definition ConditionMgr.h:150
@ CONDITION_SOURCE_TYPE_QUEST_AVAILABLE
Definition ConditionMgr.h:145
#define MAX_EFFECT_MASK
Definition DBCStructure.h:1638
LootStore LootTemplates_Spell("spell_loot_template", "spell id (random item creating)", false)
LootStore LootTemplates_Skinning("skinning_loot_template", "creature skinning id", true)
LootStore LootTemplates_Gameobject("gameobject_loot_template", "gameobject entry", true)
LootStore LootTemplates_Item("item_loot_template", "item entry", true)
LootStore LootTemplates_Milling("milling_loot_template", "item entry (herb)", true)
LootStore LootTemplates_Reference("reference_loot_template", "reference id", false)
LootStore LootTemplates_Disenchant("disenchant_loot_template", "item disenchant id", true)
LootStore LootTemplates_Prospecting("prospecting_loot_template", "item entry (ore)", true)
LootStore LootTemplates_Creature("creature_loot_template", "creature entry", true)
LootStore LootTemplates_Pickpocketing("pickpocketing_loot_template", "creature pickpocket lootid", true)
LootStore LootTemplates_Mail("mail_loot_template", "mail template id", false)
LootStore LootTemplates_Player("player_loot_template", "team id", true)
LootStore LootTemplates_Fishing("fishing_loot_template", "area id", true)
@ SPELL_EFFECT_APPLY_AREA_AURA_PARTY
Definition SharedDefines.h:801
@ SPELL_EFFECT_APPLY_AREA_AURA_FRIEND
Definition SharedDefines.h:894
@ SPELL_EFFECT_APPLY_AREA_AURA_PET
Definition SharedDefines.h:885
@ SPELL_EFFECT_APPLY_AREA_AURA_RAID
Definition SharedDefines.h:831
@ SPELL_EFFECT_PERSISTENT_AREA_AURA
Definition SharedDefines.h:793
@ SPELL_EFFECT_APPLY_AREA_AURA_ENEMY
Definition SharedDefines.h:895
@ SPELL_EFFECT_APPLY_AREA_AURA_OWNER
Definition SharedDefines.h:909
@ TARGET_SELECT_CATEGORY_CONE
Definition SpellInfo.h:82
@ TARGET_SELECT_CATEGORY_AREA
Definition SpellInfo.h:83
@ TARGET_SELECT_CATEGORY_NEARBY
Definition SpellInfo.h:81
@ TARGET_SELECT_CATEGORY_TRAJ
Definition SpellInfo.h:84
LootTemplate * GetLootForConditionFill(uint32 loot_id) const
Definition LootMgr.cpp:257
bool HaveLootFor(uint32 loot_id) const
Definition LootMgr.h:224
Definition LootMgr.h:245
bool isReference(uint32 id) const
Definition LootMgr.cpp:1897
uint32 SourceId
Definition ConditionMgr.h:202
uint32 id1
Definition CreatureData.h:372
uint32 id
Definition GameObjectData.h:717

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_HELLO, 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_OBJECT_VISIBILITY, 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_VEHICLE_SPELL, SpellInfo::Effects, LootStore::GetLootForConditionFill(), LootStore::HaveLootFor(), GameObjectData::id, CreatureData::id1, 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::SourceId, 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 ?

1124{
1125 uint32 oldMSTime = getMSTime();
1126
1127 Clean();
1128
1129 // must clear all custom handled cases (groupped types) before reload
1130 if (isReload)
1131 {
1132 LOG_INFO("server.loading", "Reseting Loot Conditions...");
1146
1147 LOG_INFO("server.loading", "Reloading `gossip_menu` Table for Conditions!");
1148 sObjectMgr->LoadGossipMenu();
1149
1150 LOG_INFO("server.loading", "Reloading `gossip_menu_option` Table for Conditions!");
1151 sObjectMgr->LoadGossipMenuItems();
1152 sSpellMgr->UnloadSpellInfoImplicitTargetConditionLists();
1153 }
1154
1155 QueryResult result = WorldDatabase.Query("SELECT SourceTypeOrReferenceId, SourceGroup, SourceEntry, SourceId, ElseGroup, ConditionTypeOrReference, ConditionTarget, "
1156 " ConditionValue1, ConditionValue2, ConditionValue3, NegativeCondition, ErrorType, ErrorTextId, ScriptName FROM conditions");
1157
1158 if (!result)
1159 {
1160 LOG_WARN("server.loading", ">> Loaded 0 conditions. DB table `conditions` is empty!");
1161 return;
1162 }
1163
1164 uint32 count = 0;
1165
1166 do
1167 {
1168 Field* fields = result->Fetch();
1169
1170 Condition* cond = new Condition();
1171 int32 iSourceTypeOrReferenceId = fields[0].Get<int32>();
1172 cond->SourceGroup = fields[1].Get<uint32>();
1173 cond->SourceEntry = fields[2].Get<int32>();
1174 cond->SourceId = fields[3].Get<int32>();
1175 cond->ElseGroup = fields[4].Get<uint32>();
1176 int32 iConditionTypeOrReference = fields[5].Get<int32>();
1177 cond->ConditionTarget = fields[6].Get<uint8>();
1178 cond->ConditionValue1 = fields[7].Get<uint32>();
1179 cond->ConditionValue2 = fields[8].Get<uint32>();
1180 cond->ConditionValue3 = fields[9].Get<uint32>();
1181 cond->NegativeCondition = fields[10].Get<uint8>();
1182 cond->ErrorType = fields[11].Get<uint32>();
1183 cond->ErrorTextId = fields[12].Get<uint32>();
1184 cond->ScriptId = sObjectMgr->GetScriptId(fields[13].Get<std::string>());
1185
1186 if (iConditionTypeOrReference >= 0)
1187 cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
1188
1189 if (iSourceTypeOrReferenceId >= 0)
1190 cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
1191
1192 if (iConditionTypeOrReference < 0) // it has a reference
1193 {
1194 if (iConditionTypeOrReference == iSourceTypeOrReferenceId) // self referencing, skip
1195 {
1196 LOG_ERROR("sql.sql", "Condition reference {} is referencing self, skipped", iSourceTypeOrReferenceId);
1197 delete cond;
1198 continue;
1199 }
1200 cond->ReferenceId = uint32(std::abs(iConditionTypeOrReference));
1201
1202 const char* rowType = "reference template";
1203 if (iSourceTypeOrReferenceId >= 0)
1204 rowType = "reference";
1205 // check for useless data
1206 if (cond->ConditionTarget)
1207 LOG_ERROR("sql.sql", "Condition {} {} has useless data in ConditionTarget ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionTarget);
1208 if (cond->ConditionValue1)
1209 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value1 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue1);
1210 if (cond->ConditionValue2)
1211 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value2 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue2);
1212 if (cond->ConditionValue3)
1213 LOG_ERROR("sql.sql", "Condition {} {} has useless data in value3 ({})!", rowType, iSourceTypeOrReferenceId, cond->ConditionValue3);
1214 if (cond->NegativeCondition)
1215 LOG_ERROR("sql.sql", "Condition {} {} has useless data in NegativeCondition ({})!", rowType, iSourceTypeOrReferenceId, cond->NegativeCondition);
1216 if (cond->SourceGroup && iSourceTypeOrReferenceId < 0)
1217 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceGroup ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceGroup);
1218 if (cond->SourceEntry && iSourceTypeOrReferenceId < 0)
1219 LOG_ERROR("sql.sql", "Condition {} {} has useless data in SourceEntry ({})!", rowType, iSourceTypeOrReferenceId, cond->SourceEntry);
1220 }
1221 else if (!isConditionTypeValid(cond)) // doesn't have reference, validate ConditionType
1222 {
1223 delete cond;
1224 continue;
1225 }
1226
1227 if (iSourceTypeOrReferenceId < 0) // it is a reference template
1228 {
1229 uint32 uRefId = std::abs(iSourceTypeOrReferenceId);
1230 if (ConditionReferenceStore.find(uRefId) == ConditionReferenceStore.end()) // make sure we have a list for our conditions, based on reference id
1231 {
1232 ConditionList mCondList;
1233 ConditionReferenceStore[uRefId] = mCondList;
1234 }
1235 ConditionReferenceStore[uRefId].push_back(cond); // add to reference storage
1236 count++;
1237 continue;
1238 } // end of reference templates
1239
1240 // if not a reference and SourceType is invalid, skip
1241 if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
1242 {
1243 delete cond;
1244 continue;
1245 }
1246
1247 // Grouping is only allowed for some types (loot templates, gossip menus, gossip items)
1248 if (cond->SourceGroup && !CanHaveSourceGroupSet(cond->SourceType))
1249 {
1250 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceGroup = {}!", uint32(cond->SourceType), cond->SourceGroup);
1251 delete cond;
1252 continue;
1253 }
1254 if (cond->SourceId && !CanHaveSourceIdSet(cond->SourceType))
1255 {
1256 LOG_ERROR("sql.sql", "Condition type {} has not allowed value of SourceId = {}!", uint32(cond->SourceType), cond->SourceId);
1257 delete cond;
1258 continue;
1259 }
1260
1261 if (cond->ErrorType && cond->SourceType != CONDITION_SOURCE_TYPE_SPELL)
1262 {
1263 LOG_ERROR("condition", "Condition type {} entry {} can't have ErrorType ({}), set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorType);
1264 cond->ErrorType = 0;
1265 }
1266
1267 if (cond->ErrorTextId && !cond->ErrorType)
1268 {
1269 LOG_ERROR("condition", "Condition type {} entry {} has any ErrorType, ErrorTextId ({}) is set, set to 0!", uint32(cond->SourceType), cond->SourceEntry, cond->ErrorTextId);
1270 cond->ErrorTextId = 0;
1271 }
1272
1275 {
1276 bool valid = false;
1277 // handle grouped conditions
1278 switch (cond->SourceType)
1279 {
1282 break;
1285 break;
1288 break;
1291 break;
1294 break;
1297 break;
1300 break;
1303 break;
1306 break;
1309 break;
1312 break;
1315 break;
1317 valid = addToGossipMenus(cond);
1318 break;
1320 valid = addToGossipMenuItems(cond);
1321 break;
1323 {
1324 SpellClickEventConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1325 valid = true;
1326 ++count;
1327 continue; // do not add to m_AllocatedMemory to avoid double deleting
1328 }
1331 break;
1333 {
1334 VehicleSpellConditionStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1335 valid = true;
1336 ++count;
1337 continue; // do not add to m_AllocatedMemory to avoid double deleting
1338 }
1340 {
1342 std::pair<int32, uint32> key = std::make_pair(cond->SourceEntry, cond->SourceId);
1343 SmartEventConditionStore[key][cond->SourceGroup].push_back(cond);
1344 valid = true;
1345 ++count;
1346 continue;
1347 }
1349 {
1350 NpcVendorConditionContainerStore[cond->SourceGroup][cond->SourceEntry].push_back(cond);
1351 valid = true;
1352 ++count;
1353 continue;
1354 }
1356 {
1357 ObjectVisibilityConditionStore[std::make_pair(uint32(cond->SourceEntry), cond->SourceGroup)][cond->SourceId].push_back(cond);
1358 valid = true;
1359 ++count;
1360 continue; // do not add to AllocatedMemoryStore to avoid double-deleting
1361 }
1363 {
1365 break;
1366 }
1367 default:
1368 break;
1369 }
1370
1371 if (!valid)
1372 {
1373 LOG_ERROR("sql.sql", "Not handled grouped condition, SourceGroup {}", cond->SourceGroup);
1374 delete cond;
1375 }
1376 else
1377 {
1378 AllocatedMemoryStore.push_back(cond);
1379 ++count;
1380 }
1381 continue;
1382 }
1383
1384 // handle not grouped conditions
1385 // make sure we have a storage list for our SourceType
1386 if (ConditionStore.find(cond->SourceType) == ConditionStore.end())
1387 {
1388 ConditionTypeContainer mTypeMap;
1389 ConditionStore[cond->SourceType] = mTypeMap; // add new empty list for SourceType
1390 }
1391
1392 // make sure we have a condition list for our SourceType's entry
1393 if (ConditionStore[cond->SourceType].find(cond->SourceEntry) == ConditionStore[cond->SourceType].end())
1394 {
1395 ConditionList mCondList;
1396 ConditionStore[cond->SourceType][cond->SourceEntry] = mCondList;
1397 }
1398
1399 // add new Condition to storage based on Type/Entry
1400 ConditionStore[cond->SourceType][cond->SourceEntry].push_back(cond);
1401 ++count;
1402 } while (result->NextRow());
1403
1404 LOG_INFO("server.loading", ">> Loaded {} conditions in {} ms", count, GetMSTimeDiffToNow(oldMSTime));
1405 LOG_INFO("server.loading", " ");
1406}
ConditionSourceType
Definition ConditionMgr.h:125
ConditionTypes
Definition ConditionMgr.h:32
std::map< uint32, ConditionList > ConditionTypeContainer
Definition ConditionMgr.h:241
std::shared_ptr< ResultSet > QueryResult
Definition DatabaseEnvFwd.h:27
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
Definition DatabaseEnv.cpp:20
std::int32_t int32
Definition Define.h:103
#define LOG_INFO(filterType__,...)
Definition Log.h:153
#define LOG_WARN(filterType__,...)
Definition Log.h:149
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
Definition Timer.h:131
uint32 getMSTime()
Definition Timer.h:103
bool isConditionTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1996
bool CanHaveSourceGroupSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:984
bool addToSpellImplicitTargetConditions(Condition *cond)
Definition ConditionMgr.cpp:1462
bool addToGossipMenus(Condition *cond)
Definition ConditionMgr.cpp:1423
bool addToGossipMenuItems(Condition *cond)
Definition ConditionMgr.cpp:1443
bool addToLootTemplate(Condition *cond, LootTemplate *loot)
Definition ConditionMgr.cpp:1408
bool isSourceTypeValid(Condition *cond)
Definition ConditionMgr.cpp:1548
bool CanHaveSourceIdSet(ConditionSourceType sourceType) const
Definition ConditionMgr.cpp:991
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
void ResetConditions()
Definition LootMgr.cpp:238
uint32 ErrorType
Definition ConditionMgr.h:208
uint32 ElseGroup
Definition ConditionMgr.h:203
uint32 ScriptId
Definition ConditionMgr.h:211
bool NegativeCondition
Definition ConditionMgr.h:213
uint32 ReferenceId
Definition ConditionMgr.h:210
uint32 ErrorTextId
Definition ConditionMgr.h:209

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_OBJECT_VISIBILITY, 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, ObjectVisibilityConditionStore, 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

◆ ObjectVisibilityConditionStore

ObjectVisibilityConditionContainer ConditionMgr::ObjectVisibilityConditionStore
private

◆ SmartEventConditionStore

SmartEventConditionContainer ConditionMgr::SmartEventConditionStore
private

◆ SpellClickEventConditionStore

CreatureSpellConditionContainer ConditionMgr::SpellClickEventConditionStore
private

◆ VehicleSpellConditionStore

CreatureSpellConditionContainer ConditionMgr::VehicleSpellConditionStore
private

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