[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;

1
src/game/ObjectMgr.h Normal file → Executable file
View file

@ -338,6 +338,7 @@ typedef std::pair<GraveYardMap::const_iterator, GraveYardMap::const_iterator> Gr
enum ConditionType
{ // value1 value2 for the Condition enumed
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_NONE = 0, // 0 0

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "12043"
#define REVISION_NR "12044"
#endif // __REVISION_NR_H__