void UDeveloperSettings::ImportConsoleVariableValues() { for (UProperty* Property = GetClass()->PropertyLink; Property; Property = Property->PropertyLinkNext) { if (!Property->HasAnyPropertyFlags(CPF_Config)) { continue; } FString CVarName = Property->GetMetaData(DeveloperSettingsConsoleVariableMetaFName); if (!CVarName.IsEmpty()) { IConsoleVariable* CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName); if (CVar) { if (Property->ImportText(*CVar->GetString(), Property->ContainerPtrToValuePtr<uint8>(this, 0), PPF_ConsoleVariable, this) == NULL) { UE_LOG(LogTemp, Error, TEXT("%s import failed for %s on console variable %s (=%s)"), *GetClass()->GetName(), *Property->GetName(), *CVarName, *CVar->GetString()); } } else { UE_LOG(LogTemp, Fatal, TEXT("%s failed to find console variable %s for %s"), *GetClass()->GetName(), *CVarName, *Property->GetName()); } } } }
bool UGameEngine::Exec( UWorld* InWorld, const TCHAR* Cmd, FOutputDevice& Ar ) { if( FParse::Command( &Cmd,TEXT("REATTACHCOMPONENTS")) || FParse::Command( &Cmd,TEXT("REREGISTERCOMPONENTS"))) { UE_LOG(LogConsoleResponse, Warning, TEXT("Deprectated command! Please use 'Reattach.Components' instead.")); return true; } else if( FParse::Command( &Cmd,TEXT("EXIT")) || FParse::Command(&Cmd,TEXT("QUIT"))) { FString CmdName = FParse::Token(Cmd, 0); bool Background = false; if (!CmdName.IsEmpty() && !FCString::Stricmp(*CmdName, TEXT("background"))) { Background = true; } if ( Background && FPlatformProperties::SupportsMinimize() ) { return HandleMinimizeCommand( Cmd, Ar ); } else if ( FPlatformProperties::SupportsQuit() ) { return HandleExitCommand( Cmd, Ar ); } else { // ignore command on xbox one and ps4 as it will cause a crash // ttp:321126 return true; } } else if( FParse::Command( &Cmd, TEXT("GETMAXTICKRATE") ) ) { return HandleGetMaxTickRateCommand( Cmd, Ar ); } else if( FParse::Command( &Cmd, TEXT("CANCEL") ) ) { return HandleCancelCommand( Cmd, Ar, InWorld ); } else if ( FParse::Command( &Cmd, TEXT("TOGGLECVAR") ) ) { FString CVarName; FParse::Token(Cmd, CVarName, false); bool bEnoughParamsSupplied = false; IConsoleVariable * CVar = nullptr; if (CVarName.Len() > 0) { CVar = IConsoleManager::Get().FindConsoleVariable(*CVarName); } if (CVar) { // values to toggle between FString StringVal1, StringVal2; if (FParse::Token(Cmd, StringVal1, false)) { if (FParse::Token(Cmd, StringVal2, false)) { bEnoughParamsSupplied = true; FString CurrentValue = CVar->GetString(); FString Command(FString::Printf(TEXT("%s %s"), *CVarName, (CurrentValue == StringVal1) ? *StringVal2 : *StringVal1)); GEngine->Exec(InWorld, *Command); } } } else { Ar.Log(*FString::Printf(TEXT("TOGGLECVAR: cvar '%s' was not found"), *CVarName)); bEnoughParamsSupplied = true; // cannot say anything about the rest of parameters } if (!bEnoughParamsSupplied) { Ar.Log(TEXT("Usage: TOGGLECVAR CVarName Value1 Value2")); } return true; } #if !UE_BUILD_SHIPPING else if( FParse::Command( &Cmd, TEXT("ApplyUserSettings") ) ) { return HandleApplyUserSettingsCommand( Cmd, Ar ); } #endif // !UE_BUILD_SHIPPING else if( InWorld && InWorld->Exec( InWorld, Cmd, Ar ) ) { return true; } else if( InWorld && InWorld->GetAuthGameMode() && InWorld->GetAuthGameMode()->ProcessConsoleExec(Cmd,Ar,NULL) ) { return true; } else { #if UE_BUILD_SHIPPING // disallow set of actor properties if network game if ((FParse::Command( &Cmd, TEXT("SET")) || FParse::Command( &Cmd, TEXT("SETNOPEC")))) { FWorldContext &Context = GetWorldContextFromWorldChecked(InWorld); if( Context.PendingNetGame != NULL || InWorld->GetNetMode() != NM_Standalone) { return true; } // the effects of this cannot be easily reversed, so prevent the user from playing network games without restarting to avoid potential exploits GDisallowNetworkTravel = true; } #endif // UE_BUILD_SHIPPING if (UEngine::Exec(InWorld, Cmd, Ar)) { return true; } else if (UPlatformInterfaceBase::StaticExec(Cmd, Ar)) { return true; } return false; } }