diff --git a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp index 172f00f89ea2b1336894055bee742fb93bf304f7..c9efeaf30d93cb815d2cd7691d1ba037b3c9f672 100644 --- a/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp +++ b/Source/RWTHVRToolkit/Private/Core/RWTHVRGameModeBase.cpp @@ -28,7 +28,7 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle // Check if we're using our custom PlayerState so that we can save the player type there. // If not, just ingore all related args. ARWTHVRPlayerState* State = Cast<ARWTHVRPlayerState>(NewPlayerController->PlayerState); - + if (State != nullptr) { int32 ClusterId = -1; @@ -63,7 +63,7 @@ FString ARWTHVRGameModeBase::InitNewPlayer(APlayerController* NewPlayerControlle void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer) { if (ARWTHVRPlayerState* State = Cast<ARWTHVRPlayerState>(NewPlayer->PlayerState); State != nullptr) - { + { // If we're in none-standalone netmode, this is only executed on the server, as the GM only exists there. // On standalone, this is executed on every node. int32 ClusterId = State->GetCorrespondingClusterId(); @@ -93,7 +93,7 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer) // Double check for sanity check(ClusterRepresentation != nullptr); - + State->SetCorrespondingClusterActor(ClusterRepresentation); if (State->GetPlayerType() == EPlayerType::nDisplayPrimary) @@ -102,7 +102,7 @@ void ARWTHVRGameModeBase::PostLogin(APlayerController* NewPlayer) ClusterRepresentation->SetOwner(NewPlayer); } } - + // Do we already have an auto-possessing pawn possessed? if (NewPlayer->GetPawn() && NewPlayer->GetPawn()->IsValidLowLevelFast()) { diff --git a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp index 57c16ee838e50f92ed1b4915829eeaf5bb475ec6..d6b2f4f0a197652d70f41be824f3443568664e1a 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/ClusterRepresentationActor.cpp @@ -50,7 +50,7 @@ void AClusterRepresentationActor::AttachDCRAIfRequired(const ARWTHVRPlayerState* "AClusterRepresentationActor::AttachDCRAIfRequired: Already attached, skipping repeated attachment."); return; } - + UE_LOGFMT(Toolkit, Display, "AClusterRepresentationActor::AttachDCRAIfRequired: Starting DCRA Attachment process."); // This should give us the first local player controller diff --git a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp index 0d11d17ce60aff2dccac2c6472640409db3f7fb1..5c27dac287d40e50e9b9bafc8fe1b9b4deb52cc4 100644 --- a/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp +++ b/Source/RWTHVRToolkit/Private/Pawn/RWTHVRPawn.cpp @@ -267,14 +267,16 @@ void ARWTHVRPawn::AttachClustertoPawn() if (const ARWTHVRPlayerState* State = GetPlayerState<ARWTHVRPlayerState>()) { if (!State->GetCorrespondingClusterActor()) - UE_LOGFMT(Toolkit, Error, - "ARWTHVRPawn::AttachClustertoPawn: GetCorrespondingClusterActor returned null! This won't work on " - "the Cave."); + UE_LOGFMT( + Toolkit, Error, + "ARWTHVRPawn::AttachClustertoPawn: GetCorrespondingClusterActor returned null! This won't work on " + "the Cave."); const FAttachmentTransformRules AttachmentRules = FAttachmentTransformRules::SnapToTargetNotIncludingScale; bool bAttached = State->GetCorrespondingClusterActor()->AttachToComponent(GetRootComponent(), AttachmentRules); - //State->GetCorrespondingClusterActor()->OnAttached(); - UE_LOGFMT(Toolkit, Display, "ARWTHVRPawn: Attaching corresponding cluster actor to our pawn returned: {Attached}", bAttached); + // State->GetCorrespondingClusterActor()->OnAttached(); + UE_LOGFMT(Toolkit, Display, + "ARWTHVRPawn: Attaching corresponding cluster actor to our pawn returned: {Attached}", bAttached); } else { diff --git a/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h b/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h index a4342f0121d2599b64a674f5153c05812f92d2b1..be8e65d9da82cf7acc215bc8154ec9772fc7537c 100644 --- a/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h +++ b/Source/RWTHVRToolkit/Public/Core/RWTHVRGameModeBase.h @@ -17,7 +17,6 @@ class RWTHVRTOOLKIT_API ARWTHVRGameModeBase : public AGameModeBase { GENERATED_BODY() public: - ARWTHVRGameModeBase(const FObjectInitializer& ObjectInitializer); protected: @@ -35,7 +34,6 @@ protected: virtual void PostLogin(APlayerController* NewPlayer) override; private: - UPROPERTY() TMap<int32, AClusterRepresentationActor*> ConnectedClusters; }; diff --git a/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h b/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h index f5fcb06de93135765253b81d1e38c79971a304e6..5c353027c84d65aebca203b891e47bcfb261ad81 100644 --- a/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h +++ b/Source/RWTHVRToolkit/Public/Core/RWTHVRPlayerState.h @@ -28,21 +28,20 @@ private: EPlayerType PlayerType = EPlayerType::Desktop; /** Replicated cluster ID for this player. Is -1 in case player is not a cluster*/ - UPROPERTY(Replicated, Category = PlayerState, BlueprintGetter = GetCorrespondingClusterId, meta = (AllowPrivateAccess)) + UPROPERTY(Replicated, Category = PlayerState, BlueprintGetter = GetCorrespondingClusterId, + meta = (AllowPrivateAccess)) int32 CorrespondingClusterId = -1; /** Replicated cluster actor for this player. Is nullptr in case player is not a cluster. - * As this is not guaranteed to be valid on BeginPlay, we need to do a callback to the CorrespondingClusterActor here... + * As this is not guaranteed to be valid on BeginPlay, we need to do a callback to the CorrespondingClusterActor + * here... */ UPROPERTY(ReplicatedUsing = OnRep_CorrespondingClusterActor) TObjectPtr<AClusterRepresentationActor> CorrespondingClusterActor; UFUNCTION() - virtual void OnRep_CorrespondingClusterActor() - { - CorrespondingClusterActor->AttachDCRAIfRequired(this); - } - + virtual void OnRep_CorrespondingClusterActor() { CorrespondingClusterActor->AttachDCRAIfRequired(this); } + UFUNCTION(Reliable, Server) void ServerSetPlayerTypeRpc(EPlayerType NewPlayerType); @@ -57,7 +56,7 @@ public: UFUNCTION(BlueprintGetter) AClusterRepresentationActor* GetCorrespondingClusterActor() const { return CorrespondingClusterActor; } - + void SetCorrespondingClusterId(int32 NewCorrespondingClusterId); void SetCorrespondingClusterActor(AClusterRepresentationActor* NewCorrespondingClusterActor);