Core/Entities: Minor refactor to viewer dependent updatefield writing to allow using viewer dependent dynamic updatefields
This commit is contained in:
@@ -38,7 +38,7 @@ namespace UF
|
||||
void ObjectData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisibilityFlags, Object const* owner, Player const* receiver) const
|
||||
{
|
||||
data << int32(EntryID);
|
||||
data << uint32(ViewerDependentValue<DynamicFlagsTag>::GetValue(DynamicFlags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<DynamicFlagsTag>::GetValue(this, owner, receiver));
|
||||
data << float(Scale);
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ void ObjectData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ign
|
||||
}
|
||||
if (changesMask[2])
|
||||
{
|
||||
data << uint32(ViewerDependentValue<DynamicFlagsTag>::GetValue(DynamicFlags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<DynamicFlagsTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[3])
|
||||
{
|
||||
@@ -932,10 +932,10 @@ bool PassiveSpellHistory::operator==(PassiveSpellHistory const& right) const
|
||||
|
||||
void UnitData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisibilityFlags, Unit const* owner, Player const* receiver) const
|
||||
{
|
||||
data << int32(ViewerDependentValue<DisplayIDTag>::GetValue(DisplayID, owner, receiver));
|
||||
data << int32(ViewerDependentValue<DisplayIDTag>::GetValue(this, owner, receiver));
|
||||
for (std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
data << uint32(ViewerDependentValue<NpcFlagsTag>::GetValue(NpcFlags[i], i, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<NpcFlagsTag>::GetValue(this, i, owner, receiver));
|
||||
}
|
||||
data << uint32(StateSpellVisualID);
|
||||
data << uint32(StateAnimID);
|
||||
@@ -993,15 +993,15 @@ void UnitData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisi
|
||||
data << int32(ScalingFactionGroup);
|
||||
data << int32(ScalingHealthItemLevelCurveID);
|
||||
data << int32(ScalingDamageItemLevelCurveID);
|
||||
data << int32(ViewerDependentValue<FactionTemplateTag>::GetValue(FactionTemplate, owner, receiver));
|
||||
data << int32(ViewerDependentValue<FactionTemplateTag>::GetValue(this, owner, receiver));
|
||||
for (std::size_t i = 0; i < 3; ++i)
|
||||
{
|
||||
VirtualItems[i].WriteCreate(data, owner, receiver);
|
||||
}
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(Flags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(this, owner, receiver));
|
||||
data << uint32(Flags2);
|
||||
data << uint32(Flags3);
|
||||
data << uint32(ViewerDependentValue<AuraStateTag>::GetValue(AuraState, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<AuraStateTag>::GetValue(this, owner, receiver));
|
||||
for (std::size_t i = 0; i < 2; ++i)
|
||||
{
|
||||
data << uint32(AttackRoundBaseTime[i]);
|
||||
@@ -1073,7 +1073,7 @@ void UnitData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisi
|
||||
data << int32(BaseHealth);
|
||||
}
|
||||
data << uint8(SheatheState);
|
||||
data << uint8(ViewerDependentValue<PvpFlagsTag>::GetValue(PvpFlags, owner, receiver));
|
||||
data << uint8(ViewerDependentValue<PvpFlagsTag>::GetValue(this, owner, receiver));
|
||||
data << uint8(PetFlags);
|
||||
data << uint8(ShapeshiftForm);
|
||||
if (fieldVisibilityFlags.HasFlag(UpdateFieldFlag::Owner))
|
||||
@@ -1232,7 +1232,7 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
|
||||
}
|
||||
if (changesMask[5])
|
||||
{
|
||||
data << int32(ViewerDependentValue<DisplayIDTag>::GetValue(DisplayID, owner, receiver));
|
||||
data << int32(ViewerDependentValue<DisplayIDTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[6])
|
||||
{
|
||||
@@ -1379,11 +1379,11 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
|
||||
}
|
||||
if (changesMask[42])
|
||||
{
|
||||
data << int32(ViewerDependentValue<FactionTemplateTag>::GetValue(FactionTemplate, owner, receiver));
|
||||
data << int32(ViewerDependentValue<FactionTemplateTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[43])
|
||||
{
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(Flags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[44])
|
||||
{
|
||||
@@ -1395,7 +1395,7 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
|
||||
}
|
||||
if (changesMask[46])
|
||||
{
|
||||
data << uint32(ViewerDependentValue<AuraStateTag>::GetValue(AuraState, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<AuraStateTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[47])
|
||||
{
|
||||
@@ -1538,7 +1538,7 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
|
||||
}
|
||||
if (changesMask[82])
|
||||
{
|
||||
data << uint8(ViewerDependentValue<PvpFlagsTag>::GetValue(PvpFlags, owner, receiver));
|
||||
data << uint8(ViewerDependentValue<PvpFlagsTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[83])
|
||||
{
|
||||
@@ -1694,7 +1694,7 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
|
||||
{
|
||||
if (changesMask[121 + i])
|
||||
{
|
||||
data << uint32(ViewerDependentValue<NpcFlagsTag>::GetValue(NpcFlags[i], i, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<NpcFlagsTag>::GetValue(this, i, owner, receiver));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4261,19 +4261,19 @@ void GameObjectData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fie
|
||||
}
|
||||
data << CreatedBy;
|
||||
data << GuildGUID;
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(Flags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(this, owner, receiver));
|
||||
data << float(ParentRotation->x);
|
||||
data << float(ParentRotation->y);
|
||||
data << float(ParentRotation->z);
|
||||
data << float(ParentRotation->w);
|
||||
data << int32(FactionTemplate);
|
||||
data << int8(ViewerDependentValue<StateTag>::GetValue(State, owner, receiver));
|
||||
data << int8(ViewerDependentValue<StateTag>::GetValue(this, owner, receiver));
|
||||
data << int8(TypeID);
|
||||
data << uint8(PercentHealth);
|
||||
data << uint32(ArtKit);
|
||||
data << uint32(EnableDoodadSets.size());
|
||||
data << uint32(CustomParam);
|
||||
data << int32(ViewerDependentValue<LevelTag>::GetValue(Level, owner, receiver));
|
||||
data << int32(ViewerDependentValue<LevelTag>::GetValue(this, owner, receiver));
|
||||
data << uint32(AnimGroupInstance);
|
||||
for (std::size_t i = 0; i < EnableDoodadSets.size(); ++i)
|
||||
{
|
||||
@@ -4359,7 +4359,7 @@ void GameObjectData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool
|
||||
}
|
||||
if (changesMask[11])
|
||||
{
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(Flags, owner, receiver));
|
||||
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[12])
|
||||
{
|
||||
@@ -4374,7 +4374,7 @@ void GameObjectData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool
|
||||
}
|
||||
if (changesMask[14])
|
||||
{
|
||||
data << int8(ViewerDependentValue<StateTag>::GetValue(State, owner, receiver));
|
||||
data << int8(ViewerDependentValue<StateTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[15])
|
||||
{
|
||||
@@ -4394,7 +4394,7 @@ void GameObjectData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool
|
||||
}
|
||||
if (changesMask[19])
|
||||
{
|
||||
data << int32(ViewerDependentValue<LevelTag>::GetValue(Level, owner, receiver));
|
||||
data << int32(ViewerDependentValue<LevelTag>::GetValue(this, owner, receiver));
|
||||
}
|
||||
if (changesMask[20])
|
||||
{
|
||||
|
||||
@@ -40,8 +40,9 @@ class ViewerDependentValue<UF::ObjectData::DynamicFlagsTag>
|
||||
public:
|
||||
using value_type = UF::ObjectData::DynamicFlagsTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type dynamicFlags, Object const* object, Player const* receiver)
|
||||
static value_type GetValue(UF::ObjectData const* objectData, Object const* object, Player const* receiver)
|
||||
{
|
||||
value_type dynamicFlags = objectData->DynamicFlags;
|
||||
if (Unit const* unit = object->ToUnit())
|
||||
{
|
||||
dynamicFlags &= ~UNIT_DYNFLAG_TAPPED;
|
||||
@@ -108,8 +109,9 @@ class ViewerDependentValue<UF::UnitData::DisplayIDTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::DisplayIDTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type displayId, Unit const* unit, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* unitData, Unit const* unit, Player const* receiver)
|
||||
{
|
||||
value_type displayId = unitData->DisplayID;
|
||||
if (unit->IsCreature())
|
||||
{
|
||||
CreatureTemplate const* cinfo = unit->ToCreature()->GetCreatureTemplate();
|
||||
@@ -145,8 +147,9 @@ class ViewerDependentValue<UF::UnitData::FactionTemplateTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::FactionTemplateTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type factionTemplate, Unit const* unit, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* unitData, Unit const* unit, Player const* receiver)
|
||||
{
|
||||
value_type factionTemplate = unitData->FactionTemplate;
|
||||
if (unit->IsControlledByPlayer() && receiver != unit && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && unit->IsInRaidWith(receiver))
|
||||
{
|
||||
FactionTemplateEntry const* ft1 = unit->GetFactionTemplateEntry();
|
||||
@@ -166,8 +169,9 @@ class ViewerDependentValue<UF::UnitData::FlagsTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::FlagsTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type flags, Unit const* /*unit*/, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* unitData, Unit const* /*unit*/, Player const* receiver)
|
||||
{
|
||||
value_type flags = unitData->Flags;
|
||||
// Gamemasters should be always able to select units - remove not selectable flag
|
||||
if (receiver->IsGameMaster())
|
||||
flags &= ~UNIT_FLAG_NOT_SELECTABLE;
|
||||
@@ -182,7 +186,7 @@ class ViewerDependentValue<UF::UnitData::AuraStateTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::AuraStateTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type /*auraState*/, Unit const* unit, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* /*unitData*/, Unit const* unit, Player const* receiver)
|
||||
{
|
||||
// Check per caster aura states to not enable using a spell in client if specified aura is not by target
|
||||
return unit->BuildAuraStateUpdateForTarget(receiver);
|
||||
@@ -195,8 +199,9 @@ class ViewerDependentValue<UF::UnitData::PvpFlagsTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::PvpFlagsTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type pvpFlags, Unit const* unit, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* unitData, Unit const* unit, Player const* receiver)
|
||||
{
|
||||
value_type pvpFlags = unitData->PvpFlags;
|
||||
if (unit->IsControlledByPlayer() && receiver != unit && sWorld->getBoolConfig(CONFIG_ALLOW_TWO_SIDE_INTERACTION_GROUP) && unit->IsInRaidWith(receiver))
|
||||
{
|
||||
FactionTemplateEntry const* ft1 = unit->GetFactionTemplateEntry();
|
||||
@@ -216,8 +221,9 @@ class ViewerDependentValue<UF::UnitData::NpcFlagsTag>
|
||||
public:
|
||||
using value_type = UF::UnitData::NpcFlagsTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type npcFlag, uint32 i, Unit const* unit, Player const* receiver)
|
||||
static value_type GetValue(UF::UnitData const* unitData, uint32 i, Unit const* unit, Player const* receiver)
|
||||
{
|
||||
value_type npcFlag = unitData->NpcFlags[i];
|
||||
if (i == 0 && unit->IsCreature() && !receiver->CanSeeSpellClickOn(unit->ToCreature()))
|
||||
npcFlag &= ~UNIT_NPC_FLAG_SPELLCLICK;
|
||||
|
||||
@@ -231,8 +237,9 @@ class ViewerDependentValue<UF::GameObjectData::FlagsTag>
|
||||
public:
|
||||
using value_type = UF::GameObjectData::FlagsTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type flags, GameObject const* gameObject, Player const* receiver)
|
||||
static value_type GetValue(UF::GameObjectData const* gameObjectData, GameObject const* gameObject, Player const* receiver)
|
||||
{
|
||||
value_type flags = gameObjectData->Flags;
|
||||
if (gameObject->GetGoType() == GAMEOBJECT_TYPE_CHEST)
|
||||
if (gameObject->GetGOInfo()->chest.usegrouplootrules && !gameObject->IsLootAllowedFor(receiver))
|
||||
flags |= GO_FLAG_LOCKED | GO_FLAG_NOT_SELECTABLE;
|
||||
@@ -247,8 +254,9 @@ class ViewerDependentValue<UF::GameObjectData::LevelTag>
|
||||
public:
|
||||
using value_type = UF::GameObjectData::LevelTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type level, GameObject const* gameObject, Player const* /*receiver*/)
|
||||
static value_type GetValue(UF::GameObjectData const* gameObjectData, GameObject const* gameObject, Player const* /*receiver*/)
|
||||
{
|
||||
value_type level = gameObjectData->Level;
|
||||
bool isStoppableTransport = gameObject->GetGoType() == GAMEOBJECT_TYPE_TRANSPORT && !gameObject->GetGOValue()->Transport.StopFrames->empty();
|
||||
return isStoppableTransport ? gameObject->GetGOValue()->Transport.PathProgress : level;
|
||||
}
|
||||
@@ -260,8 +268,9 @@ class ViewerDependentValue<UF::GameObjectData::StateTag>
|
||||
public:
|
||||
using value_type = UF::GameObjectData::StateTag::value_type;
|
||||
|
||||
static value_type GetValue(value_type state, GameObject const* gameObject, Player const* /*receiver*/)
|
||||
static value_type GetValue(UF::GameObjectData const* gameObjectData, GameObject const* gameObject, Player const* /*receiver*/)
|
||||
{
|
||||
value_type state = gameObjectData->State;
|
||||
bool isStoppableTransport = gameObject->GetGoType() == GAMEOBJECT_TYPE_TRANSPORT && !gameObject->GetGOValue()->Transport.StopFrames->empty();
|
||||
if (isStoppableTransport && gameObject->GetGoState() == GO_STATE_TRANSPORT_ACTIVE)
|
||||
if ((gameObject->GetGOValue()->Transport.StateUpdateTimer / 20000) & 1)
|
||||
|
||||
Reference in New Issue
Block a user