mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-26 18:04:07 +00:00
Compare commits
50 Commits
4.24_Locke
...
4.27-Locke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d05e0a0d79 | ||
|
|
141b15c4e4 | ||
|
|
d61c55862f | ||
|
|
3d024ae1c7 | ||
|
|
baed5da63a | ||
|
|
13c795a6e5 | ||
|
|
ef928edaef | ||
|
|
6e6b596ec4 | ||
|
|
62c655cfa7 | ||
|
|
6c5f3b8b06 | ||
|
|
1dbd091e01 | ||
|
|
d1a0b48668 | ||
|
|
3b7ec6ba65 | ||
|
|
e60ee9cf40 | ||
|
|
af1eb9342f | ||
|
|
dbc60b5046 | ||
|
|
4ad2cf5139 | ||
|
|
2520d15e54 | ||
|
|
fbbb39c06c | ||
|
|
4922cd2154 | ||
|
|
36cb58ea15 | ||
|
|
e9747ff440 | ||
|
|
ee9252a0df | ||
|
|
b3cc471bf3 | ||
|
|
9bb2c553cd | ||
|
|
56639eb4a7 | ||
|
|
31c4be3629 | ||
|
|
b986d7be2d | ||
|
|
82b2f9f594 | ||
|
|
ec634238f8 | ||
|
|
21b5b139d9 | ||
|
|
7b8bebac66 | ||
|
|
444b632a72 | ||
|
|
94fb993ad7 | ||
|
|
d67c039088 | ||
|
|
0be6427845 | ||
|
|
816b701963 | ||
|
|
e9bea6cac0 | ||
|
|
a63bb0916a | ||
|
|
be6f532c1e | ||
|
|
1f6b7dbb3b | ||
|
|
c391737812 | ||
|
|
156025af2d | ||
|
|
188d5059fc | ||
|
|
e561b92679 | ||
|
|
0cee743c63 | ||
|
|
bfd459b461 | ||
|
|
17228f6bbb | ||
|
|
c32fc3488f | ||
|
|
05497d3226 |
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
.hg/
|
||||||
|
binaries/
|
||||||
|
deriveddatacache/
|
||||||
|
.vs/
|
||||||
|
build/
|
||||||
|
intermediate/
|
||||||
|
PACKPLUGIN/
|
||||||
|
saved/
|
||||||
|
*.orig
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
"FileVersion" : 3,
|
"FileVersion" : 3,
|
||||||
|
|
||||||
"FriendlyName" : "Advanced Sessions",
|
"FriendlyName" : "Advanced Sessions",
|
||||||
"Version" : 4.24,
|
"Version" : 4.27,
|
||||||
"VersionName": "4.24",
|
"VersionName": "4.27",
|
||||||
"Description" : "Adds new blueprint functions to handle more advanced session operations.",
|
"Description" : "Adds new blueprint functions to handle more advanced session operations.",
|
||||||
"Category" : "Advanced Sessions Plugin",
|
"Category" : "Advanced Sessions Plugin",
|
||||||
"CreatedBy" : "Joshua Statzer",
|
"CreatedBy" : "Joshua Statzer",
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
// Fill out your copyright notice in the Description page of Project Settings.
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "Engine/Engine.h"
|
||||||
|
#include "Online.h"
|
||||||
|
#include "OnlineSubsystem.h"
|
||||||
|
#include "Engine/GameInstance.h"
|
||||||
|
#include "GameFramework/GameModeBase.h"
|
||||||
|
#include "GameFramework/GameSession.h"
|
||||||
|
#include "GameFramework/PlayerState.h"
|
||||||
|
|
||||||
|
//#include "UObjectIterator.h"
|
||||||
|
|
||||||
|
#include "AdvancedGameSession.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
A quick wrapper around the game session to add a partial ban implementation. Just bans for the duration of the current session
|
||||||
|
*/
|
||||||
|
UCLASS(config = Game, notplaceable)
|
||||||
|
class AAdvancedGameSession : public AGameSession
|
||||||
|
{
|
||||||
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(Transient)
|
||||||
|
TMap<FUniqueNetIdRepl, FText> BanList;
|
||||||
|
|
||||||
|
virtual bool BanPlayer(class APlayerController* BannedPlayer, const FText& BanReason)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (APlayerState* PlayerState = (BannedPlayer != NULL) ? BannedPlayer->PlayerState : NULL)
|
||||||
|
{
|
||||||
|
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
|
||||||
|
bool bWasKicked = KickPlayer(BannedPlayer, BanReason);
|
||||||
|
|
||||||
|
if (bWasKicked)
|
||||||
|
{
|
||||||
|
BanList.Add(UniqueNetID, BanReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bWasKicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should really be handled in the game mode asking game session, but I didn't want to force a custom game session AND game mode
|
||||||
|
// If done in the game mode, we could check prior to actually spooling up any player information in ApproveLogin
|
||||||
|
virtual void PostLogin(APlayerController* NewPlayer) override
|
||||||
|
{
|
||||||
|
if (APlayerState* PlayerState = (NewPlayer != NULL) ? NewPlayer->PlayerState : NULL)
|
||||||
|
{
|
||||||
|
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
|
||||||
|
|
||||||
|
if (BanList.Contains(UniqueNetID))
|
||||||
|
{
|
||||||
|
KickPlayer(NewPlayer, BanList[UniqueNetID]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AAdvancedGameSession::AAdvancedGameSession(const FObjectInitializer& ObjectInitializer)
|
||||||
|
: Super(ObjectInitializer)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -14,6 +14,9 @@
|
|||||||
#include "Engine/GameInstance.h"
|
#include "Engine/GameInstance.h"
|
||||||
#include "Interfaces/OnlineSessionInterface.h"
|
#include "Interfaces/OnlineSessionInterface.h"
|
||||||
|
|
||||||
|
#include "GameFramework/GameModeBase.h"
|
||||||
|
#include "GameFramework/GameSession.h"
|
||||||
|
|
||||||
//#include "UObjectIterator.h"
|
//#include "UObjectIterator.h"
|
||||||
|
|
||||||
#include "AdvancedSessionsLibrary.generated.h"
|
#include "AdvancedSessionsLibrary.generated.h"
|
||||||
@@ -28,6 +31,17 @@ class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
//********* Session Admin Functions *************//
|
||||||
|
|
||||||
|
// Kick a player from the currently active game session, only available on the server
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
|
||||||
|
static bool KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason);
|
||||||
|
|
||||||
|
// Ban a player from the currently active game session, only available on the server
|
||||||
|
// Note that the default gamesession class does not implement an actual ban list and just kicks when this is called
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
|
||||||
|
static bool BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason);
|
||||||
|
|
||||||
//********* Session Search Functions *************//
|
//********* Session Search Functions *************//
|
||||||
|
|
||||||
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
||||||
@@ -146,6 +160,10 @@ public:
|
|||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
|
static void GetUniqueNetID(APlayerController *PlayerController, FBPUniqueNetId &UniqueNetId);
|
||||||
|
|
||||||
|
// Get the unique net id of a network player attached to the given controller
|
||||||
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
|
static void GetUniqueNetIdOfSessionOwner(FBlueprintSessionResult SessionResult, FBPUniqueNetId& UniqueNetId);
|
||||||
|
|
||||||
// Get the unique net id of a network player who is assigned the the given player state
|
// Get the unique net id of a network player who is assigned the the given player state
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||||
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
||||||
@@ -185,6 +203,12 @@ public:
|
|||||||
// Checks if the stated session subsystem is active
|
// Checks if the stated session subsystem is active
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
||||||
static bool HasOnlineSubsystem(FName SubSystemName);
|
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);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
// 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=<UserName> -AUTH_PASSWORD=<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;
|
||||||
|
};
|
||||||
@@ -200,6 +200,17 @@ public:
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Adding in a compare operator so that std functions will work with this struct
|
||||||
|
FORCEINLINE bool operator==(const FBPUniqueNetId& Other) const
|
||||||
|
{
|
||||||
|
return (IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
|
||||||
|
}
|
||||||
|
|
||||||
|
FORCEINLINE bool operator!=(const FBPUniqueNetId& Other) const
|
||||||
|
{
|
||||||
|
return !(IsValid() && Other.IsValid() && (*GetUniqueNetId() == *Other.GetUniqueNetId()));
|
||||||
|
}
|
||||||
|
|
||||||
FBPUniqueNetId()
|
FBPUniqueNetId()
|
||||||
{
|
{
|
||||||
bUseDirectPointer = false;
|
bUseDirectPointer = false;
|
||||||
@@ -253,10 +264,18 @@ public:
|
|||||||
EBPOnlinePresenceState PresenceState;
|
EBPOnlinePresenceState PresenceState;
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||||
FString StatusString;
|
FString StatusString;
|
||||||
|
|
||||||
|
FBPFriendPresenceInfo()
|
||||||
|
{
|
||||||
|
bIsOnline = false;
|
||||||
|
bIsPlaying = false;
|
||||||
|
bIsPlayingThisGame = false;
|
||||||
|
bIsJoinable = false;
|
||||||
|
bHasVoiceSupport = false;
|
||||||
|
PresenceState = EBPOnlinePresenceState::Offline;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
USTRUCT(BlueprintType)
|
USTRUCT(BlueprintType)
|
||||||
struct FBPFriendInfo
|
struct FBPFriendInfo
|
||||||
{
|
{
|
||||||
@@ -276,8 +295,15 @@ public:
|
|||||||
bool bIsPlayingSameGame;
|
bool bIsPlayingSameGame;
|
||||||
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
UPROPERTY(EditAnywhere, BlueprintReadWrite, Category = "Online|Friend")
|
||||||
FBPFriendPresenceInfo PresenceInfo;
|
FBPFriendPresenceInfo PresenceInfo;
|
||||||
|
|
||||||
|
FBPFriendInfo()
|
||||||
|
{
|
||||||
|
OnlineState = EBPOnlinePresenceState::Offline;
|
||||||
|
bIsPlayingSameGame = false;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/** The types of comparison operations for a given search query */
|
/** The types of comparison operations for a given search query */
|
||||||
// Used to compare session properties
|
// Used to compare session properties
|
||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
@@ -340,7 +366,7 @@ public:
|
|||||||
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
|
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
|
||||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||||
{
|
{
|
||||||
UserID = PlayerState->UniqueId.GetUniqueNetId();
|
UserID = PlayerState->GetUniqueId().GetUniqueNetId();
|
||||||
if (!UserID.IsValid())
|
if (!UserID.IsValid())
|
||||||
{
|
{
|
||||||
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
|
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
|
||||||
|
|||||||
@@ -1,95 +1,107 @@
|
|||||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CoreMinimal.h"
|
#include "CoreMinimal.h"
|
||||||
#include "Engine/Engine.h"
|
#include "Engine/Engine.h"
|
||||||
#include "BlueprintDataDefinitions.h"
|
#include "BlueprintDataDefinitions.h"
|
||||||
#include "CreateSessionCallbackProxyAdvanced.generated.h"
|
#include "CreateSessionCallbackProxyAdvanced.generated.h"
|
||||||
|
|
||||||
UCLASS(MinimalAPI)
|
UCLASS(MinimalAPI)
|
||||||
class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
class UCreateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||||
{
|
{
|
||||||
GENERATED_UCLASS_BODY()
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
// Called when the session was created successfully
|
// Called when the session was created successfully
|
||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FEmptyOnlineDelegate OnSuccess;
|
FEmptyOnlineDelegate OnSuccess;
|
||||||
|
|
||||||
// Called when there was an error creating the session
|
// Called when there was an error creating the session
|
||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FEmptyOnlineDelegate OnFailure;
|
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.
|
* 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 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 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 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 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")
|
* @param bStartAfterCreate Set to true to start the session after it's created.
|
||||||
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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);
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
static UCreateSessionCallbackProxyAdvanced* CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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, bool bStartAfterCreate = true);
|
||||||
virtual void Activate() override;
|
|
||||||
// End of UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
|
virtual void Activate() override;
|
||||||
private:
|
// End of UOnlineBlueprintCallProxyBase interface
|
||||||
// Internal callback when session creation completes, calls StartSession
|
|
||||||
void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
|
private:
|
||||||
|
// Internal callback when session creation completes, calls StartSession
|
||||||
// Internal callback when session creation completes, calls StartSession
|
void OnCreateCompleted(FName SessionName, bool bWasSuccessful);
|
||||||
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
|
||||||
|
// Internal callback when session start completes
|
||||||
// The player controller triggering things
|
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
||||||
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
|
||||||
|
// The player controller triggering things
|
||||||
// The delegate executed by the online subsystem
|
TWeakObjectPtr<APlayerController> PlayerControllerWeakPtr;
|
||||||
FOnCreateSessionCompleteDelegate CreateCompleteDelegate;
|
|
||||||
|
// The delegate executed by the online subsystem
|
||||||
// The delegate executed by the online subsystem
|
FOnCreateSessionCompleteDelegate CreateCompleteDelegate;
|
||||||
FOnStartSessionCompleteDelegate StartCompleteDelegate;
|
|
||||||
|
// The delegate executed by the online subsystem
|
||||||
// Handles to the registered delegates above
|
FOnStartSessionCompleteDelegate StartCompleteDelegate;
|
||||||
FDelegateHandle CreateCompleteDelegateHandle;
|
|
||||||
FDelegateHandle StartCompleteDelegateHandle;
|
// Handles to the registered delegates above
|
||||||
|
FDelegateHandle CreateCompleteDelegateHandle;
|
||||||
// Number of public connections
|
FDelegateHandle StartCompleteDelegateHandle;
|
||||||
int NumPublicConnections;
|
|
||||||
|
// Number of public connections
|
||||||
// Number of private connections
|
int NumPublicConnections;
|
||||||
int NumPrivateConnections;
|
|
||||||
|
// Number of private connections
|
||||||
// Whether or not to search LAN
|
int NumPrivateConnections;
|
||||||
bool bUseLAN;
|
|
||||||
|
// Whether or not to search LAN
|
||||||
// Whether or not to allow invites
|
bool bUseLAN;
|
||||||
bool bAllowInvites;
|
|
||||||
|
// Whether or not to allow invites
|
||||||
// Whether this is a dedicated server or not
|
bool bAllowInvites;
|
||||||
bool bDedicatedServer;
|
|
||||||
|
// Whether this is a dedicated server or not
|
||||||
// Whether to use the presence option
|
bool bDedicatedServer;
|
||||||
bool bUsePresence;
|
|
||||||
|
// Whether to use the presence option
|
||||||
// Whether to allow joining via presence
|
bool bUsePresence;
|
||||||
bool bAllowJoinViaPresence;
|
|
||||||
|
// Whether to prefer the use of lobbies for hosting if the api supports them
|
||||||
// Allow joining via presence for friends only
|
bool bUseLobbiesIfAvailable;
|
||||||
bool bAllowJoinViaPresenceFriendsOnly;
|
|
||||||
|
// Whether to allow joining via presence
|
||||||
// Delcare the server to be anti cheat protected
|
bool bAllowJoinViaPresence;
|
||||||
bool bAntiCheatProtected;
|
|
||||||
|
// Allow joining via presence for friends only
|
||||||
// Record Stats
|
bool bAllowJoinViaPresenceFriendsOnly;
|
||||||
bool bUsesStats;
|
|
||||||
|
// Delcare the server to be anti cheat protected
|
||||||
// Should advertise server?
|
bool bAntiCheatProtected;
|
||||||
bool bShouldAdvertise;
|
|
||||||
|
// Record Stats
|
||||||
// Store extra settings
|
bool bUsesStats;
|
||||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
|
||||||
|
// Should advertise server?
|
||||||
// The world context object in which this call is taking place
|
bool bShouldAdvertise;
|
||||||
UObject* WorldContextObject;
|
|
||||||
};
|
// Whether to prefer the use of voice chat lobbies if the api supports them
|
||||||
|
bool bUseLobbiesVoiceChatIfAvailable;
|
||||||
|
|
||||||
|
// Whether to start the session automatically after it is created
|
||||||
|
bool bStartAfterCreate;
|
||||||
|
|
||||||
|
// Store extra settings
|
||||||
|
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||||
|
|
||||||
|
// The world context object in which this call is taking place
|
||||||
|
UObject* WorldContextObject;
|
||||||
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,11 @@ class UEndSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
|
|||||||
UPROPERTY(BlueprintAssignable)
|
UPROPERTY(BlueprintAssignable)
|
||||||
FEmptyOnlineDelegate OnFailure;
|
FEmptyOnlineDelegate OnFailure;
|
||||||
|
|
||||||
// Ends the current session
|
/**
|
||||||
UFUNCTION(BlueprintCallable, meta=(DeprecatedFunction,DeprecationMessage = "This function is deprecated, I realized that people have been using it wrong and it doesn't have much use in blueprints. Use Destroy Session only instead.",BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions|Deprecated")
|
* Ends the current sessions, Generally for almost all uses you should be using the engines native Destroy Session node instead.
|
||||||
|
* This exists for people using StartSession and optionally hand managing the session state.
|
||||||
|
*/
|
||||||
|
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedSessions")
|
||||||
static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController);
|
static UEndSessionCallbackProxy* EndSession(UObject* WorldContextObject, class APlayerController* PlayerController);
|
||||||
|
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
|
|||||||
@@ -7,6 +7,11 @@
|
|||||||
#include "BlueprintDataDefinitions.h"
|
#include "BlueprintDataDefinitions.h"
|
||||||
#include "FindSessionsCallbackProxyAdvanced.generated.h"
|
#include "FindSessionsCallbackProxyAdvanced.generated.h"
|
||||||
|
|
||||||
|
FORCEINLINE bool operator==(const FBlueprintSessionResult& A, const FBlueprintSessionResult& B)
|
||||||
|
{
|
||||||
|
return (A.OnlineResult.IsValid() == B.OnlineResult.IsValid() && (A.OnlineResult.GetSessionIdStr() == B.OnlineResult.GetSessionIdStr()));
|
||||||
|
}
|
||||||
|
|
||||||
UCLASS(MinimalAPI)
|
UCLASS(MinimalAPI)
|
||||||
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||||
{
|
{
|
||||||
@@ -22,7 +27,7 @@ class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
|||||||
|
|
||||||
// Searches for advertised sessions with the default online subsystem and includes an array of filters
|
// 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")
|
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<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, int MinSlotsAvailable = 0);
|
static UFindSessionsCallbackProxyAdvanced* FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int32 MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly = false, bool bNonEmptyServersOnly = false, bool bSecureServersOnly = false, bool bSearchLobbies = true, int MinSlotsAvailable = 0);
|
||||||
|
|
||||||
static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator);
|
static bool CompareVariants(const FVariantData &A, const FVariantData &B, EOnlineComparisonOpRedux Comparator);
|
||||||
|
|
||||||
@@ -92,6 +97,9 @@ private:
|
|||||||
// Search for secure servers only
|
// Search for secure servers only
|
||||||
bool bSecureServersOnly;
|
bool bSecureServersOnly;
|
||||||
|
|
||||||
|
// Search through lobbies
|
||||||
|
bool bSearchLobbies;
|
||||||
|
|
||||||
// Min slots requires to search
|
// Min slots requires to search
|
||||||
int MinSlotsAvailable;
|
int MinSlotsAvailable;
|
||||||
|
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase
|
|||||||
FEmptyOnlineDelegate OnFailure;
|
FEmptyOnlineDelegate OnFailure;
|
||||||
|
|
||||||
// Logs into the identity interface
|
// Logs into the identity interface
|
||||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
|
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AdvancedDisplay = "AuthType"), Category = "Online|AdvancedIdentity")
|
||||||
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken);
|
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType);
|
||||||
|
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
virtual void Activate() override;
|
virtual void Activate() override;
|
||||||
@@ -42,6 +42,8 @@ private:
|
|||||||
// The user pass / token
|
// The user pass / token
|
||||||
FString UserToken;
|
FString UserToken;
|
||||||
|
|
||||||
|
FString AuthType;
|
||||||
|
|
||||||
// The delegate executed by the online subsystem
|
// The delegate executed by the online subsystem
|
||||||
FOnLoginCompleteDelegate Delegate;
|
FOnLoginCompleteDelegate Delegate;
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "CoreMinimal.h"
|
||||||
|
#include "BlueprintDataDefinitions.h"
|
||||||
|
#include "StartSessionCallbackProxyAdvanced.generated.h"
|
||||||
|
|
||||||
|
UCLASS(MinimalAPI)
|
||||||
|
class UStartSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||||
|
{
|
||||||
|
GENERATED_UCLASS_BODY()
|
||||||
|
// Called when the session starts successfully
|
||||||
|
UPROPERTY(BlueprintAssignable)
|
||||||
|
FEmptyOnlineDelegate OnSuccess;
|
||||||
|
|
||||||
|
// Called when there is an error starting the session
|
||||||
|
UPROPERTY(BlueprintAssignable)
|
||||||
|
FEmptyOnlineDelegate OnFailure;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts a session with the default online subsystem. The session needs to be previously created by calling the "CreateAdvancedSession" node.
|
||||||
|
* @param WorldContextObject
|
||||||
|
*/
|
||||||
|
UFUNCTION(
|
||||||
|
BlueprintCallable
|
||||||
|
, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject")
|
||||||
|
, Category = "Online|AdvancedSessions"
|
||||||
|
)
|
||||||
|
static UStartSessionCallbackProxyAdvanced* StartAdvancedSession(const UObject* WorldContextObject);
|
||||||
|
|
||||||
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
|
virtual void Activate() override;
|
||||||
|
// End of UOnlineBlueprintCallProxyBase interface
|
||||||
|
|
||||||
|
private:
|
||||||
|
// Internal callback when session start completes
|
||||||
|
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
||||||
|
|
||||||
|
// The delegate executed by the online subsystem
|
||||||
|
FOnStartSessionCompleteDelegate StartCompleteDelegate;
|
||||||
|
|
||||||
|
// Handles to the registered delegates above
|
||||||
|
FDelegateHandle StartCompleteDelegateHandle;
|
||||||
|
|
||||||
|
// The world context object in which this call is taking place
|
||||||
|
const UObject* WorldContextObject;
|
||||||
|
};
|
||||||
@@ -21,7 +21,7 @@ class UUpdateSessionCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
|||||||
|
|
||||||
// Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values
|
// Creates a session with the default online subsystem with advanced optional inputs, you MUST fill in all categories or it will pass in values that you didn't want as default values
|
||||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
||||||
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false);
|
static UUpdateSessionCallbackProxyAdvanced* UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections = 100, int32 PrivateConnections = 0, bool bUseLAN = false, bool bAllowInvites = false, bool bAllowJoinInProgress = false, bool bRefreshOnlineData = true, bool bIsDedicatedServer = false, bool bShouldAdvertise = true);
|
||||||
|
|
||||||
// UOnlineBlueprintCallProxyBase interface
|
// UOnlineBlueprintCallProxyBase interface
|
||||||
virtual void Activate() override;
|
virtual void Activate() override;
|
||||||
@@ -38,28 +38,30 @@ private:
|
|||||||
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
||||||
|
|
||||||
// Number of public connections
|
// Number of public connections
|
||||||
int NumPublicConnections;
|
int NumPublicConnections = 100;
|
||||||
|
|
||||||
// Number of private connections
|
// Number of private connections
|
||||||
int NumPrivateConnections;
|
int NumPrivateConnections = 0;
|
||||||
|
|
||||||
// Whether or not to search LAN
|
// Whether or not to search LAN
|
||||||
bool bUseLAN;
|
bool bUseLAN = false;
|
||||||
|
|
||||||
// Whether or not to allow invites
|
// Whether or not to allow invites
|
||||||
bool bAllowInvites;
|
bool bAllowInvites = true;
|
||||||
|
|
||||||
// Store extra settings
|
// Store extra settings
|
||||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||||
|
|
||||||
// Whether to update the online data
|
// Whether to update the online data
|
||||||
bool bRefreshOnlineData;
|
bool bRefreshOnlineData = true;
|
||||||
|
|
||||||
// Allow joining in progress
|
// Allow joining in progress
|
||||||
bool bAllowJoinInProgress;
|
bool bAllowJoinInProgress = true;
|
||||||
|
|
||||||
// Update whether this is a dedicated server or not
|
// Update whether this is a dedicated server or not
|
||||||
bool bDedicatedServer;
|
bool bDedicatedServer = false;
|
||||||
|
|
||||||
|
bool bShouldAdvertise = true;
|
||||||
|
|
||||||
// The world context object in which this call is taking place
|
// The world context object in which this call is taking place
|
||||||
UObject* WorldContextObject;
|
UObject* WorldContextObject;
|
||||||
|
|||||||
@@ -263,7 +263,7 @@ void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNe
|
|||||||
int32 LocalPlayer = 0;
|
int32 LocalPlayer = 0;
|
||||||
for (int i = 0; i < PlayerList.Num(); i++)
|
for (int i = 0; i < PlayerList.Num(); i++)
|
||||||
{
|
{
|
||||||
if (*PlayerList[i]->PlayerState->UniqueId.GetUniqueNetId() == PersonInvited)
|
if (*PlayerList[i]->PlayerState->GetUniqueId().GetUniqueNetId() == PersonInvited)
|
||||||
{
|
{
|
||||||
LocalPlayer = i;
|
LocalPlayer = i;
|
||||||
Player = PlayerList[i];
|
Player = PlayerList[i];
|
||||||
|
|||||||
@@ -6,6 +6,43 @@
|
|||||||
//General Log
|
//General Log
|
||||||
DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
|
DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
|
||||||
|
|
||||||
|
|
||||||
|
bool UAdvancedSessionsLibrary::KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason)
|
||||||
|
{
|
||||||
|
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||||
|
|
||||||
|
if (World)
|
||||||
|
{
|
||||||
|
if (AGameModeBase* GameMode = World->GetAuthGameMode())
|
||||||
|
{
|
||||||
|
if (GameMode->GameSession)
|
||||||
|
{
|
||||||
|
return GameMode->GameSession->KickPlayer(PlayerToKick, KickReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSessionsLibrary::BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason)
|
||||||
|
{
|
||||||
|
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||||
|
|
||||||
|
if (World)
|
||||||
|
{
|
||||||
|
if (AGameModeBase* GameMode = World->GetAuthGameMode())
|
||||||
|
{
|
||||||
|
if (GameMode->GameSession)
|
||||||
|
{
|
||||||
|
return GameMode->GameSession->BanPlayer(PlayerToBan, BanReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
|
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
|
||||||
{
|
{
|
||||||
return SessionResult.OnlineResult.IsValid();
|
return SessionResult.OnlineResult.IsValid();
|
||||||
@@ -405,7 +442,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerControlle
|
|||||||
|
|
||||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||||
{
|
{
|
||||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
|
||||||
if (!UniqueNetId.IsValid())
|
if (!UniqueNetId.IsValid())
|
||||||
{
|
{
|
||||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!"));
|
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!"));
|
||||||
@@ -414,6 +451,17 @@ void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerControlle
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UAdvancedSessionsLibrary::GetUniqueNetIdOfSessionOwner(FBlueprintSessionResult SessionResult, FBPUniqueNetId& UniqueNetId)
|
||||||
|
{
|
||||||
|
FBPUniqueNetId ReturnID;
|
||||||
|
if (SessionResult.OnlineResult.IsValid())
|
||||||
|
{
|
||||||
|
ReturnID.SetUniqueNetId(SessionResult.OnlineResult.Session.OwningUserId);
|
||||||
|
}
|
||||||
|
|
||||||
|
UniqueNetId = ReturnID;
|
||||||
|
}
|
||||||
|
|
||||||
void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId)
|
void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId)
|
||||||
{
|
{
|
||||||
if (!PlayerState)
|
if (!PlayerState)
|
||||||
@@ -422,7 +470,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *Playe
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
|
||||||
if (!UniqueNetId.IsValid())
|
if (!UniqueNetId.IsValid())
|
||||||
{
|
{
|
||||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!"));
|
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!"));
|
||||||
@@ -491,3 +539,14 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextOb
|
|||||||
|
|
||||||
NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
|
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) return false;
|
||||||
|
World->ServerTravel(FURL,bAbsolute,bShouldSkipGameNotify);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,75 @@
|
|||||||
|
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||||
|
|
||||||
|
#include "AutoLoginUserCallbackProxy.h"
|
||||||
|
#include "Kismet/GameplayStatics.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<UAutoLoginUserCallbackProxy>();
|
||||||
|
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(APlayerController* PController = UGameplayStatics::GetPlayerController(WorldContextObject->GetWorld(), LocalUserNum))
|
||||||
|
{
|
||||||
|
ULocalPlayer* Player = Cast<ULocalPlayer>(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();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -13,7 +13,7 @@ UCreateSessionCallbackProxyAdvanced::UCreateSessionCallbackProxyAdvanced(const F
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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* UCreateSessionCallbackProxyAdvanced::CreateAdvancedSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &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, bool bStartAfterCreate)
|
||||||
{
|
{
|
||||||
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
|
UCreateSessionCallbackProxyAdvanced* Proxy = NewObject<UCreateSessionCallbackProxyAdvanced>();
|
||||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||||
@@ -25,11 +25,14 @@ UCreateSessionCallbackProxyAdvanced* UCreateSessionCallbackProxyAdvanced::Create
|
|||||||
Proxy->ExtraSettings = ExtraSettings;
|
Proxy->ExtraSettings = ExtraSettings;
|
||||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||||
Proxy->bUsePresence = bUsePresence;
|
Proxy->bUsePresence = bUsePresence;
|
||||||
|
Proxy->bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
|
||||||
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
|
Proxy->bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||||
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
Proxy->bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||||
Proxy->bAntiCheatProtected = bAntiCheatProtected;
|
Proxy->bAntiCheatProtected = bAntiCheatProtected;
|
||||||
Proxy->bUsesStats = bUsesStats;
|
Proxy->bUsesStats = bUsesStats;
|
||||||
Proxy->bShouldAdvertise = bShouldAdvertise;
|
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||||
|
Proxy->bUseLobbiesVoiceChatIfAvailable = bUseLobbiesVoiceChatIfAvailable;
|
||||||
|
Proxy->bStartAfterCreate = bStartAfterCreate;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -50,21 +53,27 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
|||||||
FOnlineSessionSettings Settings;
|
FOnlineSessionSettings Settings;
|
||||||
Settings.NumPublicConnections = NumPublicConnections;
|
Settings.NumPublicConnections = NumPublicConnections;
|
||||||
Settings.NumPrivateConnections = NumPrivateConnections;
|
Settings.NumPrivateConnections = NumPrivateConnections;
|
||||||
Settings.bShouldAdvertise = true;
|
Settings.bShouldAdvertise = bShouldAdvertise;
|
||||||
Settings.bAllowJoinInProgress = true;
|
Settings.bAllowJoinInProgress = true;
|
||||||
Settings.bIsLANMatch = bUseLAN;
|
Settings.bIsLANMatch = bUseLAN;
|
||||||
Settings.bAllowJoinViaPresence = true;
|
Settings.bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||||
Settings.bIsDedicated = bDedicatedServer;
|
Settings.bIsDedicated = bDedicatedServer;
|
||||||
|
|
||||||
if (bDedicatedServer)
|
if (bDedicatedServer)
|
||||||
|
{
|
||||||
Settings.bUsesPresence = false;
|
Settings.bUsesPresence = false;
|
||||||
|
Settings.bUseLobbiesIfAvailable = false;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
Settings.bUsesPresence = bUsePresence;
|
Settings.bUsesPresence = bUsePresence;
|
||||||
|
Settings.bUseLobbiesIfAvailable = bUseLobbiesIfAvailable;
|
||||||
|
}
|
||||||
|
|
||||||
|
Settings.bUseLobbiesVoiceChatIfAvailable = bUseLobbiesIfAvailable ? bUseLobbiesVoiceChatIfAvailable : false;
|
||||||
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
Settings.bAllowJoinViaPresenceFriendsOnly = bAllowJoinViaPresenceFriendsOnly;
|
||||||
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
Settings.bAntiCheatProtected = bAntiCheatProtected;
|
||||||
Settings.bUsesStats = bUsesStats;
|
Settings.bUsesStats = bUsesStats;
|
||||||
Settings.bShouldAdvertise = bShouldAdvertise;
|
|
||||||
|
|
||||||
// These are about the only changes over the standard Create Sessions Node
|
// These are about the only changes over the standard Create Sessions Node
|
||||||
Settings.bAllowInvites = bAllowInvites;
|
Settings.bAllowInvites = bAllowInvites;
|
||||||
@@ -124,8 +133,17 @@ void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, b
|
|||||||
|
|
||||||
if (bWasSuccessful)
|
if (bWasSuccessful)
|
||||||
{
|
{
|
||||||
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
if(this->bStartAfterCreate)
|
||||||
Sessions->StartSession(NAME_GameSession);
|
{
|
||||||
|
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned on, starting session now."));
|
||||||
|
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||||
|
Sessions->StartSession(NAME_GameSession); // We'll call `OnSuccess.Broadcast()` when start succeeds.
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
UE_LOG_ONLINE_SESSION(Display, TEXT("Session creation completed. Automatic start is turned off, to start the session call 'StartSession'."));
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
}
|
||||||
|
|
||||||
// OnStartCompleted will get called, nothing more to do now
|
// OnStartCompleted will get called, nothing more to do now
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ UFindSessionsCallbackProxyAdvanced::UFindSessionsCallbackProxyAdvanced(const FOb
|
|||||||
bIsOnSecondSearch = false;
|
bIsOnSecondSearch = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, int MinSlotsAvailable)
|
UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSessionsAdvanced(UObject* WorldContextObject, class APlayerController* PlayerController, int MaxResults, bool bUseLAN, EBPServerPresenceSearchType ServerTypeToSearch, const TArray<FSessionsSearchSetting> &Filters, bool bEmptyServersOnly, bool bNonEmptyServersOnly, bool bSecureServersOnly, bool bSearchLobbies, int MinSlotsAvailable)
|
||||||
{
|
{
|
||||||
UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
|
UFindSessionsCallbackProxyAdvanced* Proxy = NewObject<UFindSessionsCallbackProxyAdvanced>();
|
||||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||||
@@ -27,6 +27,7 @@ UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSess
|
|||||||
Proxy->bEmptyServersOnly = bEmptyServersOnly,
|
Proxy->bEmptyServersOnly = bEmptyServersOnly,
|
||||||
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
|
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
|
||||||
Proxy->bSecureServersOnly = bSecureServersOnly;
|
Proxy->bSecureServersOnly = bSecureServersOnly;
|
||||||
|
Proxy->bSearchLobbies = bSearchLobbies;
|
||||||
Proxy->MinSlotsAvailable = MinSlotsAvailable;
|
Proxy->MinSlotsAvailable = MinSlotsAvailable;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
@@ -73,6 +74,17 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
#define SEARCH_USER FName(TEXT("SEARCHUSER"))
|
#define SEARCH_USER FName(TEXT("SEARCHUSER"))
|
||||||
// Keywords to match in session search
|
// Keywords to match in session search
|
||||||
#define SEARCH_KEYWORDS FName(TEXT("SEARCHKEYWORDS"))*/
|
#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)
|
if (bEmptyServersOnly)
|
||||||
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
|
tem.Set(SEARCH_EMPTY_SERVERS_ONLY, true, EOnlineComparisonOp::Equals);
|
||||||
@@ -86,8 +98,6 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
if (MinSlotsAvailable != 0)
|
if (MinSlotsAvailable != 0)
|
||||||
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
|
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Filter results
|
// Filter results
|
||||||
if (SearchSettings.Num() > 0)
|
if (SearchSettings.Num() > 0)
|
||||||
{
|
{
|
||||||
@@ -104,6 +114,9 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
case EBPServerPresenceSearchType::ClientServersOnly:
|
case EBPServerPresenceSearchType::ClientServersOnly:
|
||||||
{
|
{
|
||||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||||
|
|
||||||
|
if (bSearchLobbies)
|
||||||
|
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -117,20 +130,24 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
|||||||
default:
|
default:
|
||||||
{
|
{
|
||||||
// Only steam uses the separate searching flags currently
|
// Only steam uses the separate searching flags currently
|
||||||
if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
//if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||||
{
|
//{
|
||||||
bRunSecondSearch = true;
|
bRunSecondSearch = true;
|
||||||
|
|
||||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||||
|
|
||||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
|
||||||
|
|
||||||
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
|
||||||
}
|
if (bSearchLobbies)
|
||||||
|
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||||
|
|
||||||
|
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||||
|
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||||
|
//}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -182,7 +199,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
|
|
||||||
FBlueprintSessionResult BPResult;
|
FBlueprintSessionResult BPResult;
|
||||||
BPResult.OnlineResult = Result;
|
BPResult.OnlineResult = Result;
|
||||||
SessionSearchResults.Add(BPResult);
|
SessionSearchResults.AddUnique(BPResult);
|
||||||
}
|
}
|
||||||
OnSuccess.Broadcast(SessionSearchResults);
|
OnSuccess.Broadcast(SessionSearchResults);
|
||||||
return;
|
return;
|
||||||
@@ -201,7 +218,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
|||||||
|
|
||||||
FBlueprintSessionResult BPResult;
|
FBlueprintSessionResult BPResult;
|
||||||
BPResult.OnlineResult = Result;
|
BPResult.OnlineResult = Result;
|
||||||
SessionSearchResults.Add(BPResult);
|
SessionSearchResults.AddUnique(BPResult);
|
||||||
}
|
}
|
||||||
if (!bRunSecondSearch)
|
if (!bRunSecondSearch)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -12,12 +12,13 @@ ULoginUserCallbackProxy::ULoginUserCallbackProxy(const FObjectInitializer& Objec
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken)
|
ULoginUserCallbackProxy* ULoginUserCallbackProxy::LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType)
|
||||||
{
|
{
|
||||||
ULoginUserCallbackProxy* Proxy = NewObject<ULoginUserCallbackProxy>();
|
ULoginUserCallbackProxy* Proxy = NewObject<ULoginUserCallbackProxy>();
|
||||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||||
Proxy->UserID = UserID;
|
Proxy->UserID = UserID;
|
||||||
Proxy->UserToken = UserToken;
|
Proxy->UserToken = UserToken;
|
||||||
|
Proxy->AuthType = AuthType;
|
||||||
Proxy->WorldContextObject = WorldContextObject;
|
Proxy->WorldContextObject = WorldContextObject;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
@@ -43,8 +44,13 @@ void ULoginUserCallbackProxy::Activate()
|
|||||||
|
|
||||||
if (Identity.IsValid())
|
if (Identity.IsValid())
|
||||||
{
|
{
|
||||||
|
// Fallback to default AuthType if nothing is specified
|
||||||
|
if (AuthType.IsEmpty())
|
||||||
|
{
|
||||||
|
AuthType = Identity->GetAuthType();
|
||||||
|
}
|
||||||
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
|
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
|
||||||
FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken);
|
FOnlineAccountCredentials AccountCreds(AuthType, UserID, UserToken);
|
||||||
Identity->Login(Player->GetControllerId(), AccountCreds);
|
Identity->Login(Player->GetControllerId(), AccountCreds);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -59,6 +65,8 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
|||||||
{
|
{
|
||||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||||
|
|
||||||
|
auto uniqueId = UserId.AsShared();
|
||||||
|
|
||||||
if (Player)
|
if (Player)
|
||||||
{
|
{
|
||||||
auto Identity = Online::GetIdentityInterface();
|
auto Identity = Online::GetIdentityInterface();
|
||||||
@@ -67,6 +75,13 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
|||||||
{
|
{
|
||||||
Identity->ClearOnLoginCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle);
|
Identity->ClearOnLoginCompleteDelegate_Handle(Player->GetControllerId(), DelegateHandle);
|
||||||
}
|
}
|
||||||
|
Player->SetCachedUniqueNetId(uniqueId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (APlayerState* State = PlayerControllerWeakPtr->PlayerState)
|
||||||
|
{
|
||||||
|
// Update UniqueId. See also ShowLoginUICallbackProxy.cpp
|
||||||
|
State->SetUniqueId((const FUniqueNetIdPtr&)uniqueId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
#include "StartSessionCallbackProxyAdvanced.h"
|
||||||
|
|
||||||
|
UStartSessionCallbackProxyAdvanced::UStartSessionCallbackProxyAdvanced(const FObjectInitializer& ObjectInitializer)
|
||||||
|
: Super(ObjectInitializer)
|
||||||
|
, StartCompleteDelegate(FOnStartSessionCompleteDelegate::CreateUObject(this, &ThisClass::OnStartCompleted))
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
UStartSessionCallbackProxyAdvanced* UStartSessionCallbackProxyAdvanced::StartAdvancedSession(
|
||||||
|
const UObject* WorldContextObject)
|
||||||
|
{
|
||||||
|
UStartSessionCallbackProxyAdvanced* Proxy = NewObject<UStartSessionCallbackProxyAdvanced>();
|
||||||
|
Proxy->WorldContextObject = WorldContextObject;
|
||||||
|
return Proxy;
|
||||||
|
}
|
||||||
|
|
||||||
|
void UStartSessionCallbackProxyAdvanced::Activate()
|
||||||
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(
|
||||||
|
TEXT("StartSession"),
|
||||||
|
GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
{
|
||||||
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
|
{
|
||||||
|
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||||
|
Sessions->StartSession(NAME_GameSession);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Fail immediately
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
}
|
||||||
|
|
||||||
|
void UStartSessionCallbackProxyAdvanced::OnStartCompleted(FName SessionName, bool bWasSuccessful)
|
||||||
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(
|
||||||
|
TEXT("StartSessionCallback"),
|
||||||
|
GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
{
|
||||||
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
|
{
|
||||||
|
Sessions->ClearOnStartSessionCompleteDelegate_Handle(StartCompleteDelegateHandle);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bWasSuccessful)
|
||||||
|
{
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
OnFailure.Broadcast();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -12,7 +12,7 @@ UUpdateSessionCallbackProxyAdvanced::UUpdateSessionCallbackProxyAdvanced(const F
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer)
|
UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::UpdateSession(UObject* WorldContextObject, const TArray<FSessionPropertyKeyPair> &ExtraSettings, int32 PublicConnections, int32 PrivateConnections, bool bUseLAN, bool bAllowInvites, bool bAllowJoinInProgress, bool bRefreshOnlineData, bool bIsDedicatedServer, bool bShouldAdvertise)
|
||||||
{
|
{
|
||||||
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
|
UUpdateSessionCallbackProxyAdvanced* Proxy = NewObject<UUpdateSessionCallbackProxyAdvanced>();
|
||||||
Proxy->NumPublicConnections = PublicConnections;
|
Proxy->NumPublicConnections = PublicConnections;
|
||||||
@@ -24,75 +24,79 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
|
|||||||
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
||||||
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||||
|
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||||
return Proxy;
|
return Proxy;
|
||||||
}
|
}
|
||||||
|
|
||||||
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
||||||
{
|
{
|
||||||
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
|
|
||||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
if (Helper.OnlineSub != nullptr)
|
||||||
|
|
||||||
if (Sessions.IsValid())
|
|
||||||
{
|
{
|
||||||
if (Sessions->GetNumSessions() < 1)
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
{
|
{
|
||||||
OnFailure.Broadcast();
|
if (Sessions->GetNumSessions() < 1)
|
||||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!"));
|
{
|
||||||
|
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 = bShouldAdvertise;
|
||||||
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
// This gets the actual session itself
|
|
||||||
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(NAME_GameSession);
|
|
||||||
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(NAME_GameSession);
|
|
||||||
|
|
||||||
if (!Settings)
|
|
||||||
{
|
{
|
||||||
// Fail immediately
|
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
||||||
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
|
// Fail immediately
|
||||||
OnFailure.Broadcast();
|
OnFailure.Broadcast();
|
||||||
@@ -101,15 +105,20 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
|
|||||||
|
|
||||||
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
||||||
{
|
{
|
||||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||||
if (Sessions.IsValid())
|
|
||||||
|
if (Helper.OnlineSub != nullptr)
|
||||||
{
|
{
|
||||||
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||||
|
if (Sessions.IsValid())
|
||||||
if (bWasSuccessful)
|
|
||||||
{
|
{
|
||||||
OnSuccess.Broadcast();
|
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
||||||
return;
|
|
||||||
|
if (bWasSuccessful)
|
||||||
|
{
|
||||||
|
OnSuccess.Broadcast();
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"FileVersion" : 3,
|
"FileVersion" : 3,
|
||||||
|
|
||||||
"FriendlyName" : "Advanced Steam Sessions",
|
"FriendlyName" : "Advanced Steam Sessions",
|
||||||
"Version" : 4.24,
|
"Version" : 4.27,
|
||||||
"VersionName": "4.24",
|
"VersionName": "4.27",
|
||||||
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
||||||
"Category" : "Advanced Sessions Plugin",
|
"Category" : "Advanced Sessions Plugin",
|
||||||
"CreatedBy" : "Joshua Statzer",
|
"CreatedBy" : "Joshua Statzer",
|
||||||
@@ -33,6 +33,10 @@
|
|||||||
{
|
{
|
||||||
"Name": "OnlineSubsystemSteam",
|
"Name": "OnlineSubsystemSteam",
|
||||||
"Enabled": true
|
"Enabled": true
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"Name": "SteamShared",
|
||||||
|
"Enabled": true
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -305,6 +305,19 @@ 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()
|
UCLASS()
|
||||||
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
|
class UAdvancedSteamFriendsLibrary : public UBlueprintFunctionLibrary
|
||||||
{
|
{
|
||||||
@@ -325,6 +338,10 @@ public:
|
|||||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
||||||
static bool OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType);
|
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.
|
// 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")
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
||||||
static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId);
|
static int32 GetFriendSteamLevel(const FBPUniqueNetId UniqueNetId);
|
||||||
@@ -350,4 +367,21 @@ public:
|
|||||||
// Get a full list of steam groups
|
// Get a full list of steam groups
|
||||||
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups")
|
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|SteamGroups")
|
||||||
static void GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups);
|
static void GetSteamGroups(TArray<FBPSteamGroupInfo> & 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();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -255,6 +255,19 @@ bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId Uni
|
|||||||
return false;
|
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)
|
UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueNetId UniqueNetId, EBlueprintAsyncResultSwitch &Result, SteamAvatarSize AvatarSize)
|
||||||
{
|
{
|
||||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||||
@@ -350,4 +363,77 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN
|
|||||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
|
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("STEAM Couldn't be verified as initialized"));
|
||||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||||
return nullptr;
|
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;
|
||||||
}
|
}
|
||||||
@@ -2,6 +2,6 @@
|
|||||||
|
|
||||||
**KantanDocGen Automatic Documentation ([KantanDocGen](http://kantandev.com/free/kantan-doc-gen))**
|
**KantanDocGen Automatic Documentation ([KantanDocGen](http://kantandev.com/free/kantan-doc-gen))**
|
||||||
|
|
||||||
**[AdvancedSessions](https://mordentral.bitbucket.io/AdvancedSessions/Advanced)**
|
**[AdvancedSessions](https://vreue4.com/generated-node-documentation?section=advanced-sessions-plugin)**
|
||||||
|
|
||||||
**[AdvancedSteamSessions](https://mordentral.bitbucket.io/AdvancedSteamSessions/Advanced)**
|
**[AdvancedSteamSessions](https://vreue4.com/generated-node-documentation?section=advanced-steam-sessions-plugin)**
|
||||||
|
|||||||
Reference in New Issue
Block a user