Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added compatibility for Linux platform #5

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions Source/DedicatedServer/DedicatedServer.Build.cs
Original file line number Diff line number Diff line change
@@ -1,16 +1,28 @@
// Copyright 2004-2016 YaS-Online, Inc. All Rights Reserved.

using System;
using System.IO;
using UnrealBuildTool;

public class DedicatedServer : ModuleRules
{
public DedicatedServer( ReadOnlyTargetRules Target ) : base( Target )
{
//PublicIncludePaths.AddRange( new string[] { "DedicatedServer/Public" } );
//PrivateIncludePaths.AddRange( new string[] { "DedicatedServer/Private" } );
//PublicIncludePaths.AddRange( new string[] { "DedicatedServer/Public" } );
//PrivateIncludePaths.AddRange( new string[] { "DedicatedServer/Private" } );
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved

PublicDependencyModuleNames.AddRange( new string[] { "Core", "ApplicationCore", "CoreUObject", "Engine", "InputCore", "HTTP", "Json", "OnlineSubsystem", "OnlineSubsystemSteam" } );
PrivatePCHHeaderFile = "Private/DedicatedServerPrivatePCH.h";

if (Target.Platform == UnrealTargetPlatform.Linux)
{
string IncludesPath = Path.Combine(ModuleDirectory, "../ThirdParty/pdcurses/include");
string LibrariesPath = Path.Combine(ModuleDirectory, "../ThirdParty/pdcurses/lib");
string LibrariesPathArch = String.Format(LibrariesPath + "/{0}", Target.Architecture);
PublicIncludePaths.Add(IncludesPath);
PublicAdditionalLibraries.Add(Path.Combine(LibrariesPathArch, "libpdcurses.a"));
}

PublicDependencyModuleNames.AddRange( new string[] { "Core", "ApplicationCore", "CoreUObject", "Engine", "InputCore", "HTTP", "Json", "OnlineSubsystem", "OnlineSubsystemSteam" } );
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved
PrivateDependencyModuleNames.AddRange( new string[] { } );
}
}
2 changes: 1 addition & 1 deletion Source/DedicatedServer/Private/DedicatedServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ void FDedicatedServerModule::ShutdownModule()
{
g_pConsole->SendNullInput();

m_hTick.Wait();
m_hTick.Reset(); // We want to stop the async task, because our module is being closed
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved
}
#endif
}
Expand Down
4 changes: 4 additions & 0 deletions Source/DedicatedServer/Private/DedicatedServerPrivatePCH.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,8 @@
#include "OnlineSubsystemSteam.h"

#include "ServerConsole.h"

#if PLATFORM_LINUX
#include "curses.h"
#endif
#endif
115 changes: 66 additions & 49 deletions Source/DedicatedServer/Private/ServerConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,41 +4,35 @@

DEFINE_LOG_CATEGORY( LogServerConsole );

// Fixme: We need to workaround a silly issue inside the engine where the help commands relies on Slate being present...
// See: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp#L3151
void DumpConsoleHelp()
{
#if !UE_BUILD_SHIPPING
UE_LOG( LogServerConsole, Display, TEXT( "\n" )
TEXT( "Console Help:" ) TEXT( "\n" )
TEXT( "=============" ) TEXT( "\n" )
TEXT( "\n" )
TEXT( "A console variable is a engine wide key value pair." ) TEXT( "\n" )
TEXT( "The key is a string usually starting with the subsystem prefix followed by '.' e.g. r.BloomQuality." ) TEXT( "\n" )
TEXT( "The value can be of different tpe (e.g. float, int, string)." ) TEXT( "\n" )
TEXT( "A console command has no state associated with and gets executed immediately." ) TEXT( "\n" )
TEXT( "\n" )
TEXT( "Console variables can be put into ini files (e.g. ConsoleVariables.ini or BaseEngine.ini) with this syntax:" ) TEXT( "\n" )
TEXT( "<Console variable> = <value>" ) TEXT( "\n" )
TEXT( "\n" )
TEXT( "DumpConsoleCommands Lists all console variables and commands that are registered (Some are not registered)" ) TEXT( "\n" )
TEXT( "<Console variable> Get the console variable state" ) TEXT( "\n" )
TEXT( "<Console variable> ? Get the console variable help text" ) TEXT( "\n" )
TEXT( "<Console variable> <value> Set the console variable value" ) TEXT( "\n" )
TEXT( "<Console command> [Params] Execute the console command with optional parameters" ) TEXT( "\n" )
);

FString FilePath = FPaths::ProjectSavedDir() + TEXT( "ConsoleHelp.html" );

UE_LOG( LogServerConsole, Display, TEXT( "\n" )
TEXT( "To browse console variables open this: '%s'" )
, *FilePath );

ConsoleCommandLibrary_DumpLibraryHTML( GEngine->GetWorld(), *GEngine, FilePath );
#endif
}

#if WITH_SERVER_CODE
// Fixme: We need to workaround a silly issue inside the engine where the help commands relies on Slate being present...
// See: https://github.com/EpicGames/UnrealEngine/blob/release/Engine/Source/Runtime/Engine/Private/UnrealEngine.cpp#L3151
void DumpConsoleHelp()
{
UE_LOG(LogEngine, Display, TEXT("Console Help:"));
UE_LOG(LogEngine, Display, TEXT("============="));
UE_LOG(LogEngine, Display, TEXT(" "));
UE_LOG(LogEngine, Display, TEXT("A console variable is a engine wide key value pair. The key is a string usually starting with the subsystem prefix followed"));
UE_LOG(LogEngine, Display, TEXT("by '.' e.g. r.BloomQuality. The value can be of different tpe (e.g. float, int, string). A console command has no state associated with"));
UE_LOG(LogEngine, Display, TEXT("and gets executed immediately."));
UE_LOG(LogEngine, Display, TEXT(" "));
UE_LOG(LogEngine, Display, TEXT("Console variables can be put into ini files (e.g. ConsoleVariables.ini or BaseEngine.ini) with this syntax:"));
UE_LOG(LogEngine, Display, TEXT("<Console variable> = <value>"));
UE_LOG(LogEngine, Display, TEXT(" "));
UE_LOG(LogEngine, Display, TEXT("DumpConsoleCommands Lists all console variables and commands that are registered (Some are not registered)"));
UE_LOG(LogEngine, Display, TEXT("<Console variable> Get the console variable state"));
UE_LOG(LogEngine, Display, TEXT("<Console variable> ? Get the console variable help text"));
UE_LOG(LogEngine, Display, TEXT("<Console variable> <value> Set the console variable value"));
UE_LOG(LogEngine, Display, TEXT("<Console command> [Params] Execute the console command with optional parameters"));

UE_LOG(LogEngine, Display, TEXT(" "));

FString FilePath = FPaths::ProjectSavedDir() + TEXT("ConsoleHelp.html");

UE_LOG(LogEngine, Display, TEXT("To browse console variables open this: '%s'"), *FilePath);
UE_LOG(LogEngine, Display, TEXT(" "));
}

#if PLATFORM_WINDOWS
#include "AllowWindowsPlatformTypes.h"

Expand Down Expand Up @@ -83,6 +77,14 @@ void DumpConsoleHelp()
}
#elif PLATFORM_MAC
#elif PLATFORM_LINUX
initscr();
noecho();
cbreak();
keypad( stdscr, TRUE );
scrollok( stdscr, TRUE );
start_color();
init_pair( 1, COLOR_GREEN, COLOR_BLACK );
SetCursorPosition( coords( LINES - 1, 0 ) );
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved
#else
#error You shall not pass!
#endif
Expand All @@ -98,29 +100,44 @@ void DumpConsoleHelp()
return m_pConsole->IsAttached();
}

void FServerConsole::Serialize( const TCHAR* sData, ELogVerbosity::Type eVerbosity, const class FName& sCategory, const double fTime )
{
FScopeLock hLock( &m_hLock );
#if PLATFORM_WINDOWS
void FServerConsole::Serialize( const TCHAR* sData, ELogVerbosity::Type eVerbosity, const class FName& sCategory, const double fTime )
{
FScopeLock hLock( &m_hLock );

#if PLATFORM_WINDOWS
COORD hCursorPosition = GetCursorPosition();
#endif
#if PLATFORM_WINDOWS
COORD hCursorPosition = GetCursorPosition();
#endif

ClearInputLine();
ClearInputLine();

m_pConsole->Serialize( sData, eVerbosity, sCategory, fTime );
m_pConsole->Serialize( sData, eVerbosity, sCategory, fTime );

RedrawInputLine();
RedrawInputLine();

#if PLATFORM_WINDOWS
hCursorPosition.Y = GetCursorPosition().Y;
#if PLATFORM_WINDOWS
hCursorPosition.Y = GetCursorPosition().Y;

SetCursorPosition( hCursorPosition );
#endif
}
SetCursorPosition( hCursorPosition );
#endif
}
#endif //PLATFORM_WINDOWS
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved

void FServerConsole::Serialize( const TCHAR* sData, ELogVerbosity::Type eVerbosity, const class FName& sCategory )
{
#if PLATFORM_WINDOWS
Serialize( sData, eVerbosity, sCategory, -1.0 );
#elif PLATFORM_LINUX
//coords hCursorPosition = GetCursorPosition();

ClearInputLine();

m_pConsole->Serialize( sData, eVerbosity, sCategory );

RedrawInputLine();

/*hCursorPosition.Y = GetCursorPosition().Y;
SetCursorPosition( hCursorPosition );*/
#endif //PLATFORM_WINDOWS
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved
}
#endif
#endif //WITH_SERVER_CODE
Scienziatogm marked this conversation as resolved.
Show resolved Hide resolved
Loading