bRelaunchInSteam

bRelaunchInSteam

#Overview

name: bRelaunchInSteam

The value of this variable can be defined or overridden in .ini config files. 1 .ini config file referencing this setting variable.

It is referenced in 5 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bRelaunchInSteam is to control whether the game should force a relaunch within the Steam client if it’s not already running through Steam. This setting is primarily used by the Online Subsystem Steam plugin, which is part of Unreal Engine’s networking and online services framework.

The Online Subsystem Steam plugin relies on this setting variable to determine how to initialize the Steam client API. Specifically, it’s used in the initialization process of the FOnlineSubsystemSteam class, which is responsible for interfacing with Steam’s online services.

The value of this variable is typically set in the DefaultEngine.ini configuration file, under the [OnlineSubsystemSteam] section. If not found, the engine logs a warning message.

This variable interacts closely with another variable, RelaunchAppId, which specifies the Steam App ID to use when relaunching the game through Steam.

Developers must be aware that when this variable is set to true and the game is not launched through Steam, it will trigger a relaunch of the game through the Steam client and exit the current instance. This behavior is crucial for ensuring that Steam’s features are properly initialized and available to the game.

Best practices when using this variable include:

  1. Ensure it’s properly set in the DefaultEngine.ini file to avoid unexpected behavior.
  2. Use it in conjunction with the correct Steam App ID to ensure proper relaunching.
  3. Be cautious when modifying this setting, as it can affect how players launch and interact with the game through Steam.
  4. Consider the implications for different build configurations (development, shipping, etc.) and adjust accordingly.
  5. Test thoroughly to ensure the game behaves correctly both when launched through Steam and when not, especially if this setting is enabled.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2246, section: [OnlineSubsystemSteam]

#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:176

Scope (from outer to inner):

file
function     bool ConfigureSteamInitDevOptions

Source code excerpt:


	// Should the game force a relaunch in Steam if the client isn't already loaded
	if (!GConfig->GetBool(TEXT("OnlineSubsystemSteam"), TEXT("bRelaunchInSteam"), RequireRelaunch, GEngineIni))
	{
		UE_LOG_ONLINE(Warning, TEXT("Missing bRelaunchInSteam key in OnlineSubsystemSteam of DefaultEngine.ini"));
	}

#else
	// Always check against the Steam client when shipping

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

Scope (from outer to inner):

file
function     bool FOnlineSubsystemSteam::Init

Source code excerpt:

bool FOnlineSubsystemSteam::Init()
{
	bool bRelaunchInSteam = false;
	int RelaunchAppId = 0;

	if (!ConfigureSteamInitDevOptions(bRelaunchInSteam, RelaunchAppId))
	{
		UE_LOG_ONLINE(Warning, TEXT("Could not set up the steam environment! Falling back to another OSS."));
		return false;
	}

	const bool bIsServer = IsRunningDedicatedServer();

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

Scope (from outer to inner):

file
function     bool FOnlineSubsystemSteam::Init

Source code excerpt:

	
	// Don't initialize the Steam Client API if we are launching as a server
	bool bClientInitSuccess = !bIsServer ? InitSteamworksClient(bRelaunchInSteam, RelaunchAppId) : true;

	// Initialize the Steam Server API if this is a dedicated server or servers should initialize on clients
	bool bServerInitSuccess = bAttemptServerInit ? (InitSteamworksServer()) : true;

	if (bClientInitSuccess && bServerInitSuccess)
	{

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

Scope (from outer to inner):

file
function     bool FOnlineSubsystemSteam::InitSteamworksClient

Source code excerpt:

}

bool FOnlineSubsystemSteam::InitSteamworksClient(bool bRelaunchInSteam, int32 SteamAppId)
{
	bSteamworksClientInitialized = false;

	// If the game was not launched from within Steam, but is supposed to, trigger a Steam launch and exit
	if (bRelaunchInSteam && SteamAppId != 0 && SteamAPI_RestartAppIfNecessary(SteamAppId))
	{
		if (FPlatformProperties::IsGameOnly() || FPlatformProperties::IsServerOnly())
		{
			UE_LOG_ONLINE(Log, TEXT("Game restarting within Steam client, exiting"));
			FPlatformMisc::RequestExit(false);
		}

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemSteam/Source/Public/OnlineSubsystemSteam.h:182

Scope (from outer to inner):

file
class        class FOnlineSubsystemSteam : public FOnlineSubsystemImpl

Source code excerpt:

	 * @return true if the API was initialized successfully, false otherwise
	 */
	bool InitSteamworksClient(bool bRelaunchInSteam, int32 SteamAppId);

	/**
	 *	Initialize the server side APIs for Steam 
	 * @return true if the API was initialized successfully, false otherwise
	 */
	bool InitSteamworksServer();