we have a weird issue. For some unknown reason, during runtime, the actor component name changes from “Position” to “position”. Specifically the result of the “GetName()” function of the actor component.
Its our c++ component. I double checked all our gameplay code and it seems unlikely that we rename it in runtime. It does not happen in editor. We noticed it because we compare a hash per frame in our lockstep multiplayer and its different between two clients. One of the clients is built with an engine build and the other one with the source engine. Does that somehow make a difference?
I am not quite sure how to tackle this as it is quite hard to reproduce and requires multiple computers. Important to know that it is reproducible on different computers.
I am grateful for any hints.
Edit:
As suspected the build from the source engine seems to rename the component to lowercase and the build from the engine build does not. When using two builds built with source it does not produce the issue (probably because on both clients the component is lower case then).
I am guessing its not actually renaming it but for some reason the GetName looks up the wrong name. It also seems to change the name of multiple components at the same time so maybe the lookup table changes their value?
this is likely caused by the fact that the underlying FName class used for names does store an index into a table and is case-insensitive at runtime.
More specifically, it will store the first instance of a string that gets registered case-sensitive. Once other FNames are created for the same string (but with possibly different casing) they will all use the same index/table entry and thus get the same casing applied that the first thing that used that name had.
So for your two engine builds it is likely the order in which these components and anything else using the FName “position” are created that defines the outcome.
You could try to force a specific casing by initializing an FName with the desired casing early on at startup, but in general the casing should be deterministic across different builds.
Hopefully that clears up the mystery a bit.
There is a define in the Engine in NameTypes.h called WITH_CASE_PRESERVING_NAME that controls this behavior. It is enabled for Editor builds but disabled in game builds.
If you have issues with a lot of names and really need the case preserved you could try enabling this define, but it will increase the memory used for FNames, since they will have to store all individual variations of a string in that case (no pun intended :D).