UI.DebugRejoin

UI.DebugRejoin

#Overview

name: UI.DebugRejoin

This variable is created as a Console Variable (cvar).

It is referenced in 4 C++ source files.

#Summary

#Usage in the C++ source code

The purpose of UI.DebugRejoin is to control and debug the rejoin functionality in Unreal Engine’s online framework. This setting variable is primarily used for debugging and testing purposes, allowing developers to force specific rejoin states during development and testing phases.

This setting variable is utilized by the Rejoin module within the Online Framework plugin of Unreal Engine 5. Based on the callsites, it’s clear that the RejoinCheck class in the Rejoin module relies on this variable.

The value of this variable is set through a console command, as it’s defined using TAutoConsoleVariable. By default, it’s set to -1, which means the debug functionality is off.

UI.DebugRejoin interacts closely with the associated variable CVarDebugRejoin. They share the same value, and CVarDebugRejoin is used in the code to access the value set by UI.DebugRejoin.

Developers must be aware that this variable is primarily for debugging purposes and should not be relied upon in production code. It’s important to note that in shipping builds, this debug functionality is likely to be disabled or removed.

Best practices when using this variable include:

  1. Only use it during development and testing phases.
  2. Ensure it’s set to -1 (off) before building for production.
  3. Use it in conjunction with other debugging tools to diagnose rejoin-related issues.
  4. Be aware that it can force rejoin states, potentially overriding normal game logic.

Regarding the associated variable CVarDebugRejoin:

The purpose of CVarDebugRejoin is to provide programmatic access to the value set by UI.DebugRejoin within the C++ code.

It is used directly in the RejoinCheck class to modify the behavior of the GetStatus() function. When CVarDebugRejoin is set to a valid rejoin state value (0 to 4, corresponding to the ERejoinStatus enum), it overrides the normal status return.

The value of CVarDebugRejoin is set automatically based on the UI.DebugRejoin console variable.

CVarDebugRejoin interacts primarily with the UI.DebugRejoin setting and the ERejoinStatus enum.

Developers should be aware that CVarDebugRejoin can significantly alter the behavior of the rejoin system when set to a non-negative value. It’s crucial to ensure it’s not unintentionally left active in production builds.

Best practices for CVarDebugRejoin include:

  1. Use GetValueOnGameThread() to access its value safely.
  2. Always check if it’s set before using it to override normal behavior.
  3. Consider wrapping its usage in preprocessor conditionals to exclude it from shipping builds.
  4. Document any usage clearly to prevent confusion for other developers.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Rejoin/Private/RejoinCheck.cpp:12

Scope: file

Source code excerpt:


static TAutoConsoleVariable<int32> CVarDebugRejoin(
	TEXT("UI.DebugRejoin"),
	-1,
	TEXT("Force switch between rejoin states (-1 is off)"));

URejoinCheck::URejoinCheck()
	: LastKnownStatus(ERejoinStatus::NeedsRecheck)
	, bRejoinAfterCheck(false)

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Rejoin/Private/RejoinCheck.cpp:11

Scope: file

Source code excerpt:

#define REJOIN_CHECK_TIMER 30.0f

static TAutoConsoleVariable<int32> CVarDebugRejoin(
	TEXT("UI.DebugRejoin"),
	-1,
	TEXT("Force switch between rejoin states (-1 is off)"));

URejoinCheck::URejoinCheck()
	: LastKnownStatus(ERejoinStatus::NeedsRecheck)

#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Rejoin/Private/RejoinCheck.cpp:31

Scope (from outer to inner):

file
function     ERejoinStatus URejoinCheck::GetStatus

Source code excerpt:

ERejoinStatus URejoinCheck::GetStatus() const
{
	int32 DbgVal = CVarDebugRejoin.GetValueOnGameThread();
	if (DbgVal >= 0 && DbgVal <= (int32)ERejoinStatus::NoMatchToRejoin_MatchEnded)
	{
		return (ERejoinStatus)DbgVal;
	}

	if (!IsRejoinCheckEnabled())

#Loc: <Workspace>/Engine/Plugins/Online/OnlineFramework/Source/Rejoin/Public/RejoinCheck.h:120

Scope (from outer to inner):

file
function     class REJOIN_API URejoinCheck : public UObject { GENERATED_BODY

Source code excerpt:

	/**
	 * Get the current state in the rejoin check flow.  
	 * Dev mode may return CVarDebugRejoin if it was set
	 */
#if UE_BUILD_SHIPPING
	ERejoinStatus GetStatus() const { return LastKnownStatus; }
#else
	ERejoinStatus GetStatus() const;
#endif

	/** @return True if the rejoin check has completed and does not need to be rerun. */
	bool HasCompletedCheck() const;