OSS.SteamInitServerOnClient

OSS.SteamInitServerOnClient

#Overview

name: OSS.SteamInitServerOnClient

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.SteamInitServerOnClient is to control whether the Steam server interface should be initialized on client machines. This setting is primarily used in the Online Subsystem Steam plugin for Unreal Engine 5.

This setting variable is relied upon by the Online Subsystem Steam plugin, which is part of Unreal Engine’s networking and online services infrastructure. Specifically, it’s used in the initialization process of the Steam subsystem.

The value of this variable is set through a console variable (CVar) named CVarSteamInitServerOnClient. It’s defined with a default value of 0 (false), meaning by default, the Steam server interface is not initialized on clients.

The associated variable CVarSteamInitServerOnClient interacts directly with OSS.SteamInitServerOnClient. They essentially represent the same setting, with CVarSteamInitServerOnClient being the actual CVar implementation.

Developers must be aware that this variable affects the initialization of the Steam server interface on client machines. Enabling this (by setting it to a non-zero value) could have implications for performance and network behavior, as it would initialize server-side Steam functionality on client machines.

Best practices when using this variable include:

  1. Leaving it at the default value (0) unless there’s a specific need for server functionality on clients.
  2. If enabling it, thoroughly testing the impact on client performance and network behavior.
  3. Considering the security implications of initializing server interfaces on clients.

Regarding the associated variable CVarSteamInitServerOnClient:

The purpose of CVarSteamInitServerOnClient is to provide a runtime-configurable way to control the OSS.SteamInitServerOnClient setting. It’s implemented as a console variable, allowing for dynamic changes during development or debugging.

This variable is used in the FOnlineSubsystemSteam::Init function to determine whether to attempt server initialization. It’s checked alongside other conditions (like whether the current instance is a server and a config file setting) to make this decision.

The value of CVarSteamInitServerOnClient can be changed through the console or configuration files. It’s defined with the ECVF_Default and ECVF_Cheat flags, indicating it’s a default variable that can be modified in non-shipping builds.

Developers should be aware that changes to this variable at runtime will affect the next initialization of the Steam subsystem. It’s particularly useful for testing and debugging but should be used cautiously in production environments.

Best practices for CVarSteamInitServerOnClient include:

  1. Using it primarily for development and testing purposes.
  2. Ensuring it’s not exposed or modifiable in shipping builds.
  3. Documenting any non-default usage of this variable in project documentation to ensure consistent behavior across development team members.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Private/OnlineSubsystemSteam.cpp:51

Scope (from outer to inner):

file
namespace    OSSConsoleVariables

Source code excerpt:

{
	TAutoConsoleVariable<int32> CVarSteamInitServerOnClient(
			TEXT("OSS.SteamInitServerOnClient"),
			0,
			TEXT("Whether or not to initialize the Steam server interface on clients (default false)"),
			ECVF_Default | ECVF_Cheat);

#if !UE_BUILD_SHIPPING
	/** CVar used by NetcodeUnitTest, to force-enable Steam within the unit test commandlet */

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Private/OnlineSubsystemSteam.cpp:50

Scope (from outer to inner):

file
namespace    OSSConsoleVariables

Source code excerpt:

namespace OSSConsoleVariables
{
	TAutoConsoleVariable<int32> CVarSteamInitServerOnClient(
			TEXT("OSS.SteamInitServerOnClient"),
			0,
			TEXT("Whether or not to initialize the Steam server interface on clients (default false)"),
			ECVF_Default | ECVF_Cheat);

#if !UE_BUILD_SHIPPING

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Private/OnlineSubsystemSteam.cpp:407

Scope (from outer to inner):

file
function     bool FOnlineSubsystemSteam::Init

Source code excerpt:

	bool bInitServerOnClient = false;
	GConfig->GetBool(TEXT("OnlineSubsystemSteam"), TEXT("bInitServerOnClient"), bInitServerOnClient, GEngineIni);
	bool bAttemptServerInit = bIsServer || !!OSSConsoleVariables::CVarSteamInitServerOnClient.GetValueOnGameThread() || bInitServerOnClient;

	UE_LOG_ONLINE(Verbose, TEXT("Steam: Starting SteamWorks. Client [%d] Server [%d]"), !bIsServer, bAttemptServerInit);
	
	// Don't initialize the Steam Client API if we are launching as a server
	bool bClientInitSuccess = !bIsServer ? InitSteamworksClient(bRelaunchInSteam, RelaunchAppId) : true;