In some situations, it can be useful to have a replicated editor-only C++ property (For example, the user that reported this issue was attempting to replicate settings to the client for game designers in ImGui). Since such a property is wrapped in C++ with "#if WITH_EDITORONLY_DATA", it should work with replication on the Editor, while having no effect on the packaged game.
If such a property is present in the code while packaging a dedicated server, its definition and usage will be correctly stripped from the compilation, but some replication code will still be generated for it. This causes the dedicated server to crash when it attempts to replicate the actor that ultimately contains the property.
The problem was tracked down to the auto-generated C++ function ValidateGeneratedRepEnums(). It is generated by the UHT function AppendNativeGeneratedInitCode() in file [Engine\Source\Programs\Shared\EpicGames.UHT\Exporters\CodeGen\UhtHeaderCodeGeneratorCppFile.cs], in the code that precedes the error message "UHT Generated Rep Indices do not match runtime populated Rep Indices for properties in ". The generator adds "#if WITH_EDITORONLY_DATA" to several places where this kind of property is mentioned, but has no special treatment at this point.
Note: This repro needs a source build of UE to allow packaging a dedicated server.
1. Compile the repro project
1.1. The project contains a C++ "AMyActor" class containing some replicated and non-replicated uproperties
1.2. Property "MyReplicatedIntB" is tagged "Replicated" and also wrapped in "#if WITH_EDITORONLY_DATA"
1.3. All usages of "MyReplicatedIntB" are wrapped in "#if WITH_EDITOR"
2. Open the repro project
2.1. The startup map contains a replicated actor "BP_MyActor"
2.2. This actor increments some integer variables at 1-second intervals and prints them to the log and screen
3. Set Net Mode "Play as Client" and PIE with 2-3 players
3.1. Variable "MyInt" is not replicated and can be seen being incremented only on the server
3.2. Variables "MyReplicatedInt
" are replicated and can be seen being incremented on the server and clients
4. Package the project:
4.1. "Windows" platform, "Development" configuration, "TestReplicationServer" target
4.2. "Windows" platform, "Development" configuration, "TestReplicationClient" target
5. Test the packaged project:
5.1. Run the server executable with "-log" on the commandline
5.2. Run the client executable with "127.0.0.1:7777 -log" on the commandline
5.3. Once the client connects, the server will crash in [MyActor.gen.cpp]
5.4. Crash message: "UHT Generated Rep Indices do not match runtime populated Rep Indices for properties in AMyActor"
i have this problem UE4CC-Windows-58DC12AF4B97F057BD108FBFF569B2E9_0000
I am not able to find world outliner how to enable it?
What method is used to fill polygonal regions when drawing spline mesh at run time?
Delay nodes occasionally don't fire the "Completed" output in a nativized build
How does TextureRenderTarget2D get TArray<uint8> type data?
Undefined sysmbol: typeinfo for AActor when cross-compile linux dedicated server on windows
How does UMG set overlapping layouts?
How to achieve HLSL Multiple Render Target in Material blueprints?
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-231448 in the post.
0 |
Component | UE - Foundation - Cpp Tools - UnrealHeaderTool |
---|---|
Affects Versions | 5.4, 5.3, 5.6, 5.5 |
Target Fix | 5.6 |
Created | Nov 26, 2024 |
---|---|
Updated | Dec 3, 2024 |