I have some extra code in my GameState that is only supposed to run on server/standalone guarded by
if (GetNetMode() < ENetMode::NM_Client)
When I PIE everything is fine and this part of code is not invoked on the client. Today I packaged client and server and tried to run them. Server starts fine and has NM_DedicatedServer
when passing the if
above… Client for some reason has NM_Standalone
at the if
, and enters the wrong path, eventually crashing because it has no server-only datatables that are loaded there.
Client is packaged using xxClient.Target.cs:
using UnrealBuildTool;
using System.Collections.Generic;
public class xxClientTarget : TargetRules
{
public xxClientTarget( TargetInfo Target) : base(Target)
{
IncludeOrderVersion = EngineIncludeOrderVersion.Unreal5_1;
Type = TargetType.Client;
DefaultBuildSettings = BuildSettingsVersion.V2;
ExtraModuleNames.AddRange( new string[] { "xx" } );
}
}
Not sure why it works fine in PIE, maybe I am doing it at the wrong point in the startup code… The if
above is in my GameState::ReceivedGameModeClass()
, and I call the Super
after I do my stuff…
Is client supposed to start with NM_Standalone
and only switch to NM_Client
after it is connected to the server? And in PIE it does not happen because the connection to the server is immediate?