# Dedicated server code split from client code

**URL:** <https://forums.unrealengine.com/t/dedicated-server-code-split-from-client-code/7446>\
**Category:** C++\
**Tags:** unreal-engine\
**Created:** [July 11, 2014, 11:31pm UTC](https://forums.unrealengine.com/t/dedicated-server-code-split-from-client-code/7446 "2014-07-11T23:31:25Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![Ben\_Zeigler](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ben\_Zeigler](https://forums.unrealengine.com/u/Ben_Zeigler)\
**Post date:** [July 14, 2014, 5:00pm UTC](https://forums.unrealengine.com/t/dedicated-server-code-split-from-client-code/7446/2 "2014-07-14T17:00:59Z")

</div>

The key to this is the Server and Client code configuration. So to build a cooked client that doesn’t have access to dedicated server code you can build “Development Client”, which is almost the same as “Development” but with server-only code disabled. What this does is set the WITH\_SERVER\_CODE define to false. When this is false various things like server-side networking are compiled out in the engine. There is no client-only configuration with editor functionality enabled, so this only works with cooked builds. And you can then use this same feature to disable any game-specific server-side code. You have two options:

1. Place #if WITH\_SERVER\_CODE around the bodies of individual server side functions. This is really useful if you only want to disable a function or 2 in a class that otherwise should exist on the client, but is very cumbersome if you want to hide an entire class from clients.
2. Make a server side module. For instance on fortnite we have a FortniteServer module that has most of the GameMode classes defined in it, as well as other support code. You make a server module very similar to how you make a game-specific editor module. You’ll then have to add a conditional module dependency on your server module to your \*Game.build.cs file. Here’s the relevant lines from ours, which is right after you declare the normal public and private module depdendencies:

```auto

if (UEBuildConfiguration.bWithServerCode == true)		
{
	PublicDependencyModuleNames.Add("FortniteServer");
	CircularlyReferencedDependentModules.Add("FortniteServer");
}

```

This will link in the module, but only when it’s not a Client configuration. Then you can use those classes from your main game module, as long as you wrap the usage in WITH\_SERVER\_CODE. We did this by adding this to our game pch file:

```auto

#if WITH_SERVER_CODE
#include "FortniteServerClasses.h"
#endif // WITH_SERVER_CODE

```

Then if we want to use a server class, we wrap the usage in WITH\_SERVER\_CODE as well.

---

_[View the full topic](https://forums.unrealengine.com/t/dedicated-server-code-split-from-client-code/7446)._
