Server Specific config files

How to setup config files for a server only ? And what naming or folder to use for server on particular platform ?

Hello,

In general, the standard configuration files (DefaultEngine.ini, DefaultGame.ini, …) are available for use, however it is possible to utilize custom configuration files (such as “ServerSettings.ini”, often used by other games) specifically for storing settings for a dedicated server.

Given the following ServerSettings.ini as an example:

[MyServerSettings] MaxPlayers=8

You can then read from it when running as a dedicated server using the following C++ code:

`if (IsRunningDedicatedServer()) {
int MaxPlayers = 0;
GConfig->GetInt(TEXT(“MyServerSettings”), TEXT(“MaxPlayers”), MaxPlayers, FPaths::ProjectConfigDir() / TEXT(“ServerSettings.ini”));

// …
}`

As for the location of the configuration files, the file needs to be placed in either the Config folder below the project folder:

[ProjectFolder]\Config\ServerSettings.ini

Or placed in one of these platform-specific Config folders:

Windows: [ProjectFolder]\Saved\Config\WindowsServer\ServerSettings.ini Linux: [ProjectFolder]/Saved/Config/LinuxServer/ServerSettings.ini macOS: [ProjectFolder]/Saved/Config/MacServer/ServerSettings.ini

Regards

Hi,

an additional note:

For the standard config files (Engine/Game/…) you can use the predefined config hierarchy to override setttings per platform (no C++ needed in that case).

There is a list with the hierarchy and the order in which config files are loaded on the docs site here (under the Configuration File Hierarchy section ).

You can also find the most up-to-date hierarchy from the source code in the file Engine/Source/Runtime/Core/Public/Misc/ConfigHierarchy.h.

In your case, for platform specific config files you can use the following paths (item 8 in the list in the docs):

<PROJECT_DIRECTORY>/Config/<PLATFORM>/<PLATFORM><CATEGORY>.iniFor example on WindowsServer you can override Engine.ini settings in

Config/WindowsServer/WindowsServerEngine.ini

Kind Regards,

Sebastian

Update: There’s also a special case for the DedicatedServer, which counts as a separate platform.

So you can also use both of these variants for dedicated servers:

Config/DedicatedServer/DedicatedServerEngine.ini Config/DedicatedServerEngine.ini

Ok the DedicatedServerEngine.ini seems to work as expected. But trying Config/LinuxServer/LinuxServerEngine.ini does not seem to be working.

Ah, this was my bad, apologies.

I’ve double checked the code and if a dedicated server is built then the DedicatedServerXXX.ini will be used instead of the LinuxServer/LinuxServerXXX.ini, not in addition to it.

There was also an issue with bool values and comments we noticed when testing these. We were using semicolon for comments and noticed that trailing comments get taken as is to determine the value. Which results in the bool always being false.

[/Script/Module.ModuleSettings]

SomeBoolValue=true ;Comment added at the end. Value will always be false

Trailing comments in .ini files are unsupported. Comments must be on a line by themselves.

This is the same for Windows as well.