ServerDefaultMap

ServerDefaultMap

#Overview

name: ServerDefaultMap

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

#Summary

#Usage in the C++ source code

The purpose of ServerDefaultMap is to specify the default map that will be loaded on a dedicated server when no other map is specified. This setting is part of Unreal Engine’s game configuration system and is specifically used for server-side operations.

This setting variable is primarily relied upon by the Engine Settings module and the Cook On The Fly system. It’s used in the following contexts:

  1. In the CookOnTheFlyServer, it’s added as a default object to be cooked.
  2. In the GameMapsSettings class, it’s defined as a configurable property.
  3. In the EngineSettingsModule, it’s used to determine the default map for dedicated servers and is involved in various configuration and initialization processes.

The value of this variable is typically set in the game’s configuration files, but it can also be modified programmatically. It’s defined as a FSoftObjectPath, which means it stores a string reference to a map asset.

ServerDefaultMap interacts closely with GameDefaultMap. The engine chooses between these two based on whether the current instance is running as a dedicated server or not.

Developers should be aware that:

  1. This variable is specifically for dedicated server scenarios.
  2. It should point to a valid map asset that exists in the project.
  3. Changes to this variable may require a restart of the server to take effect.

Best practices when using this variable include:

  1. Ensure the referenced map is always included in server builds.
  2. Use it in conjunction with GameDefaultMap to provide different default maps for client and server scenarios.
  3. Regularly validate that the referenced map exists and is appropriate for server-side gameplay.
  4. Consider the implications on network play and ensure the server default map is compatible with expected client behavior.

#Setting Variables

#References In INI files

Location: <Workspace>/Engine/Config/BaseEngine.ini:13, section: [/Script/EngineSettings.GameMapsSettings]

#References in C++ code

#Callsites

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

#Loc: <Workspace>/Engine/Source/Editor/UnrealEd/Private/CookOnTheFlyServer.cpp:9333

Scope (from outer to inner):

file
function     void UCookOnTheFlyServer::GetGameDefaultObjects

Source code excerpt:

		// get the server and game default maps/modes and cook them
		AddDefaultObject(FName(TEXT("GameDefaultMap")));
		AddDefaultObject(FName(TEXT("ServerDefaultMap")));
		AddDefaultObject(FName(TEXT("GlobalDefaultGameMode")));
		AddDefaultObject(FName(TEXT("GlobalDefaultServerGameMode")));
		AddDefaultObject(FName(TEXT("GameInstanceClass")));
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Classes/GameMapsSettings.h:199

Scope (from outer to inner):

file
class        class UGameMapsSettings : public UObject

Source code excerpt:

	/** The map that will be loaded by default when no other map is loaded (DEDICATED SERVER). */
	UPROPERTY(config, EditAnywhere, Category=DefaultMaps, AdvancedDisplay, meta=(AllowedClasses="/Script/Engine.World"))
	FSoftObjectPath ServerDefaultMap;

	/** GameMode to use if not specified in any other way. (e.g. per-map DefaultGameMode or on the URL). */
	UPROPERTY(config, noclear, EditAnywhere, Category=DefaultModes, meta=(MetaClass="/Script/Engine.GameModeBase", DisplayName="Default GameMode"))
	FSoftClassPath GlobalDefaultGameMode;

	/**

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Private/EngineSettingsModule.cpp:89

Scope (from outer to inner):

file
function     FString UGameMapsSettings::GetGameDefaultMap

Source code excerpt:

{
	return IsRunningDedicatedServer()
		? GetDefault<UGameMapsSettings>()->ServerDefaultMap.GetLongPackageName()
		: GetDefault<UGameMapsSettings>()->GameDefaultMap.GetLongPackageName();
}


FString UGameMapsSettings::GetGlobalDefaultGameMode( )
{

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Private/EngineSettingsModule.cpp:196

Scope (from outer to inner):

file
function     void UGameMapsSettings::SetGameDefaultMap

Source code excerpt:

	if (IsRunningDedicatedServer())
	{
		GameMapsSettings->ServerDefaultMap = NewMap;
	}
	else
	{
		GameMapsSettings->GameDefaultMap = NewMap;
	}
}

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Private/EngineSettingsModule.cpp:247

Scope (from outer to inner):

file
function     void UGameMapsSettings::PostInitProperties

Source code excerpt:

#endif
	FixMapAssetRef(GameDefaultMap);
	FixMapAssetRef(ServerDefaultMap);
	FixMapAssetRef(TransitionMap);
}

void UGameMapsSettings::PostReloadConfig( FProperty* PropertyThatWasLoaded )
{
	if (PropertyThatWasLoaded)

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Private/EngineSettingsModule.cpp:266

Scope (from outer to inner):

file
function     void UGameMapsSettings::PostReloadConfig

Source code excerpt:

			FixMapAssetRef(GameDefaultMap);
		}
		else if (PropertyThatWasLoaded->GetFName() == GET_MEMBER_NAME_CHECKED(UGameMapsSettings, ServerDefaultMap))
		{
			FixMapAssetRef(ServerDefaultMap);
		}
		else if (PropertyThatWasLoaded->GetFName() == GET_MEMBER_NAME_CHECKED(UGameMapsSettings, TransitionMap))
		{
			FixMapAssetRef(TransitionMap);
		}
	}

#Loc: <Workspace>/Engine/Source/Runtime/EngineSettings/Private/EngineSettingsModule.cpp:281

Scope (from outer to inner):

file
function     void UGameMapsSettings::PostReloadConfig

Source code excerpt:

#endif
		FixMapAssetRef(GameDefaultMap);
		FixMapAssetRef(ServerDefaultMap);
		FixMapAssetRef(TransitionMap);
	}
}


IMPLEMENT_MODULE(FEngineSettingsModule, EngineSettings);