From b0ae86b01755c732750a19743a21f5da09100ef1 Mon Sep 17 00:00:00 2001 From: Joshua Date: Mon, 7 Feb 2022 10:28:08 -0500 Subject: [PATCH] revert to ue5 EA on this branch, spool up a new one --- AdvancedSessions/AdvancedSessions.uplugin | 4 +- .../Classes/AutoLoginUserCallbackProxy.h | 55 ------ .../Classes/BlueprintDataDefinitions.h | 19 +- .../CreateSessionCallbackProxyAdvanced.h | 186 +++++++++--------- .../FindSessionsCallbackProxyAdvanced.h | 5 +- .../Classes/LoginUserCallbackProxy.h | 6 +- .../Private/AutoLoginUserCallbackProxy.cpp | 55 ------ .../CreateSessionCallbackProxyAdvanced.cpp | 11 +- .../FindSessionsCallbackProxyAdvanced.cpp | 19 +- .../Private/LoginUserCallbackProxy.cpp | 10 +- .../UpdateSessionCallbackProxyAdvanced.cpp | 136 ++++++------- .../Classes/AdvancedSteamFriendsLibrary.h | 34 ---- .../Private/AdvancedSteamFriendsLibrary.cpp | 86 -------- 13 files changed, 166 insertions(+), 460 deletions(-) delete mode 100644 AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h delete mode 100644 AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp diff --git a/AdvancedSessions/AdvancedSessions.uplugin b/AdvancedSessions/AdvancedSessions.uplugin index 079213e..6227fd4 100644 --- a/AdvancedSessions/AdvancedSessions.uplugin +++ b/AdvancedSessions/AdvancedSessions.uplugin @@ -2,8 +2,8 @@ "FileVersion" : 3, "FriendlyName" : "Advanced Sessions", - "Version" : 4.27, - "VersionName": "4.27", + "Version" : 4.26, + "VersionName": "4.26", "Description" : "Adds new blueprint functions to handle more advanced session operations.", "Category" : "Advanced Sessions Plugin", "CreatedBy" : "Joshua Statzer", diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h b/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h deleted file mode 100644 index dc91cff..0000000 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/AutoLoginUserCallbackProxy.h +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. -#pragma once - -#include "CoreMinimal.h" -#include "BlueprintDataDefinitions.h" -#include "Interfaces/OnlineIdentityInterface.h" -#include "Engine/LocalPlayer.h" -#include "AutoLoginUserCallbackProxy.generated.h" - -UCLASS(MinimalAPI) -class UAutoLoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase -{ - GENERATED_UCLASS_BODY() - - // Called when there is a successful destroy - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnSuccess; - - // Called when there is an unsuccessful destroy - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnFailure; - - /** - * Logs the player into the online service using parameters passed on the - * command line. Expects -AUTH_LOGIN= -AUTH_PASSWORD=. If either - * are missing, the function returns false and doesn't start the login - * process - * - * @param LocalUserNum the controller number of the associated user - * - */ - UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") - static UAutoLoginUserCallbackProxy* AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum); - - // UOnlineBlueprintCallProxyBase interface - virtual void Activate() override; - // End of UOnlineBlueprintCallProxyBase interface - -private: - // Internal callback when the operation completes, calls out to the public success/failure callbacks - void OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal); - -private: - // The controller number of the associated user - int32 LocalUserNumber; - - // The delegate executed by the online subsystem - FOnLoginCompleteDelegate Delegate; - - // Handle to the registered OnDestroySessionComplete delegate - FDelegateHandle DelegateHandle; - - // The world context object in which this call is taking place - UObject* WorldContextObject; -}; diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h b/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h index 9522be2..340caf2 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/BlueprintDataDefinitions.h @@ -264,18 +264,10 @@ public: EBPOnlinePresenceState PresenceState = EBPOnlinePresenceState::Offline; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FString StatusString; - - FBPFriendPresenceInfo() - { - bIsOnline = false; - bIsPlaying = false; - bIsPlayingThisGame = false; - bIsJoinable = false; - bHasVoiceSupport = false; - PresenceState = EBPOnlinePresenceState::Offline; - } }; + + USTRUCT(BlueprintType) struct FBPFriendInfo { @@ -295,15 +287,8 @@ public: bool bIsPlayingSameGame = false; UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend") FBPFriendPresenceInfo PresenceInfo; - - FBPFriendInfo() - { - OnlineState = EBPOnlinePresenceState::Offline; - bIsPlayingSameGame = false; - } }; - /** The types of comparison operations for a given search query */ // Used to compare session properties UENUM(BlueprintType) diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h index 0250956..067d6e1 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/CreateSessionCallbackProxyAdvanced.h @@ -1,103 +1,95 @@ -// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. -#pragma once - -#include "CoreMinimal.h" -#include "Engine/Engine.h" -#include "BlueprintDataDefinitions.h" -#include "CreateSessionCallbackProxyAdvanced.generated.h" - -UCLASS(MinimalAPI) -class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase -{ - GENERATED_UCLASS_BODY() - - // Called when the session was created successfully - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnSuccess; - - // Called when there was an error creating the session - UPROPERTY(BlueprintAssignable) - FEmptyOnlineDelegate OnFailure; - +// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. +#pragma once + +#include "CoreMinimal.h" +#include "Engine/Engine.h" +#include "BlueprintDataDefinitions.h" +#include "CreateSessionCallbackProxyAdvanced.generated.h" + +UCLASS(MinimalAPI) +class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase +{ + GENERATED_UCLASS_BODY() + + // Called when the session was created successfully + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnSuccess; + + // Called when there was an error creating the session + UPROPERTY(BlueprintAssignable) + FEmptyOnlineDelegate OnFailure; + /** * Creates a session with the default online subsystem with advanced optional inputs, for dedicated servers leave UsePresence as false and set IsDedicatedServer to true. Dedicated servers don't use presence. * @param PublicConnections When doing a 'listen' server, this must be >=2 (ListenServer itself counts as a connection) * @param bUseLAN When you want to play LAN, the level to play on must be loaded with option 'bIsLanMatch' * @param bUsePresence Must be true for a 'listen' server (Map must be loaded with option 'listen'), false for a 'dedicated' server. - * @param bUseLobbiesIfAvailable Used to flag the subsystem to use a lobby api instead of general hosting if the API supports it, generally true on steam for listen servers and false for dedicated * @param bShouldAdvertise Set to true when the OnlineSubsystem should list your server when someone is searching for servers. Otherwise the server is hidden and only join via invite is possible. - * @param bUseLobbiesVoiceChatIfAvailable Set to true to setup voice chat lobbies if the API supports it - */ - UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") - static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bUseLobbiesIfAvailable = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true, bool bUseLobbiesVoiceChatIfAvailable = false); - - // UOnlineBlueprintCallProxyBase interface - virtual void Activate() override; - // End of UOnlineBlueprintCallProxyBase interface - -private: - // Internal callback when session creation completes, calls StartSession - void OnCreateCompleted(FName SessionName, bool bWasSuccessful); - - // Internal callback when session creation completes, calls StartSession - void OnStartCompleted(FName SessionName, bool bWasSuccessful); - - // The player controller triggering things - TWeakObjectPtr PlayerControllerWeakPtr; - - // The delegate executed by the online subsystem - FOnCreateSessionCompleteDelegate CreateCompleteDelegate; - - // The delegate executed by the online subsystem - FOnStartSessionCompleteDelegate StartCompleteDelegate; - - // Handles to the registered delegates above - FDelegateHandle CreateCompleteDelegateHandle; - FDelegateHandle StartCompleteDelegateHandle; - - // Number of public connections - int NumPublicConnections; - - // Number of private connections - int NumPrivateConnections; - - // Whether or not to search LAN - bool bUseLAN; - - // Whether or not to allow invites - bool bAllowInvites; - - // Whether this is a dedicated server or not - bool bDedicatedServer; - - // Whether to use the presence option - bool bUsePresence; - - // Whether to prefer the use of lobbies for hosting if the api supports them - bool bUseLobbiesIfAvailable; - - // Whether to allow joining via presence - bool bAllowJoinViaPresence; - - // Allow joining via presence for friends only - bool bAllowJoinViaPresenceFriendsOnly; - - // Delcare the server to be anti cheat protected - bool bAntiCheatProtected; - - // Record Stats - bool bUsesStats; - - // Should advertise server? - bool bShouldAdvertise; - - // Whether to prefer the use of voice chat lobbies if the api supports them - bool bUseLobbiesVoiceChatIfAvailable; - - // Store extra settings - TArray ExtraSettings; - - // The world context object in which this call is taking place - UObject* WorldContextObject; -}; - + */ + UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions") + static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController = NULL, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = true, bool bIsDedicatedServer = false, bool bUsePresence = true, bool bAllowJoinViaPresence = true, bool bAllowJoinViaPresenceFriendsOnly = false, bool bAntiCheatProtected = false, bool bUsesStats = false, bool bShouldAdvertise = true); + + // UOnlineBlueprintCallProxyBase interface + virtual void Activate() override; + // End of UOnlineBlueprintCallProxyBase interface + +private: + // Internal callback when session creation completes, calls StartSession + void OnCreateCompleted(FName SessionName, bool bWasSuccessful); + + // Internal callback when session creation completes, calls StartSession + void OnStartCompleted(FName SessionName, bool bWasSuccessful); + + // The player controller triggering things + TWeakObjectPtr PlayerControllerWeakPtr; + + // The delegate executed by the online subsystem + FOnCreateSessionCompleteDelegate CreateCompleteDelegate; + + // The delegate executed by the online subsystem + FOnStartSessionCompleteDelegate StartCompleteDelegate; + + // Handles to the registered delegates above + FDelegateHandle CreateCompleteDelegateHandle; + FDelegateHandle StartCompleteDelegateHandle; + + // Number of public connections + int NumPublicConnections; + + // Number of private connections + int NumPrivateConnections; + + // Whether or not to search LAN + bool bUseLAN; + + // Whether or not to allow invites + bool bAllowInvites; + + // Whether this is a dedicated server or not + bool bDedicatedServer; + + // Whether to use the presence option + bool bUsePresence; + + // Whether to allow joining via presence + bool bAllowJoinViaPresence; + + // Allow joining via presence for friends only + bool bAllowJoinViaPresenceFriendsOnly; + + // Delcare the server to be anti cheat protected + bool bAntiCheatProtected; + + // Record Stats + bool bUsesStats; + + // Should advertise server? + bool bShouldAdvertise; + + // Store extra settings + TArray ExtraSettings; + + // The world context object in which this call is taking place + UObject* WorldContextObject; +}; + diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h b/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h index 713b7c6..c48994a 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/FindSessionsCallbackProxyAdvanced.h @@ -22,7 +22,7 @@ class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase // Searches for advertised sessions with the default online subsystem and includes an array of filters UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AutoCreateRefTerm="Filters"), Category = "Online|AdvancedSessions") - static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, bool bSearchLobbies = true, int MinSlotsAvailable = 0); + static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0); static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator); @@ -92,9 +92,6 @@ private: // Search for secure servers only bool bSecureServersOnly; - // Search through lobbies - bool bSearchLobbies; - // Min slots requires to search int MinSlotsAvailable; diff --git a/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h b/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h index db6dc34..72433f6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h +++ b/AdvancedSessions/Source/AdvancedSessions/Classes/LoginUserCallbackProxy.h @@ -21,8 +21,8 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase FEmptyOnlineDelegate OnFailure; // Logs into the identity interface - UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject", AdvancedDisplay = "Type"), Category = "Online|AdvancedIdentity") - static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString Type); + UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity") + static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken); // UOnlineBlueprintCallProxyBase interface virtual void Activate() override; @@ -42,8 +42,6 @@ private: // The user pass / token FString UserToken; - FString Type; - // The delegate executed by the online subsystem FOnLoginCompleteDelegate Delegate; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp deleted file mode 100644 index de3225d..0000000 --- a/AdvancedSessions/Source/AdvancedSessions/Private/AutoLoginUserCallbackProxy.cpp +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved. - -#include "AutoLoginUserCallbackProxy.h" - - -////////////////////////////////////////////////////////////////////////// -// ULoginUserCallbackProxy - -UAutoLoginUserCallbackProxy::UAutoLoginUserCallbackProxy(const FObjectInitializer& ObjectInitializer) - : Super(ObjectInitializer) - , Delegate(FOnLoginCompleteDelegate::CreateUObject(this, &ThisClass::OnCompleted)) -{ -} - -UAutoLoginUserCallbackProxy* UAutoLoginUserCallbackProxy::AutoLoginUser(UObject* WorldContextObject, int32 LocalUserNum) -{ - UAutoLoginUserCallbackProxy* Proxy = NewObject(); - Proxy->LocalUserNumber = LocalUserNum; - Proxy->WorldContextObject = WorldContextObject; - return Proxy; -} - -void UAutoLoginUserCallbackProxy::Activate() -{ - auto Identity = Online::GetIdentityInterface(); - - if (Identity.IsValid()) - { - DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(LocalUserNumber, Delegate); - Identity->AutoLogin(LocalUserNumber); - return; - } - - // Fail immediately - OnFailure.Broadcast(); -} - -void UAutoLoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessful, const FUniqueNetId& UserId, const FString& ErrorVal) -{ - auto Identity = Online::GetIdentityInterface(); - - if (Identity.IsValid()) - { - Identity->ClearOnLoginCompleteDelegate_Handle(LocalUserNum, DelegateHandle); - } - - if (bWasSuccessful) - { - OnSuccess.Broadcast(); - } - else - { - OnFailure.Broadcast(); - } -} diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp index 72b6ab8..086b8f6 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/CreateSessionCallbackProxyAdvanced.cpp @@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F { } -UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bUseLobbiesIfAvailable, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise, bool bUseLobbiesVoiceChatIfAvailable) +UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray &ExtraSettings, class APlayerController* PlayerController, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bIsDedicatedServer, bool bUsePresence, bool bAllowJoinViaPresence, bool bAllowJoinViaPresenceFriendsOnly, bool bAntiCheatProtected, bool bUsesStats, bool bShouldAdvertise) { UCreateSessionCallbackProxyAdvanced* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; @@ -25,13 +25,11 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create Proxy->ExtraSettings = ExtraSettings; Proxy->bDedicatedServer = bIsDedicatedServer; Proxy->bUsePresence = bUsePresence; - Proxy->bUseLobbiesIfAvailable = bUseLobbiesIfAvailable; Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence; Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Proxy->bAntiCheatProtected = bAntiCheatProtected; Proxy->bUsesStats = bUsesStats; Proxy->bShouldAdvertise = bShouldAdvertise; - Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable; return Proxy; } @@ -59,17 +57,10 @@ void UCreateSessionCallbackProxyAdvanced::Activate() Settings.bIsDedicated = bDedicatedServer; if (bDedicatedServer) - { Settings.bUsesPresence = false; - Settings.bUseLobbiesIfAvailable = false; - } else - { Settings.bUsesPresence = bUsePresence; - Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable; - } - Settings.bUseLobbiesVoiceChatIfAvailable = bUseLobbiesIfAvailable ? bUseLobbiesVoiceChatIfAvailable : false; Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly; Settings.bAntiCheatProtected = bAntiCheatProtected; Settings.bUsesStats = bUsesStats; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp index ff6944c..3f62d81 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/FindSessionsCallbackProxyAdvanced.cpp @@ -15,7 +15,7 @@ UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FOb bIsOnSecondSearch = false; } -UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable) +UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable) { UFindSessionsCallbackProxyAdvanced* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; @@ -27,7 +27,6 @@ UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSess Proxy->bEmptyServersOnly = bEmptyServersOnly, Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly; Proxy->bSecureServersOnly = bSecureServersOnly; - Proxy->bSearchLobbies = bSearchLobbies; Proxy->MinSlotsAvailable = MinSlotsAvailable; return Proxy; } @@ -74,17 +73,6 @@ void UFindSessionsCallbackProxyAdvanced::Activate() #define SEARCH_USER FName(TEXT("SEARCHUSER")) // Keywords to match in session search #define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/ - /** Keywords to match in session search */ - /** The matchmaking queue name to matchmake in, e.g. "TeamDeathmatch" (value is string) */ - /** #define SEARCH_MATCHMAKING_QUEUE FName(TEXT("MATCHMAKINGQUEUE"))*/ - /** If set, use the named Xbox Live hopper to find a session via matchmaking (value is a string) */ - /** #define SEARCH_XBOX_LIVE_HOPPER_NAME FName(TEXT("LIVEHOPPERNAME"))*/ - /** Which session template from the service configuration to use */ - /** #define SEARCH_XBOX_LIVE_SESSION_TEMPLATE_NAME FName(TEXT("LIVESESSIONTEMPLATE"))*/ - /** Selection method used to determine which match to join when multiple are returned (valid only on Switch) */ - /** #define SEARCH_SWITCH_SELECTION_METHOD FName(TEXT("SWITCHSELECTIONMETHOD"))*/ - /** Whether to use lobbies vs sessions */ - /** #define SEARCH_LOBBIES FName(TEXT("LOBBYSEARCH"))*/ if (bEmptyServersOnly) tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals); @@ -98,6 +86,8 @@ void UFindSessionsCallbackProxyAdvanced::Activate() if (MinSlotsAvailable != 0) tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals); + + // Filter results if (SearchSettings.Num() > 0) { @@ -114,9 +104,6 @@ void UFindSessionsCallbackProxyAdvanced::Activate() case EBPServerPresenceSearchType::ClientServersOnly: { tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals); - - if (bSearchLobbies) - tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals); } break; diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp index 3c9fb54..7d805eb 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/LoginUserCallbackProxy.cpp @@ -12,13 +12,12 @@ ULoginUserCallbackProxy::ULoginUserCallbackProxy(const FObjectInitializer& Objec { } -ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString Type) +ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken) { ULoginUserCallbackProxy* Proxy = NewObject(); Proxy->PlayerControllerWeakPtr = PlayerController; Proxy->UserID = UserID; Proxy->UserToken = UserToken; - Proxy->Type = Type; Proxy->WorldContextObject = WorldContextObject; return Proxy; } @@ -44,13 +43,8 @@ void ULoginUserCallbackProxy::Activate() if (Identity.IsValid()) { - // Fallback to default AuthType if nothing is specified - if (Type.IsEmpty()) - { - Type = Identity->GetAuthType(); - } DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate); - FOnlineAccountCredentials AccountCreds(Type, UserID, UserToken); + FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken); Identity->Login(Player->GetControllerId(), AccountCreds); return; } diff --git a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp index 0155c64..90c8a7f 100644 --- a/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp +++ b/AdvancedSessions/Source/AdvancedSessions/Private/UpdateSessionCallbackProxyAdvanced.cpp @@ -29,73 +29,70 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update void UUpdateSessionCallbackProxyAdvanced::Activate() { - const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); - if (Helper.OnlineSub != nullptr) + IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); + + if (Sessions.IsValid()) { - const auto Sessions = Helper.OnlineSub->GetSessionInterface(); - if (Sessions.IsValid()) + if (Sessions->GetNumSessions() < 1) { - if (Sessions->GetNumSessions() < 1) - { - OnFailure.Broadcast(); - GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!")); - return; - } - - // This gets the actual session itself - //FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession); - FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession); - - if (!Settings) - { - // Fail immediately - OnFailure.Broadcast(); - return; - } - - OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate); - - // FOnlineSessionSettings Settings; - //Settings->BuildUniqueId = GetBuildUniqueId(); - Settings->NumPublicConnections = NumPublicConnections; - Settings->NumPrivateConnections = NumPrivateConnections; - //Settings->bShouldAdvertise = true; - Settings->bAllowJoinInProgress = bAllowJoinInProgress; - Settings->bIsLANMatch = bUseLAN; - //Settings->bUsesPresence = true; - //Settings->bAllowJoinViaPresence = true; - Settings->bAllowInvites = bAllowInvites; - Settings->bAllowJoinInProgress = bAllowJoinInProgress; - Settings->bIsDedicated = bDedicatedServer; - - FOnlineSessionSetting * fSetting = NULL; - FOnlineSessionSetting ExtraSetting; - for (int i = 0; i < ExtraSettings.Num(); i++) - { - fSetting = Settings->Settings.Find(ExtraSettings[i].Key); - - if (fSetting) - { - fSetting->Data = ExtraSettings[i].Data; - } - else - { - ExtraSetting.Data = ExtraSettings[i].Data; - ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService; - Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting); - } - } - - Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData); - - // OnUpdateCompleted will get called, nothing more to do now + OnFailure.Broadcast(); + GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!")); return; } - else + + // This gets the actual session itself + //FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession); + FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession); + + if (!Settings) { - FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); + // Fail immediately + OnFailure.Broadcast(); + return; } + + OnUpdateSessionCompleteDelegateHandle = Sessions->AddOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegate); + + // FOnlineSessionSettings Settings; + //Settings->BuildUniqueId = GetBuildUniqueId(); + Settings->NumPublicConnections = NumPublicConnections; + Settings->NumPrivateConnections = NumPrivateConnections; + //Settings->bShouldAdvertise = true; + Settings->bAllowJoinInProgress = bAllowJoinInProgress; + Settings->bIsLANMatch = bUseLAN; + //Settings->bUsesPresence = true; + //Settings->bAllowJoinViaPresence = true; + Settings->bAllowInvites = bAllowInvites; + Settings->bAllowJoinInProgress = bAllowJoinInProgress; + Settings->bIsDedicated = bDedicatedServer; + + FOnlineSessionSetting * fSetting = NULL; + FOnlineSessionSetting ExtraSetting; + for (int i = 0; i < ExtraSettings.Num(); i++) + { + fSetting = Settings->Settings.Find(ExtraSettings[i].Key); + + if (fSetting) + { + fSetting->Data = ExtraSettings[i].Data; + } + else + { + ExtraSetting.Data = ExtraSettings[i].Data; + ExtraSetting.AdvertisementType = EOnlineDataAdvertisementType::ViaOnlineService; + Settings->Settings.Add(ExtraSettings[i].Key, ExtraSetting); + } + } + + Sessions->UpdateSession(NAME_GameSession, *Settings, bRefreshOnlineData); + + // OnUpdateCompleted will get called, nothing more to do now + return; + } + else + { + FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning); } // Fail immediately OnFailure.Broadcast(); @@ -104,20 +101,15 @@ void UUpdateSessionCallbackProxyAdvanced::Activate() void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful) { - const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull)); - - if (Helper.OnlineSub != nullptr) + IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld()); + if (Sessions.IsValid()) { - const auto Sessions = Helper.OnlineSub->GetSessionInterface(); - if (Sessions.IsValid()) + Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle); + + if (bWasSuccessful) { - Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle); - - if (bWasSuccessful) - { - OnSuccess.Broadcast(); - return; - } + OnSuccess.Broadcast(); + return; } } diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h index 998135b..02c176d 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Classes/AdvancedSteamFriendsLibrary.h @@ -305,19 +305,6 @@ public: }; -UENUM(Blueprintable) -enum class EBPTextFilteringContext : uint8 -{ - /*Unknown context.*/ - FContext_Unknown = 0, - /*Game content, only legally required filtering is performed.*/ - FContext_GameContent = 1, - /*Char from another player.*/ - FContext_Chat = 2, - /*Character or item name.*/ - FContext_Name = 3 -}; - UCLASS() class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary { @@ -338,10 +325,6 @@ public: UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType); - // Returns if the steam overlay is currently active (this can return false during initial overlay hooking) - UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI") - static bool IsOverlayEnabled(); - // Gets the level of a friends steam account, STEAM ONLY, Returns -1 if the steam level is not known, might need RequestSteamFriendInfo called first. UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI") static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId); @@ -367,21 +350,4 @@ public: // Get a full list of steam groups UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups") static void GetSteamGroups(TArray & SteamGroups); - - // Initializes text filtering (pre-loading dictonaries) - // Returns if it succeeded, false if filtering is unavailable for the games language - UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") - static bool InitTextFiltering(); - - // Attempts to filter a string with the given filtering context - // Returns true if the text has been filtered, false if it hasn't (no filtering required or operation failed) - // If false it will still output the original text - // Textsource is the steam id that is the source of the text (player name / chat) - // Requires that InitTextFiltering be called first!! - UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|TextFiltering") - static bool FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText); - - // Returns if steam is running in big picture mode - UFUNCTION(BlueprintPure, Category = "Online|SteamAPI") - static bool IsSteamInBigPictureMode(); }; diff --git a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp index bd31497..4c2dc00 100644 --- a/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp +++ b/AdvancedSteamSessions/Source/AdvancedSteamSessions/Private/AdvancedSteamFriendsLibrary.cpp @@ -255,19 +255,6 @@ bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId Uni return false; } -bool UAdvancedSteamFriendsLibrary::IsOverlayEnabled() -{ -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX - if (SteamAPI_Init()) - { - return SteamUtils()->IsOverlayEnabled(); - } -#endif - - UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!")); - return false; -} - UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize) { #if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX @@ -363,77 +350,4 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized")); Result = EBlueprintAsyncResultSwitch::OnFailure; return nullptr; -} - -bool UAdvancedSteamFriendsLibrary::InitTextFiltering() -{ -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX - - if (SteamAPI_Init()) - { - return SteamUtils()->InitFilterText(); - } - -#endif - - return false; -} - -bool UAdvancedSteamFriendsLibrary::FilterText(FString TextToFilter, EBPTextFilteringContext Context, const FBPUniqueNetId TextSourceID, FString& FilteredText) -{ -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX - - if (SteamAPI_Init()) - { - uint32 BufferLen = TextToFilter.Len() + 10; // Docs say 1 byte excess min, going with 10 - char* OutText = new char[BufferLen]; - - uint64 id = 0; - - if (TextSourceID.IsValid()) - { - id = *((uint64*)TextSourceID.UniqueNetId->GetBytes()); - } - - // MAC is bugged with current steam version according to epic, they forced it to be the old steam ver -#if PLATFORM_MAC - // Filters the provided input message and places the filtered result into pchOutFilteredText. - // pchOutFilteredText is where the output will be placed, even if no filtering or censoring is performed - // nByteSizeOutFilteredText is the size (in bytes) of pchOutFilteredText - // pchInputText is the input string that should be filtered, which can be ASCII or UTF-8 - // bLegalOnly should be false if you want profanity and legally required filtering (where required) and true if you want legally required filtering only - // Returns the number of characters (not bytes) filtered. - int FilterCount = SteamUtils()->FilterText(OutText, BufferLen, TCHAR_TO_ANSI(*TextToFilter), Context == EBPTextFilteringContext::FContext_GameContent); -#else - int FilterCount = SteamUtils()->FilterText((ETextFilteringContext)Context, id, TCHAR_TO_ANSI(*TextToFilter), OutText, BufferLen); -#endif - - if (FilterCount > 0) - { - FilteredText = FString(UTF8_TO_TCHAR(OutText)); - delete[] OutText; - return true; - } - - delete[] OutText; - } - -#endif - - FilteredText = TextToFilter; - return false; -} - -bool UAdvancedSteamFriendsLibrary::IsSteamInBigPictureMode() -{ -#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX - - if (SteamAPI_Init()) - { - return SteamUtils()->IsSteamInBigPictureMode(); - } - -#endif - - return false; } \ No newline at end of file