mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-26 18:04:07 +00:00
Compare commits
88 Commits
4.18_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 | ||
|
|
2216aaf041 | ||
|
|
192307b542 | ||
|
|
51cf0acb2e | ||
|
|
3c4ba2af3b | ||
|
|
8744035160 | ||
|
|
71f16cadd2 | ||
|
|
fdfc2d272f | ||
|
|
297848aed8 | ||
|
|
60d1d272a5 | ||
|
|
c3f889c9c5 | ||
|
|
2e93c6095a | ||
|
|
6007506189 | ||
|
|
0952d9b18a | ||
|
|
438d0a69ba | ||
|
|
85e9b54fab | ||
|
|
ba28fccfe0 | ||
|
|
d71aaede8d | ||
|
|
38b5c96cbd | ||
|
|
ad745512ac | ||
|
|
ce7d8b1bf3 | ||
|
|
abb9e5687c | ||
|
|
47c6981a2a | ||
|
|
20f99a5e10 | ||
|
|
289fa84dd5 | ||
|
|
b8a5e7500b | ||
|
|
4cc84d68c4 | ||
|
|
b553a8c3b6 | ||
|
|
bc0e8f7d1b | ||
|
|
886b4c2f8a | ||
|
|
47775e70bf | ||
|
|
924b1ecf1c | ||
|
|
c73b96993c | ||
|
|
0229b69d9c | ||
|
|
ad2881cd75 | ||
|
|
d007eed9a8 | ||
|
|
c2a5598582 | ||
|
|
2db3b7221c | ||
|
|
ea77c18a2e |
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,
|
||||
|
||||
"FriendlyName" : "Advanced Sessions",
|
||||
"Version" : 4.17,
|
||||
"VersionName": "4.17",
|
||||
"Version" : 4.27,
|
||||
"VersionName": "4.27",
|
||||
"Description" : "Adds new blueprint functions to handle more advanced session operations.",
|
||||
"Category" : "Advanced Sessions Plugin",
|
||||
"CreatedBy" : "Joshua Statzer",
|
||||
|
||||
@@ -7,11 +7,11 @@ public class AdvancedSessions : ModuleRules
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
//bEnforceIWYU = true;
|
||||
|
||||
Definitions.Add("WITH_ADVANCED_SESSIONS=1");
|
||||
|
||||
PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ });
|
||||
PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
|
||||
PublicDefinitions.Add("WITH_ADVANCED_SESSIONS=1");
|
||||
|
||||
// PrivateIncludePaths.AddRange(new string[] { "AdvancedSessions/Private"/*, "OnlineSubsystemSteam/Private"*/ });
|
||||
// PublicIncludePaths.AddRange(new string[] { "AdvancedSessions/Public" });
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets"/*"Voice", "OnlineSubsystemSteam"*/ });
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
|
||||
}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
//#include "OnlineMessageInterface.h"
|
||||
//#include "OnlinePresenceInterface.h"
|
||||
//#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
|
||||
//#include "UObjectIterator.h"
|
||||
|
||||
|
||||
@@ -2,19 +2,20 @@
|
||||
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineFriendsInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlineMessageInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "UObjectIterator.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
#include "AdvancedFriendsInterface.h"
|
||||
|
||||
#include "AdvancedFriendsGameInstance.generated.h"
|
||||
@@ -65,6 +66,7 @@ public:
|
||||
void OnSessionInviteAcceptedMaster(const bool bWasSuccessful, int32 LocalPlayer, TSharedPtr<const FUniqueNetId> PersonInviting, const FOnlineSessionSearchResult& SessionToJoin);
|
||||
|
||||
// After a session invite has been accepted by the local player this event is triggered, call JoinSession on the session result to join it
|
||||
// This function is currently not hooked up in any of Epics default subsystems, it is here for custom subsystems
|
||||
UFUNCTION(BlueprintImplementableEvent, Category = "AdvancedFriends")
|
||||
void OnSessionInviteAccepted(int32 LocalPlayerNum, FBPUniqueNetId PersonInvited, const FBlueprintSessionResult& SessionToJoin);
|
||||
|
||||
|
||||
@@ -5,14 +5,14 @@
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineFriendsInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlineMessageInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "UObjectIterator.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "AdvancedFriendsInterface.generated.h"
|
||||
|
||||
|
||||
@@ -7,14 +7,14 @@
|
||||
#include "Online.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineFriendsInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlineMessageInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
|
||||
#include "AdvancedFriendsLibrary.generated.h"
|
||||
|
||||
|
||||
@@ -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)
|
||||
{
|
||||
}
|
||||
@@ -6,13 +6,13 @@
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineIdentityInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
|
||||
#include "AdvancedIdentityLibrary.generated.h"
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "ModuleManager.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class AdvancedSessions : public IModuleInterface
|
||||
{
|
||||
|
||||
@@ -2,16 +2,20 @@
|
||||
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineFriendsInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlineMessageInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
|
||||
#include "GameFramework/GameModeBase.h"
|
||||
#include "GameFramework/GameSession.h"
|
||||
|
||||
//#include "UObjectIterator.h"
|
||||
|
||||
@@ -27,6 +31,17 @@ class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
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 *************//
|
||||
|
||||
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
||||
@@ -38,16 +53,16 @@ public:
|
||||
static void GetExtraSettings(FBlueprintSessionResult SessionResult, TArray<FSessionPropertyKeyPair> & ExtraSettings);
|
||||
|
||||
// Get the current session state
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetSessionState(EBPOnlineSessionState &SessionState);
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
|
||||
static void GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState);
|
||||
|
||||
// Get the current session settings
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "Result", WorldContext = "WorldContextObject"))
|
||||
static void GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result);
|
||||
|
||||
// Check if someone is in the current session
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession);
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
|
||||
static void IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession);
|
||||
|
||||
// Make a literal session search parameter
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
@@ -60,6 +75,14 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static bool IsValidSession(const FBlueprintSessionResult & SessionResult);
|
||||
|
||||
// Get a string copy of a session ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID);
|
||||
|
||||
// Get a string copy of the current session ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo", meta = (WorldContext = "WorldContextObject"))
|
||||
static void GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID);
|
||||
|
||||
// Get the Unique Current Build ID
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo")
|
||||
static void GetCurrentUniqueBuildID(int32 &UniqueBuildId);
|
||||
@@ -92,6 +115,7 @@ public:
|
||||
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
|
||||
|
||||
// Get session custom information key/value as Bool
|
||||
// Steam only currently supports Int,Float,String,BYTE values for search filtering!!!
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
|
||||
|
||||
@@ -113,6 +137,7 @@ public:
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
|
||||
|
||||
// Make a literal session custom information key/value pair from Bool
|
||||
// Steam only currently supports Int,Float,String,BYTE values for search filtering!
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
|
||||
|
||||
@@ -135,6 +160,10 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
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
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|PlayerInfo|PlayerID")
|
||||
static void GetUniqueNetIDFromPlayerState(APlayerState *PlayerState, FBPUniqueNetId &UniqueNetId);
|
||||
@@ -174,6 +203,12 @@ public:
|
||||
// Checks if the stated session subsystem is active
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
||||
static bool HasOnlineSubsystem(FName SubSystemName);
|
||||
|
||||
//**** Seamless travel Functions ****//
|
||||
|
||||
//Exposes Server travel to blueprint
|
||||
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Online|AdvancedSessions|Seamless", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
||||
static bool ServerTravel(UObject* WorldContextObject, const FString& InURL, bool bAbsolute, bool bShouldSkipGameNotify);
|
||||
|
||||
|
||||
};
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "VoiceInterface.h"
|
||||
#include "Interfaces/VoiceInterface.h"
|
||||
//#include "OnlineFriendsInterface.h"
|
||||
//#include "OnlineUserInterface.h"
|
||||
//#include "OnlineMessageInterface.h"
|
||||
@@ -14,7 +14,7 @@
|
||||
#include "Engine/GameInstance.h"
|
||||
//#include "OnlineSessionInterface.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
|
||||
#include "AdvancedVoiceLibrary.generated.h"
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
static bool RegisterLocalTalker(uint8 LocalPlayerNum = 0);
|
||||
|
||||
// Registers all signed in players as local talkers
|
||||
// This is already done automatically, only do it manually if you unregistered someone
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static void RegisterAllLocalTalkers();
|
||||
|
||||
@@ -60,6 +61,7 @@ public:
|
||||
static void UnRegisterAllLocalTalkers();
|
||||
|
||||
// Registers a remote player as a talker
|
||||
// This is already done automatically, only do it manually if you unregistered someone
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedVoice")
|
||||
static bool RegisterRemoteTalker(const FBPUniqueNetId& UniqueNetId);
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -1,17 +1,18 @@
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "EngineMinimal.h"
|
||||
//#include "EngineMinimal.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "Core.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
//#include "Core.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "OnlineSessionSettings.h"
|
||||
#include "OnlineDelegateMacros.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineSubsystemImpl.h"
|
||||
#include "OnlineSubsystemUtils.h"
|
||||
#include "OnlineSubsystemUtilsModule.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
#include "OnlineSubsystemUtilsClasses.h"
|
||||
#include "BlueprintDataDefinitions.generated.h"
|
||||
|
||||
@@ -199,6 +200,17 @@ public:
|
||||
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()
|
||||
{
|
||||
bUseDirectPointer = false;
|
||||
@@ -252,10 +264,18 @@ public:
|
||||
EBPOnlinePresenceState PresenceState;
|
||||
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
|
||||
{
|
||||
@@ -275,8 +295,15 @@ public:
|
||||
bool bIsPlayingSameGame;
|
||||
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)
|
||||
@@ -339,7 +366,7 @@ public:
|
||||
//return const_cast<FUniqueNetId*>(UniqueNetIdPtr);
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
UserID = PlayerState->UniqueId.GetUniqueNetId();
|
||||
UserID = PlayerState->GetUniqueId().GetUniqueNetId();
|
||||
if (!UserID.IsValid())
|
||||
{
|
||||
FFrame::KismetExecutionMessage(*FString::Printf(TEXT("%s - Cannot map local player to unique net ID"), FunctionContext), ELogVerbosity::Warning);
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "CancelFindSessionsCallbackProxy.generated.h"
|
||||
|
||||
|
||||
@@ -1,88 +1,107 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.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.
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
||||
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);
|
||||
|
||||
// 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<APlayerController> 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<FSessionPropertyKeyPair> ExtraSettings;
|
||||
|
||||
// The world context object in which this call is taking place
|
||||
UObject* WorldContextObject;
|
||||
};
|
||||
|
||||
// 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
|
||||
* @param bStartAfterCreate Set to true to start the session after it's created.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject",AutoCreateRefTerm="ExtraSettings"), Category = "Online|AdvancedSessions")
|
||||
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);
|
||||
|
||||
// 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 start completes
|
||||
void OnStartCompleted(FName SessionName, bool bWasSuccessful);
|
||||
|
||||
// The player controller triggering things
|
||||
TWeakObjectPtr<APlayerController> 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;
|
||||
|
||||
// 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;
|
||||
};
|
||||
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "EndSessionCallbackProxy.generated.h"
|
||||
|
||||
@@ -18,8 +19,11 @@ class UEndSessionCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
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);
|
||||
|
||||
// UOnlineBlueprintCallProxyBase interface
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
#pragma once
|
||||
#include "CoreMinimal.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "FindSessionsCallbackProxy.h"
|
||||
#include "BlueprintDataDefinitions.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)
|
||||
class UFindSessionsCallbackProxyAdvanced : public UOnlineBlueprintCallProxyBase
|
||||
{
|
||||
@@ -21,7 +27,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<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);
|
||||
|
||||
@@ -91,6 +97,9 @@ private:
|
||||
// Search for secure servers only
|
||||
bool bSecureServersOnly;
|
||||
|
||||
// Search through lobbies
|
||||
bool bSearchLobbies;
|
||||
|
||||
// Min slots requires to search
|
||||
int MinSlotsAvailable;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "Interfaces/OnlineIdentityInterface.h"
|
||||
#include "GetUserPrivilegeCallbackProxy.generated.h"
|
||||
|
||||
DECLARE_DYNAMIC_MULTICAST_DELEGATE_TwoParams(FBlueprintGetUserPrivilegeDelegate,/* const &FBPUniqueNetId, PlayerID,*/ EBPUserPrivileges, QueriedPrivilege, bool, HadPrivilege);
|
||||
@@ -21,7 +21,7 @@ class UGetUserPrivilegeCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FEmptyOnlineDelegate OnFailure;
|
||||
|
||||
// Logs out of the identity interface
|
||||
// Gets the privilage of the user
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
|
||||
static UGetUserPrivilegeCallbackProxy* GetUserPrivilege(UObject* WorldContextObject, const EBPUserPrivileges & PrivilegeToCheck, const FBPUniqueNetId & PlayerUniqueNetID);
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "Interfaces/OnlineIdentityInterface.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "LoginUserCallbackProxy.generated.h"
|
||||
|
||||
@@ -20,9 +20,9 @@ class ULoginUserCallbackProxy : public UOnlineBlueprintCallProxyBase
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FEmptyOnlineDelegate OnFailure;
|
||||
|
||||
// Logs out of the identity interface
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|AdvancedIdentity")
|
||||
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken);
|
||||
// Logs into the identity interface
|
||||
UFUNCTION(BlueprintCallable, meta = (BlueprintInternalUseOnly = "true", WorldContext = "WorldContextObject", AdvancedDisplay = "AuthType"), Category = "Online|AdvancedIdentity")
|
||||
static ULoginUserCallbackProxy* LoginUser(UObject* WorldContextObject, class APlayerController* PlayerController, FString UserID, FString UserToken, FString AuthType);
|
||||
|
||||
// UOnlineBlueprintCallProxyBase interface
|
||||
virtual void Activate() override;
|
||||
@@ -42,6 +42,8 @@ private:
|
||||
// The user pass / token
|
||||
FString UserToken;
|
||||
|
||||
FString AuthType;
|
||||
|
||||
// The delegate executed by the online subsystem
|
||||
FOnLoginCompleteDelegate Delegate;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "OnlineIdentityInterface.h"
|
||||
#include "Interfaces/OnlineIdentityInterface.h"
|
||||
#include "Engine/LocalPlayer.h"
|
||||
#include "LogoutUserCallbackProxy.generated.h"
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
@@ -2,6 +2,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Engine/Engine.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "UpdateSessionCallbackProxyAdvanced.generated.h"
|
||||
|
||||
@@ -20,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
|
||||
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
|
||||
virtual void Activate() override;
|
||||
@@ -37,28 +38,30 @@ private:
|
||||
FDelegateHandle OnUpdateSessionCompleteDelegateHandle;
|
||||
|
||||
// Number of public connections
|
||||
int NumPublicConnections;
|
||||
int NumPublicConnections = 100;
|
||||
|
||||
// Number of private connections
|
||||
int NumPrivateConnections;
|
||||
int NumPrivateConnections = 0;
|
||||
|
||||
// Whether or not to search LAN
|
||||
bool bUseLAN;
|
||||
bool bUseLAN = false;
|
||||
|
||||
// Whether or not to allow invites
|
||||
bool bAllowInvites;
|
||||
bool bAllowInvites = true;
|
||||
|
||||
// Store extra settings
|
||||
TArray<FSessionPropertyKeyPair> ExtraSettings;
|
||||
|
||||
// Whether to update the online data
|
||||
bool bRefreshOnlineData;
|
||||
bool bRefreshOnlineData = true;
|
||||
|
||||
// Allow joining in progress
|
||||
bool bAllowJoinInProgress;
|
||||
bool bAllowJoinInProgress = true;
|
||||
|
||||
// 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
|
||||
UObject* WorldContextObject;
|
||||
|
||||
@@ -124,7 +124,7 @@ void UAdvancedExternalUILibrary::ShowInviteUI(APlayerController *PlayerControlle
|
||||
return;
|
||||
}
|
||||
|
||||
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), GameSessionName);
|
||||
ExternalUIInterface->ShowInviteUI(Player->GetControllerId(), NAME_GameSession);
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "AdvancedFriendsGameInstance.h"
|
||||
#include "Kismet/GameplayStatics.h"
|
||||
#include "GameFramework/PlayerController.h"
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedFriendsInterfaceLog);
|
||||
@@ -20,7 +22,7 @@ UAdvancedFriendsGameInstance::UAdvancedFriendsGameInstance(const FObjectInitiali
|
||||
|
||||
void UAdvancedFriendsGameInstance::Shutdown()
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
@@ -37,7 +39,7 @@ void UAdvancedFriendsGameInstance::Shutdown()
|
||||
|
||||
if (bEnableTalkingStatusDelegate)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
|
||||
|
||||
if (VoiceInterface.IsValid())
|
||||
{
|
||||
@@ -50,7 +52,7 @@ void UAdvancedFriendsGameInstance::Shutdown()
|
||||
}
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
|
||||
|
||||
if (IdentityInterface.IsValid())
|
||||
{
|
||||
@@ -67,7 +69,7 @@ void UAdvancedFriendsGameInstance::Shutdown()
|
||||
|
||||
void UAdvancedFriendsGameInstance::Init()
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();//OnlineSub->GetSessionInterface();
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(GetWorld());//OnlineSub->GetSessionInterface();
|
||||
|
||||
if (SessionInterface.IsValid())
|
||||
{
|
||||
@@ -88,7 +90,7 @@ void UAdvancedFriendsGameInstance::Init()
|
||||
// Beginning work on the voice interface
|
||||
if (bEnableTalkingStatusDelegate)
|
||||
{
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface();
|
||||
IOnlineVoicePtr VoiceInterface = Online::GetVoiceInterface(GetWorld());
|
||||
|
||||
if (VoiceInterface.IsValid())
|
||||
{
|
||||
@@ -101,7 +103,7 @@ void UAdvancedFriendsGameInstance::Init()
|
||||
}
|
||||
}
|
||||
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface();
|
||||
IOnlineIdentityPtr IdentityInterface = Online::GetIdentityInterface(GetWorld());
|
||||
|
||||
if (IdentityInterface.IsValid())
|
||||
{
|
||||
@@ -261,7 +263,7 @@ void UAdvancedFriendsGameInstance::OnSessionInviteReceivedMaster(const FUniqueNe
|
||||
int32 LocalPlayer = 0;
|
||||
for (int i = 0; i < PlayerList.Num(); i++)
|
||||
{
|
||||
if (*PlayerList[i]->PlayerState->UniqueId.GetUniqueNetId() == PersonInvited)
|
||||
if (*PlayerList[i]->PlayerState->GetUniqueId().GetUniqueNetId() == PersonInvited)
|
||||
{
|
||||
LocalPlayer = i;
|
||||
Player = PlayerList[i];
|
||||
|
||||
@@ -50,7 +50,7 @@ void UAdvancedFriendsLibrary::SendSessionInviteToFriends(APlayerController *Play
|
||||
List.Add(val);
|
||||
}
|
||||
|
||||
if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), GameSessionName, List))
|
||||
if (SessionInterface->SendSessionInviteToFriends(Player->GetControllerId(), NAME_GameSession, List))
|
||||
{
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
return;
|
||||
@@ -94,7 +94,7 @@ void UAdvancedFriendsLibrary::SendSessionInviteToFriend(APlayerController *Playe
|
||||
return;
|
||||
}
|
||||
|
||||
if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), GameSessionName, *FriendUniqueNetId.GetUniqueNetId()))
|
||||
if (SessionInterface->SendSessionInviteToFriend(Player->GetControllerId(), NAME_GameSession, *FriendUniqueNetId.GetUniqueNetId()))
|
||||
{
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
return;
|
||||
|
||||
@@ -1,17 +1,93 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "AdvancedSessionsLibrary.h"
|
||||
|
||||
#include "GameFramework/PlayerState.h"
|
||||
#include "GameFramework/GameStateBase.h"
|
||||
|
||||
//General Log
|
||||
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)
|
||||
{
|
||||
return SessionResult.OnlineResult.IsValid();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionID_AsString(const FBlueprintSessionResult & SessionResult, FString& SessionID)
|
||||
{
|
||||
const TSharedPtr<class FOnlineSessionInfo> SessionInfo = SessionResult.OnlineResult.Session.SessionInfo;
|
||||
if (SessionInfo.IsValid() && SessionInfo->IsValid() && SessionInfo->GetSessionId().IsValid())
|
||||
{
|
||||
SessionID = SessionInfo->GetSessionId().ToString();
|
||||
return;
|
||||
}
|
||||
|
||||
// Zero the string out if we didn't have a valid one, in case this is called in c++
|
||||
SessionID.Empty();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetCurrentSessionID_AsString(UObject* WorldContextObject, FString& SessionID)
|
||||
{
|
||||
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetCurrentSessionID_AsString couldn't get the session interface!"));
|
||||
SessionID.Empty();
|
||||
return;
|
||||
}
|
||||
|
||||
const FNamedOnlineSession* Session = SessionInterface->GetNamedSession(NAME_GameSession);
|
||||
if (Session != nullptr)
|
||||
{
|
||||
const TSharedPtr<class FOnlineSessionInfo> SessionInfo = Session->SessionInfo;
|
||||
if (SessionInfo.IsValid() && SessionInfo->IsValid() && SessionInfo->GetSessionId().IsValid())
|
||||
{
|
||||
SessionID = SessionInfo->GetSessionId().ToString();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// Zero the string out if we didn't have a valid one, in case this is called in c++
|
||||
SessionID.Empty();
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetCurrentUniqueBuildID(int32 &UniqueBuildId)
|
||||
{
|
||||
UniqueBuildId = GetBuildUniqueId();
|
||||
@@ -87,9 +163,10 @@ void UAdvancedSessionsLibrary::GetExtraSettings(FBlueprintSessionResult SessionR
|
||||
}
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionState(EBPOnlineSessionState &SessionState)
|
||||
void UAdvancedSessionsLibrary::GetSessionState(UObject* WorldContextObject, EBPOnlineSessionState &SessionState)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
@@ -97,12 +174,13 @@ void UAdvancedSessionsLibrary::GetSessionState(EBPOnlineSessionState &SessionSta
|
||||
return;
|
||||
}
|
||||
|
||||
SessionState = ((EBPOnlineSessionState)SessionInterface->GetSessionState(GameSessionName));
|
||||
SessionState = ((EBPOnlineSessionState)SessionInterface->GetSessionState(NAME_GameSession));
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result)
|
||||
void UAdvancedSessionsLibrary::GetSessionSettings(UObject* WorldContextObject, int32 &NumConnections, int32 &NumPrivateConnections, bool &bIsLAN, bool &bIsDedicated, bool &bAllowInvites, bool &bAllowJoinInProgress, bool &bIsAnticheatEnabled, int32 &BuildUniqueID, TArray<FSessionPropertyKeyPair> &ExtraSettings, EBlueprintResultSwitch &Result)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
@@ -111,7 +189,7 @@ void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &
|
||||
return;
|
||||
}
|
||||
|
||||
FOnlineSessionSettings* settings = SessionInterface->GetSessionSettings(GameSessionName);
|
||||
FOnlineSessionSettings* settings = SessionInterface->GetSessionSettings(NAME_GameSession);
|
||||
if (!settings)
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetSessionSettings couldn't get the session settings!"));
|
||||
@@ -140,9 +218,10 @@ void UAdvancedSessionsLibrary::GetSessionSettings(int32 &NumConnections, int32 &
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
}
|
||||
|
||||
void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession)
|
||||
void UAdvancedSessionsLibrary::IsPlayerInSession(UObject* WorldContextObject, const FBPUniqueNetId &PlayerToCheck, bool &bIsInSession)
|
||||
{
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface();
|
||||
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||
IOnlineSessionPtr SessionInterface = Online::GetSessionInterface(World);
|
||||
|
||||
if (!SessionInterface.IsValid())
|
||||
{
|
||||
@@ -151,7 +230,7 @@ void UAdvancedSessionsLibrary::IsPlayerInSession(const FBPUniqueNetId &PlayerToC
|
||||
return;
|
||||
}
|
||||
|
||||
bIsInSession = SessionInterface->IsPlayerInSession(GameSessionName, *PlayerToCheck.GetUniqueNetId());
|
||||
bIsInSession = SessionInterface->IsPlayerInSession(NAME_GameSession, *PlayerToCheck.GetUniqueNetId());
|
||||
}
|
||||
|
||||
FSessionsSearchSetting UAdvancedSessionsLibrary::MakeLiteralSessionSearchProperty(FSessionPropertyKeyPair SessionSearchProperty, EOnlineComparisonOpRedux ComparisonOp)
|
||||
@@ -363,7 +442,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetID(APlayerController *PlayerControlle
|
||||
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromController couldn't get the player uniquenetid!"));
|
||||
@@ -372,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)
|
||||
{
|
||||
if (!PlayerState)
|
||||
@@ -380,7 +470,7 @@ void UAdvancedSessionsLibrary::GetUniqueNetIDFromPlayerState(APlayerState *Playe
|
||||
return;
|
||||
}
|
||||
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->UniqueId.GetUniqueNetId());
|
||||
UniqueNetId.SetUniqueNetId(PlayerState->GetUniqueId().GetUniqueNetId());
|
||||
if (!UniqueNetId.IsValid())
|
||||
{
|
||||
UE_LOG(AdvancedSessionsLog, Warning, TEXT("GetUniqueNetIdFromPlayerState couldn't get the player uniquenetid!"));
|
||||
@@ -427,7 +517,7 @@ void UAdvancedSessionsLibrary::GetPlayerName(APlayerController *PlayerController
|
||||
|
||||
if (APlayerState* PlayerState = (PlayerController != NULL) ? PlayerController->PlayerState : NULL)
|
||||
{
|
||||
PlayerName = PlayerState->PlayerName;
|
||||
PlayerName = PlayerState->GetPlayerName();
|
||||
return;
|
||||
}
|
||||
else
|
||||
@@ -449,3 +539,14 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextOb
|
||||
|
||||
NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
|
||||
}
|
||||
|
||||
bool UAdvancedSessionsLibrary::ServerTravel(UObject* WorldContextObject, const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify)
|
||||
{
|
||||
if (!WorldContextObject) return false;
|
||||
|
||||
//using a context object to get the world
|
||||
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
|
||||
if (!World) 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();
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "CancelFindSessionsCallbackProxy.h"
|
||||
|
||||
|
||||
|
||||
@@ -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>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
@@ -25,11 +25,14 @@ 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;
|
||||
Proxy->bStartAfterCreate = bStartAfterCreate;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
@@ -50,21 +53,27 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
FOnlineSessionSettings Settings;
|
||||
Settings.NumPublicConnections = NumPublicConnections;
|
||||
Settings.NumPrivateConnections = NumPrivateConnections;
|
||||
Settings.bShouldAdvertise = true;
|
||||
Settings.bShouldAdvertise = bShouldAdvertise;
|
||||
Settings.bAllowJoinInProgress = true;
|
||||
Settings.bIsLANMatch = bUseLAN;
|
||||
Settings.bAllowJoinViaPresence = true;
|
||||
Settings.bAllowJoinViaPresence = bAllowJoinViaPresence;
|
||||
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;
|
||||
Settings.bShouldAdvertise = bShouldAdvertise;
|
||||
|
||||
// These are about the only changes over the standard Create Sessions Node
|
||||
Settings.bAllowInvites = bAllowInvites;
|
||||
@@ -83,7 +92,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
{
|
||||
if (PlayerControllerWeakPtr.IsValid() && Helper.UserID.IsValid())
|
||||
{
|
||||
Sessions->CreateSession(*Helper.UserID, GameSessionName, Settings);
|
||||
Sessions->CreateSession(*Helper.UserID, NAME_GameSession, Settings);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -95,7 +104,7 @@ void UCreateSessionCallbackProxyAdvanced::Activate()
|
||||
}
|
||||
}
|
||||
else
|
||||
Sessions->CreateSession(0, GameSessionName, Settings);
|
||||
Sessions->CreateSession(0, NAME_GameSession, Settings);
|
||||
|
||||
// OnCreateCompleted will get called, nothing more to do now
|
||||
return;
|
||||
@@ -124,8 +133,17 @@ void UCreateSessionCallbackProxyAdvanced::OnCreateCompleted(FName SessionName, b
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
StartCompleteDelegateHandle = Sessions->AddOnStartSessionCompleteDelegate_Handle(StartCompleteDelegate);
|
||||
Sessions->StartSession(GameSessionName);
|
||||
if(this->bStartAfterCreate)
|
||||
{
|
||||
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
|
||||
return;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "EndSessionCallbackProxy.h"
|
||||
|
||||
|
||||
@@ -30,12 +29,12 @@ void UEndSessionCallbackProxy::Activate()
|
||||
auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
FNamedOnlineSession* Session = Sessions->GetNamedSession(GameSessionName);
|
||||
FNamedOnlineSession* Session = Sessions->GetNamedSession(NAME_GameSession);
|
||||
if (Session &&
|
||||
Session->SessionState == EOnlineSessionState::InProgress)
|
||||
{
|
||||
DelegateHandle = Sessions->AddOnEndSessionCompleteDelegate_Handle(Delegate);
|
||||
Sessions->EndSession(GameSessionName);
|
||||
Sessions->EndSession(NAME_GameSession);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -41,7 +41,7 @@ void UFindFriendSessionCallbackProxy::Activate()
|
||||
return;
|
||||
}
|
||||
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
||||
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
@@ -71,7 +71,7 @@ void UFindFriendSessionCallbackProxy::Activate()
|
||||
|
||||
void UFindFriendSessionCallbackProxy::OnFindFriendSessionCompleted(int32 LocalPlayer, bool bWasSuccessful, const TArray<FOnlineSessionSearchResult>& SessionInfo)
|
||||
{
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface(GetWorld());
|
||||
|
||||
if (Sessions.IsValid())
|
||||
Sessions->ClearOnFindFriendSessionCompleteDelegate_Handle(LocalPlayer, FindFriendSessionCompleteDelegateHandle);
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "FindSessionsCallbackProxyAdvanced.h"
|
||||
|
||||
|
||||
@@ -16,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<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>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
@@ -28,6 +27,7 @@ UFindSessionsCallbackProxyAdvanced* UFindSessionsCallbackProxyAdvanced::FindSess
|
||||
Proxy->bEmptyServersOnly = bEmptyServersOnly,
|
||||
Proxy->bNonEmptyServersOnly = bNonEmptyServersOnly;
|
||||
Proxy->bSecureServersOnly = bSecureServersOnly;
|
||||
Proxy->bSearchLobbies = bSearchLobbies;
|
||||
Proxy->MinSlotsAvailable = MinSlotsAvailable;
|
||||
return Proxy;
|
||||
}
|
||||
@@ -74,6 +74,17 @@ 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);
|
||||
@@ -87,8 +98,6 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
if (MinSlotsAvailable != 0)
|
||||
tem.Set(SEARCH_MINSLOTSAVAILABLE, MinSlotsAvailable, EOnlineComparisonOp::GreaterThanEquals);
|
||||
|
||||
|
||||
|
||||
// Filter results
|
||||
if (SearchSettings.Num() > 0)
|
||||
{
|
||||
@@ -105,6 +114,9 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
case EBPServerPresenceSearchType::ClientServersOnly:
|
||||
{
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
if (bSearchLobbies)
|
||||
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -118,20 +130,24 @@ void UFindSessionsCallbackProxyAdvanced::Activate()
|
||||
default:
|
||||
{
|
||||
// Only steam uses the separate searching flags currently
|
||||
if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||
{
|
||||
bRunSecondSearch = true;
|
||||
//if (IOnlineSubsystem::DoesInstanceExist("STEAM"))
|
||||
//{
|
||||
bRunSecondSearch = true;
|
||||
|
||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||
SearchObjectDedicated = MakeShareable(new FOnlineSessionSearch);
|
||||
SearchObjectDedicated->MaxSearchResults = MaxResults;
|
||||
SearchObjectDedicated->bIsLanQuery = bUseLAN;
|
||||
|
||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
FOnlineSearchSettingsEx DedicatedOnly = tem;
|
||||
|
||||
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||
}
|
||||
tem.Set(SEARCH_PRESENCE, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
if (bSearchLobbies)
|
||||
tem.Set(SEARCH_LOBBIES, true, EOnlineComparisonOp::Equals);
|
||||
|
||||
//DedicatedOnly.Set(SEARCH_DEDICATED_ONLY, true, EOnlineComparisonOp::Equals);
|
||||
SearchObjectDedicated->QuerySettings = DedicatedOnly;
|
||||
//}
|
||||
}
|
||||
break;
|
||||
}
|
||||
@@ -183,7 +199,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
SessionSearchResults.Add(BPResult);
|
||||
SessionSearchResults.AddUnique(BPResult);
|
||||
}
|
||||
OnSuccess.Broadcast(SessionSearchResults);
|
||||
return;
|
||||
@@ -202,7 +218,7 @@ void UFindSessionsCallbackProxyAdvanced::OnCompleted(bool bSuccess)
|
||||
|
||||
FBlueprintSessionResult BPResult;
|
||||
BPResult.OnlineResult = Result;
|
||||
SessionSearchResults.Add(BPResult);
|
||||
SessionSearchResults.AddUnique(BPResult);
|
||||
}
|
||||
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>();
|
||||
Proxy->PlayerControllerWeakPtr = PlayerController;
|
||||
Proxy->UserID = UserID;
|
||||
Proxy->UserToken = UserToken;
|
||||
Proxy->AuthType = AuthType;
|
||||
Proxy->WorldContextObject = WorldContextObject;
|
||||
return Proxy;
|
||||
}
|
||||
@@ -43,8 +44,13 @@ void ULoginUserCallbackProxy::Activate()
|
||||
|
||||
if (Identity.IsValid())
|
||||
{
|
||||
// Fallback to default AuthType if nothing is specified
|
||||
if (AuthType.IsEmpty())
|
||||
{
|
||||
AuthType = Identity->GetAuthType();
|
||||
}
|
||||
DelegateHandle = Identity->AddOnLoginCompleteDelegate_Handle(Player->GetControllerId(), Delegate);
|
||||
FOnlineAccountCredentials AccountCreds(Identity->GetAuthType(), UserID, UserToken);
|
||||
FOnlineAccountCredentials AccountCreds(AuthType, UserID, UserToken);
|
||||
Identity->Login(Player->GetControllerId(), AccountCreds);
|
||||
return;
|
||||
}
|
||||
@@ -59,6 +65,8 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
||||
{
|
||||
ULocalPlayer* Player = Cast<ULocalPlayer>(PlayerControllerWeakPtr->Player);
|
||||
|
||||
auto uniqueId = UserId.AsShared();
|
||||
|
||||
if (Player)
|
||||
{
|
||||
auto Identity = Online::GetIdentityInterface();
|
||||
@@ -67,6 +75,13 @@ void ULoginUserCallbackProxy::OnCompleted(int32 LocalUserNum, bool bWasSuccessfu
|
||||
{
|
||||
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>();
|
||||
Proxy->NumPublicConnections = PublicConnections;
|
||||
@@ -24,75 +24,79 @@ UUpdateSessionCallbackProxyAdvanced* UUpdateSessionCallbackProxyAdvanced::Update
|
||||
Proxy->bRefreshOnlineData = bRefreshOnlineData;
|
||||
Proxy->bAllowJoinInProgress = bAllowJoinInProgress;
|
||||
Proxy->bDedicatedServer = bIsDedicatedServer;
|
||||
Proxy->bShouldAdvertise = bShouldAdvertise;
|
||||
return Proxy;
|
||||
}
|
||||
|
||||
void UUpdateSessionCallbackProxyAdvanced::Activate()
|
||||
{
|
||||
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSession"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
|
||||
if (Sessions.IsValid())
|
||||
if (Helper.OnlineSub != nullptr)
|
||||
{
|
||||
if (Sessions->GetNumSessions() < 1)
|
||||
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
OnFailure.Broadcast();
|
||||
GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, TEXT("NO REGISTERED SESSIONS!"));
|
||||
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 = 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;
|
||||
}
|
||||
|
||||
// This gets the actual session itself
|
||||
//FNamedOnlineSession * curSession = Sessions->GetNamedSession(GameSessionName);
|
||||
FOnlineSessionSettings* Settings = Sessions->GetSessionSettings(GameSessionName);
|
||||
|
||||
if (!Settings)
|
||||
else
|
||||
{
|
||||
// Fail immediately
|
||||
OnFailure.Broadcast();
|
||||
return;
|
||||
FFrame::KismetExecutionMessage(TEXT("Sessions not supported by Online Subsystem"), ELogVerbosity::Warning);
|
||||
}
|
||||
|
||||
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(GameSessionName, *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();
|
||||
@@ -101,15 +105,20 @@ void UUpdateSessionCallbackProxyAdvanced::Activate()
|
||||
|
||||
void UUpdateSessionCallbackProxyAdvanced::OnUpdateCompleted(FName SessionName, bool bWasSuccessful)
|
||||
{
|
||||
IOnlineSessionPtr Sessions = Online::GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
const FOnlineSubsystemBPCallHelperAdvanced Helper(TEXT("UpdateSessionCallback"), GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull));
|
||||
|
||||
if (Helper.OnlineSub != nullptr)
|
||||
{
|
||||
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
||||
|
||||
if (bWasSuccessful)
|
||||
const auto Sessions = Helper.OnlineSub->GetSessionInterface();
|
||||
if (Sessions.IsValid())
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
return;
|
||||
Sessions->ClearOnUpdateSessionCompleteDelegate_Handle(OnUpdateSessionCompleteDelegateHandle);
|
||||
|
||||
if (bWasSuccessful)
|
||||
{
|
||||
OnSuccess.Broadcast();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
"FileVersion" : 3,
|
||||
|
||||
"FriendlyName" : "Advanced Steam Sessions",
|
||||
"Version" : 4.17,
|
||||
"VersionName": "4.17",
|
||||
"Version" : 4.27,
|
||||
"VersionName": "4.27",
|
||||
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
||||
"Category" : "Advanced Sessions Plugin",
|
||||
"CreatedBy" : "Joshua Statzer",
|
||||
@@ -33,6 +33,10 @@
|
||||
{
|
||||
"Name": "OnlineSubsystemSteam",
|
||||
"Enabled": true
|
||||
},
|
||||
{
|
||||
"Name": "SteamShared",
|
||||
"Enabled": true
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -8,7 +8,7 @@ public class AdvancedSteamSessions : ModuleRules
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
//bEnforceIWYU = true;
|
||||
|
||||
Definitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1");
|
||||
PublicDefinitions.Add("WITH_ADVANCED_STEAM_SESSIONS=1");
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "OnlineSubsystem", "CoreUObject", "OnlineSubsystemUtils", "Networking", "Sockets", "AdvancedSessions"/*"Voice", "OnlineSubsystemSteam"*/ });
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { "OnlineSubsystem", "Sockets", "Networking", "OnlineSubsystemUtils" /*"Voice", "Steamworks","OnlineSubsystemSteam"*/});
|
||||
|
||||
@@ -6,14 +6,232 @@
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineFriendsInterface.h"
|
||||
#include "OnlineUserInterface.h"
|
||||
#include "OnlineMessageInterface.h"
|
||||
#include "OnlinePresenceInterface.h"
|
||||
#include "Interfaces/OnlineFriendsInterface.h"
|
||||
#include "Interfaces/OnlineUserInterface.h"
|
||||
#include "Interfaces/OnlineMessageInterface.h"
|
||||
#include "Interfaces/OnlinePresenceInterface.h"
|
||||
#include "Engine/GameInstance.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
#include "BlueprintDataDefinitions.h"
|
||||
#include "UObject/UObjectIterator.h"
|
||||
|
||||
#include "UObjectIterator.h"
|
||||
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
|
||||
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
|
||||
// disable the warnings locally. Remove when this is fixed in the SDK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
// #TODO check back on this at some point
|
||||
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
#if USING_CODE_ANALYSIS
|
||||
MSVC_PRAGMA(warning(push))
|
||||
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
|
||||
#endif // USING_CODE_ANALYSIS
|
||||
|
||||
#include <steam/steam_api.h>
|
||||
|
||||
#if USING_CODE_ANALYSIS
|
||||
MSVC_PRAGMA(warning(pop))
|
||||
#endif // USING_CODE_ANALYSIS
|
||||
|
||||
#include <steam/isteamapps.h>
|
||||
#include <steam/isteamapplist.h>
|
||||
//#include <OnlineSubsystemSteamTypes.h>
|
||||
#pragma pop_macro("ARRAY_COUNT")
|
||||
|
||||
// @todo Steam: See above
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
// Making a copy of this here since the original is still in a private folder and is screwing with things
|
||||
/**
|
||||
* Steam specific implementation of the unique net id
|
||||
*/
|
||||
class FUniqueNetIdSteam2 :
|
||||
public FUniqueNetId
|
||||
{
|
||||
PACKAGE_SCOPE:
|
||||
/** Holds the net id for a player */
|
||||
uint64 UniqueNetId;
|
||||
|
||||
/** Hidden on purpose */
|
||||
FUniqueNetIdSteam2() :
|
||||
UniqueNetId(0)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy Constructor
|
||||
*
|
||||
* @param Src the id to copy
|
||||
*/
|
||||
explicit FUniqueNetIdSteam2(const FUniqueNetIdSteam2& Src) :
|
||||
UniqueNetId(Src.UniqueNetId)
|
||||
{
|
||||
}
|
||||
|
||||
public:
|
||||
/**
|
||||
* Constructs this object with the specified net id
|
||||
*
|
||||
* @param InUniqueNetId the id to set ours to
|
||||
*/
|
||||
explicit FUniqueNetIdSteam2(uint64 InUniqueNetId) :
|
||||
UniqueNetId(InUniqueNetId)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs this object with the steam id
|
||||
*
|
||||
* @param InUniqueNetId the id to set ours to
|
||||
*/
|
||||
explicit FUniqueNetIdSteam2(CSteamID InSteamId) :
|
||||
UniqueNetId(InSteamId.ConvertToUint64())
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs this object with the specified net id
|
||||
*
|
||||
* @param String textual representation of an id
|
||||
*/
|
||||
explicit FUniqueNetIdSteam2(const FString& Str) :
|
||||
UniqueNetId(FCString::Atoi64(*Str))
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Constructs this object with the specified net id
|
||||
*
|
||||
* @param InUniqueNetId the id to set ours to (assumed to be FUniqueNetIdSteam in fact)
|
||||
*/
|
||||
explicit FUniqueNetIdSteam2(const FUniqueNetId& InUniqueNetId) :
|
||||
UniqueNetId(*(uint64*)InUniqueNetId.GetBytes())
|
||||
{
|
||||
}
|
||||
|
||||
virtual FName GetType() const override
|
||||
{
|
||||
return STEAM_SUBSYSTEM;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the raw byte representation of this net id
|
||||
* This data is platform dependent and shouldn't be manipulated directly
|
||||
*
|
||||
* @return byte array of size GetSize()
|
||||
*/
|
||||
virtual const uint8* GetBytes() const override
|
||||
{
|
||||
return (uint8*)&UniqueNetId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the size of the id
|
||||
*
|
||||
* @return size in bytes of the id representation
|
||||
*/
|
||||
virtual int32 GetSize() const override
|
||||
{
|
||||
return sizeof(uint64);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check the validity of the id
|
||||
*
|
||||
* @return true if this is a well formed ID, false otherwise
|
||||
*/
|
||||
virtual bool IsValid() const override
|
||||
{
|
||||
return UniqueNetId != 0 && CSteamID(UniqueNetId).IsValid();
|
||||
}
|
||||
|
||||
/**
|
||||
* Platform specific conversion to string representation of data
|
||||
*
|
||||
* @return data in string form
|
||||
*/
|
||||
virtual FString ToString() const override
|
||||
{
|
||||
return FString::Printf(TEXT("%llu"), UniqueNetId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a human readable representation of the net id
|
||||
* Shouldn't be used for anything other than logging/debugging
|
||||
*
|
||||
* @return id in string form
|
||||
*/
|
||||
virtual FString ToDebugString() const override
|
||||
{
|
||||
CSteamID SteamID(UniqueNetId);
|
||||
if (SteamID.IsLobby())
|
||||
{
|
||||
return FString::Printf(TEXT("Lobby [0x%llX]"), UniqueNetId);
|
||||
}
|
||||
else if (SteamID.BAnonGameServerAccount())
|
||||
{
|
||||
return FString::Printf(TEXT("Server [0x%llX]"), UniqueNetId);
|
||||
}
|
||||
else if (SteamID.IsValid())
|
||||
{
|
||||
const FString NickName(SteamFriends() ? UTF8_TO_TCHAR(SteamFriends()->GetFriendPersonaName(UniqueNetId)) : TEXT("UNKNOWN"));
|
||||
return FString::Printf(TEXT("%s [0x%llX]"), *NickName, UniqueNetId);
|
||||
}
|
||||
else
|
||||
{
|
||||
return FString::Printf(TEXT("INVALID [0x%llX]"), UniqueNetId);
|
||||
}
|
||||
}
|
||||
|
||||
/** Needed for TMap::GetTypeHash() */
|
||||
friend uint32 GetTypeHash(const FUniqueNetIdSteam2& A)
|
||||
{
|
||||
return GetTypeHash(A.UniqueNetId);
|
||||
//return (uint32)(A.UniqueNetId) + ((uint32)((A.UniqueNetId) >> 32) * 23);
|
||||
}
|
||||
|
||||
/** Convenience cast to CSteamID */
|
||||
operator CSteamID()
|
||||
{
|
||||
return UniqueNetId;
|
||||
}
|
||||
|
||||
/** Convenience cast to CSteamID */
|
||||
operator const CSteamID() const
|
||||
{
|
||||
return UniqueNetId;
|
||||
}
|
||||
|
||||
/** Convenience cast to CSteamID pointer */
|
||||
operator CSteamID*()
|
||||
{
|
||||
return (CSteamID*)&UniqueNetId;
|
||||
}
|
||||
|
||||
/** Convenience cast to CSteamID pointer */
|
||||
operator const CSteamID*() const
|
||||
{
|
||||
return (const CSteamID*)&UniqueNetId;
|
||||
}
|
||||
|
||||
friend FArchive& operator<<(FArchive& Ar, FUniqueNetIdSteam2& UserId)
|
||||
{
|
||||
return Ar << UserId.UniqueNetId;
|
||||
}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#include "AdvancedSteamFriendsLibrary.generated.h"
|
||||
|
||||
@@ -24,34 +242,81 @@ DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All);
|
||||
UENUM(Blueprintable)
|
||||
enum class SteamAvatarSize : uint8
|
||||
{
|
||||
SteamAvatar_INVALID = 0,
|
||||
SteamAvatar_Small = 1,
|
||||
SteamAvatar_Medium = 2,
|
||||
SteamAvatar_Large = 3
|
||||
};
|
||||
|
||||
UENUM(Blueprintable)
|
||||
enum class ESteamUserOverlayType : uint8
|
||||
{
|
||||
/*Opens the overlay web browser to the specified user or groups profile.*/
|
||||
steamid,
|
||||
/*Opens a chat window to the specified user, or joins the group chat.*/
|
||||
chat,
|
||||
/*Opens a window to a Steam Trading session that was started with the ISteamEconomy / StartTrade Web API.*/
|
||||
jointrade,
|
||||
/*Opens the overlay web browser to the specified user's stats.*/
|
||||
stats,
|
||||
/*Opens the overlay web browser to the specified user's achievements.*/
|
||||
achievements,
|
||||
/*Opens the overlay in minimal mode prompting the user to add the target user as a friend.*/
|
||||
friendadd,
|
||||
/*Opens the overlay in minimal mode prompting the user to remove the target friend.*/
|
||||
friendremove,
|
||||
/*Opens the overlay in minimal mode prompting the user to accept an incoming friend invite.*/
|
||||
friendrequestaccept,
|
||||
/*Opens the overlay in minimal mode prompting the user to ignore an incoming friend invite.*/
|
||||
friendrequestignore
|
||||
};
|
||||
|
||||
static FString EnumToString(const FString& enumName, uint8 value)
|
||||
{
|
||||
const UEnum* EnumPtr = FindObject<UEnum>(ANY_PACKAGE, *enumName, true);
|
||||
|
||||
if (!EnumPtr)
|
||||
return FString();
|
||||
|
||||
FString EnumName = EnumPtr->GetNameStringByIndex(value);
|
||||
return EnumName;
|
||||
}
|
||||
|
||||
|
||||
USTRUCT(BlueprintType, Category = "Online|SteamAPI|SteamGroups")
|
||||
struct FBPSteamGroupInfo
|
||||
{
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
|
||||
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
FBPUniqueNetId GroupID; // Uint64 representation
|
||||
FBPUniqueNetId GroupID; // Uint64 representation
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
FString GroupName;
|
||||
FString GroupName;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
FString GroupTag;
|
||||
FString GroupTag;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
int32 numOnline;
|
||||
int32 numOnline;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
int32 numInGame;
|
||||
int32 numInGame;
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|SteamAPI|SteamGroups")
|
||||
int32 numChatting;
|
||||
int32 numChatting;
|
||||
|
||||
};
|
||||
|
||||
|
||||
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
|
||||
@@ -68,7 +333,15 @@ public:
|
||||
// Preloads the avatar and name of a steam friend, return whether it is already available or not, STEAM ONLY, Takes time to actually load everything after this is called.
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI")
|
||||
static bool RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly = false);
|
||||
|
||||
// Opens the steam overlay to go to the specified user dialog
|
||||
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);
|
||||
@@ -81,13 +354,34 @@ public:
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
|
||||
static FBPUniqueNetId CreateSteamIDFromString(const FString SteamID64);
|
||||
|
||||
// Retreives the local steam ID from steam
|
||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedFriends|SteamAPI")
|
||||
static FBPUniqueNetId GetLocalSteamIDFromSteam();
|
||||
|
||||
/* Gets the current game played by a friend - AppID is int32 even though steam ids are uint32, can't be helped in blueprint currently
|
||||
* The game name is retrieved from steamSDK AppList which isn't available to all game IDs without request, can use the AppID with the
|
||||
* WebAPI GetAppList request as an alternative.
|
||||
* can use the AppID with the WebAPI GetAppList request.
|
||||
*/
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedFriends|SteamAPI", meta = (ExpandEnumAsExecs = "Result"))
|
||||
static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result, FString & GameName, int32 & AppID);
|
||||
static void GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID);
|
||||
|
||||
// Get a full list of steam groups
|
||||
UFUNCTION(BlueprintCallable, Category = "Online|SteamAPI|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();
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "ModuleManager.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
class AdvancedSteamSessions : public IModuleInterface
|
||||
{
|
||||
|
||||
@@ -6,7 +6,11 @@
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "Online.h"
|
||||
#include "OnlineSubsystem.h"
|
||||
#include "OnlineSessionInterface.h"
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
#include "steam/isteamugc.h"
|
||||
#include "steam/isteamremotestorage.h"
|
||||
#endif
|
||||
#include "Interfaces/OnlineSessionInterface.h"
|
||||
|
||||
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
|
||||
// disable the warnings locally. Remove when this is fixed in the SDK
|
||||
@@ -79,6 +83,7 @@ public:
|
||||
UENUM(BlueprintType)
|
||||
enum class FBPSteamResult : uint8
|
||||
{
|
||||
K_EResultInvalid = 0,
|
||||
k_EResultOK = 1, // success
|
||||
k_EResultFail = 2, // generic failure
|
||||
k_EResultNoConnection = 3, // no/failed network connection
|
||||
@@ -203,11 +208,22 @@ struct FBPSteamWorkshopItemDetails
|
||||
GENERATED_USTRUCT_BODY()
|
||||
|
||||
public:
|
||||
|
||||
FBPSteamWorkshopItemDetails()
|
||||
{
|
||||
|
||||
ResultOfRequest = FBPSteamResult::k_EResultOK;
|
||||
FileType = FBPWorkshopFileType::k_EWorkshopFileTypeMax;
|
||||
CreatorAppID = 0;
|
||||
ConsumerAppID = 0;
|
||||
VotesUp = 0;
|
||||
VotesDown = 0;
|
||||
CalculatedScore = 0.f;
|
||||
bBanned = false;
|
||||
bAcceptedForUse = false;
|
||||
bTagsTruncated = false;
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
FBPSteamWorkshopItemDetails(SteamUGCDetails_t &hUGCDetails)
|
||||
{
|
||||
ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
|
||||
@@ -227,6 +243,26 @@ public:
|
||||
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
|
||||
}
|
||||
|
||||
FBPSteamWorkshopItemDetails(const SteamUGCDetails_t &hUGCDetails)
|
||||
{
|
||||
ResultOfRequest = (FBPSteamResult)hUGCDetails.m_eResult;
|
||||
FileType = (FBPWorkshopFileType)hUGCDetails.m_eFileType;
|
||||
CreatorAppID = (int32)hUGCDetails.m_nCreatorAppID;
|
||||
ConsumerAppID = (int32)hUGCDetails.m_nConsumerAppID;
|
||||
Title = FString(hUGCDetails.m_rgchTitle, k_cchPublishedDocumentTitleMax);
|
||||
Description = FString(hUGCDetails.m_rgchDescription, k_cchPublishedDocumentDescriptionMax);
|
||||
ItemUrl = FString(hUGCDetails.m_rgchURL, k_cchPublishedFileURLMax);
|
||||
VotesUp = (int32)hUGCDetails.m_unVotesUp;
|
||||
VotesDown = (int32)hUGCDetails.m_unVotesDown;
|
||||
CalculatedScore = hUGCDetails.m_flScore;
|
||||
bBanned = hUGCDetails.m_bBanned;
|
||||
bAcceptedForUse = hUGCDetails.m_bAcceptedForUse;
|
||||
bTagsTruncated = hUGCDetails.m_bTagsTruncated;
|
||||
|
||||
CreatorSteamID = FString::Printf(TEXT("%llu"), hUGCDetails.m_ulSteamIDOwner);
|
||||
}
|
||||
#endif
|
||||
|
||||
// Result of obtaining the details
|
||||
UPROPERTY(EditAnywhere, BlueprintReadOnly, Category = "Online|AdvancedSteamWorkshop")
|
||||
FBPSteamResult ResultOfRequest;
|
||||
|
||||
@@ -17,6 +17,8 @@
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#include "OnlineSubsystemSteam.h"
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
@@ -75,7 +77,7 @@ class USteamRequestGroupOfficersCallbackProxy : public UOnlineBlueprintCallProxy
|
||||
UPROPERTY(BlueprintAssignable)
|
||||
FBlueprintGroupOfficerDetailsDelegate OnFailure;
|
||||
|
||||
// Retruns a list of steam group officers
|
||||
// Returns a list of steam group officers
|
||||
UFUNCTION(BlueprintCallable, meta=(BlueprintInternalUseOnly = "true", WorldContext="WorldContextObject"), Category = "Online|SteamAPI|SteamGroups")
|
||||
static USteamRequestGroupOfficersCallbackProxy* GetSteamGroupOfficerList(UObject* WorldContextObject, FBPUniqueNetId GroupUniqueNetID);
|
||||
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#include "OnlineSubsystemSteam.h"
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
|
||||
@@ -2,45 +2,6 @@
|
||||
#include "AdvancedSteamFriendsLibrary.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
|
||||
// This is taken directly from UE4 - OnlineSubsystemSteamPrivatePCH.h as a fix for the array_count macro
|
||||
|
||||
// @todo Steam: Steam headers trigger secure-C-runtime warnings in Visual C++. Rather than mess with _CRT_SECURE_NO_WARNINGS, we'll just
|
||||
// disable the warnings locally. Remove when this is fixed in the SDK
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(push)
|
||||
#pragma warning(disable:4996)
|
||||
// #TODO check back on this at some point
|
||||
#pragma warning(disable:4265) // SteamAPI CCallback< specifically, this warning is off by default but 4.17 turned it on....
|
||||
#endif
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
#pragma push_macro("ARRAY_COUNT")
|
||||
#undef ARRAY_COUNT
|
||||
|
||||
#if USING_CODE_ANALYSIS
|
||||
MSVC_PRAGMA(warning(push))
|
||||
MSVC_PRAGMA(warning(disable : ALL_CODE_ANALYSIS_WARNINGS))
|
||||
#endif // USING_CODE_ANALYSIS
|
||||
|
||||
#include <steam/steam_api.h>
|
||||
|
||||
#if USING_CODE_ANALYSIS
|
||||
MSVC_PRAGMA(warning(pop))
|
||||
#endif // USING_CODE_ANALYSIS
|
||||
|
||||
#include <steam/isteamapps.h>
|
||||
#include <steam/isteamapplist.h>
|
||||
#include <OnlineSubsystemSteamTypes.h>
|
||||
#pragma pop_macro("ARRAY_COUNT")
|
||||
|
||||
#endif
|
||||
|
||||
// @todo Steam: See above
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
||||
//General Log
|
||||
DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
|
||||
|
||||
@@ -50,7 +11,7 @@ DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
|
||||
return 0;
|
||||
@@ -97,6 +58,7 @@ DEFINE_LOG_CATEGORY(AdvancedSteamFriendsLog);
|
||||
|
||||
void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & SteamGroups)
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
if (SteamAPI_Init())
|
||||
@@ -112,7 +74,7 @@ void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & St
|
||||
|
||||
FBPSteamGroupInfo GroupInfo;
|
||||
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(SteamGroupID));
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamGroupID));
|
||||
GroupInfo.GroupID.SetUniqueNetId(ValueID);
|
||||
SteamFriends()->GetClanActivityCounts(SteamGroupID, &GroupInfo.numOnline, &GroupInfo.numInGame, &GroupInfo.numChatting);
|
||||
GroupInfo.GroupName = FString(UTF8_TO_TCHAR(SteamFriends()->GetClanName(SteamGroupID)));
|
||||
@@ -122,13 +84,14 @@ void UAdvancedSteamFriendsLibrary::GetSteamGroups(TArray<FBPSteamGroupInfo> & St
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result, FString & GameName, int32 & AppID)
|
||||
void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId UniqueNetId, EBlueprintResultSwitch &Result/*, FString & GameName*/, int32 & AppID)
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendGamePlayed Had a bad UniqueNetId!"));
|
||||
Result = EBlueprintResultSwitch::OnFailure;
|
||||
@@ -146,13 +109,15 @@ void UAdvancedSteamFriendsLibrary::GetSteamFriendGamePlayed(const FBPUniqueNetId
|
||||
{
|
||||
AppID = GameInfo.m_gameID.AppID();
|
||||
|
||||
char NameBuffer[512];
|
||||
// Forgot this test and left it in, it is incorrect, you would need restricted access
|
||||
// And it would only find games in the local library anyway
|
||||
/*char NameBuffer[512];
|
||||
int Len = SteamAppList()->GetAppName(GameInfo.m_gameID.AppID(), NameBuffer, 512);
|
||||
|
||||
if (Len != -1) // Invalid
|
||||
{
|
||||
GameName = FString(UTF8_TO_TCHAR(NameBuffer));
|
||||
}
|
||||
}*/
|
||||
|
||||
Result = EBlueprintResultSwitch::OnSuccess;
|
||||
return;
|
||||
@@ -168,7 +133,7 @@ int32 UAdvancedSteamFriendsLibrary::GetFriendSteamLevel(const FBPUniqueNetId Uni
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("IsAFriend Had a bad UniqueNetId!"));
|
||||
return 0;
|
||||
@@ -189,7 +154,7 @@ FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId U
|
||||
{
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamPersonaName Had a bad UniqueNetId!"));
|
||||
return FString(TEXT(""));
|
||||
@@ -209,7 +174,7 @@ FString UAdvancedSteamFriendsLibrary::GetSteamPersonaName(const FBPUniqueNetId U
|
||||
FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FString SteamID64)
|
||||
{
|
||||
FBPUniqueNetId netId;
|
||||
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!(SteamID64.Len() > 0))
|
||||
{
|
||||
@@ -220,7 +185,7 @@ FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FStri
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
// Already does the conversion
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(SteamID64));
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(SteamID64));
|
||||
//FCString::Atoi64(*SteamID64));
|
||||
|
||||
netId.SetUniqueNetId(ValueID);
|
||||
@@ -231,10 +196,25 @@ FBPUniqueNetId UAdvancedSteamFriendsLibrary::CreateSteamIDFromString(const FStri
|
||||
return netId;
|
||||
}
|
||||
|
||||
FBPUniqueNetId UAdvancedSteamFriendsLibrary::GetLocalSteamIDFromSteam()
|
||||
{
|
||||
FBPUniqueNetId netId;
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
TSharedPtr<const FUniqueNetId> SteamID(new const FUniqueNetIdSteam2(SteamUser()->GetSteamID()));
|
||||
netId.SetUniqueNetId(SteamID);
|
||||
}
|
||||
#endif
|
||||
|
||||
return netId;
|
||||
}
|
||||
|
||||
bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId UniqueNetId, bool bRequireNameOnly)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("RequestSteamFriendInfo Had a bad UniqueNetId!"));
|
||||
return false;
|
||||
@@ -252,10 +232,46 @@ bool UAdvancedSteamFriendsLibrary::RequestSteamFriendInfo(const FBPUniqueNetId U
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool UAdvancedSteamFriendsLibrary::OpenSteamUserOverlay(const FBPUniqueNetId UniqueNetId, ESteamUserOverlayType DialogType)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Had a bad UniqueNetId!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
uint64 id = *((uint64*)UniqueNetId.UniqueNetId->GetBytes());
|
||||
FString DialogName = EnumToString("ESteamUserOverlayType", (uint8)DialogType);
|
||||
SteamFriends()->ActivateGameOverlayToUser(TCHAR_TO_ANSI(*DialogName), id);
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("OpenSteamUserOverlay Couldn't init steamAPI!"));
|
||||
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
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid())
|
||||
if (!UniqueNetId.IsValid() || !UniqueNetId.UniqueNetId->IsValid() || UniqueNetId.UniqueNetId->GetType() != STEAM_SUBSYSTEM)
|
||||
{
|
||||
UE_LOG(AdvancedSteamFriendsLog, Warning, TEXT("GetSteamFriendAvatar Had a bad UniqueNetId!"));
|
||||
Result = EBlueprintAsyncResultSwitch::OnFailure;
|
||||
@@ -325,7 +341,7 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN
|
||||
delete[] oAvatarRGBA;
|
||||
|
||||
//Setting some Parameters for the Texture and finally returning it
|
||||
Avatar->PlatformData->NumSlices = 1;
|
||||
Avatar->PlatformData->SetNumSlices(1);
|
||||
Avatar->NeverStream = true;
|
||||
//Avatar->CompressionSettings = TC_EditorIcon;
|
||||
|
||||
@@ -347,4 +363,77 @@ 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;
|
||||
}
|
||||
@@ -1,9 +1,13 @@
|
||||
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
|
||||
|
||||
#include "SteamRequestGroupOfficersCallbackProxy.h"
|
||||
#include "CoreOnline.h"
|
||||
#include "UObject/CoreOnline.h"
|
||||
#include "AdvancedSteamFriendsLibrary.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#include "OnlineSubsystemSteamTypes.h"
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
#include "steam/isteamfriends.h"
|
||||
#endif
|
||||
//#include "OnlineSubsystemSteamTypes.h"
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UEndSessionCallbackProxy
|
||||
@@ -41,15 +45,24 @@ void USteamRequestGroupOfficersCallbackProxy::Activate()
|
||||
OnFailure.Broadcast(EmptyArray);
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanOfficerListResponse_t *pResult, bool bIOFailure)
|
||||
{
|
||||
TArray<FBPSteamGroupOfficer> OfficerArray;
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
|
||||
FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
|
||||
|
||||
if (bIOFailure || !pResult || !pResult->m_bSuccess)
|
||||
{
|
||||
OnFailure.Broadcast(OfficerArray);
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([this]()
|
||||
{
|
||||
TArray<FBPSteamGroupOfficer> FailureArray;
|
||||
OnFailure.Broadcast(FailureArray);
|
||||
});
|
||||
}
|
||||
//OnFailure.Broadcast(OfficerArray);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,7 +75,7 @@ void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanO
|
||||
|
||||
Officer.bIsOwner = true;
|
||||
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam(ClanOwner));
|
||||
TSharedPtr<const FUniqueNetId> ValueID(new const FUniqueNetIdSteam2(ClanOwner));
|
||||
Officer.OfficerUniqueNetID.SetUniqueNetId(ValueID);
|
||||
OfficerArray.Add(Officer);
|
||||
|
||||
@@ -72,17 +85,37 @@ void USteamRequestGroupOfficersCallbackProxy::OnRequestGroupOfficerDetails(ClanO
|
||||
|
||||
Officer.bIsOwner = false;
|
||||
|
||||
TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam(OfficerSteamID));
|
||||
TSharedPtr<const FUniqueNetId> newValueID(new const FUniqueNetIdSteam2(OfficerSteamID));
|
||||
Officer.OfficerUniqueNetID.SetUniqueNetId(newValueID);
|
||||
|
||||
OfficerArray.Add(Officer);
|
||||
}
|
||||
|
||||
OnSuccess.Broadcast(OfficerArray);
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([OfficerArray, this]()
|
||||
{
|
||||
OnSuccess.Broadcast(OfficerArray);
|
||||
});
|
||||
}
|
||||
|
||||
//OnSuccess.Broadcast(OfficerArray);
|
||||
return;
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([this]()
|
||||
{
|
||||
TArray<FBPSteamGroupOfficer> FailureArray;
|
||||
OnFailure.Broadcast(FailureArray);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
OnFailure.Broadcast(OfficerArray);
|
||||
// Should never hit this anyway
|
||||
//OnFailure.Broadcast(OfficerArray);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -2,6 +2,9 @@
|
||||
|
||||
#include "SteamWSRequestUGCDetailsCallbackProxy.h"
|
||||
#include "OnlineSubSystemHeader.h"
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
#include "steam/isteamugc.h"
|
||||
#endif
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
// UEndSessionCallbackProxy
|
||||
@@ -46,26 +49,53 @@ void USteamWSRequestUGCDetailsCallbackProxy::Activate()
|
||||
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
}
|
||||
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
void USteamWSRequestUGCDetailsCallbackProxy::OnUGCRequestUGCDetails(SteamUGCQueryCompleted_t *pResult, bool bIOFailure)
|
||||
{
|
||||
#if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
|
||||
{
|
||||
FOnlineSubsystemSteam* SteamSubsystem = (FOnlineSubsystemSteam*)(IOnlineSubsystem::Get(STEAM_SUBSYSTEM));
|
||||
|
||||
if (bIOFailure || !pResult || pResult->m_unNumResultsReturned <= 0)
|
||||
{
|
||||
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
{
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([this]()
|
||||
{
|
||||
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
});
|
||||
}
|
||||
//OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
return;
|
||||
}
|
||||
if (SteamAPI_Init())
|
||||
{
|
||||
SteamUGCDetails_t Details;
|
||||
if (SteamUGC()->GetQueryUGCResult(pResult->m_handle, 0, &Details))
|
||||
{
|
||||
OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
|
||||
{
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([Details, this]()
|
||||
{
|
||||
OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
|
||||
});
|
||||
}
|
||||
|
||||
//OnSuccess.Broadcast(FBPSteamWorkshopItemDetails(Details));
|
||||
return;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
else
|
||||
{
|
||||
if (SteamSubsystem != nullptr)
|
||||
{
|
||||
SteamSubsystem->ExecuteNextTick([this]()
|
||||
{
|
||||
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
// Not needed, should never hit here
|
||||
//OnFailure.Broadcast(FBPSteamWorkshopItemDetails());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1 +1,7 @@
|
||||
Readme and documentation will be worked on soon
|
||||
### How do I use it? ###
|
||||
|
||||
**KantanDocGen Automatic Documentation ([KantanDocGen](http://kantandev.com/free/kantan-doc-gen))**
|
||||
|
||||
**[AdvancedSessions](https://vreue4.com/generated-node-documentation?section=advanced-sessions-plugin)**
|
||||
|
||||
**[AdvancedSteamSessions](https://vreue4.com/generated-node-documentation?section=advanced-steam-sessions-plugin)**
|
||||
|
||||
Reference in New Issue
Block a user