From 90fff579ba107f0bd704975490b316853a208e40 Mon Sep 17 00:00:00 2001 From: Joshua Date: Fri, 11 Mar 2022 13:45:01 -0500 Subject: [PATCH] manually merging server travel node to ue5 --- .../Classes/AdvancedSessionsLibrary.h | 5 +++++ .../Private/AdvancedSessionsLibrary.cpp | 18 ++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedSessionsLibrary.h b/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedSessionsLibrary.h index 386900a..54153ae 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedSessionsLibrary.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/AdvancedSessionsLibrary.h @@ -200,5 +200,10 @@ public: UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc") static bool HasOnlineSubsystem(FName SubSystemName); + //**** Seamless travel Functions ****// + + //Exposes Server travel to blueprint + UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Online|AdvancedSessions|Seamless", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject")) + static bool ServerTravel(UObject* WorldContextObject, const FString& InURL, bool bAbsolute, bool bShouldSkipGameNotify); }; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedSessionsLibrary.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedSessionsLibrary.cpp index feca4e3..218eabd 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedSessionsLibrary.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/AdvancedSessionsLibrary.cpp @@ -528,3 +528,21 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextOb NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num(); } + +bool UAdvancedSessionsLibrary::ServerTravel(UObject* WorldContextObject, const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify) +{ + if (!WorldContextObject) + { + return false; + } + + //using a context object to get the world + UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull); + if (World) + { + World->ServerTravel(FURL, bAbsolute, bShouldSkipGameNotify); + return true; + } + + return false; +} \ No newline at end of file