oss.PlatformOverride

oss.PlatformOverride

#Overview

name: oss.PlatformOverride

This variable is created as a Console Variable (cvar).

It is referenced in 3 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of oss.PlatformOverride is to override the detected platform of the client for debugging purposes in the Online Subsystem of Unreal Engine 5. This setting variable allows developers to simulate different platforms during development and testing without changing the actual hardware or operating system.

The Online Subsystem module relies on this setting variable. It’s primarily used in the OnlineSubsystem plugin, which is responsible for handling various online features and services in Unreal Engine games.

The value of this variable is set through a console variable (CVar) named CVarPlatformOverride. It can be set at runtime using console commands or through configuration files.

The associated variable CVarPlatformOverride interacts directly with oss.PlatformOverride. They share the same value and purpose.

Developers must be aware that:

  1. This variable is intended for debugging and should not be used in shipping builds.
  2. Valid values for this variable are WIN, MAC, PSN, XBL, IOS, AND, LIN, SWT, and OTHER.
  3. Using this variable may affect platform-specific behavior in the Online Subsystem, so thorough testing is required when using it.

Best practices when using this variable include:

  1. Only use it for debugging and testing purposes.
  2. Reset the value to an empty string or remove it entirely before shipping the game.
  3. Be cautious when testing platform-specific features, as the overridden platform may not fully simulate all aspects of the target platform.

Regarding the associated variable CVarPlatformOverride:

The purpose of CVarPlatformOverride is to provide a programmatic way to access and modify the oss.PlatformOverride value within the C++ code of the Online Subsystem.

It’s used in the OnlineSubsystem module, specifically in the IOnlineSubsystem class.

The value of CVarPlatformOverride is set when the console variable oss.PlatformOverride is modified.

CVarPlatformOverride interacts directly with the oss.PlatformOverride setting and is used to retrieve its value in the GetLocalPlatformName() function.

Developers should be aware that:

  1. CVarPlatformOverride is a TAutoConsoleVariable, which means it’s automatically registered with the console variable system.
  2. It has the ECVF_Cheat flag, indicating it should only be used for debugging and cheats.

Best practices for using CVarPlatformOverride include:

  1. Access its value using the GetValueOnAnyThread() method when needed in C++ code.
  2. Don’t modify it directly; instead, use the console commands to change oss.PlatformOverride.
  3. Consider adding preprocessor guards (#if !UE_BUILD_SHIPPING) around code that uses this variable to ensure it’s not accessed in shipping builds.

#References in C++ code

#Callsites

This variable is referenced in the following C++ source code:

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystem.cpp:266

Scope: file

Source code excerpt:


TAutoConsoleVariable<FString> CVarPlatformOverride(
	TEXT("oss.PlatformOverride"),
	TEXT(""),
	TEXT("Overrides the detected platform of this client for various debugging\n")
	TEXT("Valid values WIN MAC PSN XBL IOS AND LIN SWT OTHER"),
	ECVF_Cheat);

FString IOnlineSubsystem::GetLocalPlatformName()

#Associated Variable and Callsites

This variable is associated with another variable named CVarPlatformOverride. They share the same value. See the following C++ source code.

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystem.cpp:265

Scope: file

Source code excerpt:

}

TAutoConsoleVariable<FString> CVarPlatformOverride(
	TEXT("oss.PlatformOverride"),
	TEXT(""),
	TEXT("Overrides the detected platform of this client for various debugging\n")
	TEXT("Valid values WIN MAC PSN XBL IOS AND LIN SWT OTHER"),
	ECVF_Cheat);

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystem/Source/Private/OnlineSubsystem.cpp:277

Scope (from outer to inner):

file
function     FString IOnlineSubsystem::GetLocalPlatformName

Source code excerpt:


	// Priority: CVar -> Command line -> INI, defaults to OTHER
	OnlinePlatform = CVarPlatformOverride.GetValueOnAnyThread();
#if !UE_BUILD_SHIPPING
	if (OnlinePlatform.IsEmpty())
	{
		FParse::Value(FCommandLine::Get(), TEXT("PLATFORMTEST="), OnlinePlatform);
	}
#endif