mirror of
https://github.com/mordentral/AdvancedSessionsPlugin.git
synced 2025-10-25 09:24:18 +00:00
Compare commits
7 Commits
4.23_Locke
...
4.24_Locke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
707c055f49 | ||
|
|
aee6c013d6 | ||
|
|
064c1a989d | ||
|
|
6b315302e2 | ||
|
|
2216aaf041 | ||
|
|
192307b542 | ||
|
|
51cf0acb2e |
10
.gitignore
vendored
Normal file
10
.gitignore
vendored
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
.hg/
|
||||||
|
binaries/
|
||||||
|
deriveddatacache/
|
||||||
|
.vs/
|
||||||
|
build/
|
||||||
|
intermediate/
|
||||||
|
PACKPLUGIN/
|
||||||
|
saved/
|
||||||
|
*.orig
|
||||||
@@ -2,8 +2,8 @@
|
|||||||
"FileVersion" : 3,
|
"FileVersion" : 3,
|
||||||
|
|
||||||
"FriendlyName" : "Advanced Sessions",
|
"FriendlyName" : "Advanced Sessions",
|
||||||
"Version" : 4.23,
|
"Version" : 4.24,
|
||||||
"VersionName": "4.23",
|
"VersionName": "4.24",
|
||||||
"Description" : "Adds new blueprint functions to handle more advanced session operations.",
|
"Description" : "Adds new blueprint functions to handle more advanced session operations.",
|
||||||
"Category" : "Advanced Sessions Plugin",
|
"Category" : "Advanced Sessions Plugin",
|
||||||
"CreatedBy" : "Joshua Statzer",
|
"CreatedBy" : "Joshua Statzer",
|
||||||
|
|||||||
@@ -0,0 +1,70 @@
|
|||||||
|
// 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 "UObjectIterator.h"
|
||||||
|
|
||||||
|
#include "AdvancedGameSession.generated.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
A quick wrapper around the game session to add a partial ban implementation. Just bans for the duration of the current session
|
||||||
|
*/
|
||||||
|
UCLASS(config = Game, notplaceable)
|
||||||
|
class AAdvancedGameSession : public AGameSession
|
||||||
|
{
|
||||||
|
GENERATED_UCLASS_BODY()
|
||||||
|
|
||||||
|
public:
|
||||||
|
|
||||||
|
UPROPERTY(Transient)
|
||||||
|
TMap<FUniqueNetIdRepl, FText> BanList;
|
||||||
|
|
||||||
|
virtual bool BanPlayer(class APlayerController* BannedPlayer, const FText& BanReason)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (APlayerState* PlayerState = (BannedPlayer != NULL) ? BannedPlayer->PlayerState : NULL)
|
||||||
|
{
|
||||||
|
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
|
||||||
|
bool bWasKicked = KickPlayer(BannedPlayer, BanReason);
|
||||||
|
|
||||||
|
if (bWasKicked)
|
||||||
|
{
|
||||||
|
BanList.Add(UniqueNetID, BanReason);
|
||||||
|
}
|
||||||
|
|
||||||
|
return bWasKicked;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should really be handled in the game mode asking game session, but I didn't want to force a custom game session AND game mode
|
||||||
|
// If done in the game mode, we could check prior to actually spooling up any player information in ApproveLogin
|
||||||
|
virtual void PostLogin(APlayerController* NewPlayer) override
|
||||||
|
{
|
||||||
|
if (APlayerState* PlayerState = (NewPlayer != NULL) ? NewPlayer->PlayerState : NULL)
|
||||||
|
{
|
||||||
|
FUniqueNetIdRepl UniqueNetID = PlayerState->GetUniqueId();
|
||||||
|
|
||||||
|
if (BanList.Contains(UniqueNetID))
|
||||||
|
{
|
||||||
|
KickPlayer(NewPlayer, BanList[UniqueNetID]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
AAdvancedGameSession::AAdvancedGameSession(const FObjectInitializer& ObjectInitializer)
|
||||||
|
: Super(ObjectInitializer)
|
||||||
|
{
|
||||||
|
}
|
||||||
@@ -14,6 +14,9 @@
|
|||||||
#include "Engine/GameInstance.h"
|
#include "Engine/GameInstance.h"
|
||||||
#include "Interfaces/OnlineSessionInterface.h"
|
#include "Interfaces/OnlineSessionInterface.h"
|
||||||
|
|
||||||
|
#include "GameFramework/GameModeBase.h"
|
||||||
|
#include "GameFramework/GameSession.h"
|
||||||
|
|
||||||
//#include "UObjectIterator.h"
|
//#include "UObjectIterator.h"
|
||||||
|
|
||||||
#include "AdvancedSessionsLibrary.generated.h"
|
#include "AdvancedSessionsLibrary.generated.h"
|
||||||
@@ -28,6 +31,17 @@ class UAdvancedSessionsLibrary : public UBlueprintFunctionLibrary
|
|||||||
{
|
{
|
||||||
GENERATED_BODY()
|
GENERATED_BODY()
|
||||||
public:
|
public:
|
||||||
|
//********* Session Admin Functions *************//
|
||||||
|
|
||||||
|
// Kick a player from the currently active game session, only available on the server
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
|
||||||
|
static bool KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason);
|
||||||
|
|
||||||
|
// Ban a player from the currently active game session, only available on the server
|
||||||
|
// Note that the default gamesession class does not implement an actual ban list and just kicks when this is called
|
||||||
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions", meta = (WorldContext = "WorldContextObject"))
|
||||||
|
static bool BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason);
|
||||||
|
|
||||||
//********* Session Search Functions *************//
|
//********* Session Search Functions *************//
|
||||||
|
|
||||||
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
// Adds or modifies session settings in an existing array depending on if they exist already or not
|
||||||
@@ -101,6 +115,7 @@ public:
|
|||||||
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
|
static void GetSessionPropertyByte(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, uint8 &SettingValue);
|
||||||
|
|
||||||
// Get session custom information key/value as Bool
|
// 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"))
|
UFUNCTION(BlueprintCallable, Category = "Online|AdvancedSessions|SessionInfo", meta = (ExpandEnumAsExecs = "SearchResult"))
|
||||||
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
|
static void GetSessionPropertyBool(const TArray<FSessionPropertyKeyPair> & ExtraSettings, FName SettingName, ESessionSettingSearchResult &SearchResult, bool &SettingValue);
|
||||||
|
|
||||||
@@ -122,6 +137,7 @@ public:
|
|||||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
|
static FSessionPropertyKeyPair MakeLiteralSessionPropertyByte(FName Key, uint8 Value);
|
||||||
|
|
||||||
// Make a literal session custom information key/value pair from Bool
|
// 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")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|SessionInfo|Literals")
|
||||||
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
|
static FSessionPropertyKeyPair MakeLiteralSessionPropertyBool(FName Key, bool Value);
|
||||||
|
|
||||||
@@ -183,6 +199,12 @@ public:
|
|||||||
// Checks if the stated session subsystem is active
|
// Checks if the stated session subsystem is active
|
||||||
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
UFUNCTION(BlueprintPure, Category = "Online|AdvancedSessions|Misc")
|
||||||
static bool HasOnlineSubsystem(FName SubSystemName);
|
static bool HasOnlineSubsystem(FName SubSystemName);
|
||||||
|
|
||||||
|
//**** Seamless travel Functions ****//
|
||||||
|
|
||||||
|
//Exposes Server travel to blueprint
|
||||||
|
UFUNCTION(BlueprintCallable, BlueprintAuthorityOnly, Category = "Online|AdvancedSessions|Seamless", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
||||||
|
static bool ServerTravel(UObject* WorldContextObject, const FString& InURL, bool bAbsolute, bool bShouldSkipGameNotify);
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -6,6 +6,43 @@
|
|||||||
//General Log
|
//General Log
|
||||||
DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
|
DEFINE_LOG_CATEGORY(AdvancedSessionsLog);
|
||||||
|
|
||||||
|
|
||||||
|
bool UAdvancedSessionsLibrary::KickPlayer(UObject* WorldContextObject, APlayerController* PlayerToKick, FText KickReason)
|
||||||
|
{
|
||||||
|
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||||
|
|
||||||
|
if (World)
|
||||||
|
{
|
||||||
|
if (AGameModeBase* GameMode = World->GetAuthGameMode())
|
||||||
|
{
|
||||||
|
if (GameMode->GameSession)
|
||||||
|
{
|
||||||
|
return GameMode->GameSession->KickPlayer(PlayerToKick, KickReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSessionsLibrary::BanPlayer(UObject* WorldContextObject, APlayerController* PlayerToBan, FText BanReason)
|
||||||
|
{
|
||||||
|
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::LogAndReturnNull);
|
||||||
|
|
||||||
|
if (World)
|
||||||
|
{
|
||||||
|
if (AGameModeBase* GameMode = World->GetAuthGameMode())
|
||||||
|
{
|
||||||
|
if (GameMode->GameSession)
|
||||||
|
{
|
||||||
|
return GameMode->GameSession->BanPlayer(PlayerToBan, BanReason);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
|
bool UAdvancedSessionsLibrary::IsValidSession(const FBlueprintSessionResult & SessionResult)
|
||||||
{
|
{
|
||||||
return SessionResult.OnlineResult.IsValid();
|
return SessionResult.OnlineResult.IsValid();
|
||||||
@@ -491,3 +528,14 @@ void UAdvancedSessionsLibrary::GetNumberOfNetworkPlayers(UObject* WorldContextOb
|
|||||||
|
|
||||||
NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
|
NumNetPlayers = TheWorld->GetGameState()->PlayerArray.Num();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool UAdvancedSessionsLibrary::ServerTravel(UObject* WorldContextObject, const FString& FURL, bool bAbsolute, bool bShouldSkipGameNotify)
|
||||||
|
{
|
||||||
|
if (!WorldContextObject) return false;
|
||||||
|
|
||||||
|
//using a context object to get the world
|
||||||
|
UWorld* const World = GEngine->GetWorldFromContextObject(WorldContextObject, EGetWorldErrorMode::ReturnNull);
|
||||||
|
if (!World) return false;
|
||||||
|
World->ServerTravel(FURL,bAbsolute,bShouldSkipGameNotify);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
"FileVersion" : 3,
|
"FileVersion" : 3,
|
||||||
|
|
||||||
"FriendlyName" : "Advanced Steam Sessions",
|
"FriendlyName" : "Advanced Steam Sessions",
|
||||||
"Version" : 4.23,
|
"Version" : 4.24,
|
||||||
"VersionName": "4.23",
|
"VersionName": "4.24",
|
||||||
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
"Description" : "Adds new blueprint functions to handle more advanced session operations in Steam. REQUIRES ADVANCED SESSIONS",
|
||||||
"Category" : "Advanced Sessions Plugin",
|
"Category" : "Advanced Sessions Plugin",
|
||||||
"CreatedBy" : "Joshua Statzer",
|
"CreatedBy" : "Joshua Statzer",
|
||||||
|
|||||||
@@ -242,6 +242,7 @@ DECLARE_LOG_CATEGORY_EXTERN(AdvancedSteamFriendsLog, Log, All);
|
|||||||
UENUM(Blueprintable)
|
UENUM(Blueprintable)
|
||||||
enum class SteamAvatarSize : uint8
|
enum class SteamAvatarSize : uint8
|
||||||
{
|
{
|
||||||
|
SteamAvatar_INVALID = 0,
|
||||||
SteamAvatar_Small = 1,
|
SteamAvatar_Small = 1,
|
||||||
SteamAvatar_Medium = 2,
|
SteamAvatar_Medium = 2,
|
||||||
SteamAvatar_Large = 3
|
SteamAvatar_Large = 3
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ public:
|
|||||||
UENUM(BlueprintType)
|
UENUM(BlueprintType)
|
||||||
enum class FBPSteamResult : uint8
|
enum class FBPSteamResult : uint8
|
||||||
{
|
{
|
||||||
|
K_EResultInvalid = 0,
|
||||||
k_EResultOK = 1, // success
|
k_EResultOK = 1, // success
|
||||||
k_EResultFail = 2, // generic failure
|
k_EResultFail = 2, // generic failure
|
||||||
k_EResultNoConnection = 3, // no/failed network connection
|
k_EResultNoConnection = 3, // no/failed network connection
|
||||||
|
|||||||
@@ -328,7 +328,7 @@ UTexture2D * UAdvancedSteamFriendsLibrary::GetSteamFriendAvatar(const FBPUniqueN
|
|||||||
delete[] oAvatarRGBA;
|
delete[] oAvatarRGBA;
|
||||||
|
|
||||||
//Setting some Parameters for the Texture and finally returning it
|
//Setting some Parameters for the Texture and finally returning it
|
||||||
Avatar->PlatformData->NumSlices = 1;
|
Avatar->PlatformData->SetNumSlices(1);
|
||||||
Avatar->NeverStream = true;
|
Avatar->NeverStream = true;
|
||||||
//Avatar->CompressionSettings = TC_EditorIcon;
|
//Avatar->CompressionSettings = TC_EditorIcon;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user