Hi, I want to create a multiplayer game with downloadable clients and private servers, so none will have the dedicated server executable. But the problem is that the server code is still included in the client. Is there a way to make the server code private?
I’ve also been wondering about this. Looking forward to an answer:)
We use #ifdefs to compile the code out of the client executable
So, while you can use #ifdefs to compile out the server code, any security you have that depends on obscurity (users not reading the code) can get broken, and will get broken if your game is popular enough.
It’s always best to build your server such that it’s secure by design, without needing to hide any code. Any rules tables, encryption keys, and similar, should be provided as non-distributed data, not compiled in.
Or are you worried about “private servers” for your game? If your game is popular and interesting enough to have a significant “private servers” movement, then you’re likely popular enough that it isn’t really an economic problem for you
Thanks for the reply to all of you. How can I use #ifdefs to compile some code only on the server executable?
Just move all server specific code to separate module.
Configuration macros usually start with either UE_ or WITH_. In this case it’s the former: UE_SERVER.
To wit, you would include server-specific code like so:
#if UE_SERVER MyServerSpecificCode(); #endif // UE_SERVER
and exclude it:
#if !UE_SERVER MyServerExcludedCode(); #endif // UE_SERVER
you can also put some of your code that you want to use in a separate module and only add it in the Server build targets. So the module will be only compile & add when you build “Server” and not game.
To be fair though, even retaining the server code isn’t always enough - it’s not uncommon for people to work out how to build an equivalent server by observing data transmission to and from their clients. This is how there are unofficial and modded World of Warcraft servers out there.
I’m wondering how secure the blueprints are.