Description

A UDN user found that calling

AbilitySystemComponent->RemoveReplicatedLooseGameplayTag(TagToRemove);

while the gameplay tag was not in the TagMap, will create an entry for it with count 0, see FMinimalReplicationTagCountMap::RemoveTag. Then, since FMinimalReplicationTagCountMap::NetSerialize serializes all keys without regard for count, simulated proxies will think the tag is in the map.

I was able to repro this behavior 100% with the actor code shared under repro steps.

Steps to Reproduce

Create an actor as below, with TagToRemove being an UPROPERTY(EditAnywhere) FGameplayTag that's set to a valid tag:

ATestActor::ATestActor()
{
	bReplicates = true;
	PrimaryActorTick.bCanEverTick = true;
	AbilitySystemComponent = CreateDefaultSubobject<UAbilitySystemComponent>(TEXT("ASC"));
	AbilitySystemComponent->SetReplicationMode(EGameplayEffectReplicationMode::Minimal);
	AbilitySystemComponent->SetIsReplicated(true);
}

void ATestActor::PostInitializeComponents()
{
	Super::PostInitializeComponents();
	AbilitySystemComponent->AddSet<UAttributeSetNew>();
}

void ATestActor::BeginPlay()
{
	Super::BeginPlay();
	if (HasAuthority())
	{
		AbilitySystemComponent->RemoveReplicatedLooseGameplayTag(TagToRemove);
	}
}

void ATestActor::Tick(float DeltaSeconds)
{
	Super::Tick(DeltaSeconds);
	const bool bHasAuth = HasAuthority();
	const bool bHasTags = AbilitySystemComponent->HasMatchingGameplayTag(TagToRemove);
	UE_LOG(LogTemp, Warning, TEXT("Has auth: %d, Has tag: %d"), bHasAuth, bHasTags);
}

At runtime, the server will "remove" a tag but instead this will add an entry into the replicated TagMap with count 0. On the client, HasMatchingGameplayTag then evaluates to true. Once fixed, it should correctly evaluate to false on the client.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-170468 in the post.

2
Login to Vote

Fixed
ComponentUE - Gameplay - Gameplay Ability System
Affects Versions5.05.15.2
Target Fix5.3
Fix Commit24101181
Main Commit24101181
CreatedNov 17, 2022
ResolvedFeb 9, 2023
UpdatedSep 21, 2023
View Jira Issue