SetCVar not working when ALLOW_OTHER_PLATFORM_CONFIG is false

Hello Epic,

We found that the SetCVar console command is not working as expected when ALLOW_OTHER_PLATFORM_CONFIG is false. When this preprocessor define is true, we can use SetCVar to set a cvar to a specific value and a specific priority, but when ALLOW_OTHER_PLATFORM_CONFIG is false, SetCVar reports “Unable to lookup a CVar value on another platform in this build”. We believe this is a bug in the SetUnsetCVar function in ConsoleManager.cpp, and the end of this function should be as follows:

	if (CVar == nullptr)
	{
 Ar.Logf(TEXT("No CVar named %s"), *CVarName);
 return;
	}
 
	// get platform version
	if (PlatformName.Len())
	{
 
#if ALLOW_OTHER_PLATFORM_CONFIG
 CVar = CVar->GetPlatformValueVariable(*PlatformName, *DeviceProfileName).Get();
 
 if (CVar == nullptr)
 {
 Ar.Logf(TEXT("Failed to get CVar for platform %s"), *PlatformName);
 return;
 }
#else
 Ar.Logf(TEXT("Unable to lookup a CVar value on another platform in this build"));
 return;
#endif
	}
 
 
	FString Value;
	if (bSet)
	{
 Value = FParse::Token(Params, false);
	}
 
	EConsoleVariableFlags SetBy = ECVF_SetByConsole;
	FName Tag = NAME_None;
	FString Str;
 
	if (FParse::Value(Params, TEXT("-setby="), Str))
	{
 SetBy = GetConsoleVariableSetByValue(*Str);
	}
 
	if (FParse::Value(Params, TEXT("-tag="), Str))
	{
 Tag = *Str;
	}
 
	if (bSet)
	{
 CVar->Set(*Value, SetBy, Tag);
	}
	else
	{
 CVar->Unset(SetBy, Tag);
	}
}

We basically just move the #if line and the #else block of code.

Can you please confirm that this is the expected behavior?

Steps to Reproduce
Compile the engine with ALLOW_OTHER_PLATFORM_CONFIG set to false and use the SetCVar console command to set any CVar to a given value. Instead of setting the CVar to the given value, the engine reports “Unable to lookup a CVar value on another platform in this build”.

Hi,

I believe that your fix is correct, we should only be preventing access to the cvar values for other platforms if ALLOW_OTHER_PLATFORM_CONFIG is 0, not the current platforms.

Would you like me to just submit this to UE 5.8 or would you prefer to make a GitHub PR so that we can properly credit you with the fix? Unfortunately due to various data rules we require the PR to be able to correctly credit people.

Thanks, I’ll grab that once it makes it’s way through our system but given my timezone (GMT+2) I will not be able to safely submit this until tomorrow. I will reply here again to confirm once it is in.

UE5 Main CL 47305175

GitHub Hash 35a68ee662166beac18ec24214f3315544cf18c4

I’ll prepare a PR.

https://github.com/EpicGames/UnrealEngine/pull/13961