From 3d024ae1c7754aebc6c5a24c033834015168dc25 Mon Sep 17 00:00:00 2001 From: Joshua Date: Tue, 30 Aug 2022 08:42:18 -0400 Subject: [PATCH] set cached unique net id in auto login as well --- .../Private/AutoLoginUserCallbackProxy.cpp | 22 ++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp index de3225d..2bc65e6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp @@ -1,7 +1,7 @@ // Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. #include "AutoLoginUserCallbackProxy.h" - +#include "Kismet/GameplayStatics.h" ////////////////////////////////////////////////////////////////////////// // ULoginUserCallbackProxy @@ -44,6 +44,26 @@ void UAutoLoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSucce Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle); } + + if(APlayerController* PController = UGameplayStatics::GetPlayerController(WorldContextObject->GetWorld(), LocalUserNum)) + { + ULocalPlayer* Player = Cast(PController->Player); + + auto uniqueId = UserId.AsShared(); + + if (Player) + { + Player->SetCachedUniqueNetId(uniqueId); + } + + if (APlayerState* State = PController->PlayerState) + { + // Update UniqueId. See also ShowLoginUICallbackProxy.cpp + State->SetUniqueId((const FUniqueNetIdPtr&)uniqueId); + } + } + + if (bWasSuccessful) { OnSuccess.Broadcast();