ConversationEditor.CheckForCycles

ConversationEditor.CheckForCycles

#Overview

name: ConversationEditor.CheckForCycles

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 ConversationEditor.CheckForCycles is to control whether the Conversation Editor should check for cycles when creating links between nodes in a conversation graph. This setting is part of the CommonConversation plugin, which is likely used for managing branching dialogues or conversation systems in games developed with Unreal Engine 5.

This setting variable is primarily used in the CommonConversationGraph module, which is part of the Experimental CommonConversation plugin. Based on the callsites, it’s specifically utilized in the ConversationGraphSchema class, which defines the rules and behavior for the conversation graph system.

The value of this variable is set using the Unreal Engine’s console variable (CVar) system. It’s initialized with a default value of true (1), meaning cycle checking is enabled by default. Developers can change this value at runtime using console commands or through configuration files.

The associated variable CheckForCyclesCVar directly interacts with ConversationEditor.CheckForCycles. They share the same value, with CheckForCyclesCVar being the actual boolean variable used in the code to perform the cycle checking.

Developers must be aware that disabling this variable (setting it to 0) will remove the cycle detection in the Conversation Editor. This could potentially lead to infinite loops in conversation graphs if not managed carefully.

Best practices when using this variable include:

  1. Keeping it enabled (default value) during development to catch potential cyclic dependencies early.
  2. Only disabling it if there’s a specific need for cyclic conversations and the implications are well understood.
  3. If disabled, implementing alternative safeguards to prevent unintended infinite loops in conversations.
  4. Documenting any changes to this setting in project documentation to ensure all team members are aware of its state.

Regarding the associated variable CheckForCyclesCVar:

The purpose of CheckForCyclesCVar is to serve as the actual boolean flag used in the code to determine whether cycle checking should be performed. It’s directly linked to the ConversationEditor.CheckForCycles console variable.

This variable is used within the UConversationGraphSchema::CanCreateConnection function to determine whether to perform cycle checking when creating connections between nodes in the conversation graph.

The value of CheckForCyclesCVar is set by the ConversationEditor.CheckForCycles console variable. Any changes to the console variable will directly affect this associated variable.

Developers should be aware that this variable directly controls the behavior of the cycle checking functionality. When it’s true, the system will prevent the creation of cyclic connections in the conversation graph.

Best practices for using CheckForCyclesCVar include:

  1. Not modifying it directly in code, but rather using the ConversationEditor.CheckForCycles console variable to change its value.
  2. Being cautious when creating conversation graphs if this variable is set to false, as it removes an important safeguard against cyclic dependencies.
  3. Considering adding custom cycle detection logic if this variable is disabled but cyclic conversations are still a concern in the project.

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/CommonConversation/Source/CommonConversationGraph/Private/ConversationGraphSchema.cpp:35

Scope (from outer to inner):

file
namespace    ConversationEditorCVar

Source code excerpt:

	static bool CheckForCyclesCVar = true;
	FAutoConsoleVariableRef CVarCheckForCycles(
		TEXT("ConversationEditor.CheckForCycles"),
		CheckForCyclesCVar,
		TEXT("This cvar controles if the Conversation Editor should check for cycles when links are created.\n")
		TEXT("0: Don't Check, 1: Check for Cycles (Default)"),
		ECVF_Default);
}

#Associated Variable and Callsites

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

#Loc: <Workspace>/Engine/Plugins/Experimental/CommonConversation/Source/CommonConversationGraph/Private/ConversationGraphSchema.cpp:33

Scope (from outer to inner):

file
namespace    ConversationEditorCVar

Source code excerpt:

namespace ConversationEditorCVar
{
	static bool CheckForCyclesCVar = true;
	FAutoConsoleVariableRef CVarCheckForCycles(
		TEXT("ConversationEditor.CheckForCycles"),
		CheckForCyclesCVar,
		TEXT("This cvar controles if the Conversation Editor should check for cycles when links are created.\n")
		TEXT("0: Don't Check, 1: Check for Cycles (Default)"),
		ECVF_Default);
}

TSharedPtr<FGraphNodeClassHelper> ConversationClassCache;

#Loc: <Workspace>/Engine/Plugins/Experimental/CommonConversation/Source/CommonConversationGraph/Private/ConversationGraphSchema.cpp:333

Scope (from outer to inner):

file
function     const FPinConnectionResponse UConversationGraphSchema::CanCreateConnection

Source code excerpt:

	};

	if (ConversationEditorCVar::CheckForCyclesCVar)
	{
		// check for cycles
		FNodeVisitorCycleChecker CycleChecker;
		if (!CycleChecker.CheckForLoop(PinA->GetOwningNode(), PinB->GetOwningNode()))
		{
			return FPinConnectionResponse(CONNECT_RESPONSE_DISALLOW, LOCTEXT("PinErrorcycle", "Can't create a graph cycle"));