NetObjectPrioritizerDefinitions

NetObjectPrioritizerDefinitions

#Overview

name: NetObjectPrioritizerDefinitions

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

It is referenced in 7 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of NetObjectPrioritizerDefinitions is to define and manage a collection of network object prioritizer definitions used in Unreal Engine’s replication system. It is specifically designed for prioritizing network objects during replication, which is crucial for optimizing network traffic in multiplayer games.

This setting variable is primarily used by the Iris replication system, which is an experimental module in Unreal Engine 5. It is referenced in the ReplicationSystemTestPlugin, indicating its importance in testing and implementing replication prioritization strategies.

The value of this variable is set in the engine’s configuration files, as indicated by the UPROPERTY(Config) attribute in the UNetObjectPrioritizerDefinitions class definition.

NetObjectPrioritizerDefinitions interacts with FNetObjectPrioritizerDefinition structures, which define individual prioritizer configurations. It also works in conjunction with the UNetObjectPrioritizer class, which is the base class for implementing specific prioritization strategies.

Developers should be aware that:

  1. The definitions are loaded dynamically at runtime using StaticLoadClass.
  2. Invalid definitions (those with null Class or ConfigClass) are filtered out when retrieving valid definitions.
  3. Changes to these definitions may significantly impact network performance and gameplay experience.

Best practices when using this variable include:

  1. Carefully designing and testing prioritization strategies before deploying them.
  2. Ensuring that all referenced classes (prioritizers and their configurations) are properly implemented and available.
  3. Regularly reviewing and optimizing the prioritizer definitions based on gameplay metrics and network performance data.
  4. Using the provided GetValidDefinitions method to retrieve only the valid and usable definitions.
  5. Being cautious when modifying these definitions, especially in a live game environment, as it can affect all connected clients.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:1307, section: [/Script/IrisCore.NetObjectPrioritizerDefinitions]

Location: <Workspace>/Engine/Config/BaseEngine.ini:1308, section: [/Script/IrisCore.NetObjectPrioritizerDefinitions]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationSystemTestPlugin/Source/Private/Tests/ReplicationSystem/Prioritization/TestNetObjectPrioritizer.cpp:43

Scope (from outer to inner):

file
namespace    UE::Net::Private
class        class FTestNetPrioritizerFixture : public FReplicationSystemTestFixture
function     void InitNetObjectPrioritizerDefinitions

Source code excerpt:

		check(DefinitionsProperty != nullptr);

		// Save NetObjectPrioritizerDefinitions CDO state.
		UNetObjectPrioritizerDefinitions* PrioritizerDefinitions = GetMutableDefault<UNetObjectPrioritizerDefinitions>();
		DefinitionsProperty->CopyCompleteValue(&OriginalPrioritizerDefinitions, (void*)(UPTRINT(PrioritizerDefinitions) + DefinitionsProperty->GetOffset_ForInternal()));

		// Modify definitions to only include our mock prioritizer. Ugly... 
		TArray<FNetObjectPrioritizerDefinition> NewPrioritizerDefinitions;
		FNetObjectPrioritizerDefinition& MockDefinition = NewPrioritizerDefinitions.Emplace_GetRef();

#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationSystemTestPlugin/Source/Private/Tests/ReplicationSystem/Prioritization/TestNetObjectPrioritizer.cpp:58

Scope (from outer to inner):

file
namespace    UE::Net::Private
class        class FTestNetPrioritizerFixture : public FReplicationSystemTestFixture
function     void RestoreNetObjectPrioritizerDefinitions

Source code excerpt:

	void RestoreNetObjectPrioritizerDefinitions()
	{
		// Restore NetObjectPrioritizerDefinitions CDO state from the saved state.
		const UClass* NetObjectPrioritizerDefinitionsClass = UNetObjectPrioritizerDefinitions::StaticClass();
		const FProperty* DefinitionsProperty = NetObjectPrioritizerDefinitionsClass->FindPropertyByName(TEXT("NetObjectPrioritizerDefinitions"));
		UNetObjectPrioritizerDefinitions* PrioritizerDefinitions = GetMutableDefault<UNetObjectPrioritizerDefinitions>();
		DefinitionsProperty->CopyCompleteValue((void*)(UPTRINT(PrioritizerDefinitions) + DefinitionsProperty->GetOffset_ForInternal()), &OriginalPrioritizerDefinitions);
		OriginalPrioritizerDefinitions.Empty();

#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationSystemTestPlugin/Source/Private/Tests/ReplicationSystem/Prioritization/TestSphereNetObjectPrioritizer.cpp:114

Scope (from outer to inner):

file
namespace    UE::Net::Private
class        class FTestSphereNetObjectPrioritizer : public FReplicationSystemTestFixture
function     void InitNetObjectPrioritizerDefinitions

Source code excerpt:

		check(DefinitionsProperty != nullptr);

		// Save NetObjectPrioritizerDefinitions CDO state.
		UNetObjectPrioritizerDefinitions* PrioritizerDefinitions = GetMutableDefault<UNetObjectPrioritizerDefinitions>();
		DefinitionsProperty->CopyCompleteValue(&OriginalPrioritizerDefinitions, (void*)(UPTRINT(PrioritizerDefinitions) + DefinitionsProperty->GetOffset_ForInternal()));

		// Modify definitions to only include our mock prioritizer. Ugly... 
		TArray<FNetObjectPrioritizerDefinition> NewPrioritizerDefinitions;
		FNetObjectPrioritizerDefinition& SphereDefinition = NewPrioritizerDefinitions.Emplace_GetRef();

#Loc: <Workspace>/Engine/Plugins/Runtime/ReplicationSystemTestPlugin/Source/Private/Tests/ReplicationSystem/Prioritization/TestSphereNetObjectPrioritizer.cpp:129

Scope (from outer to inner):

file
namespace    UE::Net::Private
class        class FTestSphereNetObjectPrioritizer : public FReplicationSystemTestFixture
function     void RestoreNetObjectPrioritizerDefinitions

Source code excerpt:

	void RestoreNetObjectPrioritizerDefinitions()
	{
		// Restore NetObjectPrioritizerDefinitions CDO state from the saved state.
		const UClass* NetObjectPrioritizerDefinitionsClass = UNetObjectPrioritizerDefinitions::StaticClass();
		const FProperty* DefinitionsProperty = NetObjectPrioritizerDefinitionsClass->FindPropertyByName(TEXT("NetObjectPrioritizerDefinitions"));
		UNetObjectPrioritizerDefinitions* PrioritizerDefinitions = GetMutableDefault<UNetObjectPrioritizerDefinitions>();
		DefinitionsProperty->CopyCompleteValue((void*)(UPTRINT(PrioritizerDefinitions) + DefinitionsProperty->GetOffset_ForInternal()), &OriginalPrioritizerDefinitions);
		OriginalPrioritizerDefinitions.Empty();

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/Prioritization/NetObjectPrioritizerDefinitions.cpp:6

Scope (from outer to inner):

file
function     void UNetObjectPrioritizerDefinitions::GetValidDefinitions

Source code excerpt:

void UNetObjectPrioritizerDefinitions::GetValidDefinitions(TArray<FNetObjectPrioritizerDefinition>& OutDefinitions) const
{
	OutDefinitions.Reserve(NetObjectPrioritizerDefinitions.Num());
	for (const FNetObjectPrioritizerDefinition& Definition : NetObjectPrioritizerDefinitions)
	{
		if (Definition.Class != nullptr && (Definition.ConfigClassName.IsNone() || Definition.ConfigClass != nullptr))
		{
			OutDefinitions.Push(Definition);
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/Prioritization/NetObjectPrioritizerDefinitions.cpp:35

Scope (from outer to inner):

file
function     void UNetObjectPrioritizerDefinitions::LoadDefinitions

Source code excerpt:

void UNetObjectPrioritizerDefinitions::LoadDefinitions()
{
	for (FNetObjectPrioritizerDefinition& Definition : NetObjectPrioritizerDefinitions)
	{
		Definition.Class = StaticLoadClass(UNetObjectPrioritizer::StaticClass(), nullptr, *Definition.ClassName.ToString(), nullptr, LOAD_Quiet);
		UE_CLOG(Definition.Class == nullptr, LogIris, Error, TEXT("NetObjectPrioritizer class could not be loaded: %s"), *Definition.ClassName.GetPlainNameString());

		if (!Definition.ConfigClassName.IsNone())
		{

#Loc: <Workspace>/Engine/Source/Runtime/Experimental/Iris/Core/Private/Iris/ReplicationSystem/Prioritization/NetObjectPrioritizerDefinitions.h:63

Scope (from outer to inner):

file
class        class UNetObjectPrioritizerDefinitions final : public UObject

Source code excerpt:

	 */
	UPROPERTY(Config)
	TArray<FNetObjectPrioritizerDefinition> NetObjectPrioritizerDefinitions;
};