Skip to content

Commit

Permalink
Alternate define lets us manually turn on GSDK for client-cmd builds …
Browse files Browse the repository at this point in the history
…via 1 line code change (#97)

This is mostly an internal testing condition that's not relevant to customers.
  • Loading branch information
pgilmorepf committed Oct 27, 2021
1 parent 4520dc9 commit 89ab63b
Showing 1 changed file with 18 additions and 10 deletions.
28 changes: 18 additions & 10 deletions UnrealPlugin/Source/PlayfabGSDK/Private/PlayfabGSDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@

#include "PlayFabGSDK.h"

#include "GSDKConfiguration.h"
#if UE_SERVER
#define PLAYFAB_GSDK_SERVER true
#else
#define PLAYFAB_GSDK_SERVER false
#endif



#include "GSDKConfiguration.h"
#if PLAYFAB_GSDK_SERVER
#include "GSDKUtils.h"
#include "Misc/ScopeLock.h"
#endif
Expand All @@ -26,7 +34,7 @@ DEFINE_LOG_CATEGORY(LogPlayFabGSDK);

void FPlayFabGSDKModule::StartupModule()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
GSDKInternal = new FGSDKInternal();

GSDKInternal->OnShutdown.BindLambda([this]()
Expand Down Expand Up @@ -57,7 +65,7 @@ void FPlayFabGSDKModule::StartupModule()

void FPlayFabGSDKModule::ShutdownModule()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
if (GSDKInternal)
{
delete GSDKInternal;
Expand All @@ -68,7 +76,7 @@ void FPlayFabGSDKModule::ShutdownModule()

bool FPlayFabGSDKModule::ReadyForPlayers()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
if (GSDKInternal->GetHeartbeatRequest().CurrentGameState != EGameState::Active)
{
GSDKInternal->SetState(EGameState::StandingBy);
Expand All @@ -83,7 +91,7 @@ bool FPlayFabGSDKModule::ReadyForPlayers()

const FGameServerConnectionInfo FPlayFabGSDKModule::GetGameServerConnectionInfo()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
return GSDKInternal->GetConnectionInfo();
#else
return FGameServerConnectionInfo();
Expand All @@ -92,7 +100,7 @@ const FGameServerConnectionInfo FPlayFabGSDKModule::GetGameServerConnectionInfo(

FString FPlayFabGSDKModule::GetConfigValue(const FString& Key)
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
return GSDKInternal->GetConfigValue(Key);
#else
return TEXT("");
Expand All @@ -101,22 +109,22 @@ FString FPlayFabGSDKModule::GetConfigValue(const FString& Key)

void FPlayFabGSDKModule::UpdateConnectedPlayers(const TArray<FConnectedPlayer>& CurrentlyConnectedPlayers)
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
GSDKInternal->SetConnectedPlayers(CurrentlyConnectedPlayers);
#endif
}

const FString FPlayFabGSDKModule::GetLogsDirectory()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
return GSDKInternal->GetConfigValue(LOG_FOLDER_KEY);
#endif
return TEXT("");
}

const FString FPlayFabGSDKModule::GetSharedContentDirectory()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
return GSDKInternal->GetConfigValue(SHARED_CONTENT_FOLDER_KEY);
#endif

Expand All @@ -125,7 +133,7 @@ const FString FPlayFabGSDKModule::GetSharedContentDirectory()

const TArray<FString> FPlayFabGSDKModule::GetInitialPlayers()
{
#if UE_SERVER
#if PLAYFAB_GSDK_SERVER
return GSDKInternal->GetInitialPlayers();
#else
return TArray<FString>();
Expand Down

0 comments on commit 89ab63b

Please sign in to comment.