diff options
author | joschiwald <joschiwald.trinity@gmail.com> | 2014-08-24 00:10:09 +0200 |
---|---|---|
committer | joschiwald <joschiwald.trinity@gmail.com> | 2014-08-24 00:10:09 +0200 |
commit | 2a36d2bf5b7f14284a499a14f476c4633b1fc0eb (patch) | |
tree | 57574852dc9b1b2f5648a434aab94fc55925d6c1 /src | |
parent | f2fa1533d9c2c72bb1c457d22109f356811acb57 (diff) |
Core/Conditions: allow CONDITION_OBJECT_ENTRY to check for object guid
Ref #12910
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.cpp | 67 | ||||
-rw-r--r-- | src/server/game/Conditions/ConditionMgr.h | 2 |
2 files changed, 58 insertions, 11 deletions
diff --git a/src/server/game/Conditions/ConditionMgr.cpp b/src/server/game/Conditions/ConditionMgr.cpp index 817adc9c45b..948dc9b7cb3 100644 --- a/src/server/game/Conditions/ConditionMgr.cpp +++ b/src/server/game/Conditions/ConditionMgr.cpp @@ -211,10 +211,25 @@ bool Condition::Meets(ConditionSourceInfo& sourceInfo) condMeets = GetClosestGameObjectWithEntry(object, ConditionValue1, (float)ConditionValue2) ? true : false; break; } - case CONDITION_OBJECT_ENTRY: + case CONDITION_OBJECT_ENTRY_GUID: { if (uint32(object->GetTypeId()) == ConditionValue1) - condMeets = (!ConditionValue2) || (object->GetEntry() == ConditionValue2); + { + condMeets = !ConditionValue2 || (object->GetEntry() == ConditionValue2); + + if (ConditionValue3) + { + switch (object->GetTypeId()) + { + case TYPEID_UNIT: + condMeets &= object->ToCreature()->GetDBTableGUIDLow() == ConditionValue3; + break; + case TYPEID_GAMEOBJECT: + condMeets &= object->ToGameObject()->GetDBTableGUIDLow() == ConditionValue3; + break; + } + } + } break; } case CONDITION_TYPE_MASK: @@ -419,7 +434,7 @@ uint32 Condition::GetSearcherTypeMaskForCondition() case CONDITION_NEAR_GAMEOBJECT: mask |= GRID_MAP_TYPE_MASK_ALL; break; - case CONDITION_OBJECT_ENTRY: + case CONDITION_OBJECT_ENTRY_GUID: switch (ConditionValue1) { case TYPEID_UNIT: @@ -1810,35 +1825,67 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) TC_LOG_ERROR("sql.sql", "NearGameObject condition has useless data in value3 (%u)!", cond->ConditionValue3); break; } - case CONDITION_OBJECT_ENTRY: + case CONDITION_OBJECT_ENTRY_GUID: { switch (cond->ConditionValue1) { case TYPEID_UNIT: if (cond->ConditionValue2 && !sObjectMgr->GetCreatureTemplate(cond->ConditionValue2)) { - TC_LOG_ERROR("sql.sql", "ObjectEntry condition has non existing creature template entry (%u), skipped", cond->ConditionValue2); + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature template entry (%u), skipped", cond->ConditionValue2); return false; } + if (cond->ConditionValue3) + { + if (CreatureData const* creatureData = sObjectMgr->GetCreatureData(cond->ConditionValue3)) + { + if (cond->ConditionValue2 && creatureData->id != cond->ConditionValue2) + { + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match creature entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2); + return false; + } + } + else + { + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing creature guid (%u), skipped", cond->ConditionValue3); + return false; + } + } break; case TYPEID_GAMEOBJECT: if (cond->ConditionValue2 && !sObjectMgr->GetGameObjectTemplate(cond->ConditionValue2)) { - TC_LOG_ERROR("sql.sql", "ObjectEntry condition has non existing game object template entry (%u), skipped", cond->ConditionValue2); + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject template entry (%u), skipped", cond->ConditionValue2); return false; } + if (cond->ConditionValue3) + { + if (GameObjectData const* goData = sObjectMgr->GetGOData(cond->ConditionValue3)) + { + if (cond->ConditionValue2 && goData->id != cond->ConditionValue2) + { + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has guid %u set but does not match gameobject entry (%u), skipped", cond->ConditionValue3, cond->ConditionValue2); + return false; + } + } + else + { + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has non existing gameobject guid (%u), skipped", cond->ConditionValue3); + return false; + } + } break; case TYPEID_PLAYER: case TYPEID_CORPSE: if (cond->ConditionValue2) - TC_LOG_ERROR("sql.sql", "ObjectEntry condition has useless data in value2 (%u)!", cond->ConditionValue2); + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value2 (%u)!", cond->ConditionValue2); + if (cond->ConditionValue3) + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has useless data in value3 (%u)!", cond->ConditionValue3); break; default: - TC_LOG_ERROR("sql.sql", "ObjectEntry condition has wrong typeid set (%u), skipped", cond->ConditionValue1); + TC_LOG_ERROR("sql.sql", "ObjectEntryGuid condition has wrong typeid set (%u), skipped", cond->ConditionValue1); return false; } - if (cond->ConditionValue3) - TC_LOG_ERROR("sql.sql", "ObjectEntry condition has useless data in value3 (%u)!", cond->ConditionValue3); break; } case CONDITION_TYPE_MASK: diff --git a/src/server/game/Conditions/ConditionMgr.h b/src/server/game/Conditions/ConditionMgr.h index d5428ed2d14..ff508210fb1 100644 --- a/src/server/game/Conditions/ConditionMgr.h +++ b/src/server/game/Conditions/ConditionMgr.h @@ -63,7 +63,7 @@ enum ConditionTypes CONDITION_QUEST_COMPLETE = 28, // quest_id 0 0 true if player has quest_id with all objectives complete, but not yet rewarded CONDITION_NEAR_CREATURE = 29, // creature entry distance 0 true if there is a creature of entry in range CONDITION_NEAR_GAMEOBJECT = 30, // gameobject entry distance 0 true if there is a gameobject of entry in range - CONDITION_OBJECT_ENTRY = 31, // TypeID entry 0 true if object is type TypeID and the entry is 0 or matches entry of the object + CONDITION_OBJECT_ENTRY_GUID = 31, // TypeID entry guid true if object is type TypeID and the entry is 0 or matches entry of the object or matches guid of the object CONDITION_TYPE_MASK = 32, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask CONDITION_RELATION_TO = 33, // ConditionTarget RelationType 0 true if object is in given relation with object specified by ConditionTarget CONDITION_REACTION_TO = 34, // ConditionTarget rankMask 0 true if object's reaction matches rankMask object specified by ConditionTarget |