What's not execute on dedicated server?

Well, hello there. A quick question about dedicated server code.

To my understanding when UE is run as a dedicated server, a lot of thing is omitted automatically. (Things such as rendering etc,) My question is, to what extend do I need to block out dedicated server code? What codes do I know if UE will care of not executing them for me. For example, If I have “playsound” code, should I block this out from server code or just leave it to UE to decide not to play it on dedicated server?

What’s the general guide line for this sort of thing?

It’s up to you to take care of such things. You can always check if code is running on dedicated server or not via “IsRunningDedicatedServer()” (or something like that). And then ‘mask out’ the parts that are not intended to be run there. Otherwise you can crash it if you try to do some UMG logic for instance (which is not present in the server build).

Or if you know that some method only needs to be run on the server you can wrap it in #ifdef WITH_SERVER_CODE (again, something like that) and it will only compile if the special boolean is set in the build file (which is true for server configurations).

I kinda want some guideline on this though.

Anyway, I just ran into an even more disturbing problem with server code last week. I tried to use #if !UE_Server to block out all the gui running on the dedicated server to save some cpu. However, this somehow seem to crash my client built everytime after exactly one minute (garbage collected?).

Putting in #ifdef should leave the client code totally unchanged, but it seems that’s not the case. Could it be possible that the hosting client forced gc on the hud? That sound very unlikely but i can’t provide any other explanation. The dedicated server itself runs fine though. So I have no idea what’s happening here. Any clue on this?

Best Regard,