aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Conditions/ConditionMgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/server/game/Conditions/ConditionMgr.cpp')
-rwxr-xr-xsrc/server/game/Conditions/ConditionMgr.cpp175
1 files changed, 23 insertions, 152 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp
index f52cb96501f..320a02a30ed 100755
--- a/src/server/game/Conditions/ConditionMgr.cpp
+++ b/src/server/game/Conditions/ConditionMgr.cpp
@@ -40,7 +40,6 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
return false;
}
bool condMeets = false;
- bool sendErrorMsg = false;
switch (ConditionType)
{
case CONDITION_NONE:
@@ -49,15 +48,7 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case CONDITION_AURA:
{
if (Unit* unit = object->ToUnit())
- {
- if (!ConditionValue3)
- condMeets = unit->HasAuraEffect(ConditionValue1, ConditionValue2);
- else if (Player* player = unit->ToPlayer())
- {
- if (Unit* target = player->GetSelectedUnit())
- condMeets = target->HasAuraEffect(ConditionValue1, ConditionValue2);
- }
- }
+ condMeets = unit->HasAuraEffect(ConditionValue1, ConditionValue2);
break;
}
case CONDITION_ITEM:
@@ -165,49 +156,12 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo)
case CONDITION_SPELL_SCRIPT_TARGET:
condMeets = true;//spell target condition is handled in spellsystem, here it is always true
break;
- case CONDITION_CREATURE_TARGET:
- {
- if (Player* player = object->ToPlayer())
- {
- Unit* target = player->GetSelectedUnit();
- if (target)
- if (Creature* cTarget = target->ToCreature())
- if (cTarget->GetEntry() == ConditionValue1)
- condMeets = true;
- }
- break;
- }
- case CONDITION_TARGET_HEALTH_BELOW_PCT:
- {
- if (Player* player = object->ToPlayer())
- {
- Unit* target = player->GetSelectedUnit();
- if (target)
- condMeets = !target->HealthAbovePct(ConditionValue1);
- break;
- }
- }
- case CONDITION_TARGET_RANGE:
- {
- if (Player* player = object->ToPlayer())
- {
- if (Unit* target = player->GetSelectedUnit())
- if (player->GetDistance(target) >= ConditionValue1 && (!ConditionValue2 || player->GetDistance(target) <= ConditionValue2))
- condMeets = true;
- }
- break;
- }
case CONDITION_MAPID:
condMeets = object->GetMapId() == ConditionValue1;
break;
case CONDITION_AREAID:
condMeets = object->GetAreaId() == ConditionValue1;
break;
- case CONDITION_ITEM_TARGET:
- {
- condMeets = true; //handled in Item::IsTargetValidForItemUse
- break;
- }
case CONDITION_SPELL:
{
if (Player* player = object->ToPlayer())
@@ -553,6 +507,9 @@ void ConditionMgr::LoadConditions(bool isReload)
if (iConditionTypeOrReference >= 0)
cond->ConditionType = ConditionTypes(iConditionTypeOrReference);
+ if (iSourceTypeOrReferenceId >= 0)
+ cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
+
if (iConditionTypeOrReference < 0)//it has a reference
{
if (iConditionTypeOrReference == iSourceTypeOrReferenceId)//self referencing, skip
@@ -601,8 +558,6 @@ void ConditionMgr::LoadConditions(bool isReload)
continue;
}//end of reference templates
- cond->SourceType = ConditionSourceType(iSourceTypeOrReferenceId);
-
//if not a reference and SourceType is invalid, skip
if (iConditionTypeOrReference >= 0 && !isSourceTypeValid(cond))
{
@@ -768,7 +723,7 @@ bool ConditionMgr::addToGossipMenus(Condition* cond)
{
for (GossipMenusContainer::iterator itr = pMenuBounds.first; itr != pMenuBounds.second; ++itr)
{
- if ((*itr).second.entry == cond->SourceGroup && (*itr).second.text_id == cond->SourceEntry)
+ if ((*itr).second.entry == cond->SourceGroup && (*itr).second.text_id == uint32(cond->SourceEntry))
{
(*itr).second.conditions.push_back(cond);
return true;
@@ -787,7 +742,7 @@ bool ConditionMgr::addToGossipMenuItems(Condition* cond)
{
for (GossipMenuItemsContainer::iterator itr = pMenuItemBounds.first; itr != pMenuItemBounds.second; ++itr)
{
- if ((*itr).second.MenuId == cond->SourceGroup && (*itr).second.OptionIndex == cond->SourceEntry)
+ if ((*itr).second.MenuId == cond->SourceGroup && (*itr).second.OptionIndex == uint32(cond->SourceEntry))
{
(*itr).second.Conditions.push_back(cond);
return true;
@@ -1092,50 +1047,6 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
}
break;
}
- case CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET:
- {
- if (cond->ConditionType != CONDITION_ITEM_TARGET)
- {
- sLog->outErrorDb("SourceEntry %u in `condition` table, has ConditionType %u. Only CONDITION_ITEM_TARGET(24) is valid for CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET(18), ignoring.", cond->SourceEntry, uint32(cond->ConditionType));
- return false;
- }
-
- ItemTemplate const* pItemProto = sObjectMgr->GetItemTemplate(cond->SourceEntry);
- if (!pItemProto)
- {
- sLog->outErrorDb("SourceEntry %u in `condition` table, does not exist in `item_tamplate`, ignoring.", cond->SourceEntry);
- return false;
- }
-
- bool bIsItemSpellValid = false;
- for (uint8 i = 0; i < MAX_ITEM_PROTO_SPELLS; ++i)
- {
- if (SpellInfo const* pSpellInfo = sSpellMgr->GetSpellInfo(pItemProto->Spells[i].SpellId))
- {
- if (pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_USE ||
- pItemProto->Spells[i].SpellTrigger == ITEM_SPELLTRIGGER_ON_NO_DELAY_USE)
- {
- ConditionList conditions = sConditionMgr->GetConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_SPELL_SCRIPT_TARGET, pSpellInfo->Id);//script loading is done before item target loading
- if (!conditions.empty())
- break;
-
- if (pSpellInfo->NeedsExplicitUnitTarget())
- {
- bIsItemSpellValid = true;
- break;
- }
- }
- }
- }
-
- if (!bIsItemSpellValid)
- {
- sLog->outErrorDb("Conditions: CONDITION_SOURCE_TYPE_ITEM_REQUIRED_TARGET for item %u, which either doesn't have item spelltrigger or its spells don't allow caster to select a unit target"
- ", or the spells are already listed in CONDITION_SOURCE_TYPE_SPELL_SCRIPT_TARGET conditions.", cond->SourceEntry);
- break;
- }
- break;
- }
case CONDITION_SOURCE_TYPE_QUEST_ACCEPT:
if (!sObjectMgr->GetQuestTemplate(cond->SourceEntry))
{
@@ -1163,6 +1074,9 @@ bool ConditionMgr::isSourceTypeValid(Condition* cond)
return false;
}
break;
+ case CONDITION_SOURCE_TYPE_UNUSED_18:
+ sLog->outErrorDb("Found SourceTypeOrReferenceId = CONDITION_SOURCE_TYPE_UNUSED_18 in `conditions` table - ignoring");
+ return false;
case CONDITION_SOURCE_TYPE_GOSSIP_MENU:
case CONDITION_SOURCE_TYPE_GOSSIP_MENU_OPTION:
case CONDITION_SOURCE_TYPE_SMART_EVENT:
@@ -1202,6 +1116,8 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
sLog->outErrorDb("Aura condition has non existing effect index (%u) (must be 0..2), skipped", cond->ConditionValue2);
return false;
}
+ if (cond->ConditionValue3)
+ sLog->outErrorDb("Aura condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
case CONDITION_ITEM:
@@ -1415,45 +1331,6 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
}
break;
}
- case CONDITION_CREATURE_TARGET:
- {
- if (!cond->ConditionValue1 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue1))
- {
- sLog->outErrorDb("CreatureTarget condition has non existing creature template entry (%u) as target, skipped", cond->ConditionValue1);
- return false;
- }
-
- if (cond->ConditionValue2)
- sLog->outErrorDb("CreatureTarget condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- sLog->outErrorDb("CreatureTarget condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
- case CONDITION_TARGET_HEALTH_BELOW_PCT:
- {
- if (cond->ConditionValue1 > 100)
- {
- sLog->outErrorDb("TargetHealthBelowPct condition has invalid data in value1 (%u), skipped", cond->ConditionValue1);
- return false;
- }
-
- if (cond->ConditionValue2)
- sLog->outErrorDb("TargetHealthBelowPct condition has useless data in value2 (%u)!", cond->ConditionValue2);
- if (cond->ConditionValue3)
- sLog->outErrorDb("TargetHealthBelowPct condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
- case CONDITION_TARGET_RANGE:
- {
- if (cond->ConditionValue2 && cond->ConditionValue2 < cond->ConditionValue1)//maxDist can be 0 for infinit max range
- {
- sLog->outErrorDb("TargetRange condition has max distance closer then min distance, skipped");
- return false;
- }
- if (cond->ConditionValue3)
- sLog->outErrorDb("TargetRange condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
case CONDITION_MAPID:
{
MapEntry const* me = sMapStore.LookupEntry(cond->ConditionValue1);
@@ -1469,24 +1346,6 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
sLog->outErrorDb("Map condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
- case CONDITION_ITEM_TARGET:
- {
- if (!cond->ConditionValue1 || cond->ConditionValue1 > MAX_ITEM_REQ_TARGET_TYPE)
- {
- sLog->outErrorDb("ItemTarget condition has incorrect target type (%u), skipped", cond->ConditionValue1);
- return false;
- }
-
- if (!cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2))
- {
- sLog->outErrorDb("ItemTarget condition has non existing creature template entry (%u) as target, skipped", cond->ConditionValue2);
- return false;
- }
-
- if (cond->ConditionValue3)
- sLog->outErrorDb("ItemTarget condition has useless data in value3 (%u)!", cond->ConditionValue3);
- break;
- }
case CONDITION_SPELL:
{
if (!sSpellMgr->GetSpellInfo(cond->ConditionValue1))
@@ -1712,6 +1571,18 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond)
sLog->outErrorDb("Phasemask condition has useless data in value3 (%u)!", cond->ConditionValue3);
break;
}
+ case CONDITION_UNUSED_19:
+ sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
+ return false;
+ case CONDITION_UNUSED_20:
+ sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
+ return false;
+ case CONDITION_UNUSED_21:
+ sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
+ return false;
+ case CONDITION_UNUSED_24:
+ sLog->outErrorDb("Found ConditionTypeOrReference = CONDITION_UNUSED_19 in `conditions` table - ignoring");
+ return false;
default:
break;
}