bForceOfflineMode

bForceOfflineMode

#Overview

name: bForceOfflineMode

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 bForceOfflineMode is to simulate an offline environment within the Null Online Subsystem of Unreal Engine. It allows developers to test how their game behaves when network connectivity is unavailable.

This setting variable is primarily used by the Null Online Subsystem, which is a part of Unreal Engine’s online services framework. It’s specifically utilized in the OnlineSubsystemNull plugin, which provides a mock implementation of online features for testing and development purposes.

The value of this variable is set in multiple ways:

  1. It can be set via the console variable “OSSNull.ForceOfflineMode”.
  2. It can be configured in the engine’s configuration file (GEngineIni) under the “OnlineSubsystemNull” section.
  3. It’s initialized as a static boolean in the FOnlineSubsystemNull class.

This variable interacts with other parts of the Null Online Subsystem, particularly affecting the behavior of user login status and privileges. For example, when bForceOfflineMode is true, the GetLoginStatus function returns “UsingLocalProfile” instead of an online status.

Developers should be aware that enabling this variable will cause the system to behave as if it’s offline, which can affect various online-dependent features. It’s particularly useful for testing offline scenarios or simulating network unavailability.

Best practices when using this variable include:

  1. Use it during development and testing phases to ensure your game gracefully handles offline scenarios.
  2. Remember to disable it when testing actual online functionality.
  3. Consider using it in combination with other Null Online Subsystem settings for comprehensive offline testing.
  4. Be aware that it may affect other systems that depend on online functionality, so thorough testing is necessary when toggling this setting.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:2319, section: [OnlineSubsystemNull]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemNull/Source/Private/OnlineIdentityNull.cpp:278

Scope (from outer to inner):

file
function     ELoginStatus::Type FOnlineIdentityNull::GetLoginStatus

Source code excerpt:

		UserAccount->GetUserId()->IsValid())
	{
		if (FOnlineSubsystemNull::bForceOfflineMode)
		{
			return ELoginStatus::UsingLocalProfile;
		}
		else if (FOnlineSubsystemNull::bOnlineRequiresSecondLogin)
		{
			FString LoginCountString = TEXT("0");

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemNull/Source/Private/OnlineIdentityNull.cpp:353

Scope (from outer to inner):

file
function     void FOnlineIdentityNull::GetUserPrivilege

Source code excerpt:

void FOnlineIdentityNull::GetUserPrivilege(const FUniqueNetId& UserId, EUserPrivileges::Type Privilege, const FOnGetUserPrivilegeCompleteDelegate& Delegate, EShowPrivilegeResolveUI ShowResolveUI)
{
	if (FOnlineSubsystemNull::bForceOfflineMode && Privilege == EUserPrivileges::CanPlayOnline)
	{
		Delegate.ExecuteIfBound(UserId, Privilege, (uint32)EPrivilegeResults::NetworkConnectionUnavailable);
	}
	Delegate.ExecuteIfBound(UserId, Privilege, (uint32)EPrivilegeResults::NoFailures);
}

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemNull/Source/Private/OnlineSubsystemNull.cpp:251

Scope: file

Source code excerpt:

	ECVF_Default | ECVF_Cheat);

bool FOnlineSubsystemNull::bForceOfflineMode = false;
FAutoConsoleVariableRef CVarForceOfflineMode(
	TEXT("OSSNull.ForceOfflineMode"),
	FOnlineSubsystemNull::bForceOfflineMode,
	TEXT("True if it should fail faked network queries and act like an offline system"),
	ECVF_Default | ECVF_Cheat);

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemNull/Source/Private/OnlineSubsystemNull.cpp:283

Scope (from outer to inner):

file
function     bool FOnlineSubsystemNull::Init

Source code excerpt:

			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bAddUserNumToNullId"), bAddUserNumToNullId, GEngineIni);
			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bForceStableNullId"), bForceStableNullId, GEngineIni);
			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bForceOfflineMode"), bForceOfflineMode, GEngineIni);
			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bOnlineRequiresSecondLogin"), bOnlineRequiresSecondLogin, GEngineIni);

			if (FParse::Param(FCommandLine::Get(), TEXT("StableNullID")))
			{
				bForceStableNullId = true;
			}

#Loc: <Workspace>/Engine/Plugins/Online/OnlineSubsystemNull/Source/Public/OnlineSubsystemNull.h:123

Scope (from outer to inner):

file
class        class FOnlineSubsystemNull : public FOnlineSubsystemImpl

Source code excerpt:


	/** True if it should fail faked network queries and act like an offline system */
	static bool bForceOfflineMode;

	/** True if the first login only counts as local login, a second is required for online access */
	static bool bOnlineRequiresSecondLogin;

private: