From ae670475c9383c76a0b9a1a681b65a8ef26dd006 Mon Sep 17 00:00:00 2001 From: gd <11874515+gregor-dietrich@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:27:40 +0100 Subject: [PATCH 1/5] Remove redundant ternary operators --- .../Private/MultiplayerSessionsSubsystem.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp index 55a0256..cc43200 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp @@ -40,7 +40,7 @@ void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FS CreateSessionCompleteDelegateHandle = SessionInterface->AddOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegate); LastSessionSettings = MakeShareable(new FOnlineSessionSettings()); - LastSessionSettings->bIsLANMatch = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL" ? true : false; + LastSessionSettings->bIsLANMatch = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL"; LastSessionSettings->NumPublicConnections = NumPublicConnections; LastSessionSettings->bAllowJoinInProgress = true; LastSessionSettings->bAllowJoinViaPresence = true; @@ -70,7 +70,7 @@ void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults) LastSessionSearch = MakeShareable(new FOnlineSessionSearch()); LastSessionSearch->MaxSearchResults = MaxSearchResults; - LastSessionSearch->bIsLanQuery = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL" ? true : false; + LastSessionSearch->bIsLanQuery = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL"; LastSessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); From d9057421f64701459e0969b64c91c466c6d7f141 Mon Sep 17 00:00:00 2001 From: gd <11874515+gregor-dietrich@users.noreply.github.com> Date: Fri, 6 Jan 2023 22:45:05 +0100 Subject: [PATCH 2/5] Declare MultiplayerSessionsSubsystem as UPROPERTY() to prevent random garbage collection --- .../MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h | 1 + 1 file changed, 1 insertion(+) diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h index 2e796ec..1a19dd4 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h @@ -52,6 +52,7 @@ class MULTIPLAYERSESSIONS_API UMenu : public UUserWidget void MenuTearDown(); // The subsystem designed to handle all online session functionality + UPROPERTY() class UMultiplayerSessionsSubsystem* MultiplayerSessionsSubsystem; int32 NumPublicConnections{4}; From 56e2d4dacf631049ec594bea3d54f74854c13e32 Mon Sep 17 00:00:00 2001 From: gd <11874515+gregor-dietrich@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:09:18 +0100 Subject: [PATCH 3/5] minor refactors for readability & DefaultEngine.ini update --- Config/DefaultEngine.ini | 1 + .../MultiplayerSessions/Private/Menu.cpp | 194 +++++++++--------- .../Private/MultiplayerSessionsSubsystem.cpp | 76 +++---- 3 files changed, 125 insertions(+), 146 deletions(-) diff --git a/Config/DefaultEngine.ini b/Config/DefaultEngine.ini index 0b9f180..e724f92 100644 --- a/Config/DefaultEngine.ini +++ b/Config/DefaultEngine.ini @@ -33,6 +33,7 @@ DefaultPlatformService=Steam [OnlineSubsystemSteam] bEnabled=true SteamDevAppId=480 +bInitServerOnClient=true [/Script/OnlineSubsystemSteam.SteamNetDriver] NetConnectionClassName="OnlineSubsystemSteam.SteamNetConnection" \ No newline at end of file diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp index f9117e3..cb7ac6e 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp @@ -9,58 +9,53 @@ void UMenu::MenuSetup(int32 NumberOfPublicConnections, FString TypeOfMatch, FString LobbyPath) { - PathToLobby = FString::Printf(TEXT("%s?listen"), *LobbyPath); NumPublicConnections = NumberOfPublicConnections; MatchType = TypeOfMatch; + PathToLobby = FString::Printf(TEXT("%s?listen"), *LobbyPath); + AddToViewport(); SetVisibility(ESlateVisibility::Visible); bIsFocusable = true; - UWorld* World = GetWorld(); - if (World) - { - APlayerController* PlayerController = World->GetFirstPlayerController(); - if (PlayerController) - { - FInputModeUIOnly InputModeData; - InputModeData.SetWidgetToFocus(TakeWidget()); - InputModeData.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock); - PlayerController->SetInputMode(InputModeData); - PlayerController->SetShowMouseCursor(true); - } - } + const auto World = GetWorld(); + if (!World) + return; - UGameInstance* GameInstance = GetGameInstance(); - if (GameInstance) - { - MultiplayerSessionsSubsystem = GameInstance->GetSubsystem(); - } + const auto PlayerController = World->GetFirstPlayerController(); + if (!PlayerController) + return; - if (MultiplayerSessionsSubsystem) - { - MultiplayerSessionsSubsystem->MultiplayerOnCreateSessionComplete.AddDynamic(this, &ThisClass::OnCreateSession); - MultiplayerSessionsSubsystem->MultiplayerOnFindSessionsComplete.AddUObject(this, &ThisClass::OnFindSessions); - MultiplayerSessionsSubsystem->MultiplayerOnJoinSessionComplete.AddUObject(this, &ThisClass::OnJoinSession); - MultiplayerSessionsSubsystem->MultiplayerOnDestroySessionComplete.AddDynamic(this, &ThisClass::OnDestroySession); - MultiplayerSessionsSubsystem->MultiplayerOnStartSessionComplete.AddDynamic(this, &ThisClass::OnStartSession); - } + FInputModeUIOnly InputModeData; + InputModeData.SetWidgetToFocus(TakeWidget()); + InputModeData.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock); + PlayerController->SetInputMode(InputModeData); + PlayerController->bShowMouseCursor = ShowMouseCursor; + + const auto GameInstance = GetGameInstance(); + if (!GameInstance) + return; + + MultiplayerSessionsSubsystem = GameInstance->GetSubsystem(); + if (!MultiplayerSessionsSubsystem) + return; + + MultiplayerSessionsSubsystem->MultiplayerOnCreateSessionComplete.AddDynamic(this, &ThisClass::OnCreateSession); + MultiplayerSessionsSubsystem->MultiplayerOnFindSessionsComplete.AddUObject(this, &ThisClass::OnFindSessions); + MultiplayerSessionsSubsystem->MultiplayerOnJoinSessionComplete.AddUObject(this, &ThisClass::OnJoinSession); + MultiplayerSessionsSubsystem->MultiplayerOnDestroySessionComplete.AddDynamic(this, &ThisClass::OnDestroySession); + MultiplayerSessionsSubsystem->MultiplayerOnStartSessionComplete.AddDynamic(this, &ThisClass::OnStartSession); } bool UMenu::Initialize() { if (!Super::Initialize()) - { return false; - } - if (HostButton) - { - HostButton->OnClicked.AddDynamic(this, &ThisClass::HostButtonClicked); - } - if (JoinButton) - { - JoinButton->OnClicked.AddDynamic(this, &ThisClass::JoinButtonClicked); - } + if (!HostButton || !JoinButton) + return false; + + HostButton->OnClicked.AddDynamic(this, &ThisClass::HostButtonClicked); + JoinButton->OnClicked.AddDynamic(this, &ThisClass::JoinButtonClicked); return true; } @@ -73,70 +68,66 @@ void UMenu::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld) void UMenu::OnCreateSession(bool bWasSuccessful) { - if (bWasSuccessful) - { - UWorld* World = GetWorld(); - if (World) - { - World->ServerTravel(PathToLobby); - } - } - else + if (!GEngine) + return; + + if (!bWasSuccessful) { - if (GEngine) - { - GEngine->AddOnScreenDebugMessage( - -1, - 15.f, - FColor::Red, - FString(TEXT("Failed to create session!")) - ); - } + GEngine->AddOnScreenDebugMessage(-1, 15.0f, FColor::Red, FString(TEXT("Failed to create session"))); HostButton->SetIsEnabled(true); + return; } + + if (const auto World = GetWorld()) + World->ServerTravel(PathToLobby); } void UMenu::OnFindSessions(const TArray& SessionResults, bool bWasSuccessful) { if (MultiplayerSessionsSubsystem == nullptr) - { return; - } for (auto Result : SessionResults) { + if (!Result.IsValid()) + continue; + FString SettingsValue; Result.Session.SessionSettings.Get(FName("MatchType"), SettingsValue); - if (SettingsValue == MatchType) - { - MultiplayerSessionsSubsystem->JoinSession(Result); - return; - } + if (SettingsValue != MatchType) + continue; + + MultiplayerSessionsSubsystem->JoinSession(Result); + return; } - if (!bWasSuccessful || SessionResults.Num() == 0) - { + + if (!bWasSuccessful || SessionResults.Num() <= 0) JoinButton->SetIsEnabled(true); - } } void UMenu::OnJoinSession(EOnJoinSessionCompleteResult::Type Result) { - IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get(); - if (Subsystem) - { - IOnlineSessionPtr SessionInterface = Subsystem->GetSessionInterface(); - if (SessionInterface.IsValid()) - { - FString Address; - SessionInterface->GetResolvedConnectString(NAME_GameSession, Address); - - APlayerController* PlayerController = GetGameInstance()->GetFirstLocalPlayerController(); - if (PlayerController) - { - PlayerController->ClientTravel(Address, ETravelType::TRAVEL_Absolute); - } - } - } + const auto Subsystem = IOnlineSubsystem::Get(); + if (!Subsystem) + return; + + const auto SessionInterface = Subsystem->GetSessionInterface(); + if (!SessionInterface.IsValid()) + return; + + FString Address; + SessionInterface->GetResolvedConnectString(NAME_GameSession, Address); + + const auto PlayerController = GetGameInstance()->GetFirstLocalPlayerController(); + if (!PlayerController) + return; + + PlayerController->ClientTravel(Address, ETravelType::TRAVEL_Absolute); + + if (Result == EOnJoinSessionCompleteResult::Success) + return; + + JoinButton->SetIsEnabled(true); } void UMenu::OnDestroySession(bool bWasSuccessful) @@ -150,33 +141,36 @@ void UMenu::OnStartSession(bool bWasSuccessful) void UMenu::HostButtonClicked() { HostButton->SetIsEnabled(false); - if (MultiplayerSessionsSubsystem) - { - MultiplayerSessionsSubsystem->CreateSession(NumPublicConnections, MatchType); - } + + if (!MultiplayerSessionsSubsystem) + return; + + MultiplayerSessionsSubsystem->CreateSession(NumPublicConnections, MatchType); } void UMenu::JoinButtonClicked() { JoinButton->SetIsEnabled(false); - if (MultiplayerSessionsSubsystem) - { - MultiplayerSessionsSubsystem->FindSessions(10000); - } + + if (!MultiplayerSessionsSubsystem) + return; + + MultiplayerSessionsSubsystem->FindSessions(10000); } void UMenu::MenuTearDown() { RemoveFromParent(); - UWorld* World = GetWorld(); - if (World) - { - APlayerController* PlayerController = World->GetFirstPlayerController(); - if (PlayerController) - { - FInputModeGameOnly InputModeData; - PlayerController->SetInputMode(InputModeData); - PlayerController->SetShowMouseCursor(false); - } - } + + const auto World = GetWorld(); + if (!World) + return; + + const auto PlayerController = World->GetFirstPlayerController(); + if (!PlayerController) + return; + + const FInputModeGameOnly InputModeData; + PlayerController->SetInputMode(InputModeData); + PlayerController->bShowMouseCursor = false; } diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp index cc43200..bb6d6a8 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/MultiplayerSessionsSubsystem.cpp @@ -12,19 +12,14 @@ UMultiplayerSessionsSubsystem::UMultiplayerSessionsSubsystem(): DestroySessionCompleteDelegate(FOnDestroySessionCompleteDelegate::CreateUObject(this, &ThisClass::OnDestroySessionComplete)), StartSessionCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartSessionComplete)) { - IOnlineSubsystem* Subsystem = IOnlineSubsystem::Get(); - if (Subsystem) - { + if (const auto Subsystem = IOnlineSubsystem::Get()) SessionInterface = Subsystem->GetSessionInterface(); - } } void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FString MatchType) { if (!SessionInterface.IsValid()) - { return; - } auto ExistingSession = SessionInterface->GetNamedSession(NAME_GameSession); if (ExistingSession != nullptr) @@ -46,25 +41,22 @@ void UMultiplayerSessionsSubsystem::CreateSession(int32 NumPublicConnections, FS LastSessionSettings->bAllowJoinViaPresence = true; LastSessionSettings->bShouldAdvertise = true; LastSessionSettings->bUsesPresence = true; + LastSessionSettings->bUseLobbiesIfAvailable = true; LastSessionSettings->Set(FName("MatchType"), MatchType, EOnlineDataAdvertisementType::ViaOnlineServiceAndPing); LastSessionSettings->BuildUniqueId = 1; + + const auto LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); + if (SessionInterface->CreateSession(*LocalPlayer->GetPreferredUniqueNetId(), NAME_GameSession, *LastSessionSettings)) + return; - const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); - if (!SessionInterface->CreateSession(*LocalPlayer->GetPreferredUniqueNetId(), NAME_GameSession, *LastSessionSettings)) - { - SessionInterface->ClearOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegateHandle); - - // Broadcast our own custom delegate - MultiplayerOnCreateSessionComplete.Broadcast(false); - } + SessionInterface->ClearOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegateHandle); + MultiplayerOnCreateSessionComplete.Broadcast(false); } void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults) { if (!SessionInterface.IsValid()) - { return; - } FindSessionsCompleteDelegateHandle = SessionInterface->AddOnFindSessionsCompleteDelegate_Handle(FindSessionsCompleteDelegate); @@ -73,13 +65,12 @@ void UMultiplayerSessionsSubsystem::FindSessions(int32 MaxSearchResults) LastSessionSearch->bIsLanQuery = IOnlineSubsystem::Get()->GetSubsystemName() == "NULL"; LastSessionSearch->QuerySettings.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); - const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); - if (!SessionInterface->FindSessions(*LocalPlayer->GetPreferredUniqueNetId(), LastSessionSearch.ToSharedRef())) - { - SessionInterface->ClearOnFindSessionsCompleteDelegate_Handle(FindSessionsCompleteDelegateHandle); + const auto LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); + if (SessionInterface->FindSessions(*LocalPlayer->GetPreferredUniqueNetId(), LastSessionSearch.ToSharedRef())) + return; - MultiplayerOnFindSessionsComplete.Broadcast(TArray(), false); - } + SessionInterface->ClearOnFindSessionsCompleteDelegate_Handle(FindSessionsCompleteDelegateHandle); + MultiplayerOnFindSessionsComplete.Broadcast({}, false); } void UMultiplayerSessionsSubsystem::JoinSession(const FOnlineSessionSearchResult& SessionResult) @@ -92,13 +83,12 @@ void UMultiplayerSessionsSubsystem::JoinSession(const FOnlineSessionSearchResult JoinSessionCompleteDelegateHandle = SessionInterface->AddOnJoinSessionCompleteDelegate_Handle(JoinSessionCompleteDelegate); - const ULocalPlayer* LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); - if (!SessionInterface->JoinSession(*LocalPlayer->GetPreferredUniqueNetId(), NAME_GameSession, SessionResult)) - { - SessionInterface->ClearOnJoinSessionCompleteDelegate_Handle(JoinSessionCompleteDelegateHandle); + const auto LocalPlayer = GetWorld()->GetFirstLocalPlayerFromController(); + if (SessionInterface->JoinSession(*LocalPlayer->GetPreferredUniqueNetId(), NAME_GameSession, SessionResult)) + return; - MultiplayerOnJoinSessionComplete.Broadcast(EOnJoinSessionCompleteResult::UnknownError); - } + SessionInterface->ClearOnJoinSessionCompleteDelegate_Handle(JoinSessionCompleteDelegateHandle); + MultiplayerOnJoinSessionComplete.Broadcast(EOnJoinSessionCompleteResult::UnknownError); } void UMultiplayerSessionsSubsystem::DestroySession() @@ -111,11 +101,11 @@ void UMultiplayerSessionsSubsystem::DestroySession() DestroySessionCompleteDelegateHandle = SessionInterface->AddOnDestroySessionCompleteDelegate_Handle(DestroySessionCompleteDelegate); - if (!SessionInterface->DestroySession(NAME_GameSession)) - { - SessionInterface->ClearOnDestroySessionCompleteDelegate_Handle(DestroySessionCompleteDelegateHandle); - MultiplayerOnDestroySessionComplete.Broadcast(false); - } + if (SessionInterface->DestroySession(NAME_GameSession)) + return; + + SessionInterface->ClearOnDestroySessionCompleteDelegate_Handle(DestroySessionCompleteDelegateHandle); + MultiplayerOnDestroySessionComplete.Broadcast(false); } void UMultiplayerSessionsSubsystem::StartSession() @@ -124,20 +114,16 @@ void UMultiplayerSessionsSubsystem::StartSession() void UMultiplayerSessionsSubsystem::OnCreateSessionComplete(FName SessionName, bool bWasSuccessful) { - if (SessionInterface) - { + if (SessionInterface.IsValid()) SessionInterface->ClearOnCreateSessionCompleteDelegate_Handle(CreateSessionCompleteDelegateHandle); - } - + MultiplayerOnCreateSessionComplete.Broadcast(bWasSuccessful); } void UMultiplayerSessionsSubsystem::OnFindSessionsComplete(bool bWasSuccessful) { - if (SessionInterface) - { + if (SessionInterface.IsValid()) SessionInterface->ClearOnFindSessionsCompleteDelegate_Handle(FindSessionsCompleteDelegateHandle); - } if (LastSessionSearch->SearchResults.Num() <= 0) { @@ -150,25 +136,23 @@ void UMultiplayerSessionsSubsystem::OnFindSessionsComplete(bool bWasSuccessful) void UMultiplayerSessionsSubsystem::OnJoinSessionComplete(FName SessionName, EOnJoinSessionCompleteResult::Type Result) { - if (SessionInterface) - { + if (SessionInterface.IsValid()) SessionInterface->ClearOnJoinSessionCompleteDelegate_Handle(JoinSessionCompleteDelegateHandle); - } MultiplayerOnJoinSessionComplete.Broadcast(Result); } void UMultiplayerSessionsSubsystem::OnDestroySessionComplete(FName SessionName, bool bWasSuccessful) { - if (SessionInterface) - { + if (SessionInterface.IsValid()) SessionInterface->ClearOnDestroySessionCompleteDelegate_Handle(DestroySessionCompleteDelegateHandle); - } + if (bWasSuccessful && bCreateSessionOnDestroy) { bCreateSessionOnDestroy = false; CreateSession(LastNumPublicConnections, LastMatchType); } + MultiplayerOnDestroySessionComplete.Broadcast(bWasSuccessful); } From b6b305687bb6ee76d4fb04831c977c6167f3ba01 Mon Sep 17 00:00:00 2001 From: gd <11874515+gregor-dietrich@users.noreply.github.com> Date: Fri, 6 Jan 2023 23:19:32 +0100 Subject: [PATCH 4/5] Use SetShowMouseCursor instead of bShowMouseCursor --- .../Source/MultiplayerSessions/Private/Menu.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp index cb7ac6e..6652711 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp @@ -29,7 +29,7 @@ void UMenu::MenuSetup(int32 NumberOfPublicConnections, FString TypeOfMatch, FStr InputModeData.SetWidgetToFocus(TakeWidget()); InputModeData.SetLockMouseToViewportBehavior(EMouseLockMode::DoNotLock); PlayerController->SetInputMode(InputModeData); - PlayerController->bShowMouseCursor = ShowMouseCursor; + PlayerController->SetShowMouseCursor(true); const auto GameInstance = GetGameInstance(); if (!GameInstance) @@ -172,5 +172,5 @@ void UMenu::MenuTearDown() const FInputModeGameOnly InputModeData; PlayerController->SetInputMode(InputModeData); - PlayerController->bShowMouseCursor = false; + PlayerController->SetShowMouseCursor(false); } From f7e7f1671c560ae4fb2de6d41ebdf32ce50ecd0b Mon Sep 17 00:00:00 2001 From: gd <11874515+gregor-dietrich@users.noreply.github.com> Date: Sat, 7 Jan 2023 01:31:55 +0100 Subject: [PATCH 5/5] Update for UE 5.1 --- .../Source/MultiplayerSessions/Private/Menu.cpp | 4 ++-- .../Source/MultiplayerSessions/Public/Menu.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp index 6652711..2d2c605 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Private/Menu.cpp @@ -60,10 +60,10 @@ bool UMenu::Initialize() return true; } -void UMenu::OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld) +void UMenu::NativeDestruct() { MenuTearDown(); - Super::OnLevelRemovedFromWorld(InLevel, InWorld); + Super::NativeDestruct(); } void UMenu::OnCreateSession(bool bWasSuccessful) diff --git a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h index 1a19dd4..b17d35c 100644 --- a/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h +++ b/Plugins/MultiplayerSessions/Source/MultiplayerSessions/Public/Menu.h @@ -21,7 +21,7 @@ class MULTIPLAYERSESSIONS_API UMenu : public UUserWidget protected: virtual bool Initialize() override; - virtual void OnLevelRemovedFromWorld(ULevel* InLevel, UWorld* InWorld) override; + virtual void NativeDestruct() override; // // Callbacks for the custom delegates on the MultiplayerSessionsSubsystem