[12044] Add CONDITION_NOT (-3) to conditions system

Signed-off-by: Schmoozerd <schmoozerd@scriptdev2.com>
This commit is contained in:
codels 2012-06-24 13:11:06 +04:00 committed by Schmoozerd
parent c8c6418d6e
commit a3faf136bc
3 changed files with 30 additions and 11 deletions

38
src/game/ObjectMgr.cpp Normal file → Executable file
View file

@ -7540,6 +7540,9 @@ bool PlayerCondition::Meets(Player const * player) const
switch (m_condition)
{
case CONDITION_NOT:
// Checked on load
return !sConditionStorage.LookupEntry<PlayerCondition>(m_value1)->Meets(player);
case CONDITION_OR:
// Checked on load
return sConditionStorage.LookupEntry<PlayerCondition>(m_value1)->Meets(player) || sConditionStorage.LookupEntry<PlayerCondition>(m_value2)->Meets(player);
@ -7744,29 +7747,44 @@ bool PlayerCondition::IsValid(uint16 entry, ConditionType condition, uint32 valu
{
switch (condition)
{
case CONDITION_OR:
case CONDITION_AND:
case CONDITION_NOT:
{
if (value1 >= entry)
{
sLog.outErrorDb("And or Or condition (entry %u, type %d) has invalid value1 %u, must be lower than entry, skipped", entry, condition, value1);
return false;
}
if (value2 >= entry)
{
sLog.outErrorDb("And or Or condition (entry %u, type %d) has invalid value2 %u, must be lower than entry, skipped", entry, condition, value2);
sLog.outErrorDb("CONDITION_NOT (entry %u, type %d) has invalid value1 %u, must be lower than entry, skipped", entry, condition, value1);
return false;
}
const PlayerCondition* condition1 = sConditionStorage.LookupEntry<PlayerCondition>(value1);
if (!condition1)
{
sLog.outErrorDb("And or Or condition (entry %u, type %d) has value1 %u without proper condition, skipped", entry, condition, value1);
sLog.outErrorDb("CONDITION_NOT (entry %u, type %d) has value1 %u without proper condition, skipped", entry, condition, value1);
return false;
}
break;
}
case CONDITION_OR:
case CONDITION_AND:
{
if (value1 >= entry)
{
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has invalid value1 %u, must be lower than entry, skipped", entry, condition, value1);
return false;
}
if (value2 >= entry)
{
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has invalid value2 %u, must be lower than entry, skipped", entry, condition, value2);
return false;
}
const PlayerCondition* condition1 = sConditionStorage.LookupEntry<PlayerCondition>(value1);
if (!condition1)
{
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has value1 %u without proper condition, skipped", entry, condition, value1);
return false;
}
const PlayerCondition* condition2 = sConditionStorage.LookupEntry<PlayerCondition>(value2);
if (!condition2)
{
sLog.outErrorDb("And or Or condition (entry %u, type %d) has value2 %u without proper condition, skipped", entry, condition, value2);
sLog.outErrorDb("CONDITION _AND or _OR (entry %u, type %d) has value2 %u without proper condition, skipped", entry, condition, value2);
return false;
}
break;