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; }
/** * 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; }
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(); }