How-To For Servers

This how-to covers compiling the GodotSteam server code; used primarily for dedicated servers. It is still under construction, has not been thoroughly tested, and should not be used for production games. That being said, it has lots of functionality to tinker with. If you find it is stable and functional, you can try using it in the wild.


1. Preparing

Unzip the Godot Engine source code and place the contents into a folder. For the purpose of this how-to we will name the folder godot.

Unzip the GodotSteam you downloaded and copy the godotsteam_server folder from it into the godot/modules/ folder.

Alternate Preparation Option

Once you have the pre-compiles and Steamworks SDK, skip ahead to Step 5 in this tutorial.


2. Copy The Steamworks SDK

Unzip the Steamworks SDK and extract the following folders into the godot/modules/godotsteam_server/sdk/ folder:


public/
redistributable_bin/


3. Folder Layout

The repo's directory contents should now look like this:


godot/modules/godotsteam_server/sdk/public/*
godot/modules/godotsteam_server/sdk/redistributable_bin/*
godot/modules/godotsteam_server/SCsub
godot/modules/godotsteam_server/config.py
godot/modules/godotsteam_server/godotsteam_server.cpp
godot/modules/godotsteam_server/godotsteam_server.h
godot/modules/godotsteam_server/register_types.cpp
godot/modules/godotsteam_server/register_types.h


4. Compiling

Compile for your platform:
On Windows ( http://docs.godotengine.org/en/stable/reference/compiling_for_windows.html )
On Linux ( http://docs.godotengine.org/en/stable/reference/compiling_for_x11.html )
On OSX ( http://docs.godotengine.org/en/stable/reference/compiling_for_osx.html )

REMEMBER: You must also compile the templates for your target operating system(s). Typically by adding target=release tools=no use_lto=yes to your compiling command.

NOTE: when creating templates for OSX, please refer to this post for assistance as the documentation is a bit lacking ( http://steamcommunity.com/app/404790/discussions/0/364042703865087202/ ).

NOTE: using MinGW causes crashes. There is a _mingw-patch.py_ file that corrects one known crash due to compiling with MinGW but there is now a newer crash that hasn't been solved; as well as who knows how many unfound issues. I strong recommend you do not use MinGW to compile at this time.


5. Copy Steamworks Redistributables

When compiling the engine is finished, copy the shared library (steam_api), for your OS, from godot/modules/godotsteam_server/sdk/redistributable_bin/ folder to the Godot binary location. By default, it is in the Godot source godot/bin/ folder. You can move them to a new folder but, for the sake of the how-to, we will leave them in the bin folder.

In the godot/bin/ folder, or wherever you put the editor executable, you must include a steam_appid.txt file with either your game's Steam ID, or the generic 480, as the only text inside. Running the game from the editor or outside of the Steam client will cause a crash without it.

With everything now in place, your working directory should look like this:

Linux 32-bit

godot/bin/libsteam_api.so
godot/bin/steam_appid.txt
godot/bin/godot.linux.tools.32
Linux 64-bit

godot/bin/libsteam_api.so
godot/bin/steam_appid.txt
godot/bin/godot.linux.tools.64
OSX

godot/bin/libsteam_api.dylib
godot/bin/steam_appid.txt
godot/bin/godot.osx.tools.64
Windows 32-bit

godot/bin/steam_api.dll
godot/bin/steam_appid.txt
godot/bin/godot.windows.tools.32.exe
Windows 64-bit

godot/bin/steam_api64.dll
godot/bin/steam_appid.txt
godot/bin/godot.windows.tools.64.exe

6. Done

Remember, every function starts with the SteamServer class; e.g. SteamServer.run_callbacks() or SteamServer.getUserID(). All of the available functions can be found in the editor in the Search section under SteamServer. Additionally, you should be able to read the Steamworks API documentation to see what all is available and cross-reference with GodotSteam.

Valve has other master server functionality in the developer's back-end for Steam. Some of this may need set correctly for things to work. I will be creating a tutorial to cover all that in the near future.


7. Exporting / Shipping

Check out the exporting and shipping tutorial to learn more details about process. Here are a few important bits though:

Your game must ship with the executable and Steam API DLL/SO/DyLIB to function. Lack of the Steam API DLL/SO/DyLib (for your respective OS) will cause it fail and crash. Do not, however, ship your steam_appid.txt file; it is a harmless file to include by Valve recommends you do not.

NOTE: For Linux, some users may experience problems with the editor or game finding the libsteam_api.so file even with it right there in the directory. It is actually an issue with how Steam installed that file on the system. Read more on this in the Linux Caveats tutorial.

NOTE: For OSX, the libsteam_api.dylib must be in the Content/MacOS/ folder in your application zip or the game will crash. Read more on this in the Mac Exporting tutorial. Those of you using the pre-compiled OSX template from the GodotSteam release section can ignore this as libsteam_api.dylib is already included.