FAtModuleInit() { static TScopedPointer<FVTuneExternalProfiler> ProfilerVTune( new FVTuneExternalProfiler() ); if( !ProfilerVTune->Initialize() ) { ProfilerVTune.Reset(); } }
void FDedicatedServerModule::ShutdownModule() { m_bShutdown = true; #if WITH_SERVER_CODE if( m_hAutoUpdateTicker.IsValid() ) FTicker::GetCoreTicker().RemoveTicker( m_hAutoUpdateTicker ); if( g_pConsole.IsValid() && m_hTick.IsValid() ) { g_pConsole->SendNullInput(); m_hTick.Wait(); } #endif }
/** * Finds the metadata for the struct specified * * @param Struct the struct to search for * * @return pointer to the metadata for the struct specified, or NULL * if the struct doesn't exist in the list (for example, if it * is declared in a package that is already compiled and has had its * source stripped) */ FStructData* FClassMetaData::FindStructData( UScriptStruct* Struct ) { FStructData* Result = NULL; TScopedPointer<FStructData>* pStructData = StructData.Find(Struct); if ( pStructData != NULL ) { Result = pStructData->GetOwnedPointer(); } if ( Result == NULL ) { UClass* OwnerClass = Struct->GetOwnerClass(); FClassMetaData* OwnerClassData = GScriptHelper.FindClassData(OwnerClass); if ( OwnerClassData && OwnerClassData != this ) { Result = OwnerClassData->FindStructData(Struct); } } return Result; }
/** * Finds the metadata for the property specified * * @param Prop the property to search for * * @return pointer to the metadata for the property specified, or NULL * if the property doesn't exist in the list (for example, if it * is declared in a package that is already compiled and has had its * source stripped) */ FTokenData* FClassMetaData::FindTokenData( UProperty* Prop ) { check(Prop); FTokenData* Result = nullptr; UObject* Outer = Prop->GetOuter(); UClass* OuterClass = nullptr; if (Outer->IsA<UStruct>()) { Result = GlobalPropertyData.Find(Prop); if (Result == nullptr) { OuterClass = Cast<UClass>(Outer); if (Result == nullptr && OuterClass != nullptr && OuterClass->GetSuperClass() != OuterClass) { OuterClass = OuterClass->GetSuperClass(); } } } else { UFunction* OuterFunction = Cast<UFunction>(Outer); if ( OuterFunction != NULL ) { // function parameter, return, or local property FFunctionData* FuncData = nullptr; if (FFunctionData::TryFindForFunction(OuterFunction, FuncData)) { FPropertyData& FunctionParameters = FuncData->GetParameterData(); Result = FunctionParameters.Find(Prop); if ( Result == NULL ) { Result = FuncData->GetReturnTokenData(); } } else { OuterClass = OuterFunction->GetOwnerClass(); } } else { // struct property UScriptStruct* OuterStruct = Cast<UScriptStruct>(Outer); check(OuterStruct != NULL); TScopedPointer<FStructData>* pStructInfo = StructData.Find(OuterStruct); if ( pStructInfo != NULL ) { FStructData* StructInfo = pStructInfo->GetOwnedPointer(); check(StructInfo); FPropertyData& StructProperties = StructInfo->GetStructPropertyData(); Result = StructProperties.Find(Prop); } else { OuterClass = OuterStruct->GetOwnerClass(); } } } if (Result == nullptr && OuterClass != nullptr) { FClassMetaData* SuperClassData = GScriptHelper.FindClassData(OuterClass); if (SuperClassData && SuperClassData != this) { Result = SuperClassData->FindTokenData(Prop); } } return Result; }
IPlatformFile* FPlatformFileManager::GetPlatformFile(const TCHAR* Name) { IPlatformFile* PlatformFile = NULL; // Check Core platform files (Profile, Log) by name. if (FCString::Strcmp(FLoggedPlatformFile::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FLoggedPlatformFile()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } #if !UE_BUILD_SHIPPING else if (FCString::Strcmp(TProfiledPlatformFile<FProfiledFileStatsFileDetailed>::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new TProfiledPlatformFile<FProfiledFileStatsFileDetailed>()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } else if (FCString::Strcmp(TProfiledPlatformFile<FProfiledFileStatsFileSimple>::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new TProfiledPlatformFile<FProfiledFileStatsFileSimple>()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } else if (FCString::Strcmp(FPlatformFileReadStats::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FPlatformFileReadStats()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } else if (FCString::Strcmp(FPlatformFileOpenLog::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FPlatformFileOpenLog()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } #endif else if (FCString::Strcmp(FCachedReadPlatformFile::GetTypeName(), Name) == 0) { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FCachedReadPlatformFile()); PlatformFile = AutoDestroySingleton.GetOwnedPointer(); } else { // Try to load a module containing the platform file. class IPlatformFileModule* PlatformFileModule = FModuleManager::LoadModulePtr<IPlatformFileModule>(Name); if (PlatformFileModule != NULL) { // TODO: Attempt to create platform file PlatformFile = PlatformFileModule->GetPlatformFile(); } } return PlatformFile; }
void FDedicatedServerModule::StartupModule() { #if WITH_SERVER_CODE if( IsRunningDedicatedServer() ) { bool bUseConsole = FParse::Param( FCommandLine::Get(), TEXT( "console" ) ); if( bUseConsole && !TIsSame<decltype( GLogConsole ), FServerConsole>::Value ) { g_pConsole = new FServerConsole(); if( g_pConsole.IsValid() ) { g_pConsole->Show( true ); GLog->RemoveOutputDevice( GLogConsole ); GLogConsole = g_pConsole.GetOwnedPointer(); GLog->AddOutputDevice( GLogConsole ); } m_hTick = Async<void>( EAsyncExecution::Thread, [this]() -> void { while( !m_bShutdown ) { if( g_pConsole.IsValid() && g_pConsole->IsShown() ) g_pConsole->Tick(); } } ); } bool bUseAutoUpdate = FParse::Param( FCommandLine::Get(), TEXT( "autoupdate" ) ); if( bUseAutoUpdate ) { FString sVersion = GConfig->GetStr( TEXT( "OnlineSubsystemSteam" ), TEXT( "GameVersion" ), GEngineIni ); IOnlineSubsystem* pSteam = IOnlineSubsystem::Get( STEAM_SUBSYSTEM ); m_hAutoUpdateTicker = FTicker::GetCoreTicker().AddTicker( FTickerDelegate::CreateLambda( [=]( float fDeltaTime ) -> bool { UE_LOG( LogDedicatedServer, Display, TEXT( "Checking for updates..." ) ); // ToDo: Do we have alternatives to the Steam API check? if( pSteam ) { TSharedRef<class IHttpRequest> hHTTPRequest = FHttpModule::Get().CreateRequest(); // Note: UpToDateCheck is expecting a uint32 where the rest of Steamworks uses a semver / integer string, so we have to convert it here... hHTTPRequest->SetURL( FString::Printf( TEXT( "https://api.steampowered.com/ISteamApps/UpToDateCheck/v0001/?appid=%s&version=%s" ), *pSteam->GetAppId(), *sVersion.Replace( TEXT( "." ), TEXT( "" ) ) ) ); hHTTPRequest->SetVerb( TEXT( "GET" ) ); hHTTPRequest->OnProcessRequestComplete().BindLambda( [=]( FHttpRequestPtr pHTTPRequest, FHttpResponsePtr pHTTPResponse, bool bSucceeded ) -> void { if( bSucceeded && pHTTPResponse->GetResponseCode() == EHttpResponseCodes::Ok ) { TSharedPtr<FJsonObject> pJSONObject; TSharedRef<TJsonReader<>> hJSONReader = TJsonReaderFactory<>::Create( pHTTPResponse->GetContentAsString() ); if( FJsonSerializer::Deserialize( hJSONReader, pJSONObject ) && pJSONObject.IsValid() ) { TSharedPtr<FJsonObject> pResponse = pJSONObject->GetObjectField( TEXT( "response" ) ); if( pResponse.IsValid() && pResponse->GetBoolField( TEXT( "success" ) ) ) { if( !pResponse->GetBoolField( TEXT( "up_to_date" ) ) ) { // ToDo: find a better way which also respects the message field... FString sRequiredVersion = FString::FromInt( pResponse->GetIntegerField( TEXT( "required_version" ) ) ); UE_LOG( LogDedicatedServer, Warning, TEXT( "The server is outdated( %s -> %s ), restarting..." ), *sVersion, ( sRequiredVersion.Equals( sVersion ) ? *sRequiredVersion : *Str2SemVer( sRequiredVersion ) )/*, pResponse->GetStringField( "message" )*/ ); GIsRequestingExit = true; m_bShutdown = true; } else UE_LOG( LogDedicatedServer, Display, TEXT( "The server is using the most recent version( %s )" ), *sVersion ); } } } } ); hHTTPRequest->ProcessRequest(); } if( m_bShutdown ) return false; return true; } ), 60.0f ); } } #endif }
virtual IPlatformFile* GetPlatformFile() override { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FSandboxPlatformFile(true)); return AutoDestroySingleton.GetOwnedPointer(); }
virtual IPlatformFile* GetPlatformFile() override { static TScopedPointer<IPlatformFile> AutoDestroySingleton(new FStreamingNetworkPlatformFile()); return AutoDestroySingleton.GetOwnedPointer(); }
void FAsyncSoundFileImportTask::DoWork() { // Create a new sound file object TScopedPointer<FSoundFile> SoundFileInput = TScopedPointer<FSoundFile>(new FSoundFile()); // Open the file ESoundFileError::Type Error = SoundFileInput->OpenFileForReading(ImportSettings.SoundFilePath); SOUND_IMPORT_CHECK(Error); TSharedPtr<ISoundFileData> SoundFileData; Error = SoundFileInput->GetSoundFileData(SoundFileData); SOUND_IMPORT_CHECK(Error); // Get the input file's description const FSoundFileDescription& InputDescription = SoundFileData->GetDescription(); // Get the input file's channel map const TArray<ESoundFileChannelMap::Type>& InputChannelMap = SoundFileData->GetChannelMap(); // Build a description for the new file FSoundFileDescription NewSoundFileDescription; NewSoundFileDescription.NumChannels = InputDescription.NumChannels; NewSoundFileDescription.NumFrames = InputDescription.NumFrames; NewSoundFileDescription.FormatFlags = ImportSettings.Format; NewSoundFileDescription.SampleRate = ImportSettings.SampleRate; NewSoundFileDescription.NumSections = 0; NewSoundFileDescription.bIsSeekable = 1; // Open it as an empty file for reading and writing ISoundFileInternal* SoundFileInternal = (ISoundFileInternal*)SoundFile.Get(); Error = SoundFileInternal->OpenEmptyFileForImport(NewSoundFileDescription, InputChannelMap); SOUND_IMPORT_CHECK(Error); // Set the original description on the new sound file Error = SoundFileInternal->SetImportFileInfo(InputDescription, ImportSettings.SoundFilePath); SOUND_IMPORT_CHECK(Error); // Set the encoding quality (will only do anything if import target is Ogg-Vorbis) Error = SoundFileInternal->SetEncodingQuality(ImportSettings.EncodingQuality); SOUND_IMPORT_CHECK(Error); // Set the state of the sound file to be loading Error = SoundFileInternal->BeginImport(); SOUND_IMPORT_CHECK(Error); // Create a buffer to do the processing SoundFileCount ProcessBufferSamples = 1024 * NewSoundFileDescription.NumChannels; TArray<double> ProcessBuffer; ProcessBuffer.Init(0.0, ProcessBufferSamples); // Find the max value if we've been told to do peak normalization on import double MaxValue = 0.0; SoundFileCount SamplesRead = 0; bool bPerformPeakNormalization = ImportSettings.bPerformPeakNormalization; if (bPerformPeakNormalization) { Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead); SOUND_IMPORT_CHECK(Error); while (SamplesRead) { for (SoundFileCount Sample = 0; Sample < SamplesRead; ++Sample) { if (ProcessBuffer[Sample] > FMath::Abs(MaxValue)) { MaxValue = ProcessBuffer[Sample]; } } Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead); SOUND_IMPORT_CHECK(Error); } // If this happens, it means we have a totally silent file if (MaxValue == 0.0) { bPerformPeakNormalization = false; } // Seek the file back to the beginning SoundFileCount OutOffset; SoundFileInput->SeekFrames(0, ESoundFileSeekMode::FROM_START, OutOffset); } // Now perform the encoding to the target file Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead); SOUND_IMPORT_CHECK(Error); while (SamplesRead) { SOUND_IMPORT_CHECK(SoundFileInput->GetError()); // Normalize the samples if we're told to if (bPerformPeakNormalization) { for (int32 Sample = 0; Sample < SamplesRead; ++Sample) { ProcessBuffer[Sample] /= MaxValue; } } SoundFileCount SamplesWritten; Error = SoundFileInternal->WriteSamples((const double*)ProcessBuffer.GetData(), SamplesRead, SamplesWritten); SOUND_IMPORT_CHECK(Error); Error = SoundFileInput->ReadSamples(ProcessBuffer.GetData(), ProcessBufferSamples, SamplesRead); SOUND_IMPORT_CHECK(Error); } SoundFileInput->ReleaseSoundFileHandle(); SoundFileInternal->ReleaseSoundFileHandle(); // We're done doing the encoding Error = SoundFileInternal->EndImport(); SOUND_IMPORT_CHECK(Error); }