Custom Engine Integration
During the initial phase, it’s required to integrate the source code into the game and configure the necessary SARD components. You can do that by following steps outlined bellow.
- Copy the code snippet that matches your game's programming language (either C# or C++) and paste it into the game's source code
- Call
sardInitialize()
function at the very beginning of your game's code. - Call
setUserName()
function after player is authorized by game-server. Note: An argument should be attributed to setUserName() function. - Call
sardFinalize()
function on game exit and as a part of crash handling.
- C++ code sample
- C# code sample
static HMODULE sard_lib = 0;
static void (*SardSetUserName)(const char*);
static void (*SardFinalize)();
static void finish()
{
if (SardFinalize)
{
SardFinalize();
}
}
static void setUserName(const char* name)
{
if (SardSetUserName)
{
SardSetUserName(name);
}
}
static void SardInit(const char* dllPath)
{
sard_lib = LoadLibraryA(dllPath);
if (sard_lib)
{
SardSetUserName = (void (*)(const char*)) GetProcAddress(sard_lib, "sardSetUserName");
SardFinalize = (void (*)()) GetProcAddress(sard_lib, "sardFinalize");
void (*SardInitialize)() = (void (*)()) GetProcAddress(sard_lib, "sardInitialize");
if (SardInitialize)
{
SardInitialize();
}
}
}
[DllImport(".\\Sard\\armour.dll", EntryPoint = "sardInitialize", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern void SardInitialize();
[DllImport(".\\Sard\\armour.dll", EntryPoint = "sardSetUserName", CallingConvention = CallingConvention.Cdecl, CharSet = CharSet.Unicode)]
public static extern void SardSetUserName(string userName);
static void Main(string[] args)
{
SardInitialize();
SardSetUserName("PLAYER NAME");
}
Building the solution
- Build your project
- Download Sard-Updater.exe and put it in
SARD
folder in the same directory as your game.exe
- Launch the
SardUpdater.exe
with following parameterssarkKey
: the key that could be obtained in your title at admin panel (please refer to admin panel guide for details).sardGame
: relative path to the game executable- Example:
SardUpdater.exe -sardKey xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx -sardGame "..\xxxx.exe"
SardUpdater
will download necessary files includingarmour.dll
(that's why set such path inDll Path
inside the sample code)- Shortly after completing these steps functionality of admin panel should be unlocked, confirming the success of integration