Skip to content
Snippets Groups Projects
Commit 16b89cf6 authored by David Gilbert's avatar David Gilbert :bug:
Browse files

fix(replication, cave): Only executes DCRA Attachment on_rep of owned player...

fix(replication, cave): Only executes DCRA Attachment on_rep of owned player state. Adds some logs to see if it works.
parent 59aa41f6
Branches
No related tags found
2 merge requests!107UE5.4-2024.1-rc1,!98Improved join/attachment logic for clusters to support multi-cluster connections at some point
Pipeline #442203 failed
...@@ -50,12 +50,12 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState* ...@@ -50,12 +50,12 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState*
if (bIsAttached) if (bIsAttached)
{ {
UE_LOGFMT(Toolkit, Display, UE_LOGFMT(Toolkit, Display, "{Name} AttachDCRAIfRequired: Already attached, skipping repeated attachment.",
"AClusterRepresentationActor::AttachDCRAIfRequired: Already attached, skipping repeated attachment."); *this->GetName());
return; return;
} }
UE_LOGFMT(Toolkit, Display, "AClusterRepresentationActor::AttachDCRAIfRequired: Starting DCRA Attachment process."); UE_LOGFMT(Toolkit, Display, "{Name} AttachDCRAIfRequired: Starting DCRA Attachment process.", *this->GetName());
// This should give us the first local player controller // This should give us the first local player controller
const auto* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0); const auto* PlayerController = UGameplayStatics::GetPlayerController(GetWorld(), 0);
...@@ -63,9 +63,9 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState* ...@@ -63,9 +63,9 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState*
// Only run this for the local controller - redundant, but double check // Only run this for the local controller - redundant, but double check
if (!PlayerController || !PlayerController->IsLocalController()) if (!PlayerController || !PlayerController->IsLocalController())
{ {
UE_LOGFMT( UE_LOGFMT(Toolkit, Warning,
Toolkit, Warning, "{Name} AttachDCRAIfRequired: PlayerController not valid or not locally controlled.",
"AClusterRepresentationActor::AttachDCRAIfRequired: PlayerController not valid or not locally controlled."); *this->GetName());
return; return;
} }
const auto* PlayerState = const auto* PlayerState =
...@@ -73,16 +73,20 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState* ...@@ -73,16 +73,20 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState*
if (!PlayerState) if (!PlayerState)
{ {
UE_LOGFMT(Toolkit, Error, UE_LOGFMT(Toolkit, Error,
"AClusterRepresentationActor::AttachDCRAIfRequired: PlayerState is not valid or not of type " "{Name} AttachDCRAIfRequired: PlayerState is not valid or not of type "
"ARWTHVRPlayerState."); "ARWTHVRPlayerState.",
*this->GetName());
return; return;
} }
UE_LOGFMT(Toolkit, Display,
"{Name} AttachDCRAIfRequired: Player State is {PlayerState}, PlayerState->CCA is {CCA}.", GetName(),
PlayerState->GetName(), PlayerState->GetCorrespondingClusterActor()->GetName());
// The local player this is executed on corresponds to this actor // The local player this is executed on corresponds to this actor
if (PlayerState->GetCorrespondingClusterActor() == this) if (PlayerState->GetCorrespondingClusterActor() == this)
{ {
UE_LOGFMT(Toolkit, Display, "AClusterRepresentationActor::AttachDCRAIfRequired: Attaching DCRA to {Name}.", UE_LOGFMT(Toolkit, Display, "{Name} AttachDCRAIfRequired: Attaching DCRA to {Name}.", GetName());
GetName());
bIsAttached = AttachDCRA(); bIsAttached = AttachDCRA();
} }
...@@ -119,7 +123,7 @@ bool AClusterRepresentationActor::AttachDCRA() ...@@ -119,7 +123,7 @@ bool AClusterRepresentationActor::AttachDCRA()
} }
bool bAttached = DCRA->AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale); bool bAttached = DCRA->AttachToActor(this, FAttachmentTransformRules::SnapToTargetNotIncludingScale);
UE_LOGFMT(Toolkit, Display, "Attaching {This} to DCRA {DCRA} returned {Res}", GetName(), DCRA->GetName(), UE_LOGFMT(Toolkit, Display, "Attaching DCRA {DCRA} to {this} returned {Res}", GetName(), DCRA->GetName(),
bAttached); bAttached);
DCRA->SetActorEnableCollision(false); DCRA->SetActorEnableCollision(false);
......
...@@ -40,7 +40,12 @@ private: ...@@ -40,7 +40,12 @@ private:
TObjectPtr<AClusterRepresentationActor> CorrespondingClusterActor; TObjectPtr<AClusterRepresentationActor> CorrespondingClusterActor;
UFUNCTION() UFUNCTION()
virtual void OnRep_CorrespondingClusterActor() { CorrespondingClusterActor->AttachDCRAIfRequired(this); } virtual void OnRep_CorrespondingClusterActor()
{
// Only execute this on the local owning player
if (HasLocalNetOwner())
CorrespondingClusterActor->AttachDCRAIfRequired(this);
}
UFUNCTION(Reliable, Server) UFUNCTION(Reliable, Server)
void ServerSetPlayerTypeRpc(EPlayerType NewPlayerType); void ServerSetPlayerTypeRpc(EPlayerType NewPlayerType);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment