PlayerController.LevelVisibilityDontSerializeFileName

PlayerController.LevelVisibilityDontSerializeFileName

#Overview

name: PlayerController.LevelVisibilityDontSerializeFileName

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 PlayerController.LevelVisibilityDontSerializeFileName is to control the serialization behavior of level visibility information, specifically whether to serialize the FileName along with other level visibility data.

This setting variable is primarily used in the Unreal Engine’s level streaming and visibility system, which is part of the core engine module. It affects how level visibility information is serialized and transmitted over the network.

The value of this variable is set through the Unreal Engine’s console variable system. It’s defined as a static boolean variable within the PlayerControllerCVars namespace and is exposed as a console variable using FAutoConsoleVariableRef.

The associated variable LevelVisibilityDontSerializeFileName directly interacts with it. They share the same value and purpose, with the console variable acting as an interface to modify the static boolean.

Developers must be aware that when this variable is set to true, the engine will always skip serializing the FileName with FUpdateLevelVisibilityLevelInfo structures. This can save bandwidth in networked games but may impact functionality if the game relies on both PackageName and FileName being distinct and available.

Best practices when using this variable include:

  1. Only enable it if your game doesn’t need both PackageName and FileName for level visibility operations.
  2. Test thoroughly to ensure that skipping FileName serialization doesn’t break any game-specific logic.
  3. Consider the trade-off between bandwidth savings and potential loss of information.

Regarding the associated variable LevelVisibilityDontSerializeFileName:

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/UpdateLevelVisibilityLevelInfo.cpp:11

Scope (from outer to inner):

file
namespace    PlayerControllerCVars

Source code excerpt:

	static bool LevelVisibilityDontSerializeFileName = false;
	FAutoConsoleVariableRef CVarLevelVisibilityDontSerializeFileName(
		TEXT("PlayerController.LevelVisibilityDontSerializeFileName"),
		LevelVisibilityDontSerializeFileName,
		TEXT("When true, we'll always skip serializing FileName with FUpdateLevelVisibilityLevelInfo's. This will save bandwidth when games don't need both.")
	);
}

FUpdateLevelVisibilityLevelInfo::FUpdateLevelVisibilityLevelInfo(const ULevel* const Level, const bool bInIsVisible, const bool bInTryMakeVisible)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/UpdateLevelVisibilityLevelInfo.cpp:9

Scope (from outer to inner):

file
namespace    PlayerControllerCVars

Source code excerpt:

namespace PlayerControllerCVars
{
	static bool LevelVisibilityDontSerializeFileName = false;
	FAutoConsoleVariableRef CVarLevelVisibilityDontSerializeFileName(
		TEXT("PlayerController.LevelVisibilityDontSerializeFileName"),
		LevelVisibilityDontSerializeFileName,
		TEXT("When true, we'll always skip serializing FileName with FUpdateLevelVisibilityLevelInfo's. This will save bandwidth when games don't need both.")
	);
}

FUpdateLevelVisibilityLevelInfo::FUpdateLevelVisibilityLevelInfo(const ULevel* const Level, const bool bInIsVisible, const bool bInTryMakeVisible)
	: bIsVisible(bInIsVisible)

#Loc: <Workspace>/Engine/Source/Runtime/Engine/Private/GameFramework/UpdateLevelVisibilityLevelInfo.cpp:36

Scope (from outer to inner):

file
function     bool FUpdateLevelVisibilityLevelInfo::NetSerialize

Source code excerpt:

bool FUpdateLevelVisibilityLevelInfo::NetSerialize(FArchive& Ar, UPackageMap* PackageMap, bool& bOutSuccess)
{
	bool bArePackageAndFileTheSame = !!((PlayerControllerCVars::LevelVisibilityDontSerializeFileName) || (FileName == PackageName) || (FileName == NAME_None));
	bool bLocalIsVisible = !!bIsVisible;
	bool bLocalTryMakeVisible = !!bTryMakeVisible;

	Ar.SerializeBits(&bArePackageAndFileTheSame, 1);
	Ar.SerializeBits(&bLocalIsVisible, 1);
	Ar.SerializeBits(&bLocalTryMakeVisible, 1);