Core/Players: Allow GMs to target npcs with UNIT_FLAG2_UNTARGETABLE_BY_CLIENT flag (#30041)

This commit is contained in:
TheCarl
2024-06-22 14:38:01 +02:00
committed by GitHub
parent 4fd013e200
commit 5ee28a9161
3 changed files with 20 additions and 2 deletions

View File

@@ -995,7 +995,7 @@ void UnitData::WriteCreate(ByteBuffer& data, EnumFlag<UpdateFieldFlag> fieldVisi
VirtualItems[i].WriteCreate(data, owner, receiver);
}
data << uint32(ViewerDependentValue<FlagsTag>::GetValue(this, owner, receiver));
data << uint32(Flags2);
data << uint32(ViewerDependentValue<Flags2Tag>::GetValue(this, owner, receiver));
data << uint32(ViewerDependentValue<Flags3Tag>::GetValue(this, owner, receiver));
data << uint32(ViewerDependentValue<AuraStateTag>::GetValue(this, owner, receiver));
for (uint32 i = 0; i < 2; ++i)
@@ -1388,7 +1388,7 @@ void UnitData::WriteUpdate(ByteBuffer& data, Mask const& changesMask, bool ignor
}
if (changesMask[43])
{
data << uint32(Flags2);
data << uint32(ViewerDependentValue<Flags2Tag>::GetValue(this, owner, receiver));
}
if (changesMask[44])
{

View File

@@ -304,6 +304,7 @@ struct UnitData : public IsUpdateFieldStructureTag, public HasChangesMask<217>
UpdateField<uint32, 32, 42> Flags;
struct FlagsTag : ViewerDependentValueTag<uint32> {};
UpdateField<uint32, 32, 43> Flags2;
struct Flags2Tag : ViewerDependentValueTag<uint32> {};
UpdateField<uint32, 32, 44> Flags3;
struct Flags3Tag : ViewerDependentValueTag<uint32> {};
UpdateField<uint32, 32, 45> AuraState;

View File

@@ -240,6 +240,23 @@ public:
}
};
template<>
class ViewerDependentValue<UF::UnitData::Flags2Tag>
{
public:
using value_type = UF::UnitData::Flags2Tag::value_type;
static value_type GetValue(UF::UnitData const* unitData, Unit const* /*unit*/, Player const* receiver)
{
value_type flags = unitData->Flags2;
// Gamemasters should be always able to interact with units - remove uninteractible flag
if (receiver->IsGameMaster())
flags &= ~UNIT_FLAG2_UNTARGETABLE_BY_CLIENT;
return flags;
}
};
template<>
class ViewerDependentValue<UF::UnitData::Flags3Tag>
{