Allow using up to 4 params in OR and AND conditions.
This commit is contained in:
+42
-3
@@ -139,13 +139,24 @@ bool inline ConditionEntry::Evaluate(WorldObject const* target, Map const* map,
|
||||
}
|
||||
case CONDITION_OR:
|
||||
{
|
||||
// Checked on load
|
||||
// Third and fourth condition are optional
|
||||
if (m_value3 && sConditionStorage.LookupEntry<ConditionEntry>(m_value3)->Meets(target, map, source, conditionSourceType))
|
||||
return true;
|
||||
if (m_value4 && sConditionStorage.LookupEntry<ConditionEntry>(m_value4)->Meets(target, map, source, conditionSourceType))
|
||||
return true;
|
||||
|
||||
return sConditionStorage.LookupEntry<ConditionEntry>(m_value1)->Meets(target, map, source, conditionSourceType) || sConditionStorage.LookupEntry<ConditionEntry>(m_value2)->Meets(target, map, source, conditionSourceType);
|
||||
}
|
||||
case CONDITION_AND:
|
||||
{
|
||||
// Checked on load
|
||||
return sConditionStorage.LookupEntry<ConditionEntry>(m_value1)->Meets(target, map, source, conditionSourceType) && sConditionStorage.LookupEntry<ConditionEntry>(m_value2)->Meets(target, map, source, conditionSourceType);
|
||||
// Third and fourth condition are optional
|
||||
bool extraConditionsSatisfied = true;
|
||||
if (m_value3)
|
||||
extraConditionsSatisfied = extraConditionsSatisfied && sConditionStorage.LookupEntry<ConditionEntry>(m_value3)->Meets(target, map, source, conditionSourceType);
|
||||
if (m_value4)
|
||||
extraConditionsSatisfied = extraConditionsSatisfied && sConditionStorage.LookupEntry<ConditionEntry>(m_value4)->Meets(target, map, source, conditionSourceType);
|
||||
|
||||
return extraConditionsSatisfied && sConditionStorage.LookupEntry<ConditionEntry>(m_value1)->Meets(target, map, source, conditionSourceType) && sConditionStorage.LookupEntry<ConditionEntry>(m_value2)->Meets(target, map, source, conditionSourceType);
|
||||
}
|
||||
case CONDITION_NONE:
|
||||
{
|
||||
@@ -657,6 +668,34 @@ bool ConditionEntry::IsValid()
|
||||
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has value2 %u without proper condition, skipped", m_entry, m_condition, m_value2);
|
||||
return false;
|
||||
}
|
||||
if (m_value3)
|
||||
{
|
||||
if (m_value3 >= m_entry)
|
||||
{
|
||||
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has invalid value3 %u, must be lower than entry, skipped", m_entry, m_condition, m_value3);
|
||||
return false;
|
||||
}
|
||||
const ConditionEntry* condition3 = sConditionStorage.LookupEntry<ConditionEntry>(m_value3);
|
||||
if (!condition3)
|
||||
{
|
||||
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has value3 %u without proper condition, skipped", m_entry, m_condition, m_value3);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (m_value4)
|
||||
{
|
||||
if (m_value4 >= m_entry)
|
||||
{
|
||||
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has invalid value4 %u, must be lower than entry, skipped", m_entry, m_condition, m_value4);
|
||||
return false;
|
||||
}
|
||||
const ConditionEntry* condition4 = sConditionStorage.LookupEntry<ConditionEntry>(m_value4);
|
||||
if (!condition4)
|
||||
{
|
||||
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has value4 %u without proper condition, skipped", m_entry, m_condition, m_value4);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CONDITION_AURA:
|
||||
|
||||
@@ -27,8 +27,8 @@ enum ConditionType
|
||||
{
|
||||
// // value1 value2 value3 value4
|
||||
CONDITION_NOT = -3, // cond-id-1 0 returns !cond-id-1
|
||||
CONDITION_OR = -2, // cond-id-1 cond-id-2 returns cond-id-1 OR cond-id-2
|
||||
CONDITION_AND = -1, // cond-id-1 cond-id-2 returns cond-id-1 AND cond-id-2
|
||||
CONDITION_OR = -2, // cond-id-1 cond-id-2 cond-id-3 cond-id-4 returns true if at least one of the conditions is satisfied
|
||||
CONDITION_AND = -1, // cond-id-1 cond-id-2 cond-id-3 cond-id-4 returns true only if all conditions are satisfied
|
||||
CONDITION_NONE = 0, // 0 0
|
||||
CONDITION_AURA = 1, // spell_id effindex
|
||||
CONDITION_ITEM = 2, // item_id count check present req. amount items in inventory
|
||||
|
||||
Reference in New Issue
Block a user