diff options
| -rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 51 | 
1 files changed, 39 insertions, 12 deletions
| diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 9c2d8d58b96..b6881990567 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -1312,17 +1312,44 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const      std::list<uint32> sharedMasks;      for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)      { -        // check if effect is already a part of some shared mask -        bool found = false; -        for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr) +        // additional checks by condition type +        if (conditionEffMask & (1 << i))          { -            if ((1<<i) & *itr) +            switch (cond->ConditionType)              { -                found = true; -                break; +                case CONDITION_OBJECT_ENTRY_GUID: +                { +                    uint32 implicitTargetMask = GetTargetFlagMask(spellInfo->Effects[i].TargetA.GetObjectType()) | GetTargetFlagMask(spellInfo->Effects[i].TargetB.GetObjectType()); +                    if ((implicitTargetMask & TARGET_FLAG_UNIT_MASK) && cond->ConditionValue1 != TYPEID_UNIT && cond->ConditionValue1 != TYPEID_PLAYER) +                    { +                        TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - " +                            "target requires ConditionValue1 to be either TYPEID_UNIT (%u) or TYPEID_PLAYER (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_UNIT), uint32(TYPEID_PLAYER)); +                        return false; +                    } + +                    if ((implicitTargetMask & TARGET_FLAG_GAMEOBJECT_MASK) && cond->ConditionValue1 != TYPEID_GAMEOBJECT) +                    { +                        TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - " +                            "target requires ConditionValue1 to be TYPEID_GAMEOBJECT (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_GAMEOBJECT)); +                        return false; +                    } + +                    if ((implicitTargetMask & TARGET_FLAG_CORPSE_MASK) && cond->ConditionValue1 != TYPEID_CORPSE) +                    { +                        TC_LOG_ERROR("sql.sql", "%s in `condition` table - spell %u EFFECT_%u - " +                            "target requires ConditionValue1 to be TYPEID_CORPSE (%u)", cond->ToString().c_str(), spellInfo->Id, uint32(i), uint32(TYPEID_CORPSE)); +                        return false; +                    } +                    break; +                } +                default: +                    break;              }          } -        if (found) + +        // check if effect is already a part of some shared mask +        auto itr = std::find_if(sharedMasks.begin(), sharedMasks.end(), [i](uint32 mask) { return !!(mask & (1 << i)); }); +        if (itr != sharedMasks.end())              continue;          // build new shared mask with found effect @@ -1336,14 +1363,14 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const          sharedMasks.push_back(sharedMask);      } -    for (std::list<uint32>::iterator itr = sharedMasks.begin(); itr != sharedMasks.end(); ++itr) +    for (uint32 effectMask : sharedMasks)      {          // some effect indexes should have same data -        if (uint32 commonMask = *itr & conditionEffMask) +        if (uint32 commonMask = effectMask & conditionEffMask)          {              uint8 firstEffIndex = 0;              for (; firstEffIndex < MAX_SPELL_EFFECTS; ++firstEffIndex) -                if ((1<<firstEffIndex) & *itr) +                if ((1 << firstEffIndex) & effectMask)                      break;              if (firstEffIndex >= MAX_SPELL_EFFECTS) @@ -1356,7 +1383,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const              if (sharedList)              {                  // we have overlapping masks in db -                if (conditionEffMask != *itr) +                if (conditionEffMask != effectMask)                  {                      TC_LOG_ERROR("sql.sql", "%s in `condition` table, has incorrect SourceGroup %u (spell effectMask) set - "                          "effect masks are overlapping (all SourceGroup values having given bit set must be equal) - ignoring.", cond->ToString().c_str(), cond->SourceGroup); @@ -1371,7 +1398,7 @@ bool ConditionMgr::addToSpellImplicitTargetConditions(Condition* cond) const                  bool assigned = false;                  for (uint8 i = firstEffIndex; i < MAX_SPELL_EFFECTS; ++i)                  { -                    if ((1<<i) & commonMask) +                    if ((1 << i) & commonMask)                      {                          spellInfo->Effects[i].ImplicitTargetConditions = sharedList;                          assigned = true; | 
