Core/Conditions: Reimplemented CONDITION_OBJECT_ENTRY_GUID and CONDITION_TYPE_MASK under new values to allow easier porting conditions between branches. Old data is dynamically converted during startup

This commit is contained in:
Shauren
2019-07-21 17:12:34 +02:00
parent 3058d8c5ab
commit ff334ae707
3 changed files with 79 additions and 3 deletions

View File

@@ -122,7 +122,10 @@ ConditionMgr::ConditionTypeInfo const ConditionMgr::StaticConditionTypeData[COND
{ "On Taxi", false, false, false },
{ "Quest state mask", true, true, false },
{ "Objective Complete", true, false, false },
{ "Map Difficulty", true, false, false }
{ "Map Difficulty", true, false, false },
{ nullptr, false, false, false },
{ "Object Entry or Guid", true, true, true },
{ "Object TypeMask", true, false, false },
};
// Checks if object meets the condition
@@ -2084,6 +2087,10 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
}
break;
}
case CONDITION_OBJECT_ENTRY_GUID_LEGACY:
cond->ConditionType = CONDITION_OBJECT_ENTRY_GUID;
cond->ConditionValue1 = Trinity::Legacy::ConvertLegacyTypeID(Trinity::Legacy::TypeID(cond->ConditionValue1));
/* fallthrough */
case CONDITION_OBJECT_ENTRY_GUID:
{
switch (cond->ConditionValue1)
@@ -2147,6 +2154,10 @@ bool ConditionMgr::isConditionTypeValid(Condition* cond) const
}
break;
}
case CONDITION_TYPE_MASK_LEGACY:
cond->ConditionType = CONDITION_TYPE_MASK;
cond->ConditionValue1 = Trinity::Legacy::ConvertLegacyTypeMask(cond->ConditionValue1);
/* fallthrough */
case CONDITION_TYPE_MASK:
{
if (!cond->ConditionValue1 || (cond->ConditionValue1 & ~(TYPEMASK_UNIT | TYPEMASK_PLAYER | TYPEMASK_GAMEOBJECT | TYPEMASK_CORPSE)))

View File

@@ -83,8 +83,8 @@ 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 dead (0/1) 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_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_OBJECT_ENTRY_GUID_LEGACY = 31, // LEGACY_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_LEGACY = 32, // LEGACY_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
CONDITION_DISTANCE_TO = 35, // ConditionTarget distance ComparisonType true if object and ConditionTarget are within distance given by parameters
@@ -102,6 +102,8 @@ enum ConditionTypes
CONDITION_QUESTSTATE = 47, // quest_id state_mask 0 true if player is in any of the provided quest states for the quest (1 = not taken, 2 = completed, 8 = in progress, 32 = failed, 64 = rewarded)
CONDITION_QUEST_OBJECTIVE_COMPLETE = 48, // ID 0 0 true if player has ID objective complete, but quest not yet rewarded
CONDITION_DIFFICULTY_ID = 49, // Difficulty 0 0 true is map has difficulty id
CONDITION_OBJECT_ENTRY_GUID = 51, // 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 = 52, // TypeMask 0 0 true if object is type object's TypeMask matches provided TypeMask
CONDITION_MAX
};

View File

@@ -399,4 +399,67 @@ namespace std
};
}
namespace Trinity
{
namespace Legacy
{
enum class TypeID
{
Object = 0,
Item = 1,
Container = 2,
Unit = 3,
Player = 4,
GameObject = 5,
DynamicObject = 6,
Corpse = 7,
AreaTrigger = 8,
SceneObject = 9,
Conversation = 10,
Max
};
constexpr inline ::TypeID ConvertLegacyTypeID(TypeID legacyTypeID)
{
switch (legacyTypeID)
{
case TypeID::Object:
return TYPEID_OBJECT;
case TypeID::Item:
return TYPEID_ITEM;
case TypeID::Container:
return TYPEID_CONTAINER;
case TypeID::Unit:
return TYPEID_UNIT;
case TypeID::Player:
return TYPEID_PLAYER;
case TypeID::GameObject:
return TYPEID_GAMEOBJECT;
case TypeID::DynamicObject:
return TYPEID_DYNAMICOBJECT;
case TypeID::Corpse:
return TYPEID_CORPSE;
case TypeID::AreaTrigger:
return TYPEID_AREATRIGGER;
case TypeID::SceneObject:
return TYPEID_SCENEOBJECT;
case TypeID::Conversation:
return TYPEID_CONVERSATION;
default:
return TYPEID_OBJECT;
}
}
constexpr inline TypeMask ConvertLegacyTypeMask(uint32 legacyTypeMask)
{
uint32 typeMask = 0;
for (TypeID i = TypeID::Object; i < TypeID::Max; i = TypeID(uint32(i) + 1))
if (legacyTypeMask & (1 << uint32(i)))
typeMask |= 1u << ConvertLegacyTypeID(i);
return TypeMask(typeMask);
}
}
}
#endif // ObjectGuid_h__