2014-12-07 19:09:38 -05:00
// Copyright 1998-2015 Epic Games, Inc. All Rights Reserved.
2014-03-14 14:13:41 -04:00
# include "LaunchPrivatePCH.h"
# include "Internationalization/Internationalization.h"
# include "Ticker.h"
# include "ConsoleManager.h"
# include "ExceptionHandling.h"
# include "FileManagerGeneric.h"
# include "TaskGraphInterfaces.h"
2015-04-14 05:21:25 -04:00
# include "StatsMallocProfilerProxy.h"
2014-06-20 13:02:34 -04:00
# include "Runtime/Core/Public/Modules/ModuleVersion.h"
2014-03-14 14:13:41 -04:00
# include "Projects.h"
# include "UProjectInfo.h"
# include "EngineVersion.h"
2014-10-30 10:07:51 -04:00
# include "ModuleManager.h"
2014-03-14 14:13:41 -04:00
# if WITH_EDITOR
# include "EditorStyle.h"
# include "AutomationController.h"
# include "ProfilerClient.h"
# include "RemoteConfigIni.h"
2014-11-17 15:04:07 -05:00
# include "EditorCommandLineUtils.h"
2014-03-14 14:13:41 -04:00
# if PLATFORM_WINDOWS
# include "AllowWindowsPlatformTypes.h"
# include <objbase.h>
# include "HideWindowsPlatformTypes.h"
# endif
# endif
# if WITH_ENGINE
# include "Database.h"
# include "DerivedDataCacheInterface.h"
# include "RenderCore.h"
# include "ShaderCompiler.h"
2015-02-25 08:13:48 -05:00
# include "ShaderCache.h"
2014-08-28 13:54:31 -04:00
# include "DistanceFieldAtlas.h"
2014-03-14 14:13:41 -04:00
# include "GlobalShader.h"
# include "ParticleHelper.h"
# include "Online.h"
2014-05-29 17:36:51 -04:00
# include "PhysicsPublic.h"
2014-03-14 14:13:41 -04:00
# include "PlatformFeatures.h"
2014-05-29 17:11:10 -04:00
# include "DeviceProfiles/DeviceProfileManager.h"
2014-05-29 17:15:00 -04:00
# include "Commandlets/Commandlet.h"
2014-06-18 07:25:31 -04:00
# include "EngineService.h"
# include "ContentStreaming.h"
2014-08-13 06:12:21 -04:00
# include "HighResScreenshot.h"
2014-09-05 12:46:22 -04:00
# include "HotReloadInterface.h"
2014-12-12 17:38:18 -05:00
# include "ISessionService.h"
# include "ISessionServicesModule.h"
2015-02-23 15:58:14 -05:00
# include "Engine/GameInstance.h"
2014-05-29 17:15:00 -04:00
2014-03-14 14:13:41 -04:00
# if !UE_SERVER
2014-08-28 13:49:44 -04:00
# include "HeadMountedDisplay.h"
2014-06-09 14:36:21 -04:00
# include "ISlateRHIRendererModule.h"
2014-11-05 13:10:54 -05:00
# include "EngineFontServices.h"
2014-03-14 14:13:41 -04:00
# endif
# include "MoviePlayer.h"
# if !UE_BUILD_SHIPPING
# include "STaskGraph.h"
# include "ProfilerService.h"
# endif
# if WITH_AUTOMATION_WORKER
# include "AutomationWorker.h"
# endif
/**
* Function to free up the resources in GPrevPerBoneMotionBlur
* Should only be called at application exit
*/
ENGINE_API void MotionBlur_Free ( ) ;
# endif //WITH_ENGINE
# if WITH_EDITOR
# include "FeedbackContextEditor.h"
static FFeedbackContextEditor UnrealEdWarn ;
# endif // WITH_EDITOR
2014-05-14 20:01:43 -04:00
# if UE_EDITOR
# include "DesktopPlatformModule.h"
# endif
2014-03-14 14:13:41 -04:00
# define LOCTEXT_NAMESPACE "LaunchEngineLoop"
# if PLATFORM_WINDOWS
# include "AllowWindowsPlatformTypes.h"
# include <ObjBase.h>
# include "HideWindowsPlatformTypes.h"
# endif
2014-10-14 10:29:46 -04:00
# if ENABLE_VISUAL_LOG
# include "VisualLogger / VisualLogger.h"
# endif
2014-03-14 14:13:41 -04:00
// Pipe output to std output
// This enables UBT to collect the output for it's own use
class FOutputDeviceStdOutput : public FOutputDevice
{
public :
FOutputDeviceStdOutput ( )
{
bAllowLogVerbosity = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " AllowStdOutLogVerbosity " ) ) ;
}
virtual ~ FOutputDeviceStdOutput ( )
{
}
2014-06-13 06:14:46 -04:00
virtual void Serialize ( const TCHAR * V , ELogVerbosity : : Type Verbosity , const class FName & Category ) override
2014-03-14 14:13:41 -04:00
{
if ( ( bAllowLogVerbosity & & Verbosity < = ELogVerbosity : : Log ) | | ( Verbosity < = ELogVerbosity : : Display ) )
{
# if PLATFORM_USE_LS_SPEC_FOR_WIDECHAR
printf ( " \n %ls " , * FOutputDevice : : FormatLogLine ( Verbosity , Category , V , GPrintLogTimes ) ) ;
# else
wprintf ( TEXT ( " \n %s " ) , * FOutputDevice : : FormatLogLine ( Verbosity , Category , V , GPrintLogTimes ) ) ;
# endif
fflush ( stdout ) ;
}
}
private :
bool bAllowLogVerbosity ;
} ;
2014-05-09 13:52:29 -04:00
// Exits the game/editor if any of the specified phrases appears in the log output
class FOutputDeviceTestExit : public FOutputDevice
{
TArray < FString > ExitPhrases ;
public :
FOutputDeviceTestExit ( const TArray < FString > & InExitPhrases )
: ExitPhrases ( InExitPhrases )
{
}
virtual ~ FOutputDeviceTestExit ( )
{
}
2014-06-13 06:14:46 -04:00
virtual void Serialize ( const TCHAR * V , ELogVerbosity : : Type Verbosity , const class FName & Category ) override
2014-05-09 13:52:29 -04:00
{
if ( ! GIsRequestingExit )
{
for ( auto & Phrase : ExitPhrases )
{
if ( FCString : : Stristr ( V , * Phrase ) & & ! FCString : : Stristr ( V , TEXT ( " -testexit= " ) ) )
{
2014-05-09 14:17:38 -04:00
# if WITH_ENGINE
2014-05-09 13:52:29 -04:00
if ( GEngine ! = NULL )
{
if ( GIsEditor )
{
GEngine - > DeferredCommands . Add ( TEXT ( " CLOSE_SLATE_MAINFRAME " ) ) ;
}
else
{
GEngine - > Exec ( NULL , TEXT ( " QUIT " ) ) ;
}
}
2014-05-09 14:17:38 -04:00
# else
FPlatformMisc : : RequestExit ( true ) ;
# endif
2014-05-09 13:52:29 -04:00
break ;
}
}
}
}
} ;
2014-03-14 14:13:41 -04:00
static TScopedPointer < FOutputDeviceConsole > GScopedLogConsole ;
static TScopedPointer < FOutputDeviceStdOutput > GScopedStdOut ;
2014-05-09 13:52:29 -04:00
static TScopedPointer < FOutputDeviceTestExit > GScopedTestExit ;
2014-03-14 14:13:41 -04:00
2014-04-23 17:47:30 -04:00
/**
* Initializes std out device and adds it to GLog
* */
void InitializeStdOutDevice ( )
{
// Check if something is trying to initialize std out device twice.
check ( ! GScopedStdOut . IsValid ( ) ) ;
GScopedStdOut = new FOutputDeviceStdOutput ( ) ;
GLog - > AddOutputDevice ( GScopedStdOut . GetOwnedPointer ( ) ) ;
}
2014-03-14 14:13:41 -04:00
bool ParseGameProjectFromCommandLine ( const TCHAR * InCmdLine , FString & OutProjectFilePath , FString & OutGameName )
{
const TCHAR * CmdLine = InCmdLine ;
FString FirstCommandLineToken = FParse : : Token ( CmdLine , 0 ) ;
// trim any whitespace at edges of string - this can happen if the token was quoted with leading or trailing whitespace
// VC++ tends to do this in its "external tools" config
FirstCommandLineToken = FirstCommandLineToken . Trim ( ) ;
//
OutProjectFilePath = TEXT ( " " ) ;
OutGameName = TEXT ( " " ) ;
if ( FirstCommandLineToken . Len ( ) & & ! FirstCommandLineToken . StartsWith ( TEXT ( " - " ) ) )
{
// The first command line argument could be the project file if it exists or the game name if not launching with a project file
const FString ProjectFilePath = FString ( FirstCommandLineToken ) ;
2014-09-08 13:51:36 -04:00
if ( FPaths : : GetExtension ( ProjectFilePath ) = = FProjectDescriptor : : GetExtension ( ) )
2014-03-14 14:13:41 -04:00
{
OutProjectFilePath = FirstCommandLineToken ;
// Here we derive the game name from the project file
OutGameName = FPaths : : GetBaseFilename ( OutProjectFilePath ) ;
return true ;
}
else if ( FPlatformProperties : : IsMonolithicBuild ( ) = = false )
{
// Full game name is assumed to be the first token
OutGameName = MoveTemp ( FirstCommandLineToken ) ;
// Derive the project path from the game name. All games must have a uproject file, even if they are in the root folder.
2014-09-08 13:51:36 -04:00
OutProjectFilePath = FPaths : : Combine ( * FPaths : : RootDir ( ) , * OutGameName , * FString ( OutGameName + TEXT ( " . " ) + FProjectDescriptor : : GetExtension ( ) ) ) ;
2014-03-14 14:13:41 -04:00
return true ;
}
}
2014-11-17 15:04:07 -05:00
# if WITH_EDITOR
if ( FEditorCommandLineUtils : : ParseGameProjectPath ( InCmdLine , OutProjectFilePath , OutGameName ) )
{
return true ;
}
# endif
2014-03-14 14:13:41 -04:00
return false ;
}
bool LaunchSetGameName ( const TCHAR * InCmdLine )
{
if ( GIsGameAgnosticExe )
{
2014-10-14 10:31:43 -04:00
// Initialize GameName to an empty string. Populate it below.
FApp : : SetGameName ( TEXT ( " " ) ) ;
2014-03-14 14:13:41 -04:00
FString ProjFilePath ;
FString LocalGameName ;
if ( ParseGameProjectFromCommandLine ( InCmdLine , ProjFilePath , LocalGameName ) = = true )
{
// Only set the game name if this is NOT a program...
if ( FPlatformProperties : : IsProgram ( ) = = false )
{
2014-10-14 10:31:43 -04:00
FApp : : SetGameName ( * LocalGameName ) ;
2014-03-14 14:13:41 -04:00
}
FPaths : : SetProjectFilePath ( ProjFilePath ) ;
}
# if UE_GAME
else
{
// Try to use the executable name as the game name.
LocalGameName = FPlatformProcess : : ExecutableName ( ) ;
2014-10-14 10:31:43 -04:00
FApp : : SetGameName ( * LocalGameName ) ;
2014-03-14 14:13:41 -04:00
// Check it's not UE4Game, otherwise assume a uproject file relative to the game project directory
if ( LocalGameName ! = TEXT ( " UE4Game " ) )
{
2014-09-08 13:51:36 -04:00
ProjFilePath = FPaths : : Combine ( TEXT ( " .. " ) , TEXT ( " .. " ) , TEXT ( " .. " ) , * LocalGameName , * FString ( LocalGameName + TEXT ( " . " ) + FProjectDescriptor : : GetExtension ( ) ) ) ;
2014-03-14 14:13:41 -04:00
FPaths : : SetProjectFilePath ( ProjFilePath ) ;
}
}
# endif
static bool bPrinted = false ;
if ( ! bPrinted )
{
bPrinted = true ;
if ( FApp : : HasGameName ( ) )
{
2014-10-14 10:31:43 -04:00
UE_LOG ( LogInit , Display , TEXT ( " Running engine for game: %s " ) , FApp : : GetGameName ( ) ) ;
2014-03-14 14:13:41 -04:00
}
else
{
if ( FPlatformProperties : : RequiresCookedData ( ) )
{
UE_LOG ( LogInit , Fatal , TEXT ( " Non-agnostic games on cooked platforms require a uproject file be specified. " ) ) ;
}
else
{
UE_LOG ( LogInit , Display , TEXT ( " Running engine without a game " ) ) ;
}
}
}
}
else
{
FString ProjFilePath ;
FString LocalGameName ;
if ( ParseGameProjectFromCommandLine ( InCmdLine , ProjFilePath , LocalGameName ) = = true )
{
if ( FPlatformProperties : : RequiresCookedData ( ) )
{
2014-10-14 10:31:43 -04:00
// Non-agnostic exes that require cooked data cannot load projects, so make sure that the LocalGameName is the GameName
if ( LocalGameName ! = FApp : : GetGameName ( ) )
2014-03-14 14:13:41 -04:00
{
UE_LOG ( LogInit , Fatal , TEXT ( " Non-agnostic games cannot load projects on cooked platforms - try running UE4Game. " ) ) ;
}
}
// Only set the game name if this is NOT a program...
if ( FPlatformProperties : : IsProgram ( ) = = false )
{
2014-10-14 10:31:43 -04:00
FApp : : SetGameName ( * LocalGameName ) ;
2014-03-14 14:13:41 -04:00
}
FPaths : : SetProjectFilePath ( ProjFilePath ) ;
}
// In a non-game agnostic exe, the game name should already be assigned by now.
if ( ! FApp : : HasGameName ( ) )
{
UE_LOG ( LogInit , Fatal , TEXT ( " Could not set game name! " ) ) ;
}
}
return true ;
}
2014-10-14 10:31:43 -04:00
void LaunchFixGameNameCase ( )
{
# if PLATFORM_DESKTOP && !IS_PROGRAM
// This is to make sure this function is not misused and is only called when the game name is set
check ( FApp : : HasGameName ( ) ) ;
// correct the case of the game name, if possible (unless we're running a program and the game name is already set)
if ( FPaths : : IsProjectFilePathSet ( ) )
{
const FString GameName ( FPaths : : GetBaseFilename ( IFileManager : : Get ( ) . GetFilenameOnDisk ( * FPaths : : GetProjectFilePath ( ) ) ) ) ;
const bool bGameNameMatchesProjectCaseSensitive = ( FCString : : Strcmp ( * GameName , FApp : : GetGameName ( ) ) = = 0 ) ;
if ( ! bGameNameMatchesProjectCaseSensitive & & ( FApp : : IsGameNameEmpty ( ) | | GIsGameAgnosticExe | | ( GameName . Len ( ) > 0 & & GIsGameAgnosticExe ) ) )
{
if ( GameName = = FApp : : GetGameName ( ) ) // case insensitive compare
{
FApp : : SetGameName ( * GameName ) ;
}
else
{
const FText Message = FText : : Format (
2014-11-18 11:54:51 -05:00
NSLOCTEXT ( " Core " , " MismatchedGameNames " , " The name of the .uproject file ('{0}') must match the name of the project passed in the command line ('{1}'). " ) ,
FText : : FromString ( * GameName ) ,
FText : : FromString ( FApp : : GetGameName ( ) ) ) ;
2014-10-14 10:31:43 -04:00
if ( ! GIsBuildMachine )
{
UE_LOG ( LogInit , Warning , TEXT ( " %s " ) , * Message . ToString ( ) ) ;
FMessageDialog : : Open ( EAppMsgType : : Ok , Message ) ;
}
FApp : : SetGameName ( TEXT ( " " ) ) ; // this disables part of the crash reporter to avoid writing log files to a bogus directory
if ( ! GIsBuildMachine )
{
exit ( 1 ) ;
}
UE_LOG ( LogInit , Fatal , TEXT ( " %s " ) , * Message . ToString ( ) ) ;
}
}
}
# endif //PLATFORM_DESKTOP
}
2014-03-14 14:13:41 -04:00
2015-03-06 13:30:49 -05:00
static IPlatformFile * ConditionallyCreateFileWrapper ( const TCHAR * Name , IPlatformFile * CurrentPlatformFile , const TCHAR * CommandLine , bool * OutFailedToInitialize = NULL , bool * bOutShouldBeUsed = NULL )
2014-03-14 14:13:41 -04:00
{
if ( OutFailedToInitialize )
{
* OutFailedToInitialize = false ;
}
2015-03-06 13:30:49 -05:00
if ( bOutShouldBeUsed )
{
* bOutShouldBeUsed = false ;
}
2014-03-14 14:13:41 -04:00
IPlatformFile * WrapperFile = FPlatformFileManager : : Get ( ) . GetPlatformFile ( Name ) ;
if ( WrapperFile ! = NULL & & WrapperFile - > ShouldBeUsed ( CurrentPlatformFile , CommandLine ) )
{
2015-03-06 13:30:49 -05:00
if ( bOutShouldBeUsed )
{
* bOutShouldBeUsed = true ;
}
2014-03-14 14:13:41 -04:00
if ( WrapperFile - > Initialize ( CurrentPlatformFile , CommandLine ) = = false )
{
if ( OutFailedToInitialize )
{
* OutFailedToInitialize = true ;
}
// Don't delete the platform file. It will be automatically deleted by its module.
WrapperFile = NULL ;
}
}
else
{
// Make sure it won't be used.
WrapperFile = NULL ;
}
return WrapperFile ;
}
/**
* Look for any file overrides on the command line ( i . e . network connection file handler )
*/
bool LaunchCheckForFileOverride ( const TCHAR * CmdLine , bool & OutFileOverrideFound )
{
OutFileOverrideFound = false ;
// Get the physical platform file.
IPlatformFile * CurrentPlatformFile = & FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ;
// Try to create pak file wrapper
{
2015-04-08 14:46:25 -04:00
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " PakFile " ) , CurrentPlatformFile , CmdLine ) ;
2014-03-14 14:13:41 -04:00
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " CachedReadFile " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
// Try to create sandbox wrapper
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " SandboxFile " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
# if !UE_BUILD_SHIPPING // UFS clients are not available in shipping builds.
// Streaming network wrapper (it has a priority over normal network wrapper)
bool bNetworkFailedToInitialize = false ;
do
{
2015-03-06 13:30:49 -05:00
bool bShouldUseStreamingFile = false ;
IPlatformFile * NetworkPlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " StreamingFile " ) , CurrentPlatformFile , CmdLine , & bNetworkFailedToInitialize , & bShouldUseStreamingFile ) ;
2014-03-14 14:13:41 -04:00
if ( NetworkPlatformFile )
{
CurrentPlatformFile = NetworkPlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
2015-03-06 13:30:49 -05:00
// if streaming network platform file was tried this loop don't try this one
2014-03-14 14:13:41 -04:00
// Network file wrapper (only create if the streaming wrapper hasn't been created)
2015-03-06 13:30:49 -05:00
if ( ! bShouldUseStreamingFile & & ! NetworkPlatformFile )
2014-03-14 14:13:41 -04:00
{
NetworkPlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " NetworkFile " ) , CurrentPlatformFile , CmdLine , & bNetworkFailedToInitialize ) ;
if ( NetworkPlatformFile )
{
CurrentPlatformFile = NetworkPlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
2015-03-06 13:30:49 -05:00
2014-03-14 14:13:41 -04:00
if ( bNetworkFailedToInitialize )
{
FString HostIpString ;
FParse : : Value ( CmdLine , TEXT ( " -FileHostIP= " ) , HostIpString ) ;
# if PLATFORM_REQUIRES_FILESERVER
2015-04-28 08:46:09 -04:00
FPlatformMisc : : LowLevelOutputDebugStringf ( TEXT ( " Failed to connect to file server at %s. RETRYING in 5s. \n " ) , * HostIpString ) ;
FPlatformProcess : : Sleep ( 5.0f ) ;
2014-03-14 14:13:41 -04:00
uint32 Result = 2 ;
# else //PLATFORM_REQUIRES_FILESERVER
2014-09-24 20:02:40 -04:00
// note that this can't be localized because it happens before we connect to a filserver - localizing would cause ICU to try to load.... from over the file server connection!
FString Error = FString : : Printf ( TEXT ( " Failed to connect to any of the following file servers: \n \n %s \n \n Would you like to try again? No will fallback to local disk files, Cancel will quit. " ) , * HostIpString . Replace ( TEXT ( " + " ) , TEXT ( " \n " ) ) ) ;
uint32 Result = FMessageDialog : : Open ( EAppMsgType : : YesNoCancel , FText : : FromString ( Error ) ) ;
2014-03-14 14:13:41 -04:00
# endif //PLATFORM_REQUIRES_FILESERVER
if ( Result = = EAppReturnType : : No )
{
break ;
}
else if ( Result = = EAppReturnType : : Cancel )
{
// Cancel - return a failure, and quit
return false ;
}
}
}
while ( bNetworkFailedToInitialize ) ;
# endif
# if !UE_BUILD_SHIPPING
// Try to create file profiling wrapper
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " ProfileFile " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " SimpleProfileFile " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
// Try and create file timings stats wrapper
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " FileReadStats " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
// Try and create file open log wrapper (lists the order files are first opened)
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " FileOpenLog " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
# endif //#if !UE_BUILD_SHIPPING
// Wrap the above in a file logging singleton if requested
{
IPlatformFile * PlatformFile = ConditionallyCreateFileWrapper ( TEXT ( " LogFile " ) , CurrentPlatformFile , CmdLine ) ;
if ( PlatformFile )
{
CurrentPlatformFile = PlatformFile ;
FPlatformFileManager : : Get ( ) . SetPlatformFile ( * CurrentPlatformFile ) ;
}
}
// If our platform file is different than it was when we started, then an override was used
OutFileOverrideFound = ( CurrentPlatformFile ! = & FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) ) ;
return true ;
}
bool LaunchHasIncompleteGameName ( )
{
if ( FApp : : HasGameName ( ) & & ! FPaths : : IsProjectFilePathSet ( ) )
{
// Verify this is a legitimate game name
// Launched with a game name. See if the <GameName> folder exists. If it doesn't, it could instead be <GameName>Game
2014-10-14 10:31:43 -04:00
const FString NonSuffixedGameFolder = FPaths : : RootDir ( ) / FApp : : GetGameName ( ) ;
2014-03-14 14:13:41 -04:00
if ( FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) . DirectoryExists ( * NonSuffixedGameFolder ) = = false )
{
const FString SuffixedGameFolder = NonSuffixedGameFolder + TEXT ( " Game " ) ;
if ( FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) . DirectoryExists ( * SuffixedGameFolder ) )
{
return true ;
}
}
}
return false ;
}
void LaunchUpdateMostRecentProjectFile ( )
{
// If we are launching without a game name or project file, we should use the last used project file, if it exists
const FString & AutoLoadProjectFileName = IProjectManager : : Get ( ) . GetAutoLoadProjectFileName ( ) ;
FString RecentProjectFileContents ;
if ( FFileHelper : : LoadFileToString ( RecentProjectFileContents , * AutoLoadProjectFileName ) )
{
if ( RecentProjectFileContents . Len ( ) )
{
const FString AutoLoadInProgressFilename = AutoLoadProjectFileName + TEXT ( " .InProgress " ) ;
if ( FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) . FileExists ( * AutoLoadInProgressFilename ) )
{
// We attempted to auto-load a project but the last run did not make it to UEditorEngine::InitEditor.
// This indicates that there was a problem loading the project.
// Do not auto-load the project, instead load normally until the next time the editor starts successfully.
UE_LOG ( LogInit , Display , TEXT ( " There was a problem auto-loading %s. Auto-load will be disabled until the editor successfully starts up with a project. " ) , * RecentProjectFileContents ) ;
}
else if ( FPlatformFileManager : : Get ( ) . GetPlatformFile ( ) . FileExists ( * RecentProjectFileContents ) )
{
// The previously loaded project file was found. Change the game name here and update the project file path
2014-10-14 10:31:43 -04:00
FApp : : SetGameName ( * FPaths : : GetBaseFilename ( RecentProjectFileContents ) ) ;
2014-03-14 14:13:41 -04:00
FPaths : : SetProjectFilePath ( RecentProjectFileContents ) ;
UE_LOG ( LogInit , Display , TEXT ( " Loading recent project file: %s " ) , * RecentProjectFileContents ) ;
// Write a file indicating that we are trying to auto-load a project.
// This file prevents auto-loading of projects for as long as it exists. It is a detection system for failed auto-loads.
// The file is deleted in UEditorEngine::InitEditor, thus if the load does not make it that far then the project will not be loaded again.
FFileHelper : : SaveStringToFile ( TEXT ( " " ) , * AutoLoadInProgressFilename ) ;
}
}
}
}
/*-----------------------------------------------------------------------------
FEngineLoop implementation .
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
FEngineLoop : : FEngineLoop ( )
# if WITH_ENGINE
: EngineService ( NULL )
# endif
{ }
2014-04-23 20:10:59 -04:00
int32 FEngineLoop : : PreInit ( int32 ArgC , TCHAR * ArgV [ ] , const TCHAR * AdditionalCommandline )
2014-03-14 14:13:41 -04:00
{
FString CmdLine ;
// loop over the parameters, skipping the first one (which is the executable name)
for ( int32 Arg = 1 ; Arg < ArgC ; Arg + + )
{
FString ThisArg = ArgV [ Arg ] ;
if ( ThisArg . Contains ( TEXT ( " " ) ) & & ! ThisArg . Contains ( TEXT ( " \" " ) ) )
{
int32 EqualsAt = ThisArg . Find ( TEXT ( " = " ) ) ;
if ( EqualsAt > 0 & & ThisArg . Find ( TEXT ( " " ) ) > EqualsAt )
{
ThisArg = ThisArg . Left ( EqualsAt + 1 ) + FString ( " \" " ) + ThisArg . RightChop ( EqualsAt + 1 ) + FString ( " \" " ) ;
}
else
{
ThisArg = FString ( " \" " ) + ThisArg + FString ( " \" " ) ;
}
}
CmdLine + = ThisArg ;
// put a space between each argument (not needed after the end)
if ( Arg + 1 < ArgC )
{
CmdLine + = TEXT ( " " ) ;
}
}
// append the additional extra command line
if ( AdditionalCommandline )
{
CmdLine + = TEXT ( " " ) ;
CmdLine + = AdditionalCommandline ;
}
// send the command line without the exe name
return GEngineLoop . PreInit ( * CmdLine ) ;
}
# if WITH_ENGINE
2014-04-23 22:06:10 -04:00
bool IsServerDelegateForOSS ( FName WorldContextHandle )
2014-03-14 14:13:41 -04:00
{
2014-04-23 19:56:01 -04:00
if ( IsRunningDedicatedServer ( ) )
{
return true ;
}
UWorld * World = NULL ;
2014-04-23 22:06:10 -04:00
if ( WorldContextHandle ! = NAME_None )
2014-04-23 19:56:01 -04:00
{
FWorldContext & WorldContext = GEngine - > GetWorldContextFromHandleChecked ( WorldContextHandle ) ;
check ( WorldContext . WorldType = = EWorldType : : Game | | WorldContext . WorldType = = EWorldType : : PIE ) ;
World = WorldContext . World ( ) ;
}
else
{
2014-07-14 19:41:38 -04:00
UGameEngine * GameEngine = Cast < UGameEngine > ( GEngine ) ;
if ( GameEngine )
{
World = GameEngine - > GetGameWorld ( ) ;
}
else
{
UE_LOG ( LogInit , Error , TEXT ( " Failed to determine if OSS is server in PIE, OSS requests will fail " ) ) ;
return false ;
}
2014-04-23 19:56:01 -04:00
}
ENetMode NetMode = World ? World - > GetNetMode ( ) : NM_Standalone ;
return ( NetMode = = NM_ListenServer | | NetMode = = NM_DedicatedServer ) ;
2014-03-14 14:13:41 -04:00
}
# endif
int32 FEngineLoop : : PreInit ( const TCHAR * CmdLine )
{
DECLARE_SCOPE_CYCLE_COUNTER ( TEXT ( " Engine Pre-Initialized " ) , STAT_PreInit , STATGROUP_LoadTime ) ;
2014-04-23 18:15:18 -04:00
if ( FParse : : Param ( CmdLine , TEXT ( " UTF8Output " ) ) )
{
FPlatformMisc : : SetUTF8Output ( ) ;
}
2014-03-14 14:13:41 -04:00
// Switch into executable's directory.
FPlatformProcess : : SetCurrentWorkingDirectoryToBaseDir ( ) ;
2014-07-31 07:38:19 -04:00
// this is set later with shorter command lines, but we want to make sure it is set ASAP as some subsystems will do the tests themselves...
// also realize that command lines can be pulled from the network at a slightly later time.
if ( ! FCommandLine : : Set ( CmdLine ) )
{
// Fail, shipping builds will crash if setting command line fails
return - 1 ;
}
2015-04-14 05:21:25 -04:00
# if STATS
// Create the stats malloc profiler proxy.
if ( FStatsMallocProfilerProxy : : HasMemoryProfilerToken ( ) )
{
// Assumes no concurrency here.
GMalloc = FStatsMallocProfilerProxy : : Get ( ) ;
}
# endif // STATS
2014-10-14 10:31:43 -04:00
// Set GameName, based on the command line
2014-07-31 07:38:19 -04:00
if ( LaunchSetGameName ( CmdLine ) = = false )
{
// If it failed, do not continue
return 1 ;
}
2014-03-14 14:13:41 -04:00
// Initialize log console here to avoid statics initialization issues when launched from the command line.
GScopedLogConsole = FPlatformOutputDevices : : GetLogConsole ( ) ;
// Always enable the backlog so we get all messages, we will disable and clear it in the game
// as soon as we determine whether GIsEditor == false
GLog - > EnableBacklog ( true ) ;
2014-04-23 17:47:30 -04:00
// Initialize std out device as early as possible if requested in the command line
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " stdout " ) ) )
{
InitializeStdOutDevice ( ) ;
}
2014-05-09 13:52:29 -04:00
# if !UE_BUILD_SHIPPING
if ( FPlatformProperties : : SupportsQuit ( ) )
{
FString ExitPhrases ;
if ( FParse : : Value ( FCommandLine : : Get ( ) , TEXT ( " testexit= " ) , ExitPhrases ) )
{
TArray < FString > ExitPhrasesList ;
2015-03-02 15:51:37 -05:00
if ( ExitPhrases . ParseIntoArray ( ExitPhrasesList , TEXT ( " + " ) , true ) > 0 )
2014-05-09 13:52:29 -04:00
{
GScopedTestExit = new FOutputDeviceTestExit ( ExitPhrasesList ) ;
GLog - > AddOutputDevice ( GScopedTestExit . GetOwnedPointer ( ) ) ;
}
}
}
# endif // !UE_BUILD_SHIPPING
2014-03-14 14:13:41 -04:00
// Switch into executable's directory (may be required by some of the platform file overrides)
FPlatformProcess : : SetCurrentWorkingDirectoryToBaseDir ( ) ;
2014-04-02 18:09:23 -04:00
// This fixes up the relative project path, needs to happen before we set platform file paths
2014-03-14 14:13:41 -04:00
if ( FPlatformProperties : : IsProgram ( ) = = false )
{
if ( FPaths : : IsProjectFilePathSet ( ) )
{
FString ProjPath = FPaths : : GetProjectFilePath ( ) ;
if ( FPaths : : FileExists ( ProjPath ) = = false )
{
UE_LOG ( LogInit , Display , TEXT ( " Project file not found: %s " ) , * ProjPath ) ;
UE_LOG ( LogInit , Display , TEXT ( " \t Attempting to find via project info helper. " ) ) ;
// Use the uprojectdirs
2014-10-14 10:31:43 -04:00
FString GameProjectFile = FUProjectDictionary : : GetDefault ( ) . GetRelativeProjectPathForGame ( FApp : : GetGameName ( ) , FPlatformProcess : : BaseDir ( ) ) ;
2014-03-14 14:13:41 -04:00
if ( GameProjectFile . IsEmpty ( ) = = false )
{
UE_LOG ( LogInit , Display , TEXT ( " \t Found project file %s. " ) , * GameProjectFile ) ;
FPaths : : SetProjectFilePath ( GameProjectFile ) ;
}
}
}
}
2014-04-02 18:09:23 -04:00
// allow the command line to override the platform file singleton
bool bFileOverrideFound = false ;
if ( LaunchCheckForFileOverride ( CmdLine , bFileOverrideFound ) = = false )
{
// if it failed, we cannot continue
return 1 ;
}
// Initialize file manager
IFileManager : : Get ( ) . ProcessCommandLineOptions ( ) ;
2014-03-14 14:13:41 -04:00
if ( GIsGameAgnosticExe )
{
// If we launched without a project file, but with a game name that is incomplete, warn about the improper use of a Game suffix
if ( LaunchHasIncompleteGameName ( ) )
{
// We did not find a non-suffixed folder and we DID find the suffixed one.
// The engine MUST be launched with <GameName>Game.
2014-10-14 10:31:43 -04:00
const FText GameNameText = FText : : FromString ( FApp : : GetGameName ( ) ) ;
2014-03-14 14:13:41 -04:00
FMessageDialog : : Open ( EAppMsgType : : Ok , FText : : Format ( LOCTEXT ( " RequiresGamePrefix " , " Error: UE4Editor does not append 'Game' to the passed in game name. \n You must use the full name. \n You specified '{0}', use '{0}Game'. " ) , GameNameText ) ) ;
return 1 ;
}
}
// remember thread id of the main thread
GGameThreadId = FPlatformTLS : : GetCurrentThreadId ( ) ;
GIsGameThreadIdInitialized = true ;
2014-05-12 08:40:54 -04:00
FPlatformProcess : : SetThreadAffinityMask ( FPlatformAffinity : : GetMainGameMask ( ) ) ;
2014-06-17 18:27:26 -04:00
FPlatformProcess : : SetupGameOrRenderThread ( false ) ;
2014-03-14 14:13:41 -04:00
// Figure out whether we're the editor, ucc or the game.
const SIZE_T CommandLineSize = FCString : : Strlen ( CmdLine ) + 1 ;
TCHAR * CommandLineCopy = new TCHAR [ CommandLineSize ] ;
FCString : : Strcpy ( CommandLineCopy , CommandLineSize , CmdLine ) ;
const TCHAR * ParsedCmdLine = CommandLineCopy ;
FString Token = FParse : : Token ( ParsedCmdLine , 0 ) ;
2014-11-26 12:51:01 -05:00
# if WITH_ENGINE
2014-03-14 14:13:41 -04:00
TArray < FString > Tokens ;
TArray < FString > Switches ;
UCommandlet : : ParseCommandLine ( CommandLineCopy , Tokens , Switches ) ;
bool bHasCommandletToken = false ;
for ( int32 TokenIndex = 0 ; TokenIndex < Tokens . Num ( ) ; + + TokenIndex )
{
if ( Tokens [ TokenIndex ] . EndsWith ( TEXT ( " Commandlet " ) ) )
{
bHasCommandletToken = true ;
Token = Tokens [ TokenIndex ] ;
break ;
}
}
for ( int32 SwitchIndex = 0 ; SwitchIndex < Switches . Num ( ) & & ! bHasCommandletToken ; + + SwitchIndex )
{
if ( Switches [ SwitchIndex ] . StartsWith ( TEXT ( " RUN= " ) ) )
{
bHasCommandletToken = true ;
Token = Switches [ SwitchIndex ] ;
break ;
}
}
# endif // UE_EDITOR
// trim any whitespace at edges of string - this can happen if the token was quoted with leading or trailing whitespace
// VC++ tends to do this in its "external tools" config
Token = Token . Trim ( ) ;
2014-06-12 17:02:29 -04:00
// Path returned by FPaths::GetProjectFilePath() is normalized, so may have symlinks and ~ resolved and may differ from the original path to .uproject passed in the command line
FString NormalizedToken = Token ;
FPaths : : NormalizeFilename ( NormalizedToken ) ;
2014-10-14 10:31:43 -04:00
const bool bFirstTokenIsGameName = ( FApp : : HasGameName ( ) & & Token = = FApp : : GetGameName ( ) ) ;
2014-06-12 17:02:29 -04:00
const bool bFirstTokenIsGameProjectFilePath = ( FPaths : : IsProjectFilePathSet ( ) & & NormalizedToken = = FPaths : : GetProjectFilePath ( ) ) ;
2014-04-23 17:35:03 -04:00
const bool bFirstTokenIsGameProjectFileShortName = ( FPaths : : IsProjectFilePathSet ( ) & & Token = = FPaths : : GetCleanFilename ( FPaths : : GetProjectFilePath ( ) ) ) ;
2014-03-14 14:13:41 -04:00
2014-04-02 18:09:23 -04:00
if ( bFirstTokenIsGameName | | bFirstTokenIsGameProjectFilePath | | bFirstTokenIsGameProjectFileShortName )
2014-03-14 14:13:41 -04:00
{
// first item on command line was the game name, remove it in all cases
FString RemainingCommandline = ParsedCmdLine ;
FCString : : Strcpy ( CommandLineCopy , CommandLineSize , * RemainingCommandline ) ;
ParsedCmdLine = CommandLineCopy ;
// Set a new command-line that doesn't include the game name as the first argument
FCommandLine : : Set ( ParsedCmdLine ) ;
Token = FParse : : Token ( ParsedCmdLine , 0 ) ;
Token = Token . Trim ( ) ;
2015-04-22 13:05:07 -04:00
// if the next token is a project file, then we skip it (which can happen on some platforms that combine
// commandlines... this handles extra .uprojects, but if you run with MyGame MyGame, we can't tell if
// the second MyGame is a map or not)
while ( FPaths : : GetExtension ( Token ) = = FProjectDescriptor : : GetExtension ( ) )
{
Token = FParse : : Token ( ParsedCmdLine , 0 ) ;
Token = Token . Trim ( ) ;
}
2014-04-02 18:09:23 -04:00
if ( bFirstTokenIsGameProjectFilePath | | bFirstTokenIsGameProjectFileShortName )
2014-03-14 14:13:41 -04:00
{
// Convert it to relative if possible...
FString RelativeGameProjectFilePath = FFileManagerGeneric : : DefaultConvertToRelativePath ( * FPaths : : GetProjectFilePath ( ) ) ;
if ( RelativeGameProjectFilePath ! = FPaths : : GetProjectFilePath ( ) )
{
FPaths : : SetProjectFilePath ( RelativeGameProjectFilePath ) ;
}
}
}
// look early for the editor token
bool bHasEditorToken = false ;
# if UE_EDITOR
// Check each token for '-game', '-server' or '-run='
bool bIsNotEditor = false ;
// This isn't necessarily pretty, but many requests have been made to allow
// UE4Editor.exe <GAMENAME> -game <map>
// or
// UE4Editor.exe <GAMENAME> -game 127.0.0.0
// We don't want to remove the -game from the commandline just yet in case
// we need it for something later. So, just move it to the end for now...
const bool bFirstTokenIsGame = ( Token = = TEXT ( " -GAME " ) ) ;
const bool bFirstTokenIsServer = ( Token = = TEXT ( " -SERVER " ) ) ;
const bool bFirstTokenIsModeOverride = bFirstTokenIsGame | | bFirstTokenIsServer | | bHasCommandletToken ;
const TCHAR * CommandletCommandLine = NULL ;
if ( bFirstTokenIsModeOverride )
{
bIsNotEditor = true ;
if ( bFirstTokenIsGame | | bFirstTokenIsServer )
{
// Move the token to the end of the list...
FString RemainingCommandline = ParsedCmdLine ;
RemainingCommandline = RemainingCommandline . Trim ( ) ;
RemainingCommandline + = FString : : Printf ( TEXT ( " %s " ) , * Token ) ;
FCommandLine : : Set ( * RemainingCommandline ) ;
}
if ( bHasCommandletToken )
{
# if STATS
FThreadStats : : MasterDisableForever ( ) ;
# endif
if ( Token . StartsWith ( TEXT ( " run= " ) ) )
{
Token = Token . RightChop ( 4 ) ;
if ( ! Token . EndsWith ( TEXT ( " Commandlet " ) ) )
{
Token + = TEXT ( " Commandlet " ) ;
}
}
CommandletCommandLine = ParsedCmdLine ;
}
}
if ( ! bIsNotEditor & & GIsGameAgnosticExe )
{
// If we launched without a game name or project name, try to load the most recently loaded project file.
// We can not do this if we are using a FilePlatform override since the game directory may already be established.
const bool bIsBuildMachine = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " BUILDMACHINE " ) ) ;
const bool bLoadMostRecentProjectFileIfItExists = ! FApp : : HasGameName ( ) & & ! bFileOverrideFound & & ! bIsBuildMachine & & ! FParse : : Param ( CmdLine , TEXT ( " norecentproject " ) ) ;
if ( bLoadMostRecentProjectFileIfItExists )
{
LaunchUpdateMostRecentProjectFile ( ) ;
}
}
# if !UE_BUILD_SHIPPING
// Benchmarking.
2014-04-23 18:12:58 -04:00
FApp : : SetBenchmarking ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " BENCHMARK " ) ) ) ;
2014-03-14 14:13:41 -04:00
# else
2014-04-23 18:12:58 -04:00
FApp : : SetBenchmarking ( false ) ;
2014-03-14 14:13:41 -04:00
# endif // !UE_BUILD_SHIPPING
// Initialize random number generator.
2014-04-23 18:12:58 -04:00
if ( FApp : : IsBenchmarking ( ) | | FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " FIXEDSEED " ) ) )
2014-03-14 14:13:41 -04:00
{
FMath : : RandInit ( 0 ) ;
FMath : : SRandInit ( 0 ) ;
2015-01-15 11:57:16 -05:00
UE_LOG ( LogInit , Display , TEXT ( " RandInit(0) SRandInit(0). " ) ) ;
2014-03-14 14:13:41 -04:00
}
else
{
2015-01-15 11:57:16 -05:00
uint32 Cycles1 = FPlatformTime : : Cycles ( ) ;
FMath : : RandInit ( Cycles1 ) ;
uint32 Cycles2 = FPlatformTime : : Cycles ( ) ;
FMath : : SRandInit ( Cycles2 ) ;
UE_LOG ( LogInit , Display , TEXT ( " RandInit(%d) SRandInit(%d). " ) , Cycles1 , Cycles2 ) ;
2014-03-14 14:13:41 -04:00
}
FString CheckToken = Token ;
bool bFoundValidToken = false ;
while ( ! bFoundValidToken & & ( CheckToken . Len ( ) > 0 ) )
{
if ( ! bIsNotEditor )
{
bool bHasNonEditorToken = ( CheckToken = = TEXT ( " -GAME " ) ) | | ( CheckToken = = TEXT ( " -SERVER " ) ) | | ( CheckToken . StartsWith ( TEXT ( " RUN= " ) ) ) | | CheckToken . EndsWith ( TEXT ( " Commandlet " ) ) ;
if ( bHasNonEditorToken )
{
bIsNotEditor = true ;
bFoundValidToken = true ;
}
}
CheckToken = FParse : : Token ( ParsedCmdLine , 0 ) ;
}
bHasEditorToken = ! bIsNotEditor ;
2014-11-26 12:51:01 -05:00
# elif WITH_ENGINE
const TCHAR * CommandletCommandLine = NULL ;
if ( bHasCommandletToken )
{
# if STATS
FThreadStats : : MasterDisableForever ( ) ;
# endif
if ( Token . StartsWith ( TEXT ( " run= " ) ) )
{
Token = Token . RightChop ( 4 ) ;
if ( ! Token . EndsWith ( TEXT ( " Commandlet " ) ) )
{
Token + = TEXT ( " Commandlet " ) ;
}
}
CommandletCommandLine = ParsedCmdLine ;
}
2014-03-14 14:13:41 -04:00
# if WITH_EDITOR && WITH_EDITORONLY_DATA
// If a non-editor target build w/ WITH_EDITOR and WITH_EDITORONLY_DATA, use the old token check...
//@todo. Is this something we need to support?
bHasEditorToken = Token = = TEXT ( " EDITOR " ) ;
# else
// Game, server and commandlets never set the editor token
bHasEditorToken = false ;
# endif
# endif //UE_EDITOR
# if !IS_PROGRAM
if ( ! GIsGameAgnosticExe & & FApp : : HasGameName ( ) & & ! FPaths : : IsProjectFilePathSet ( ) )
{
// If we are using a non-agnostic exe where a name was specified but we did not specify a project path. Assemble one based on the game name.
2014-09-08 13:51:36 -04:00
const FString ProjectFilePath = FPaths : : Combine ( * FPaths : : GameDir ( ) , * FString : : Printf ( TEXT ( " %s.%s " ) , FApp : : GetGameName ( ) , * FProjectDescriptor : : GetExtension ( ) ) ) ;
2014-03-14 14:13:41 -04:00
FPaths : : SetProjectFilePath ( ProjectFilePath ) ;
}
// Now verify the project file if we have one
if ( FPaths : : IsProjectFilePathSet ( ) )
{
if ( ! IProjectManager : : Get ( ) . LoadProjectFile ( FPaths : : GetProjectFilePath ( ) ) )
{
// The project file was invalid or saved with a newer version of the engine. Exit.
2014-05-20 07:48:06 -04:00
UE_LOG ( LogInit , Warning , TEXT ( " Could not find a valid project file, the engine will exit now. " ) ) ;
2014-03-14 14:13:41 -04:00
return 1 ;
}
}
if ( FApp : : HasGameName ( ) )
{
// Tell the module manager what the game binaries folder is
const FString GameBinariesDirectory = FPaths : : Combine ( FPlatformMisc : : GameDir ( ) , TEXT ( " Binaries " ) , FPlatformProcess : : GetBinariesSubdirectory ( ) ) ;
FModuleManager : : Get ( ) . SetGameBinariesDirectory ( * GameBinariesDirectory ) ;
2014-10-14 10:31:43 -04:00
LaunchFixGameNameCase ( ) ;
2014-03-14 14:13:41 -04:00
}
# endif
2014-08-05 10:55:00 -04:00
// Load Core modules required for everything else to work (needs to be loaded before InitializeRenderingCVarsCaching)
LoadCoreModules ( ) ;
# if WITH_ENGINE
extern ENGINE_API void InitializeRenderingCVarsCaching ( ) ;
InitializeRenderingCVarsCaching ( ) ;
# endif
2014-03-14 14:13:41 -04:00
bool bTokenDoesNotHaveDash = Token . Len ( ) & & FCString : : Strnicmp ( * Token , TEXT ( " - " ) , 1 ) ! = 0 ;
# if WITH_EDITOR
// If we're running as an game but don't have a project, inform the user and exit.
if ( bHasEditorToken = = false & & bHasCommandletToken = = false )
{
if ( ! FPaths : : IsProjectFilePathSet ( ) )
{
//@todo this is too early to localize
FMessageDialog : : Open ( EAppMsgType : : Ok , NSLOCTEXT ( " Engine " , " UE4RequiresProjectFiles " , " UE4 games require a project file as the first parameter. " ) ) ;
return 1 ;
}
}
if ( GIsUCCMakeStandaloneHeaderGenerator )
{
// Rebuilding script requires some hacks in the engine so we flag that.
PRIVATE_GIsRunningCommandlet = true ;
}
# endif //WITH_EDITOR
2015-03-24 07:29:32 -04:00
// initialize task graph sub-system with potential multiple threads
FTaskGraphInterface : : Startup ( FPlatformMisc : : NumberOfCores ( ) ) ;
FTaskGraphInterface : : Get ( ) . AttachToThread ( ENamedThreads : : GameThread ) ;
# if STATS
FThreadStats : : StartThread ( ) ;
# endif
2014-03-14 14:13:41 -04:00
if ( FPlatformProcess : : SupportsMultithreading ( ) )
{
GThreadPool = FQueuedThreadPool : : Allocate ( ) ;
int32 NumThreadsInThreadPool = FPlatformMisc : : NumberOfWorkerThreadsToSpawn ( ) ;
// we are only going to give dedicated servers one pool thread
if ( FPlatformProperties : : IsServerOnly ( ) )
{
NumThreadsInThreadPool = 1 ;
}
verify ( GThreadPool - > Create ( NumThreadsInThreadPool ) ) ;
}
// Get a pointer to the log output device
GLogConsole = GScopedLogConsole . GetOwnedPointer ( ) ;
LoadPreInitModules ( ) ;
2014-05-14 20:01:43 -04:00
// Start the application
if ( ! AppInit ( ) )
{
return 1 ;
}
2014-03-14 14:13:41 -04:00
# if WITH_ENGINE
// Initialize system settings before anyone tries to use it...
GSystemSettings . Initialize ( bHasEditorToken ) ;
// Apply renderer settings from console variables stored in the INI.
2014-10-27 14:02:50 -04:00
ApplyCVarSettingsFromIni ( TEXT ( " /Script/Engine.RendererSettings " ) , * GEngineIni , ECVF_SetByProjectSetting ) ;
2014-03-14 14:13:41 -04:00
2014-08-13 11:28:31 -04:00
# if !UE_SERVER
if ( ! IsRunningDedicatedServer ( ) )
{
if ( ! IsRunningCommandlet ( ) )
{
// Note: It is critical that resolution settings are loaded before the movie starts playing so that the window size and fullscreen state is known
UGameUserSettings : : PreloadResolutionSettings ( ) ;
}
}
# endif
2014-03-14 14:13:41 -04:00
// As early as possible to avoid expensive re-init of subsystems,
// after SystemSettings.ini file loading so we get the right state,
// before ConsoleVariables.ini so the local developer can always override.
// before InitializeCVarsForActiveDeviceProfile() so the platform can override user settings
2015-04-20 10:12:55 -04:00
Scalability : : LoadState ( ( bHasEditorToken & & ! GEditorSettingsIni . IsEmpty ( ) ) ? GEditorSettingsIni : GGameUserSettingsIni ) ;
2014-03-14 14:13:41 -04:00
// Set all CVars which have been setup in the device profiles.
UDeviceProfileManager : : InitializeCVarsForActiveDeviceProfile ( ) ;
2014-09-02 19:18:22 -04:00
if ( FApp : : ShouldUseThreadingForPerformance ( ) & & FPlatformMisc : : AllowRenderThread ( ) )
2014-03-14 14:13:41 -04:00
{
GUseThreadedRendering = true ;
}
# endif
FConfigCacheIni : : LoadConsoleVariablesFromINI ( ) ;
{
DECLARE_SCOPE_CYCLE_COUNTER ( TEXT ( " Platform Initialization " ) , STAT_PlatformInit , STATGROUP_LoadTime ) ;
// platform specific initialization now that the SystemSettings are loaded
FPlatformMisc : : PlatformInit ( ) ;
FPlatformMemory : : Init ( ) ;
}
// Let LogConsole know what ini file it should use to save its setting on exit.
// We can't use GGameIni inside log console because it's destroyed in the global
// scoped pointer and at that moment GGameIni may already be gone.
if ( GLogConsole ! = NULL )
{
GLogConsole - > SetIniFilename ( * GGameIni ) ;
}
# if CHECK_PUREVIRTUALS
FMessageDialog : : Open ( EAppMsgType : : Ok , * NSLOCTEXT ( " Engine " , " Error_PureVirtualsEnabled " , " The game cannot run with CHECK_PUREVIRTUALS enabled. Please disable CHECK_PUREVIRTUALS and rebuild the executable. " ) . ToString ( ) ) ;
FPlatformMisc : : RequestExit ( false ) ;
# endif
# if WITH_ENGINE
// allow for game explorer processing (including parental controls) and firewalls installation
if ( ! FPlatformMisc : : CommandLineCommands ( ) )
{
FPlatformMisc : : RequestExit ( false ) ;
}
bool bIsSeekFreeDedicatedServer = false ;
bool bIsRegularClient = false ;
if ( ! bHasEditorToken )
{
// See whether the first token on the command line is a commandlet.
//@hack: We need to set these before calling StaticLoadClass so all required data gets loaded for the commandlets.
GIsClient = true ;
GIsServer = true ;
# if WITH_EDITOR
GIsEditor = true ;
# endif //WITH_EDITOR
2014-11-26 12:51:01 -05:00
PRIVATE_GIsRunningCommandlet = true ;
2014-03-14 14:13:41 -04:00
2015-04-23 18:09:01 -04:00
// Allow commandlet rendering based on command line switch (too early to let the commandlet itself override this).
PRIVATE_GAllowCommandletRendering = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " AllowCommandletRendering " ) ) ;
2014-03-14 14:13:41 -04:00
// We need to disregard the empty token as we try finding Token + "Commandlet" which would result in finding the
// UCommandlet class if Token is empty.
bool bDefinitelyCommandlet = ( bTokenDoesNotHaveDash & & Token . EndsWith ( TEXT ( " Commandlet " ) ) ) ;
if ( ! bTokenDoesNotHaveDash )
{
if ( Token . StartsWith ( TEXT ( " run= " ) ) )
{
Token = Token . RightChop ( 4 ) ;
bDefinitelyCommandlet = true ;
if ( ! Token . EndsWith ( TEXT ( " Commandlet " ) ) )
{
Token + = TEXT ( " Commandlet " ) ;
}
}
}
else
{
if ( ! bDefinitelyCommandlet )
{
UClass * TempCommandletClass = FindObject < UClass > ( ANY_PACKAGE , * ( Token + TEXT ( " Commandlet " ) ) , false ) ;
if ( TempCommandletClass )
{
check ( TempCommandletClass - > IsChildOf ( UCommandlet : : StaticClass ( ) ) ) ; // ok so you have a class that ends with commandlet that is not a commandlet
Token + = TEXT ( " Commandlet " ) ;
bDefinitelyCommandlet = true ;
}
}
}
if ( ! bDefinitelyCommandlet )
{
bIsRegularClient = true ;
GIsClient = true ;
GIsServer = false ;
# if WITH_EDITORONLY_DATA
GIsEditor = false ;
# endif
2014-11-26 12:51:01 -05:00
PRIVATE_GIsRunningCommandlet = false ;
2014-03-14 14:13:41 -04:00
}
}
if ( IsRunningDedicatedServer ( ) )
{
GIsClient = false ;
GIsServer = true ;
PRIVATE_GIsRunningCommandlet = false ;
2014-11-26 12:51:01 -05:00
# if WITH_EDITOR
2014-03-14 14:13:41 -04:00
GIsEditor = false ;
# endif
bIsSeekFreeDedicatedServer = FPlatformProperties : : RequiresCookedData ( ) ;
}
2014-04-23 19:56:01 -04:00
// If std out device hasn't been initialized yet (there was no -stdout param in the command line) and
2014-04-23 17:47:30 -04:00
// we meet all the criteria, initialize it now.
if ( ! GScopedStdOut . IsValid ( ) & & ! bHasEditorToken & & ! bIsRegularClient & & ! IsRunningDedicatedServer ( ) )
{
InitializeStdOutDevice ( ) ;
}
2014-03-14 14:13:41 -04:00
FIOSystem : : Get ( ) ; // force it to be created if it isn't already
// allow the platform to start up any features it may need
IPlatformFeaturesModule : : Get ( ) ;
// Init physics engine before loading anything, in case we want to do things like cook during post-load.
InitGamePhys ( ) ;
// Delete temporary files in cache.
FPlatformProcess : : CleanFileCache ( ) ;
# if !UE_BUILD_SHIPPING
GIsDemoMode = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " DEMOMODE " ) ) ;
# endif
if ( bHasEditorToken )
{
# if WITH_EDITOR
// We're the editor.
GIsClient = true ;
GIsServer = true ;
GIsEditor = true ;
PRIVATE_GIsRunningCommandlet = false ;
GWarn = & UnrealEdWarn ;
# else
FMessageDialog : : Open ( EAppMsgType : : Ok , NSLOCTEXT ( " Engine " , " EditorNotSupported " , " Editor not supported in this mode. " ) ) ;
FPlatformMisc : : RequestExit ( false ) ;
return 1 ;
# endif //WITH_EDITOR
}
2014-09-09 12:18:29 -04:00
# endif // WITH_ENGINE
2014-03-14 14:13:41 -04:00
// If we're not in the editor stop collecting the backlog now that we know
if ( ! GIsEditor )
{
GLog - > EnableBacklog ( false ) ;
}
2014-09-09 12:18:29 -04:00
# if WITH_ENGINE
2014-03-14 14:13:41 -04:00
EndInitTextLocalization ( ) ;
2014-05-07 09:39:27 -04:00
IStreamingManager : : Get ( ) ;
2014-03-14 14:13:41 -04:00
if ( FPlatformProcess : : SupportsMultithreading ( ) & & ! IsRunningDedicatedServer ( ) & & ( bIsRegularClient | | bHasEditorToken ) )
{
FPlatformSplash : : Show ( ) ;
}
2014-07-07 10:11:07 -04:00
if ( ! IsRunningDedicatedServer ( ) & & ( bHasEditorToken | | bIsRegularClient ) )
2014-03-14 14:13:41 -04:00
{
2014-07-07 10:11:07 -04:00
// Init platform application
FSlateApplication : : Create ( ) ;
2014-03-14 14:13:41 -04:00
}
2014-07-08 07:53:13 -04:00
else
{
// If we're not creating the slate application there is some basic initialization
// that it does that still must be done
EKeys : : Initialize ( ) ;
FCoreStyle : : ResetToDefault ( ) ;
}
2014-03-14 14:13:41 -04:00
2014-11-05 13:10:54 -05:00
# if !UE_SERVER
FEngineFontServices : : Create ( ) ;
# endif
2014-10-08 04:42:34 -04:00
FScopedSlowTask SlowTask ( 100 , NSLOCTEXT ( " EngineLoop " , " EngineLoop_Initializing " , " Initializing... " ) ) ;
SlowTask . EnterProgressFrame ( 10 ) ;
2015-03-17 09:50:32 -04:00
// Initialize the RHI.
RHIInit ( bHasEditorToken ) ;
if ( ! FPlatformProperties : : RequiresCookedData ( ) )
{
check ( ! GShaderCompilingManager ) ;
GShaderCompilingManager = new FShaderCompilingManager ( ) ;
check ( ! GDistanceFieldAsyncQueue ) ;
GDistanceFieldAsyncQueue = new FDistanceFieldAsyncQueue ( ) ;
}
2014-03-14 14:13:41 -04:00
{
DECLARE_SCOPE_CYCLE_COUNTER ( TEXT ( " Initial UObject load " ) , STAT_InitialUObjectLoad , STATGROUP_LoadTime ) ;
// Initialize shader types before loading any shaders
InitializeShaderTypes ( ) ;
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 30 ) ;
2014-03-14 14:13:41 -04:00
// Load the global shaders.
2014-08-28 06:22:54 -04:00
if ( GetGlobalShaderMap ( GMaxRHIFeatureLevel ) = = NULL & & GIsRequestingExit )
2014-03-14 14:13:41 -04:00
{
// This means we can't continue without the global shader map.
return 1 ;
}
// In order to be able to use short script package names get all script
// package names from ini files and register them with FPackageName system.
FPackageName : : RegisterShortPackageNamesForUObjectModules ( ) ;
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 5 ) ;
2014-03-14 14:13:41 -04:00
// Make sure all UObject classes are registered and default properties have been initialized
ProcessNewlyLoadedUObjects ( ) ;
// Default materials may have been loaded due to dependencies when loading
// classes and class default objects. If not, do so now.
UMaterialInterface : : InitDefaultMaterials ( ) ;
UMaterialInterface : : AssertDefaultMaterialsExist ( ) ;
UMaterialInterface : : AssertDefaultMaterialsPostLoaded ( ) ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 5 ) ;
2014-10-08 04:42:34 -04:00
2014-03-14 14:13:41 -04:00
// Tell the module manager is may now process newly-loaded UObjects when new C++ modules are loaded
FModuleManager : : Get ( ) . StartProcessingNewlyLoadedObjects ( ) ;
// load up the seek-free startup packages
if ( ! FStartupPackages : : LoadAll ( ) )
{
// At least one startup package failed to load, return 1 to indicate an error
return 1 ;
}
// Setup GC optimizations
if ( bIsSeekFreeDedicatedServer | | bHasEditorToken )
{
2015-04-01 03:03:18 -04:00
GetUObjectArray ( ) . DisableDisregardForGC ( ) ;
2014-03-14 14:13:41 -04:00
}
2014-10-08 04:42:34 -04:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
if ( ! LoadStartupCoreModules ( ) )
{
// At least one startup module failed to load, return 1 to indicate an error
return 1 ;
}
# if !UE_SERVER // && !UE_EDITOR
if ( ! IsRunningDedicatedServer ( ) & & ! IsRunningCommandlet ( ) )
{
2014-06-09 14:36:21 -04:00
TSharedRef < FSlateRenderer > SlateRenderer = FModuleManager : : Get ( ) . GetModuleChecked < ISlateRHIRendererModule > ( " SlateRHIRenderer " ) . CreateSlateRHIRenderer ( ) ;
2014-03-14 14:13:41 -04:00
// If Slate is being used, initialize the renderer after RHIInit
FSlateApplication & CurrentSlateApp = FSlateApplication : : Get ( ) ;
CurrentSlateApp . InitializeRenderer ( SlateRenderer ) ;
2014-09-09 12:12:38 -04:00
2014-03-14 14:13:41 -04:00
GetMoviePlayer ( ) - > SetSlateRenderer ( SlateRenderer ) ;
}
# endif
2014-10-08 04:42:34 -04:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
// Load up all modules that need to hook into the loading screen
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : PreLoadingScreen ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : PreLoadingScreen ) )
2014-03-14 14:13:41 -04:00
{
return 1 ;
}
# if !UE_SERVER
if ( ! IsRunningDedicatedServer ( ) )
{
// @todo ps4: If a loading movie starts earlier, which it probably should, then please see PS4's PlatformPostInit() implementation!
// allow the movie player to load a sequence from the .inis (a PreLoadingScreen module could have already initialized a sequence, in which case
// it wouldn't have anything in it's .ini file)
GetMoviePlayer ( ) - > SetupLoadingScreenFromIni ( ) ;
GetMoviePlayer ( ) - > Initialize ( ) ;
GetMoviePlayer ( ) - > PlayMovie ( ) ;
2015-03-09 09:57:44 -04:00
// do any post appInit processing, before the render thread is started.
FPlatformMisc : : PlatformPostInit ( ! GetMoviePlayer ( ) - > IsMovieCurrentlyPlaying ( ) ) ;
}
else
2014-06-18 16:38:05 -04:00
# endif
2015-03-09 09:57:44 -04:00
{
// do any post appInit processing, before the render thread is started.
FPlatformMisc : : PlatformPostInit ( true ) ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 5 ) ;
2014-10-08 04:42:34 -04:00
2014-03-14 14:13:41 -04:00
if ( GUseThreadedRendering )
{
2015-03-24 08:49:41 -04:00
if ( GRHISupportsRHIThread )
2014-09-04 11:35:18 -04:00
{
2015-03-24 08:49:41 -04:00
const bool DefaultUseRHIThread = true ;
GUseRHIThread = DefaultUseRHIThread ;
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " rhithread " ) ) )
{
GUseRHIThread = true ;
}
else if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " norhithread " ) ) )
{
GUseRHIThread = false ;
}
2014-09-04 11:35:18 -04:00
}
2014-03-14 14:13:41 -04:00
StartRenderingThread ( ) ;
}
if ( ! LoadStartupModules ( ) )
{
// At least one startup module failed to load, return 1 to indicate an error
return 1 ;
}
MarkObjectsToDisregardForGC ( ) ;
2015-04-01 03:03:18 -04:00
GetUObjectArray ( ) . CloseDisregardForGC ( ) ;
2014-03-14 14:13:41 -04:00
SetIsServerForOnlineSubsystemsDelegate ( FQueryIsRunningServer : : CreateStatic ( & IsServerDelegateForOSS ) ) ;
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 5 ) ;
2014-10-08 04:42:34 -04:00
2014-03-14 14:13:41 -04:00
if ( ! bHasEditorToken )
{
UClass * CommandletClass = NULL ;
if ( ! bIsRegularClient )
{
CommandletClass = FindObject < UClass > ( ANY_PACKAGE , * Token , false ) ;
if ( ! CommandletClass )
{
2014-06-11 04:21:48 -04:00
if ( GLogConsole & & ! GIsSilent )
{
GLogConsole - > Show ( true ) ;
}
UE_LOG ( LogInit , Error , TEXT ( " %s looked like a commandlet, but we could not find the class. " ) , * Token ) ;
GIsRequestingExit = true ;
return 1 ;
2014-03-14 14:13:41 -04:00
}
2014-11-26 14:56:09 -05:00
# if PLATFORM_WINDOWS || PLATFORM_MAC || PLATFORM_LINUX
2014-03-14 14:13:41 -04:00
extern bool GIsConsoleExecutable ;
if ( GIsConsoleExecutable )
{
if ( GLogConsole ! = NULL & & GLogConsole - > IsAttached ( ) )
{
GLog - > RemoveOutputDevice ( GLogConsole ) ;
}
// Setup Ctrl-C handler for console application
FPlatformMisc : : SetGracefulTerminationHandler ( ) ;
}
else
2014-11-26 14:56:09 -05:00
# endif
2014-03-14 14:13:41 -04:00
{
// Bring up console unless we're a silent build.
if ( GLogConsole & & ! GIsSilent )
{
GLogConsole - > Show ( true ) ;
}
}
// print output immediately
setvbuf ( stdout , NULL , _IONBF , 0 ) ;
UE_LOG ( LogInit , Log , TEXT ( " Executing %s " ) , * CommandletClass - > GetFullName ( ) ) ;
// Allow commandlets to individually override those settings.
UCommandlet * Default = CastChecked < UCommandlet > ( CommandletClass - > GetDefaultObject ( ) ) ;
if ( GIsRequestingExit )
{
// commandlet set GIsRequestingExit during construction
return 1 ;
}
GIsClient = Default - > IsClient ;
GIsServer = Default - > IsServer ;
2014-11-26 12:51:01 -05:00
# if WITH_EDITOR
2014-03-14 14:13:41 -04:00
GIsEditor = Default - > IsEditor ;
2014-11-26 12:51:01 -05:00
# else
if ( Default - > IsEditor )
{
UE_LOG ( LogInit , Error , TEXT ( " Cannot run editor commandlet %s with game executable. " ) , * CommandletClass - > GetFullName ( ) ) ;
GIsRequestingExit = true ;
return 1 ;
}
# endif
2014-03-14 14:13:41 -04:00
PRIVATE_GIsRunningCommandlet = true ;
// Reset aux log if we don't want to log to the console window.
if ( ! Default - > LogToConsole )
{
GLog - > RemoveOutputDevice ( GLogConsole ) ;
}
GIsRequestingExit = true ; // so CTRL-C will exit immediately
// allow the commandlet the opportunity to create a custom engine
CommandletClass - > GetDefaultObject < UCommandlet > ( ) - > CreateCustomEngine ( CommandletCommandLine ) ;
if ( GEngine = = NULL )
{
2014-11-26 12:51:01 -05:00
# if WITH_EDITOR
2014-03-14 14:13:41 -04:00
if ( GIsEditor )
{
UClass * EditorEngineClass = StaticLoadClass ( UEditorEngine : : StaticClass ( ) , NULL , TEXT ( " engine-ini:/Script/Engine.Engine.EditorEngine " ) , NULL , LOAD_None , NULL ) ;
2015-02-03 05:40:57 -05:00
GEngine = GEditor = NewObject < UEditorEngine > ( GetTransientPackage ( ) , EditorEngineClass ) ;
2014-03-14 14:13:41 -04:00
2014-06-12 10:34:19 -04:00
GEngine - > ParseCommandline ( ) ;
2014-03-14 14:13:41 -04:00
UE_LOG ( LogInit , Log , TEXT ( " Initializing Editor Engine... " ) ) ;
GEditor - > InitEditor ( this ) ;
UE_LOG ( LogInit , Log , TEXT ( " Initializing Editor Engine Completed " ) ) ;
}
else
2014-11-26 12:51:01 -05:00
# endif
2014-03-14 14:13:41 -04:00
{
UClass * EngineClass = StaticLoadClass ( UEngine : : StaticClass ( ) , NULL , TEXT ( " engine-ini:/Script/Engine.Engine.GameEngine " ) , NULL , LOAD_None , NULL ) ;
// must do this here so that the engine object that we create on the next line receives the correct property values
2015-02-03 05:40:57 -05:00
GEngine = NewObject < UEngine > ( GetTransientPackage ( ) , EngineClass ) ;
2014-03-14 14:13:41 -04:00
check ( GEngine ) ;
GEngine - > ParseCommandline ( ) ;
UE_LOG ( LogInit , Log , TEXT ( " Initializing Game Engine... " ) ) ;
GEngine - > Init ( this ) ;
UE_LOG ( LogInit , Log , TEXT ( " Initializing Game Engine Completed " ) ) ;
}
}
//run automation smoke tests now that the commandlet has had a chance to override the above flags and GEngine is available
# if !PLATFORM_HTML5 && !PLATFORM_HTML5_WIN32
FAutomationTestFramework : : GetInstance ( ) . RunSmokeTests ( ) ;
# endif
2015-02-03 05:40:57 -05:00
UCommandlet * Commandlet = NewObject < UCommandlet > ( GetTransientPackage ( ) , CommandletClass ) ;
2014-03-14 14:13:41 -04:00
check ( Commandlet ) ;
Commandlet - > AddToRoot ( ) ;
// Execute the commandlet.
double CommandletExecutionStartTime = FPlatformTime : : Seconds ( ) ;
// Commandlets don't always handle -run= properly in the commandline so we'll provide them
// with a custom version that doesn't have it.
Commandlet - > ParseParms ( CommandletCommandLine ) ;
int32 ErrorLevel = Commandlet - > Main ( CommandletCommandLine ) ;
// Log warning/ error summary.
if ( Commandlet - > ShowErrorCount )
{
if ( GWarn - > Errors . Num ( ) | | GWarn - > Warnings . Num ( ) )
{
SET_WARN_COLOR ( COLOR_WHITE ) ;
UE_LOG ( LogInit , Display , TEXT ( " " ) ) ;
UE_LOG ( LogInit , Display , TEXT ( " Warning/Error Summary " ) ) ;
UE_LOG ( LogInit , Display , TEXT ( " --------------------- " ) ) ;
static const int32 MaxMessagesToShow = 50 ;
TSet < FString > ShownMessages ;
SET_WARN_COLOR ( COLOR_RED ) ;
ShownMessages . Empty ( MaxMessagesToShow ) ;
for ( auto It = GWarn - > Errors . CreateConstIterator ( ) ; It ; + + It )
{
bool bAlreadyShown = false ;
ShownMessages . Add ( * It , & bAlreadyShown ) ;
if ( ! bAlreadyShown )
{
if ( ShownMessages . Num ( ) > MaxMessagesToShow )
{
SET_WARN_COLOR ( COLOR_WHITE ) ;
UE_LOG ( LogInit , Display , TEXT ( " NOTE: Only first %d errors displayed. " ) , MaxMessagesToShow ) ;
break ;
}
UE_LOG ( LogInit , Display , TEXT ( " %s " ) , * * It ) ;
}
}
SET_WARN_COLOR ( COLOR_YELLOW ) ;
ShownMessages . Empty ( MaxMessagesToShow ) ;
for ( auto It = GWarn - > Warnings . CreateConstIterator ( ) ; It ; + + It )
{
bool bAlreadyShown = false ;
ShownMessages . Add ( * It , & bAlreadyShown ) ;
if ( ! bAlreadyShown )
{
if ( ShownMessages . Num ( ) > MaxMessagesToShow )
{
SET_WARN_COLOR ( COLOR_WHITE ) ;
UE_LOG ( LogInit , Display , TEXT ( " NOTE: Only first %d warnings displayed. " ) , MaxMessagesToShow ) ;
break ;
}
UE_LOG ( LogInit , Display , TEXT ( " %s " ) , * * It ) ;
}
}
}
UE_LOG ( LogInit , Display , TEXT ( " " ) ) ;
if ( ErrorLevel ! = 0 )
{
SET_WARN_COLOR ( COLOR_RED ) ;
UE_LOG ( LogInit , Display , TEXT ( " Commandlet->Main return this error code: %d " ) , ErrorLevel ) ;
UE_LOG ( LogInit , Display , TEXT ( " With %d error(s), %d warning(s) " ) , GWarn - > Errors . Num ( ) , GWarn - > Warnings . Num ( ) ) ;
}
else if ( ( GWarn - > Errors . Num ( ) = = 0 ) )
{
SET_WARN_COLOR ( GWarn - > Warnings . Num ( ) ? COLOR_YELLOW : COLOR_GREEN ) ;
UE_LOG ( LogInit , Display , TEXT ( " Success - %d error(s), %d warning(s) " ) , GWarn - > Errors . Num ( ) , GWarn - > Warnings . Num ( ) ) ;
}
else
{
SET_WARN_COLOR ( COLOR_RED ) ;
UE_LOG ( LogInit , Display , TEXT ( " Failure - %d error(s), %d warning(s) " ) , GWarn - > Errors . Num ( ) , GWarn - > Warnings . Num ( ) ) ;
ErrorLevel = 1 ;
}
CLEAR_WARN_COLOR ( ) ;
}
else
{
UE_LOG ( LogInit , Display , TEXT ( " Finished. " ) ) ;
}
double CommandletExecutionTime = FPlatformTime : : Seconds ( ) - CommandletExecutionStartTime ;
UE_LOG ( LogInit , Display , LINE_TERMINATOR TEXT ( " Execution of commandlet took: %.2f seconds " ) , CommandletExecutionTime ) ;
// We're ready to exit!
return ErrorLevel ;
}
else
{
// We're a regular client.
check ( bIsRegularClient ) ;
if ( bTokenDoesNotHaveDash )
{
// here we give people a reasonable warning if they tried to use the short name of a commandlet
UClass * TempCommandletClass = FindObject < UClass > ( ANY_PACKAGE , * ( Token + TEXT ( " Commandlet " ) ) , false ) ;
if ( TempCommandletClass )
{
UE_LOG ( LogInit , Fatal , TEXT ( " You probably meant to call a commandlet. Please use the full name %s. " ) , * ( Token + TEXT ( " Commandlet " ) ) ) ;
}
}
}
}
// exit if wanted.
if ( GIsRequestingExit )
{
if ( GEngine ! = NULL )
{
GEngine - > PreExit ( ) ;
}
AppPreExit ( ) ;
// appExit is called outside guarded block.
return 1 ;
}
FString MatineeName ;
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " DUMPMOVIE " ) ) | | FParse : : Value ( FCommandLine : : Get ( ) , TEXT ( " -MATINEESSCAPTURE= " ) , MatineeName ) )
{
// -1: remain on
GIsDumpingMovie = - 1 ;
}
// If dumping movie then we do NOT want on-screen messages
GAreScreenMessagesEnabled = ! GIsDumpingMovie & & ! GIsDemoMode ;
# if !UE_BUILD_SHIPPING
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " NOSCREENMESSAGES " ) ) )
{
GAreScreenMessagesEnabled = false ;
}
// Don't update INI files if benchmarking or -noini
2014-04-23 18:12:58 -04:00
if ( FApp : : IsBenchmarking ( ) | | FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " NOINI " ) ) )
2014-03-14 14:13:41 -04:00
{
GConfig - > Detach ( GEngineIni ) ;
GConfig - > Detach ( GInputIni ) ;
GConfig - > Detach ( GGameIni ) ;
GConfig - > Detach ( GEditorIni ) ;
}
# endif // !UE_BUILD_SHIPPING
delete [ ] CommandLineCopy ;
// initialize the pointer, as it is deleted before being assigned in the first frame
PendingCleanupObjects = NULL ;
// Initialize profile visualizers.
# if !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " TaskGraph " ) ) ;
if ( FPlatformProcess : : SupportsMultithreading ( ) )
{
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " ProfilerService " ) ) ;
FModuleManager : : Get ( ) . GetModuleChecked < IProfilerServiceModule > ( " ProfilerService " ) . CreateProfilerServiceManager ( ) ;
}
# endif
2014-12-10 09:42:32 -05:00
// Init HighRes screenshot system.
GetHighResScreenshotConfig ( ) . Init ( ) ;
2014-04-23 18:26:02 -04:00
2014-05-29 17:32:09 -04:00
# else // WITH_ENGINE
2014-04-23 18:26:02 -04:00
EndInitTextLocalization ( ) ;
2014-05-29 17:32:09 -04:00
FPlatformMisc : : PlatformPostInit ( ) ;
# endif // WITH_ENGINE
2014-04-23 18:26:02 -04:00
2014-03-14 14:13:41 -04:00
//run automation smoke tests now that everything is setup to run
FAutomationTestFramework : : GetInstance ( ) . RunSmokeTests ( ) ;
2014-08-06 16:48:03 -04:00
2014-12-17 02:15:23 -05:00
// Note we still have 20% remaining on the slow task: this will be used by the Editor/Engine initialization next
2014-03-14 14:13:41 -04:00
return 0 ;
}
2014-07-31 07:38:19 -04:00
void FEngineLoop : : LoadCoreModules ( )
{
// Always attempt to load CoreUObject. It requires additional pre-init which is called from its module's StartupModule method.
# if WITH_COREUOBJECT
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " CoreUObject " ) ) ;
# endif
}
2014-03-14 14:13:41 -04:00
void FEngineLoop : : LoadPreInitModules ( )
{
DECLARE_SCOPE_CYCLE_COUNTER ( TEXT ( " Loading PreInit Modules " ) , STAT_PreInitModules , STATGROUP_LoadTime ) ;
// GGetMapNameDelegate is initialized here
# if WITH_ENGINE
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " Engine " ) ) ;
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " Renderer " ) ) ;
2014-09-22 09:43:40 -04:00
FPlatformMisc : : LoadPreInitModules ( ) ;
2014-03-14 14:13:41 -04:00
# if !UE_SERVER
if ( ! IsRunningDedicatedServer ( ) )
{
// This needs to be loaded before InitializeShaderTypes is called
2014-06-09 14:36:21 -04:00
FModuleManager : : Get ( ) . LoadModuleChecked < ISlateRHIRendererModule > ( " SlateRHIRenderer " ) ;
2014-03-14 14:13:41 -04:00
}
# endif
2014-11-19 13:56:48 -05:00
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " Landscape " ) ) ;
2014-03-14 14:13:41 -04:00
// Initialize ShaderCore before loading or compiling any shaders,
// But after Renderer and any other modules which implement shader types.
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " ShaderCore " ) ) ;
2014-11-19 13:56:48 -05:00
2014-03-14 14:13:41 -04:00
# if WITH_EDITORONLY_DATA
// Load the texture compressor module before any textures load. They may
// compress asynchronously and that can lead to a race condition.
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " TextureCompressor " ) ) ;
# endif
# endif // WITH_ENGINE
}
# if WITH_ENGINE
bool FEngineLoop : : LoadStartupCoreModules ( )
{
2014-12-17 02:15:23 -05:00
FScopedSlowTask SlowTask ( 100 ) ;
2014-03-14 14:13:41 -04:00
DECLARE_SCOPE_CYCLE_COUNTER ( TEXT ( " Loading Startup Modules " ) , STAT_StartupModules , STATGROUP_LoadTime ) ;
bool bSuccess = true ;
// Load all Runtime modules
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
{
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " Core " ) ) ;
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " Networking " ) ) ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
FPlatformMisc : : LoadStartupModules ( ) ;
// initialize messaging
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
if ( FPlatformProcess : : SupportsMultithreading ( ) )
{
FModuleManager : : LoadModuleChecked < IMessagingModule > ( " Messaging " ) ;
if ( ! IsRunningCommandlet ( ) )
{
SessionService = FModuleManager : : LoadModuleChecked < ISessionServicesModule > ( " SessionServices " ) . GetSessionService ( ) ;
SessionService - > Start ( ) ;
}
EngineService = new FEngineService ( ) ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
# if WITH_EDITOR
FModuleManager : : LoadModuleChecked < IEditorStyleModule > ( " EditorStyle " ) ;
# endif //WITH_EDITOR
2015-03-09 09:57:44 -04:00
// Load UI modules
SlowTask . EnterProgressFrame ( 10 ) ;
if ( ! IsRunningDedicatedServer ( ) )
2014-03-14 14:13:41 -04:00
{
FModuleManager : : Get ( ) . LoadModule ( " Slate " ) ;
2015-03-09 09:57:44 -04:00
}
# if WITH_EDITOR
// In dedicated server builds with the editor, we need to load UMG/UMGEditor for compiling blueprints.
// UMG must be loaded for runtime and cooking.
FModuleManager : : Get ( ) . LoadModule ( " UMG " ) ;
# else
if ( ! IsRunningDedicatedServer ( ) )
{
2014-06-30 18:17:51 -04:00
// UMG must be loaded for runtime and cooking.
FModuleManager : : Get ( ) . LoadModule ( " UMG " ) ;
2015-03-09 09:57:44 -04:00
}
# endif //WITH_EDITOR
2014-03-14 14:13:41 -04:00
2015-03-09 09:57:44 -04:00
// Load all Development modules
SlowTask . EnterProgressFrame ( 20 ) ;
if ( ! IsRunningDedicatedServer ( ) )
{
2014-03-14 14:13:41 -04:00
# if WITH_UNREAL_DEVELOPER_TOOLS
FModuleManager : : Get ( ) . LoadModule ( " MessageLog " ) ;
FModuleManager : : Get ( ) . LoadModule ( " CollisionAnalyzer " ) ;
# endif //WITH_UNREAL_DEVELOPER_TOOLS
}
# if WITH_UNREAL_DEVELOPER_TOOLS
FModuleManager : : Get ( ) . LoadModule ( " FunctionalTesting " ) ;
# endif //WITH_UNREAL_DEVELOPER_TOOLS
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 30 ) ;
2014-03-14 14:13:41 -04:00
# if (WITH_EDITOR && !(UE_BUILD_SHIPPING || UE_BUILD_TEST))
// HACK: load BT editor as early as possible for statically initialized assets (non cooked BT assets needs it)
// cooking needs this module too
2014-10-15 05:26:17 -04:00
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " BehaviorTreeEditor " ) ) ;
2014-03-14 14:13:41 -04:00
2014-05-29 16:56:15 -04:00
// -----------------------------------------------------
2014-06-04 17:06:44 -04:00
// HACK: load AbilitySystem editor as early as possible for statically initialized assets (non cooked BT assets needs it)
2014-05-29 16:56:15 -04:00
// cooking needs this module too
2014-06-04 17:06:44 -04:00
bool bGameplayAbilitiesEnabled = false ;
2014-09-16 21:07:55 -04:00
GConfig - > GetBool ( TEXT ( " GameplayAbilities " ) , TEXT ( " GameplayAbilitiesEditorEnabled " ) , bGameplayAbilitiesEnabled , GEngineIni ) ;
2014-06-04 17:06:44 -04:00
if ( bGameplayAbilitiesEnabled )
2014-05-29 16:56:15 -04:00
{
2014-06-04 17:06:44 -04:00
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " GameplayAbilitiesEditor " ) ) ;
2014-05-29 16:56:15 -04:00
}
// -----------------------------------------------------
2014-03-14 14:13:41 -04:00
// HACK: load EQS editor as early as possible for statically initialized assets (non cooked EQS assets needs it)
// cooking needs this module too
bool bEnvironmentQueryEditor = false ;
GConfig - > GetBool ( TEXT ( " EnvironmentQueryEd " ) , TEXT ( " EnableEnvironmentQueryEd " ) , bEnvironmentQueryEditor , GEngineIni ) ;
2014-10-24 17:47:36 -04:00
if ( bEnvironmentQueryEditor
# if WITH_EDITOR
| | GetDefault < UEditorExperimentalSettings > ( ) - > bEQSEditor
# endif // WITH_EDITOR
)
2014-03-14 14:13:41 -04:00
{
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " EnvironmentQueryEditor " ) ) ;
}
2014-05-29 16:58:50 -04:00
// We need this for blueprint projects that have online functionality.
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " OnlineBlueprintSupport " ) ) ;
2014-03-14 14:13:41 -04:00
# endif //(WITH_EDITOR && !(UE_BUILD_SHIPPING || UE_BUILD_TEST))
return bSuccess ;
}
bool FEngineLoop : : LoadStartupModules ( )
{
2014-12-17 02:15:23 -05:00
FScopedSlowTask SlowTask ( 3 ) ;
SlowTask . EnterProgressFrame ( 1 ) ;
2014-03-14 14:13:41 -04:00
// Load any modules that want to be loaded before default modules are loaded up.
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : PreDefault ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : PreDefault ) )
2014-03-14 14:13:41 -04:00
{
return false ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 1 ) ;
2014-03-14 14:13:41 -04:00
// Load modules that are configured to load in the default phase
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : Default ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : Default ) )
2014-03-14 14:13:41 -04:00
{
return false ;
}
2014-12-17 02:15:23 -05:00
SlowTask . EnterProgressFrame ( 1 ) ;
2014-03-14 14:13:41 -04:00
// Load any modules that want to be loaded after default modules are loaded up.
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : PostDefault ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : PostDefault ) )
2014-03-14 14:13:41 -04:00
{
return false ;
}
return true ;
}
void FEngineLoop : : InitTime ( )
{
// Init variables used for benchmarking and ticking.
2014-04-23 18:12:58 -04:00
FApp : : SetCurrentTime ( FPlatformTime : : Seconds ( ) ) ;
2014-03-14 14:13:41 -04:00
MaxFrameCounter = 0 ;
MaxTickTime = 0 ;
TotalTickTime = 0 ;
LastFrameCycles = FPlatformTime : : Cycles ( ) ;
float FloatMaxTickTime = 0 ;
# if !UE_BUILD_SHIPPING
FParse : : Value ( FCommandLine : : Get ( ) , TEXT ( " SECONDS= " ) , FloatMaxTickTime ) ;
MaxTickTime = FloatMaxTickTime ;
2014-04-23 18:12:58 -04:00
// look of a version of seconds that only is applied if FApp::IsBenchmarking() is set. This makes it easier on
2014-03-14 14:13:41 -04:00
// say, iOS, where we have a toggle setting to enable benchmarking, but don't want to have to make user
// also disable the seconds setting as well. -seconds= will exit the app after time even if benchmarking
// is not enabled
// NOTE: This will override -seconds= if it's specified
2014-04-23 18:12:58 -04:00
if ( FApp : : IsBenchmarking ( ) )
2014-03-14 14:13:41 -04:00
{
if ( FParse : : Value ( FCommandLine : : Get ( ) , TEXT ( " BENCHMARKSECONDS= " ) , FloatMaxTickTime ) & & FloatMaxTickTime )
{
MaxTickTime = FloatMaxTickTime ;
}
}
// Use -FPS=X to override fixed tick rate if e.g. -BENCHMARK is used.
float FixedFPS = 0 ;
FParse : : Value ( FCommandLine : : Get ( ) , TEXT ( " FPS= " ) , FixedFPS ) ;
if ( FixedFPS > 0 )
{
2015-02-16 14:18:26 -05:00
GEngine - > MatineeScreenshotOptions . MatineeCaptureFPS = ( int32 ) FixedFPS ;
2014-04-23 18:12:58 -04:00
FApp : : SetFixedDeltaTime ( 1 / FixedFPS ) ;
2014-03-14 14:13:41 -04:00
}
2014-04-02 18:09:23 -04:00
2014-03-14 14:13:41 -04:00
# endif // !UE_BUILD_SHIPPING
2014-04-23 18:12:58 -04:00
// convert FloatMaxTickTime into number of frames (using 1 / FApp::GetFixedDeltaTime() to convert fps to seconds )
2014-05-06 06:26:25 -04:00
MaxFrameCounter = FMath : : TruncToInt ( MaxTickTime / FApp : : GetFixedDeltaTime ( ) ) ;
2014-03-14 14:13:41 -04:00
}
//called via FCoreDelegates::StarvedGameLoop
void GameLoopIsStarved ( )
{
2014-07-15 07:34:34 -04:00
FlushPendingDeleteRHIResources_GameThread ( ) ;
2014-06-12 12:09:36 -04:00
FStats : : AdvanceFrame ( true , FStats : : FOnAdvanceRenderingThreadStats : : CreateStatic ( & AdvanceRenderingThreadStatsGT ) ) ;
2014-03-14 14:13:41 -04:00
}
int32 FEngineLoop : : Init ( )
{
2014-10-08 04:42:34 -04:00
FScopedSlowTask SlowTask ( 100 ) ;
SlowTask . EnterProgressFrame ( 10 ) ;
2014-03-14 14:13:41 -04:00
// Figure out which UEngine variant to use.
UClass * EngineClass = NULL ;
if ( ! GIsEditor )
{
// We're the game.
EngineClass = StaticLoadClass ( UGameEngine : : StaticClass ( ) , NULL , TEXT ( " engine-ini:/Script/Engine.Engine.GameEngine " ) , NULL , LOAD_None , NULL ) ;
2015-02-03 05:40:57 -05:00
GEngine = NewObject < UEngine > ( GetTransientPackage ( ) , EngineClass ) ;
2014-03-14 14:13:41 -04:00
}
else
{
# if WITH_EDITOR
// We're UnrealEd.
EngineClass = StaticLoadClass ( UUnrealEdEngine : : StaticClass ( ) , NULL , TEXT ( " engine-ini:/Script/Engine.Engine.UnrealEdEngine " ) , NULL , LOAD_None , NULL ) ;
2015-02-03 05:40:57 -05:00
GEngine = GEditor = GUnrealEd = NewObject < UUnrealEdEngine > ( GetTransientPackage ( ) , EngineClass ) ;
2014-03-14 14:13:41 -04:00
# else
check ( 0 ) ;
# endif
}
check ( GEngine ) ;
GetMoviePlayer ( ) - > PassLoadingScreenWindowBackToGame ( ) ;
GEngine - > ParseCommandline ( ) ;
InitTime ( ) ;
2014-10-08 04:42:34 -04:00
SlowTask . EnterProgressFrame ( 60 ) ;
2014-03-14 14:13:41 -04:00
GEngine - > Init ( this ) ;
2014-10-08 04:42:34 -04:00
SlowTask . EnterProgressFrame ( 30 ) ;
2014-07-10 21:04:34 -04:00
// Load all the post-engine init modules
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : PostEngineInit ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : PostEngineInit ) )
2014-07-10 21:04:34 -04:00
{
GIsRequestingExit = true ;
return 1 ;
}
2014-11-07 09:48:16 -05:00
2014-03-14 14:13:41 -04:00
GetMoviePlayer ( ) - > WaitForMovieToFinish ( ) ;
// initialize automation worker
# if WITH_AUTOMATION_WORKER
FModuleManager : : Get ( ) . LoadModule ( " AutomationWorker " ) ;
# endif
# if WITH_EDITOR
if ( GIsEditor )
{
FModuleManager : : GetModuleChecked < IAutomationControllerModule > ( " AutomationController " ) . Init ( ) ;
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " ProfilerClient " ) ) ;
}
# endif
GIsRunning = true ;
if ( ! GIsEditor )
{
// hide a couple frames worth of rendering
FViewport : : SetGameRenderingEnabled ( true , 3 ) ;
}
// Begin the async platform hardware survey
GEngine - > InitHardwareSurvey ( ) ;
FCoreDelegates : : StarvedGameLoop . BindStatic ( & GameLoopIsStarved ) ;
return 0 ;
}
void FEngineLoop : : Exit ( )
{
GIsRunning = 0 ;
GLogConsole = NULL ;
2014-10-14 10:29:46 -04:00
// shutdown visual logger and flush all data
# if ENABLE_VISUAL_LOG
FVisualLogger : : Get ( ) . Shutdown ( ) ;
# endif
2014-09-30 15:44:12 -04:00
GetMoviePlayer ( ) - > Shutdown ( ) ;
2014-03-14 14:13:41 -04:00
// Make sure we're not in the middle of loading something.
FlushAsyncLoading ( ) ;
// Block till all outstanding resource streaming requests are fulfilled.
2014-05-07 09:39:27 -04:00
if ( ! IStreamingManager : : HasShutdown ( ) )
2014-03-14 14:13:41 -04:00
{
UTexture2D : : CancelPendingTextureStreaming ( ) ;
2014-05-07 09:39:27 -04:00
IStreamingManager : : Get ( ) . BlockTillAllRequestsFinished ( ) ;
2014-03-14 14:13:41 -04:00
}
# if WITH_ENGINE
// shut down messaging
delete EngineService ;
EngineService = NULL ;
if ( SessionService . IsValid ( ) )
{
SessionService - > Stop ( ) ;
SessionService . Reset ( ) ;
}
2014-08-28 13:54:31 -04:00
if ( GDistanceFieldAsyncQueue )
{
GDistanceFieldAsyncQueue - > Shutdown ( ) ;
delete GDistanceFieldAsyncQueue ;
}
2014-03-14 14:13:41 -04:00
# endif // WITH_ENGINE
MALLOC_PROFILER ( GEngine - > Exec ( NULL , TEXT ( " MPROF STOP " ) ) ; )
if ( GEngine ! = NULL )
{
2015-03-12 12:59:33 -04:00
GEngine - > ShutdownAudioDeviceManager ( ) ;
2014-03-14 14:13:41 -04:00
}
if ( GEngine ! = NULL )
{
GEngine - > PreExit ( ) ;
}
2014-11-05 13:10:54 -05:00
# if !UE_SERVER
2014-11-10 13:33:10 -05:00
if ( FEngineFontServices : : IsInitialized ( ) )
{
FEngineFontServices : : Destroy ( ) ;
}
2014-11-05 13:10:54 -05:00
# endif
2014-10-21 13:39:30 -04:00
// close all windows
FSlateApplication : : Shutdown ( ) ;
2014-10-30 12:29:17 -04:00
AppPreExit ( ) ;
2014-03-14 14:13:41 -04:00
TermGamePhys ( ) ;
ParticleVertexFactoryPool_FreePool ( ) ;
MotionBlur_Free ( ) ;
// Stop the rendering thread.
StopRenderingThread ( ) ;
// Tear down the RHI.
RHIExit ( ) ;
2014-09-05 12:46:22 -04:00
# if WITH_ENGINE
// Save the hot reload state
IHotReloadInterface * HotReload = IHotReloadInterface : : GetPtr ( ) ;
if ( HotReload ! = nullptr )
{
HotReload - > SaveConfig ( ) ;
}
# endif
2014-03-14 14:13:41 -04:00
// Unload all modules. Note that this doesn't actually unload the module DLLs (that happens at
// process exit by the OS), but it does call ShutdownModule() on all loaded modules in the reverse
// order they were loaded in, so that systems can unregister and perform general clean up.
FModuleManager : : Get ( ) . UnloadModulesAtShutdown ( ) ;
# if STATS
FThreadStats : : StopThread ( ) ;
# endif
FTaskGraphInterface : : Shutdown ( ) ;
2014-05-07 09:39:27 -04:00
IStreamingManager : : Shutdown ( ) ;
2014-03-14 14:13:41 -04:00
FIOSystem : : Shutdown ( ) ;
}
2015-02-23 15:58:14 -05:00
void FEngineLoop : : ProcessLocalPlayerSlateOperations ( ) const
2014-09-18 17:01:00 -04:00
{
FSlateApplication & SlateApp = FSlateApplication : : Get ( ) ;
// For all the game worlds drill down to the player controller for each game viewport and process it's slate operation
2015-02-23 15:58:14 -05:00
for ( const FWorldContext & Context : GEngine - > GetWorldContexts ( ) )
2014-09-18 17:01:00 -04:00
{
UWorld * CurWorld = Context . World ( ) ;
2015-02-23 15:58:14 -05:00
if ( CurWorld & & CurWorld - > IsGameWorld ( ) )
2014-09-18 17:01:00 -04:00
{
UGameViewportClient * GameViewportClient = CurWorld - > GetGameViewport ( ) ;
2015-02-23 15:58:14 -05:00
TSharedPtr < SViewport > ViewportWidget = GameViewportClient ? GameViewportClient - > GetGameViewportWidget ( ) : nullptr ;
if ( ViewportWidget . IsValid ( ) )
2014-09-18 17:01:00 -04:00
{
2015-02-23 15:58:14 -05:00
for ( FConstPlayerControllerIterator Iterator = CurWorld - > GetPlayerControllerIterator ( ) ; Iterator ; + + Iterator )
2014-09-18 17:01:00 -04:00
{
2015-02-23 15:58:14 -05:00
APlayerController * PlayerController = * Iterator ;
if ( PlayerController )
2014-09-18 17:01:00 -04:00
{
2015-02-23 15:58:14 -05:00
ULocalPlayer * LocalPlayer = Cast < ULocalPlayer > ( PlayerController - > Player ) ;
if ( LocalPlayer )
{
FReply & TheReply = LocalPlayer - > GetSlateOperations ( ) ;
2014-09-18 17:01:00 -04:00
2015-02-23 15:58:14 -05:00
FWidgetPath PathToWidget ;
SlateApp . GeneratePathToWidgetUnchecked ( ViewportWidget . ToSharedRef ( ) , PathToWidget ) ;
2014-09-18 17:01:00 -04:00
2015-02-23 15:58:14 -05:00
SlateApp . ProcessReply ( PathToWidget , TheReply , nullptr , nullptr , LocalPlayer - > GetControllerId ( ) ) ;
2014-09-18 17:01:00 -04:00
2015-02-23 15:58:14 -05:00
TheReply = FReply : : Unhandled ( ) ;
}
2014-09-18 17:01:00 -04:00
}
}
}
}
}
}
2014-03-14 14:13:41 -04:00
bool FEngineLoop : : ShouldUseIdleMode ( ) const
{
static const auto CVarIdleWhenNotForeground = IConsoleManager : : Get ( ) . FindTConsoleVariableDataInt ( TEXT ( " t.IdleWhenNotForeground " ) ) ;
bool bIdleMode = false ;
2014-05-16 11:42:50 -04:00
// Yield cpu usage if desired
if ( FApp : : IsGame ( )
2014-03-14 14:13:41 -04:00
& & FPlatformProperties : : SupportsWindowedMode ( )
2014-05-16 11:42:50 -04:00
& & CVarIdleWhenNotForeground - > GetValueOnGameThread ( )
2014-03-14 14:13:41 -04:00
& & ! FPlatformProcess : : IsThisApplicationForeground ( ) )
{
bIdleMode = true ;
2014-06-27 15:53:24 -04:00
for ( const FWorldContext & Context : GEngine - > GetWorldContexts ( ) )
2014-03-14 14:13:41 -04:00
{
2014-06-27 15:53:24 -04:00
if ( ! Context . World ( ) - > AreAlwaysLoadedLevelsLoaded ( ) )
2014-03-14 14:13:41 -04:00
{
bIdleMode = false ;
break ;
}
}
}
return bIdleMode ;
}
void FEngineLoop : : Tick ( )
{
2014-11-14 14:38:40 -05:00
// Ensure we aren't starting a frame while loading or playing a loading movie
ensure ( GetMoviePlayer ( ) - > IsLoadingFinished ( ) & & ! GetMoviePlayer ( ) - > IsMovieCurrentlyPlaying ( ) ) ;
2014-03-14 14:13:41 -04:00
// early in the Tick() to get the callbacks for cvar changes called
2015-03-04 08:31:40 -05:00
{
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_CallAllConsoleVariableSinks ) ;
# endif
IConsoleManager : : Get ( ) . CallAllConsoleVariableSinks ( ) ;
}
2014-03-14 14:13:41 -04:00
{
SCOPE_CYCLE_COUNTER ( STAT_FrameTime ) ;
ENQUEUE_UNIQUE_RENDER_COMMAND (
2014-09-03 10:52:00 -04:00
BeginFrame ,
{
GRHICommandList . LatchBypass ( ) ;
GFrameNumberRenderThread + + ;
2014-09-11 09:38:38 -04:00
RHICmdList . PushEvent ( * FString : : Printf ( TEXT ( " Frame%d " ) , GFrameNumberRenderThread ) ) ;
2014-09-03 10:52:00 -04:00
RHICmdList . BeginFrame ( ) ;
} ) ;
2014-03-14 14:13:41 -04:00
2015-03-04 08:31:40 -05:00
{
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_FlushThreadedLogs ) ;
# endif
// Flush debug output which has been buffered by other threads.
GLog - > FlushThreadedLogs ( ) ;
}
2014-03-14 14:13:41 -04:00
// Exit if frame limit is reached in benchmark mode.
2014-04-23 18:12:58 -04:00
if ( ( FApp : : IsBenchmarking ( ) & & MaxFrameCounter & & ( GFrameCounter > MaxFrameCounter ) )
2014-03-14 14:13:41 -04:00
// or time limit is reached if set.
| | ( MaxTickTime & & ( TotalTickTime > MaxTickTime ) ) )
{
FPlatformMisc : : RequestExit ( 0 ) ;
}
2015-03-04 08:31:40 -05:00
{
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_UpdateTimeAndHandleMaxTickRate ) ;
# endif
// Set FApp::CurrentTime, FApp::DeltaTime and potentially wait to enforce max tick rate.
GEngine - > UpdateTimeAndHandleMaxTickRate ( ) ;
}
2014-03-14 14:13:41 -04:00
2015-03-04 08:31:40 -05:00
{
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_TickFPSChart ) ;
# endif
GEngine - > TickFPSChart ( FApp : : GetDeltaTime ( ) ) ;
}
2014-03-14 14:13:41 -04:00
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Malloc_UpdateStats ) ;
# endif
2014-04-23 16:37:37 -04:00
// Update platform memory and memory allocator stats.
FPlatformMemory : : UpdateStats ( ) ;
GMalloc - > UpdateStats ( ) ;
2014-03-14 14:13:41 -04:00
}
2014-06-12 12:09:36 -04:00
FStats : : AdvanceFrame ( false , FStats : : FOnAdvanceRenderingThreadStats : : CreateStatic ( & AdvanceRenderingThreadStatsGT ) ) ;
2014-03-14 14:13:41 -04:00
{
SCOPE_CYCLE_COUNTER ( STAT_FrameTime ) ;
// Calculates average FPS/MS (outside STATS on purpose)
CalculateFPSTimings ( ) ;
// Note the start of a new frame
MALLOC_PROFILER ( GMalloc - > Exec ( NULL , * FString : : Printf ( TEXT ( " SNAPSHOTMEMORYFRAME " ) ) , * GLog ) ) ;
// handle some per-frame tasks on the rendering thread
ENQUEUE_UNIQUE_RENDER_COMMAND (
ResetDeferredUpdates ,
{
FDeferredUpdateResource : : ResetNeedsUpdate ( ) ;
2014-07-15 07:34:34 -04:00
FlushPendingDeleteRHIResources_RenderThread ( ) ;
2014-03-14 14:13:41 -04:00
} ) ;
{
# if WITH_ENGINE
SCOPE_CYCLE_COUNTER ( STAT_PlatformMessageTime ) ;
# endif
SCOPE_CYCLE_COUNTER ( STAT_PumpMessages ) ;
FPlatformMisc : : PumpMessages ( true ) ;
}
2015-03-04 08:31:40 -05:00
bool bIdleMode ;
2014-03-14 14:13:41 -04:00
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Idle ) ;
# endif
// Idle mode prevents ticking and rendering completely
bIdleMode = ShouldUseIdleMode ( ) ;
if ( bIdleMode )
{
// Yield CPU time
FPlatformProcess : : Sleep ( .1f ) ;
}
2014-03-14 14:13:41 -04:00
}
if ( FSlateApplication : : IsInitialized ( ) & & ! bIdleMode )
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_SlateInput ) ;
# endif
2014-10-15 13:53:01 -04:00
FSlateApplication & SlateApp = FSlateApplication : : Get ( ) ;
SlateApp . PollGameDeviceState ( ) ;
// Gives widgets a chance to process any accumulated input
SlateApp . FinishedInputThisFrame ( ) ;
2014-03-14 14:13:41 -04:00
}
2014-04-23 18:12:58 -04:00
GEngine - > Tick ( FApp : : GetDeltaTime ( ) , bIdleMode ) ;
2014-11-14 14:38:40 -05:00
// If a movie that is blocking the game thread has been playing,
// wait for it to finish before we continue to tick or tick again
// We do this right after GEngine->Tick() because that is where user code would initiate a load / movie.
2015-03-04 08:31:40 -05:00
{
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_WaitForMovieToFinish ) ;
# endif
GetMoviePlayer ( ) - > WaitForMovieToFinish ( ) ;
}
2014-11-14 14:38:40 -05:00
2014-03-14 14:13:41 -04:00
if ( GShaderCompilingManager )
{
// Process any asynchronous shader compile results that are ready, limit execution time
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_GShaderCompilingManager ) ;
# endif
2014-03-14 14:13:41 -04:00
GShaderCompilingManager - > ProcessAsyncResults ( true , false ) ;
}
2014-08-28 13:54:31 -04:00
if ( GDistanceFieldAsyncQueue )
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_GDistanceFieldAsyncQueue ) ;
# endif
2014-08-28 13:54:31 -04:00
GDistanceFieldAsyncQueue - > ProcessAsyncTasks ( ) ;
}
2014-03-14 14:13:41 -04:00
if ( FSlateApplication : : IsInitialized ( ) & & ! bIdleMode )
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_ProcessPlayerControllersSlateOperations ) ;
# endif
2014-03-14 14:13:41 -04:00
check ( ! IsRunningDedicatedServer ( ) ) ;
2014-09-18 17:01:00 -04:00
// Process slate operations accumulated in the world ticks.
2015-02-23 15:58:14 -05:00
ProcessLocalPlayerSlateOperations ( ) ;
2014-03-14 14:13:41 -04:00
// Tick Slate application
FSlateApplication : : Get ( ) . Tick ( ) ;
}
Simple and Group Stat Exec commands can now be triggered from the level viewport Show menu directly.
#ttp 306334 - ROCKET: TASK: PUNTABLE: Stats: FN: Make diagnostic stats discoverable and available in the UI (don't require console to toggle)
#branch UE4
#change
DECLARE_STATS_GROUP û Added additional param GroupCategory, for subfolder use in the UI. Fixedup all Stats Group usage so the category is now propagated through where it needs to be.
Currently all Group stats have the Category æAdvancedÆ, and all engine stats have the Category æSimpleÆ û this is just to differentiate them for now, better categories will come along in future.
Modified FindOrAddMetaData as it now broadcasts a delegate (via a TaskGraph) whenever a new stat meta data is added û this was needed as not all the stat groups are æregisteredÆ when the level viewports are created (they are drip loaded), so the viewports need to listen for any additions thereafter...
GroupDescription is displayed as a tooltip in the UI for the stat entry and we may want to localize these.
RenderStats & RenderGroupedWithHierarchy: Modified so that it now takes the viewport that it should render to as a param (which is also used to determine if each stat should be visible).
Removed StatsEnabled delegate in favour of StatCheckEnabled, StatEnabled, StatDisabled, StatDisableAll for more finite usage and feedback when toggling them.
Modified FHUDGroupManager HandleCommand It now uses the new delegates to work out whether it needs to enable or disable for the current viewport, so itÆs more involved than a simple toggle, itÆs more ôis the stat enabled for the current viewport, and is it enabled for any viewportö delegate querying so it can react accordingly.
Added struct FSimpleStatFuncs: Which contains info on each æSimple StatÆ such as; name, category, description, renderfunc, togglefunc and the side of the viewport it should be rendered to
ExecSimpleStat û Calls Exec for a registered Simple Stat, ensuring the correct viewport is set
IsSimpleStat û Checks to see if a stat is a registered Simple Stat or not
SetSimpleStat û Sets the state of a specified Simple Stats
SetSimpleStats - Sets the state of the specified Simple Stats
RenderSimpleStats û Renders the Simple Stats if they are enabled, and have Render functions assigned.
Each Exec function had the code it executes which itÆs toggled and rendered into functions
Added FStatUnitData & FStatHitchesData: Moved all the globals/static variables used when enabling Stat Unit/Hitches into a struct as itÆs now used by multiple viewports and they needed their own copies. Also moved their draw functions here too.
FSceneViewport:
SwapStatCommands û Exchanges the enabled stats between two viewports, this is so when PIEing the stats which were enabled on the Level Viewport (if playing in active viewport only) get transposed to the Game Viewport, and then restored when PIE ends.
SEditorViewport:
ToggleStatCommand û Called when a stat is enabled/disabled from the UI
IsStatCommandVisible û Checks to see if a stat command should appear as visible in the UI
SEditorViewportViewMenu:
GenerateViewMenuContent û Made protected and virtual so it could be called externally.
FLevelViewportCommands: Added the code needed to generate commands for each of the Stat menu entries, however because not all stats are registered when this happens, it also creates some delegates to listen out for others that are registered later
Destructor û Needed to reset delegates
HandleNewGroupStat û Creates the new group stat commands
HandleNewStat û Creates the new stat command
FindStatIndex û Looks for where a stat should be inserted in the menu in order to maintain alphabetical order
SLevelViewport:
Modified the code so that the states of all the SimpleStats are saved so they can be restored next time the editor is ran (previously just handled FPS).
OnFloatingButtonClicked û Called whenever any of the level viewports floating buttons are clicked in order to correctly set the ælastÆ viewport global
OnToggleAllStatCommands û Called when the user selects æHide AllÆ from the viewport.
ToggleStatCommand û Called when the user selects any other stat option from the viewport.
BindStatCommand û Used to bind the menu action to the command name (used by delegate)
Added SLevelEditorViewportViewMenu (extends SEditorViewportViewMenu), and overrode GenerateViewMenuContent so that OnFloatingButtonClicked can be called whenever the menu is clicked on. This is also called during GenerateOptionsMenu, GenerateCameraMenu, GenerateShowMenu & OnToggleMaximize
Added global ptr GStatProcessingViewportClient (sim to Current, Last) used to keep track of which viewport the stat should be applied too (only valid within the scope of the Exec call).
FViewportClient:
Moved global ESoundShowFlags enum list into this class.
FCommonViewportClient:
Destructor û Needed to reset GStatProcessingViewportClient
FLevelEditorViewportClient
SetCurrentViewport û moved code responsible for setting the global æcurrentÆ viewport ptr into a func
SetLastKeyViewport û moved the code responsible for settings the global ælastÆ viewport ptr into a func
UGameViewportClient:
Destructor û Needed to cleanup delegate usage.
FViewportClient & FLevelEditorViewportClient & UGameViewportClient*
GetStatUnitData û The viewports copy of the variables needed when running the Stat Unit Exec
GetStatHitchesData û The viewports copy of the variables needed when running the Stat Hitches Exec
GetEnabledStats û Gets a list of all the stats which are enabled for the viewport
SetEnabledStats û Sets a list of all the stats which should be enabled for the viewport
IsStatEnabled û Checks to see if a specific stat is enabled for the viewport
SetStatEnabled û Sets a specifics stats state to enabled or disabled
GetSoundShowFlags û Gets which flags are enabled for the Stat Sounds Exec
SetSoundShowFlags û Sets which flags are enabled for the Stat Sounds Exec
HandleViewportStatCheckEnabled (delegate) û checks to see if a specific stat is enabled on this viewport
HandleViewportStatEnabled (delegate) û enables a specific stat for the viewport
HandleViewportStatDisabled (delegate) û disables a specific stat for the viewport
HandleViewportStatDisableAll (delegate) û disables all stats for the viewport
*FViewportClient has dummy virtual funcs and LevelEditor/Game both have the same implementations, the only differences is the GameViewports member variables are static so that the stat info persists between runs.
FLevelEditorViewportInstanceSettings deprecated bShowFPS in favour of an EnabledStats array (so we can track the state of all stats, not just FPS).
Added new config var bSaveSimpleStats: if enabled, restores previously enabled level viewport simple stats the next time the editor runs (defaults to false).
Modified FillShowFlagMenu so that thereÆs just one func and you specify where (if any) youÆd like a separator to occur.
Added FillShowStatsSubMenus so that menus can be generated which have submenus
Added the Stats sub menu to the View menu
Modified Execs so that the GStatProcessingViewportClient is set to the correct default viewport (if it wasnÆt specified), and clears again after itÆs been processed
HandleStatCommand now takes World and ViewportClient as params too û needed when Execs enabled other Execs so the world/viewport persists.
SetAverageUnitTimes û Added as a Setter func for GetAverageUnitTimes (moved code out of Stat Unit renderer and modified so that it only updates once per frame).
Stripped out all unneeded globals
[CL 2058522 by Andrew Brown in Main branch]
2014-04-29 04:04:27 -04:00
# if STATS
// Clear any stat group notifications we have pending just incase they weren't claimed during FSlateApplication::Get().Tick
extern CORE_API void ClearPendingStatGroups ( ) ;
ClearPendingStatGroups ( ) ;
# endif
2014-03-14 14:13:41 -04:00
# if WITH_EDITOR
if ( GIsEditor )
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_AutomationController ) ;
# endif
2014-09-11 16:48:17 -04:00
static FName AutomationController ( " AutomationController " ) ;
2014-03-14 14:13:41 -04:00
//Check if module loaded to support the change to allow this to be hot compilable.
2014-09-11 16:48:17 -04:00
if ( FModuleManager : : Get ( ) . IsModuleLoaded ( AutomationController ) )
2014-03-14 14:13:41 -04:00
{
2014-09-11 16:48:17 -04:00
FModuleManager : : GetModuleChecked < IAutomationControllerModule > ( AutomationController ) . Tick ( ) ;
2014-03-14 14:13:41 -04:00
}
}
# endif
# if WITH_ENGINE
# if WITH_AUTOMATION_WORKER
{
2015-03-04 08:31:40 -05:00
# if WITH_ENGINE
QUICK_SCOPE_CYCLE_COUNTER ( STAT_FEngineLoop_Tick_AutomationWorker ) ;
# endif
//Check if module loaded to support the change to allow this to be hot compilable.
static const FName AutomationWorkerModuleName = TEXT ( " AutomationWorker " ) ;
if ( FModuleManager : : Get ( ) . IsModuleLoaded ( AutomationWorkerModuleName ) )
{
FModuleManager : : GetModuleChecked < IAutomationWorkerModule > ( AutomationWorkerModuleName ) . Tick ( ) ;
}
2014-03-14 14:13:41 -04:00
}
# endif
# endif //WITH_ENGINE
{
# if WITH_ENGINE
SCOPE_CYCLE_COUNTER ( STAT_RHITickTime ) ;
# endif
2014-04-23 18:12:58 -04:00
RHITick ( FApp : : GetDeltaTime ( ) ) ; // Update RHI.
2014-03-14 14:13:41 -04:00
}
// Increment global frame counter. Once for each engine tick.
GFrameCounter + + ;
// Disregard first few ticks for total tick time as it includes loading and such.
if ( GFrameCounter > 6 )
{
2014-04-23 18:12:58 -04:00
TotalTickTime + = FApp : : GetDeltaTime ( ) ;
2014-03-14 14:13:41 -04:00
}
// Find the objects which need to be cleaned up the next frame.
FPendingCleanupObjects * PreviousPendingCleanupObjects = PendingCleanupObjects ;
PendingCleanupObjects = GetPendingCleanupObjects ( ) ;
{
# if WITH_ENGINE
SCOPE_CYCLE_COUNTER ( STAT_FrameSyncTime ) ;
# endif
// this could be perhaps moved down to get greater parallelizm
// Sync game and render thread. Either total sync or allowing one frame lag.
static FFrameEndSync FrameEndSync ;
static auto CVarAllowOneFrameThreadLag = IConsoleManager : : Get ( ) . FindTConsoleVariableDataInt ( TEXT ( " r.OneFrameThreadLag " ) ) ;
FrameEndSync . Sync ( CVarAllowOneFrameThreadLag - > GetValueOnGameThread ( ) ! = 0 ) ;
}
{
# if WITH_ENGINE
SCOPE_CYCLE_COUNTER ( STAT_DeferredTickTime ) ;
# endif
// Delete the objects which were enqueued for deferred cleanup before the previous frame.
delete PreviousPendingCleanupObjects ;
2014-04-23 18:12:58 -04:00
FTicker : : GetCoreTicker ( ) . Tick ( FApp : : GetDeltaTime ( ) ) ;
2014-03-14 14:13:41 -04:00
FSingleThreadManager : : Get ( ) . Tick ( ) ;
GEngine - > TickDeferredCommands ( ) ;
}
ENQUEUE_UNIQUE_RENDER_COMMAND (
EndFrame ,
{
2015-02-25 08:13:48 -05:00
FShaderCache : : PreDrawShaders ( RHICmdList ) ;
2014-06-27 11:07:13 -04:00
RHICmdList . EndFrame ( ) ;
2014-09-11 09:38:38 -04:00
RHICmdList . PopEvent ( ) ;
2014-03-14 14:13:41 -04:00
} ) ;
}
// Check for async platform hardware survey results
GEngine - > TickHardwareSurvey ( ) ;
// Set CPU utilization stats.
const FCPUTime CPUTime = FPlatformTime : : GetCPUTime ( ) ;
SET_FLOAT_STAT ( STAT_CPUTimePct , CPUTime . CPUTimePct ) ;
SET_FLOAT_STAT ( STAT_CPUTimePctRelative , CPUTime . CPUTimePctRelative ) ;
}
void FEngineLoop : : ClearPendingCleanupObjects ( )
{
delete PendingCleanupObjects ;
PendingCleanupObjects = NULL ;
}
# endif // WITH_ENGINE
2015-04-21 13:43:58 -04:00
static void CheckForPrintTimesOverride ( )
{
GPrintLogTimes = ELogTimes : : None ;
// Determine whether to override the default setting for including timestamps in the log.
FString LogTimes ;
if ( GConfig - > GetString ( TEXT ( " LogFiles " ) , TEXT ( " LogTimes " ) , LogTimes , GEngineIni ) )
{
if ( LogTimes = = TEXT ( " SinceStart " ) )
{
GPrintLogTimes = ELogTimes : : SinceGStartTime ;
}
// Assume this is a bool for backward compatibility
else if ( FCString : : ToBool ( * LogTimes ) )
{
GPrintLogTimes = ELogTimes : : UTC ;
}
}
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " LOGTIMES " ) ) )
{
GPrintLogTimes = ELogTimes : : UTC ;
}
else if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " NOLOGTIMES " ) ) )
{
GPrintLogTimes = ELogTimes : : None ;
}
else if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " LOGTIMESINCESTART " ) ) )
{
GPrintLogTimes = ELogTimes : : SinceGStartTime ;
}
}
2014-03-14 14:13:41 -04:00
/* FEngineLoop static interface
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
2014-05-14 20:01:43 -04:00
bool FEngineLoop : : AppInit ( )
2014-03-14 14:13:41 -04:00
{
// Output devices.
GError = FPlatformOutputDevices : : GetError ( ) ;
GWarn = FPlatformOutputDevices : : GetWarn ( ) ;
BeginInitTextLocalization ( ) ;
// Avoiding potential exploits by not exposing command line overrides in the shipping games.
# if !UE_BUILD_SHIPPING && WITH_EDITORONLY_DATA
// 8192 is the maximum length of the command line on Windows XP.
TCHAR CmdLineEnv [ 8192 ] ;
// Retrieve additional command line arguments from environment variable.
FPlatformMisc : : GetEnvironmentVariable ( TEXT ( " UE-CmdLineArgs " ) , CmdLineEnv , ARRAY_COUNT ( CmdLineEnv ) ) ;
// Manually NULL terminate just in case. The NULL string is returned above in the error case so
// we don't have to worry about that.
CmdLineEnv [ ARRAY_COUNT ( CmdLineEnv ) - 1 ] = 0 ;
FString Env = FString ( CmdLineEnv ) . Trim ( ) ;
if ( Env . Len ( ) )
{
// Append the command line environment after inserting a space as we can't set it in the
// environment. Note that any code accessing GCmdLine before appInit obviously won't
// respect the command line environment additions.
FCommandLine : : Append ( TEXT ( " -EnvAfterHere " ) ) ;
FCommandLine : : Append ( CmdLineEnv ) ;
}
# endif
// Error history.
FCString : : Strcpy ( GErrorHist , TEXT ( " Fatal error! " LINE_TERMINATOR LINE_TERMINATOR ) ) ;
// Platform specific pre-init.
FPlatformMisc : : PlatformPreInit ( ) ;
// Keep track of start time.
GSystemStartTime = FDateTime : : Now ( ) . ToString ( ) ;
// Switch into executable's directory.
FPlatformProcess : : SetCurrentWorkingDirectoryToBaseDir ( ) ;
// Now finish initializing the file manager after the command line is set up
IFileManager : : Get ( ) . ProcessCommandLineOptions ( ) ;
# if !UE_BUILD_SHIPPING
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " BUILDMACHINE " ) ) )
{
GIsBuildMachine = true ;
}
2014-08-08 13:30:27 -04:00
// If "-WaitForDebugger" was specified, halt startup and wait for a debugger to attach before continuing
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " WaitForDebugger " ) ) )
{
2014-08-08 13:36:58 -04:00
while ( ! FPlatformMisc : : IsDebuggerPresent ( ) )
2014-08-08 13:30:27 -04:00
{
FPlatformProcess : : Sleep ( 0.1f ) ;
}
}
2014-03-14 14:13:41 -04:00
# endif // !UE_BUILD_SHIPPING
# if PLATFORM_WINDOWS
2014-11-07 09:46:18 -05:00
// make sure that the log directory exists
IFileManager : : Get ( ) . MakeDirectory ( * FPaths : : GameLogDir ( ) ) ;
2014-03-14 14:13:41 -04:00
// update the mini dump filename now that we have enough info to point it to the log folder even in installed builds
FCString : : Strcpy ( MiniDumpFilenameW , * IFileManager : : Get ( ) . ConvertToAbsolutePathForExternalAppForWrite ( * FString : : Printf ( TEXT ( " %sunreal-v%i-%s.dmp " ) , * FPaths : : GameLogDir ( ) , GEngineVersion . GetChangelist ( ) , * FDateTime : : Now ( ) . ToString ( ) ) ) ) ;
# endif
// Init logging to disk
2014-08-08 21:42:14 -04:00
FPlatformOutputDevices : : SetupOutputDevices ( ) ;
2014-03-14 14:13:41 -04:00
// init config system
FConfigCacheIni : : InitializeConfigSystem ( ) ;
2015-04-21 13:43:58 -04:00
CheckForPrintTimesOverride ( ) ;
2014-05-14 20:01:43 -04:00
// Check whether the project or any of its plugins are missing or are out of date
# if UE_EDITOR
2014-07-30 13:16:05 -04:00
if ( ! GIsBuildMachine & & FPaths : : IsProjectFilePathSet ( ) & & IPluginManager : : Get ( ) . AreRequiredPluginsAvailable ( ) )
2014-05-14 20:01:43 -04:00
{
2015-03-11 15:53:29 -04:00
const FProjectDescriptor * CurrentProject = IProjectManager : : Get ( ) . GetCurrentProject ( ) ;
if ( CurrentProject ! = nullptr & & CurrentProject - > Modules . Num ( ) > 0 )
2014-05-14 20:01:43 -04:00
{
2015-03-11 15:53:29 -04:00
bool bNeedCompile = false ;
2015-04-20 10:12:55 -04:00
GConfig - > GetBool ( TEXT ( " /Script/UnrealEd.EditorLoadingSavingSettings " ) , TEXT ( " bForceCompilationAtStartup " ) , bNeedCompile , GEditorPerProjectIni ) ;
2014-09-10 12:43:07 -04:00
2015-03-11 15:53:29 -04:00
if ( ! bNeedCompile )
2014-05-14 20:01:43 -04:00
{
2015-03-11 15:53:29 -04:00
// Check if any of the project or plugin modules are out of date, and the user wants to compile them.
TArray < FString > IncompatibleFiles ;
IProjectManager : : Get ( ) . CheckModuleCompatibility ( IncompatibleFiles ) ;
IPluginManager : : Get ( ) . CheckModuleCompatibility ( IncompatibleFiles ) ;
2014-09-10 12:43:07 -04:00
2015-03-11 15:53:29 -04:00
if ( IncompatibleFiles . Num ( ) > 0 )
2014-09-10 12:43:07 -04:00
{
2015-03-11 15:53:29 -04:00
// Log the modules which need to be rebuilt
FString ModulesList = TEXT ( " The following modules are missing or built with a different engine version: \n \n " ) ;
for ( int Idx = 0 ; Idx < IncompatibleFiles . Num ( ) ; Idx + + )
{
UE_LOG ( LogInit , Warning , TEXT ( " Incompatible or missing module: %s " ) , * IncompatibleFiles [ Idx ] ) ;
ModulesList + = IncompatibleFiles [ Idx ] + TEXT ( " \n " ) ;
}
ModulesList + = TEXT ( " \n Would you like to rebuild them now? " ) ;
// If we're running with -stdout, assume that we're a non interactive process and about to fail
if ( FApp : : IsUnattended ( ) | | FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " stdout " ) ) )
{
return false ;
}
// Ask whether to compile before continuing
if ( FPlatformMisc : : MessageBoxExt ( EAppMsgType : : YesNo , * ModulesList , * FString : : Printf ( TEXT ( " Missing %s Modules " ) , FApp : : GetGameName ( ) ) ) = = EAppReturnType : : No )
{
return false ;
}
bNeedCompile = true ;
}
}
if ( bNeedCompile )
{
// Try to compile it
FFeedbackContext * Context = ( FFeedbackContext * ) FDesktopPlatformModule : : Get ( ) - > GetNativeFeedbackContext ( ) ;
Context - > BeginSlowTask ( FText : : FromString ( TEXT ( " Starting build... " ) ) , true , true ) ;
bool bCompileResult = FDesktopPlatformModule : : Get ( ) - > CompileGameProject ( FPaths : : RootDir ( ) , FPaths : : GetProjectFilePath ( ) , Context ) ;
Context - > EndSlowTask ( ) ;
// Get a list of modules which are still incompatible
TArray < FString > StillIncompatibleFiles ;
IProjectManager : : Get ( ) . CheckModuleCompatibility ( StillIncompatibleFiles ) ;
IPluginManager : : Get ( ) . CheckModuleCompatibility ( StillIncompatibleFiles ) ;
if ( ! bCompileResult | | StillIncompatibleFiles . Num ( ) > 0 )
{
for ( int Idx = 0 ; Idx < StillIncompatibleFiles . Num ( ) ; Idx + + )
{
UE_LOG ( LogInit , Warning , TEXT ( " Still incompatible or missing module: %s " ) , * StillIncompatibleFiles [ Idx ] ) ;
}
FPlatformMisc : : MessageBoxExt ( EAppMsgType : : Ok , * FString : : Printf ( TEXT ( " %s could not be compiled. Try rebuilding from source manually. " ) , FApp : : GetGameName ( ) ) , TEXT ( " Error " ) ) ;
return false ;
2014-09-10 12:43:07 -04:00
}
}
2014-05-14 20:01:43 -04:00
}
}
# endif
2014-03-14 14:13:41 -04:00
// Load "pre-init" plugin modules
2014-07-30 13:16:05 -04:00
if ( ! IProjectManager : : Get ( ) . LoadModulesForProject ( ELoadingPhase : : PostConfigInit ) | | ! IPluginManager : : Get ( ) . LoadModulesForEnabledPlugins ( ELoadingPhase : : PostConfigInit ) )
2014-03-14 14:13:41 -04:00
{
2014-07-30 13:16:05 -04:00
return false ;
2014-03-14 14:13:41 -04:00
}
2014-08-05 17:36:56 -04:00
PreInitHMDDevice ( ) ;
2014-03-14 14:13:41 -04:00
// Put the command line and config info into the suppression system
FLogSuppressionInterface : : Get ( ) . ProcessConfigAndCommandLine ( ) ;
// after the above has run we now have the REQUIRED set of engine .INIs (all of the other .INIs)
// that are gotten from .h files' config() are not requires and are dynamically loaded when the .u files are loaded
# if !UE_BUILD_SHIPPING
// Prompt the user for remote debugging?
bool bPromptForRemoteDebug = false ;
GConfig - > GetBool ( TEXT ( " Engine.ErrorHandling " ) , TEXT ( " bPromptForRemoteDebugging " ) , bPromptForRemoteDebug , GEngineIni ) ;
bool bPromptForRemoteDebugOnEnsure = false ;
GConfig - > GetBool ( TEXT ( " Engine.ErrorHandling " ) , TEXT ( " bPromptForRemoteDebugOnEnsure " ) , bPromptForRemoteDebugOnEnsure , GEngineIni ) ;
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " PROMPTREMOTEDEBUG " ) ) )
{
bPromptForRemoteDebug = true ;
}
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " PROMPTREMOTEDEBUGENSURE " ) ) )
{
bPromptForRemoteDebug = true ;
bPromptForRemoteDebugOnEnsure = true ;
}
FPlatformMisc : : SetShouldPromptForRemoteDebugging ( bPromptForRemoteDebug ) ;
FPlatformMisc : : SetShouldPromptForRemoteDebugOnEnsure ( bPromptForRemoteDebugOnEnsure ) ;
// Feedback context.
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " WARNINGSASERRORS " ) ) )
{
GWarn - > TreatWarningsAsErrors = true ;
}
if ( FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " SILENT " ) ) )
{
GIsSilent = true ;
}
// Show log if wanted.
if ( GLogConsole & & FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " LOG " ) ) )
{
GLogConsole - > Show ( true ) ;
}
# endif // !UE_BUILD_SHIPPING
//// Command line.
UE_LOG ( LogInit , Log , TEXT ( " Version: %s " ) , * GEngineVersion . ToString ( ) ) ;
2014-06-20 13:02:34 -04:00
UE_LOG ( LogInit , Log , TEXT ( " API Version: %u " ) , MODULE_API_VERSION ) ;
2014-03-14 14:13:41 -04:00
# if PLATFORM_64BITS
UE_LOG ( LogInit , Log , TEXT ( " Compiled (64-bit): %s %s " ) , ANSI_TO_TCHAR ( __DATE__ ) , ANSI_TO_TCHAR ( __TIME__ ) ) ;
# else
UE_LOG ( LogInit , Log , TEXT ( " Compiled (32-bit): %s %s " ) , ANSI_TO_TCHAR ( __DATE__ ) , ANSI_TO_TCHAR ( __TIME__ ) ) ;
# endif
2014-08-18 09:48:44 -04:00
// Print compiler version info
# if defined(__clang__)
UE_LOG ( LogInit , Log , TEXT ( " Compiled with Clang: %s " ) , ANSI_TO_TCHAR ( __clang_version__ ) ) ;
# elif defined( _MSC_VER )
# ifndef __INTELLISENSE__ // Intellisense compiler doesn't support _MSC_FULL_VER
{
const FString VisualCPPVersion ( FString : : Printf ( TEXT ( " %d " ) , _MSC_FULL_VER ) ) ;
const FString VisualCPPRevisionNumber ( FString : : Printf ( TEXT ( " %02d " ) , _MSC_BUILD ) ) ;
UE_LOG ( LogInit , Log , TEXT ( " Compiled with Visual C++: %s.%s.%s.%s " ) ,
* VisualCPPVersion . Mid ( 0 , 2 ) , // Major version
* VisualCPPVersion . Mid ( 2 , 2 ) , // Minor version
* VisualCPPVersion . Mid ( 4 ) , // Build version
* VisualCPPRevisionNumber // Revision number
) ;
}
# endif
# else
UE_LOG ( LogInit , Log , TEXT ( " Compiled with unrecognized C++ compiler " ) ) ;
# endif
2014-03-14 14:13:41 -04:00
UE_LOG ( LogInit , Log , TEXT ( " Build Configuration: %s " ) , EBuildConfigurations : : ToString ( FApp : : GetBuildConfiguration ( ) ) ) ;
UE_LOG ( LogInit , Log , TEXT ( " Branch Name: %s " ) , * FApp : : GetBranchName ( ) ) ;
UE_LOG ( LogInit , Log , TEXT ( " Command line: %s " ) , FCommandLine : : Get ( ) ) ;
UE_LOG ( LogInit , Log , TEXT ( " Base directory: %s " ) , FPlatformProcess : : BaseDir ( ) ) ;
//UE_LOG(LogInit, Log, TEXT("Character set: %s"), sizeof(TCHAR)==1 ? TEXT("ANSI") : TEXT("Unicode") );
// if a logging build, clear out old log files
# if !NO_LOGGING && !(UE_BUILD_SHIPPING || UE_BUILD_TEST)
FMaintenance : : DeleteOldLogs ( ) ;
# endif
# if !UE_BUILD_SHIPPING
FApp : : InitializeSession ( ) ;
# endif
# if WITH_ENGINE
// Earliest place to init the online subsystems
// Code needs GConfigFile to be valid
// Must be after FThreadStats::StartThread();
// Must be before Render/RHI subsystem D3DCreate()
// For platform services that need D3D hooks like Steam
2015-02-26 16:03:12 -05:00
// --
// Why load HTTP?
// Because most, if not all online subsystems will load HTTP themselves. This can cause problems though, as HTTP will be loaded *after* OSS,
// and if OSS holds on to resources allocated by it, this will cause crash (modules are being unloaded in LIFO order with no dependency tracking).
// Loading HTTP before OSS works around this problem by making ModuleManager unload HTTP after OSS, at the cost of extra module for the few OSS (like Null) that don't use it.
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " HTTP " ) ) ;
2014-03-14 14:13:41 -04:00
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " OnlineSubsystem " ) ) ;
FModuleManager : : Get ( ) . LoadModule ( TEXT ( " OnlineSubsystemUtils " ) ) ;
# endif
// Checks.
check ( sizeof ( uint8 ) = = 1 ) ;
check ( sizeof ( int8 ) = = 1 ) ;
check ( sizeof ( uint16 ) = = 2 ) ;
check ( sizeof ( uint32 ) = = 4 ) ;
check ( sizeof ( uint64 ) = = 8 ) ;
check ( sizeof ( ANSICHAR ) = = 1 ) ;
# if PLATFORM_TCHAR_IS_4_BYTES
check ( sizeof ( TCHAR ) = = 4 ) ;
# else
check ( sizeof ( TCHAR ) = = 2 ) ;
# endif
check ( sizeof ( int16 ) = = 2 ) ;
check ( sizeof ( int32 ) = = 4 ) ;
check ( sizeof ( int64 ) = = 8 ) ;
check ( sizeof ( bool ) = = 1 ) ;
check ( sizeof ( float ) = = 4 ) ;
check ( sizeof ( double ) = = 8 ) ;
2014-04-30 07:58:10 -04:00
check ( GEngineNetVersion = = 0 | | GEngineNetVersion > = GEngineMinNetVersion | | GEngineVersion . IsLicenseeVersion ( ) ) ;
2014-03-14 14:13:41 -04:00
// Init list of common colors.
GColorList . CreateColorMap ( ) ;
2014-08-19 09:49:21 -04:00
bool bForceSmokeTests = false ;
GConfig - > GetBool ( TEXT ( " AutomationTesting " ) , TEXT ( " bForceSmokeTests " ) , bForceSmokeTests , GEngineIni ) ;
bForceSmokeTests | = FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " bForceSmokeTests " ) ) ;
FAutomationTestFramework : : GetInstance ( ) . SetForceSmokeTests ( bForceSmokeTests ) ;
2014-03-14 14:13:41 -04:00
// Init other systems.
FCoreDelegates : : OnInit . Broadcast ( ) ;
2014-05-14 20:01:43 -04:00
return true ;
2014-03-14 14:13:41 -04:00
}
void FEngineLoop : : AppPreExit ( )
{
UE_LOG ( LogExit , Log , TEXT ( " Preparing to exit. " ) ) ;
FCoreDelegates : : OnPreExit . Broadcast ( ) ;
# if WITH_ENGINE
if ( FString ( FCommandLine : : Get ( ) ) . Contains ( TEXT ( " CreatePak " ) ) & & GetDerivedDataCache ( ) )
{
// if we are creating a Pak, we need to make sure everything is done and written before we exit
UE_LOG ( LogInit , Display , TEXT ( " Closing DDC Pak File. " ) ) ;
GetDerivedDataCacheRef ( ) . WaitForQuiescence ( true ) ;
}
# endif
# if WITH_EDITOR
FRemoteConfig : : Flush ( ) ;
# endif
FCoreDelegates : : OnExit . Broadcast ( ) ;
// Clean up the thread pool
2015-03-24 07:29:32 -04:00
if ( GThreadPool ! = nullptr )
2014-03-14 14:13:41 -04:00
{
GThreadPool - > Destroy ( ) ;
}
2014-04-25 16:10:53 -04:00
# if WITH_ENGINE
if ( GShaderCompilingManager )
{
GShaderCompilingManager - > Shutdown ( ) ;
2014-12-16 20:00:07 -05:00
delete GShaderCompilingManager ;
GShaderCompilingManager = nullptr ;
2014-04-25 16:10:53 -04:00
}
# endif
2014-03-14 14:13:41 -04:00
}
void FEngineLoop : : AppExit ( )
{
UE_LOG ( LogExit , Log , TEXT ( " Exiting. " ) ) ;
2014-08-19 22:04:56 -04:00
FPlatformMisc : : PlatformTearDown ( ) ;
2014-03-14 14:13:41 -04:00
if ( GConfig )
{
GConfig - > Exit ( ) ;
delete GConfig ;
GConfig = NULL ;
}
if ( GLog )
{
GLog - > TearDown ( ) ;
}
2014-05-02 11:04:22 -04:00
FInternationalization : : TearDown ( ) ;
2014-03-14 14:13:41 -04:00
}
2014-08-05 17:36:56 -04:00
void FEngineLoop : : PreInitHMDDevice ( )
{
2014-08-28 13:49:44 -04:00
# if WITH_ENGINE && !UE_SERVER
2014-08-05 17:36:56 -04:00
if ( ! GIsEditor )
{
2014-08-14 21:29:44 -04:00
//@todo vr: only preinit first valid hmd?
2014-08-05 17:36:56 -04:00
if ( ! FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " nohmd " ) ) & & ! FParse : : Param ( FCommandLine : : Get ( ) , TEXT ( " emulatestereo " ) ) )
{
// Get a list of plugins that implement this feature
TArray < IHeadMountedDisplayModule * > HMDImplementations = IModularFeatures : : Get ( ) . GetModularFeatureImplementations < IHeadMountedDisplayModule > ( IHeadMountedDisplayModule : : GetModularFeatureName ( ) ) ;
for ( auto HMDModuleIt = HMDImplementations . CreateIterator ( ) ; HMDModuleIt ; + + HMDModuleIt )
{
( * HMDModuleIt ) - > PreInit ( ) ;
}
}
}
2014-08-28 13:49:44 -04:00
# endif // #if WITH_ENGINE && !UE_SERVER
2014-08-05 17:36:56 -04:00
}
2015-03-11 15:53:29 -04:00
# undef LOCTEXT_NAMESPACE