bAddUserNumToNullId

bAddUserNumToNullId

#Overview

name: bAddUserNumToNullId

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 6 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of bAddUserNumToNullId is to control whether the local user number should be added to the generated user ID in the Null Online Subsystem. This setting is primarily used for testing and development purposes within Unreal Engine’s online services framework.

This setting variable is relied upon by the Null Online Subsystem, which is part of Unreal Engine’s online services framework. Specifically, it’s used in the OnlineSubsystemNull plugin and the OnlineServicesNull plugin, which provide mock implementations of online services for testing and development.

The value of this variable is set in multiple ways:

  1. It can be set via the engine configuration file (GEngineIni) under the [OnlineSubsystemNull] section.
  2. It’s exposed as a console variable “OSSNull.AddUserNumToNullId”, allowing runtime modification.
  3. It’s initialized in the FOnlineSubsystemNull::Init function, where it reads the value from the configuration file.

This variable interacts with other settings in the Null Online Subsystem, such as bForceStableNullId and bForceOfflineMode. These settings collectively determine how the mock online system behaves.

Developers must be aware that this variable affects the generation of user IDs in the Null Online Subsystem. When set to true, it appends the local user number to the generated ID, which can be useful for testing scenarios where you need to simulate multiple users on the same machine.

Best practices when using this variable include:

  1. Use it primarily in development and testing environments, not in production.
  2. Consider enabling it when testing features that rely on unique user IDs for multiple local users.
  3. Be consistent in its usage across your development team to ensure reproducible behavior in the Null Online Subsystem.
  4. Document its usage in your project’s development guidelines to ensure all team members understand its purpose and effects.

#Setting Variables

#References In INI files

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

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineServicesNull/Source/Private/Online/AuthNull.cpp:16

Scope (from outer to inner):

file
namespace    UE::Online

Source code excerpt:

struct FAuthNullConfig
{
	bool bAddUserNumToNullId = false;
	bool bForceStableNullId = false;
};

namespace Meta {

BEGIN_ONLINE_STRUCT_META(FAuthNullConfig)
	ONLINE_STRUCT_FIELD(FAuthNullConfig, bAddUserNumToNullId),
	ONLINE_STRUCT_FIELD(FAuthNullConfig, bForceStableNullId)
END_ONLINE_STRUCT_META()

/* Meta*/ }

namespace {

#Loc: <Workspace>/Engine/Plugins/Online/OnlineServicesNull/Source/Private/Online/AuthNull.cpp:48

Scope (from outer to inner):

file
namespace    UE::Online
namespace    anonymous
function     FString GenerateRandomUserId

Source code excerpt:

	FString UserSuffix;

	if (Config.bAddUserNumToNullId)
	{
		UserSuffix = FString::Printf(TEXT("-%d"), PlatformUserId.GetInternalId());
	}
	 
	if (FPlatformProcess::IsFirstInstance() && !GIsEditor)
	{

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

Scope (from outer to inner):

file
function     FString FOnlineIdentityNull::GenerateRandomUserId

Source code excerpt:

	FString UserSuffix;

	if (FOnlineSubsystemNull::bAddUserNumToNullId)
	{
		UserSuffix = FString::Printf(TEXT("-%d"), LocalUserNum);
	}

	if (FPlatformProcess::IsFirstInstance() && !GIsEditor)
	{

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

Scope: file

Source code excerpt:

	ECVF_Default | ECVF_Cheat);

bool FOnlineSubsystemNull::bAddUserNumToNullId = false;
FAutoConsoleVariableRef CVarAddUserNumToNullId(
	TEXT("OSSNull.AddUserNumToNullId"),
	FOnlineSubsystemNull::bAddUserNumToNullId,
	TEXT("True if login name should include the local user number, which allows different stable Ids per user num"),
	ECVF_Default | ECVF_Cheat);

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

Scope (from outer to inner):

file
function     bool FOnlineSubsystemNull::Init

Source code excerpt:

			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bForceShowLoginUIUserChange"), bForceShowLoginUIUserChange, GEngineIni);
			GConfig->GetBool(TEXT("OnlineSubsystemNull"), TEXT("bRequireLoginCredentials"), bRequireLoginCredentials, GEngineIni);
			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")))
			{

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

Scope (from outer to inner):

file
class        class FOnlineSubsystemNull : public FOnlineSubsystemImpl

Source code excerpt:


	/** True if login name should include the local user number, which allows different stable IDs per user num */
	static bool bAddUserNumToNullId;

	/** True if it should use a system-stable null Id for login, same as -StableNullID on command line */
	static bool bForceStableNullId;

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