Lesson 55 working properly now
This commit is contained in:
@@ -1,58 +0,0 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "ShooterGameModeBase.h"
|
||||
#include "ShooterGameMode.generated.h"
|
||||
|
||||
DECLARE_LOG_CATEGORY_EXTERN(LogShooterGameMode, Log, All);
|
||||
|
||||
struct FProcessParameters;
|
||||
struct FServerParameters;
|
||||
|
||||
struct FGameLiftConfig
|
||||
{
|
||||
bool bIsAnywhereFleet = false;
|
||||
bool bAllOptionsFound = false;
|
||||
|
||||
int32 ServerPort = 7777;
|
||||
|
||||
cmdlineparser::details::FParseResult AuthTokenResult;
|
||||
cmdlineparser::details::FParseResult FleetIdResult;
|
||||
cmdlineparser::details::FParseResult HostIdResult;
|
||||
cmdlineparser::details::FParseResult WebSocketUrlResult;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API AShooterGameMode : public AShooterGameModeBase
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
AShooterGameMode();
|
||||
|
||||
protected:
|
||||
virtual void BeginPlay() override;
|
||||
virtual void InitGame(const FString& MapName, const FString& Options, FString& ErrorMessage) override;
|
||||
|
||||
private:
|
||||
FGameLiftConfig GameLiftConfig;
|
||||
FString CachedCommandLine;
|
||||
|
||||
static FString GetSHA256Hash(const FString& CommandLineString);
|
||||
void InitGameLift();
|
||||
|
||||
bool GetAnywhereFleetParameters(const FString& CommandLineString);
|
||||
void LogAnywhereFleetParameters();
|
||||
#if WITH_GAMELIFT
|
||||
static void LogServerParameters(const FServerParameters& InServerParameters);
|
||||
#endif
|
||||
static FString GetValueOrHash(const FString& Value);
|
||||
|
||||
TSharedPtr<FProcessParameters> ProcessParameters;
|
||||
};
|
||||
@@ -3,14 +3,14 @@
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/GameMode.h"
|
||||
#include "DedicatedServers/Public/Game/DS_GameMode.h"
|
||||
#include "ShooterGameModeBase.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class FPSTEMPLATE_API AShooterGameModeBase : public AGameMode
|
||||
class FPSTEMPLATE_API AShooterGameModeBase : public ADS_GameMode
|
||||
{
|
||||
GENERATED_BODY()
|
||||
public:
|
||||
|
||||
@@ -1,30 +0,0 @@
|
||||
#pragma once
|
||||
#include "GameLiftClpTypes.h"
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
struct FPortResult
|
||||
{
|
||||
int32 Port;
|
||||
bool bUsedDefaultPort;
|
||||
FString WarningMessage;
|
||||
};
|
||||
|
||||
namespace cmdlineparser
|
||||
{
|
||||
FPortResult GetConfiguredOrDefaultPort(const FString& Token = TEXT("port="));
|
||||
FPortResult GetConfiguredOrDefaultPort(const FString& CommandLine, const FString& Token = TEXT("port="));
|
||||
|
||||
details::FParseResult GetValueOfToken(const FString& CommandLine, const details::EAvailableTokens Token);
|
||||
}
|
||||
|
||||
namespace cmdlineparser::details
|
||||
{
|
||||
inline static constexpr int32 MIN_PORT = 1024;
|
||||
inline static constexpr int32 MAX_PORT = 65535;
|
||||
inline static constexpr const TCHAR* DEFAULT_PORT_TOKEN = TEXT("port=");
|
||||
|
||||
FString EnsureEndsWith(const FString& Token, const TCHAR* Suffix);
|
||||
FPortResult GetConfiguredOrDefaultPort(const FString& CommandLine, const FString& Token);
|
||||
bool DoesRegExMatch(const FString& Text, const FString& Pattern);
|
||||
}
|
||||
|
||||
@@ -1,37 +0,0 @@
|
||||
#pragma once
|
||||
|
||||
namespace cmdlineparser::details
|
||||
{
|
||||
enum EAvailableTokens
|
||||
{
|
||||
Unknown = 0,
|
||||
AuthToken,
|
||||
HostId,
|
||||
FleetId,
|
||||
WebsocketUrl,
|
||||
MaxToken
|
||||
};
|
||||
|
||||
enum EErrorCodes
|
||||
{
|
||||
NoError,
|
||||
TokenNotFound,
|
||||
ValueEmpty,
|
||||
FailedValidation,
|
||||
MaxCode
|
||||
};
|
||||
|
||||
extern const TArray<FString>& ERROR_MESSAGES;
|
||||
extern const TArray<FString>& CLI_TOKENS;
|
||||
extern const TArray<FString>& REGEX_PATTERNS;
|
||||
|
||||
struct FParseResult
|
||||
{
|
||||
EAvailableTokens Token = EAvailableTokens::Unknown;
|
||||
FString Value = FString();
|
||||
bool bIsValid = false;
|
||||
EErrorCodes ErrorCode = EErrorCodes::TokenNotFound;
|
||||
FString ErrorMessage = FString();
|
||||
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user