Updated GetConfiguredOrDefaultPort()
This commit is contained in:
@@ -32,7 +32,7 @@ namespace GameLiftValidators {
|
|||||||
const int32 WebSocketPortMin = 1;
|
const int32 WebSocketPortMin = 1;
|
||||||
const int32 WebSocketPortMax = 60000;
|
const int32 WebSocketPortMax = 60000;
|
||||||
|
|
||||||
bool ValidateString(const FString& Value, const FRegexPattern* OptionalPattern, const int32 Min, const int32 Max)
|
bool IsStringValid(const FString& Value, const FRegexPattern* OptionalPattern, const int32 Min, const int32 Max)
|
||||||
{
|
{
|
||||||
if (Value.IsEmpty()) return false;
|
if (Value.IsEmpty()) return false;
|
||||||
|
|
||||||
@@ -48,7 +48,7 @@ namespace GameLiftValidators {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ValidateNumber(const int32 Value, const int32 Min, const int32 Max)
|
bool IsNumberValid(const int32 Value, const int32 Min, const int32 Max)
|
||||||
{
|
{
|
||||||
return Value >= Min && Value <= Max;
|
return Value >= Min && Value <= Max;
|
||||||
}
|
}
|
||||||
@@ -76,7 +76,6 @@ void AShooterGameMode::InitGame(const FString& MapName, const FString& Options,
|
|||||||
CachedCommandLine = FCommandLine::Get();
|
CachedCommandLine = FCommandLine::Get();
|
||||||
|
|
||||||
// Parsing of Command Line
|
// Parsing of Command Line
|
||||||
bDebugMode = FParse::Param(*CachedCommandLine, TEXT("Debug"));
|
|
||||||
GameLiftConfig.bDebugMode = FParse::Param(*CachedCommandLine, TEXT("Debug"));
|
GameLiftConfig.bDebugMode = FParse::Param(*CachedCommandLine, TEXT("Debug"));
|
||||||
|
|
||||||
if (GameLiftConfig.bDebugMode)
|
if (GameLiftConfig.bDebugMode)
|
||||||
@@ -256,22 +255,20 @@ void AShooterGameMode::InitGame_original(const FString& MapName, const FString&
|
|||||||
int32 AShooterGameMode::GetConfiguredOrDefaultPort() const
|
int32 AShooterGameMode::GetConfiguredOrDefaultPort() const
|
||||||
{
|
{
|
||||||
// Default Unreal Engine listen/dedicated server port
|
// Default Unreal Engine listen/dedicated server port
|
||||||
int32 Port = 7777;
|
constexpr int32 DefaultPort = 7777;
|
||||||
|
|
||||||
|
int32 CmdPort = DefaultPort;
|
||||||
|
|
||||||
// Check if a port was passed via command line: -port=xxxx
|
// Check if a port was passed via command line: -port=xxxx
|
||||||
int32 CmdPort = 0;
|
|
||||||
if (FParse::Value(*CachedCommandLine, TEXT("port="), CmdPort))
|
if (FParse::Value(*CachedCommandLine, TEXT("port="), CmdPort) &&
|
||||||
|
GameLiftValidators::IsNumberValid(CmdPort, GameLiftValidators::ServerPortMin, GameLiftValidators::ServerPortMax))
|
||||||
{
|
{
|
||||||
if (CmdPort > 1024 && CmdPort <= 65535)
|
return CmdPort;
|
||||||
{
|
|
||||||
Port = CmdPort;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
Port = 0;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return Port;
|
|
||||||
|
UE_LOGFMT(LogShooterGameMode, Warning, "Invalid/Missing port in command line - using {0}", DefaultPort);
|
||||||
|
return DefaultPort;
|
||||||
}
|
}
|
||||||
|
|
||||||
FString AShooterGameMode::GetSHA256Hash(const FString& Input)
|
FString AShooterGameMode::GetSHA256Hash(const FString& Input)
|
||||||
|
|||||||
@@ -50,8 +50,8 @@ namespace GameLiftValidators
|
|||||||
extern const int32 WebSocketPortMin;
|
extern const int32 WebSocketPortMin;
|
||||||
extern const int32 WebSocketPortMax;
|
extern const int32 WebSocketPortMax;
|
||||||
|
|
||||||
bool ValidateString(const FString& Value, const FRegexPattern& OptionalPattern, int32 Min, int32 Max);
|
bool IsStringValid(const FString& Value, const FRegexPattern& OptionalPattern, int32 Min, int32 Max);
|
||||||
bool ValidateNumber(int32 Value, int32 Min, int32 Max);
|
bool IsNumberValid(int32 Value, int32 Min, int32 Max);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user