Danbias/Code/Game/GameServer/GameServerAPI.h

83 lines
2.3 KiB
C
Raw Normal View History

/////////////////////////////////////////
// Created by [Dennis Andersen] [2013] //
/////////////////////////////////////////
2013-12-03 12:07:37 +01:00
#ifndef DANBIAS_SERVER_DANBIAS_SERVER_H
#define DANBIAS_SERVER_DANBIAS_SERVER_H
#include <vld.h>
2013-12-13 23:47:16 +01:00
2013-12-12 09:33:59 +01:00
#define DANBIAS_SERVER
2013-12-03 12:07:37 +01:00
2013-12-12 09:33:59 +01:00
#ifdef DANBIAS_SERVER_DLL_EXPORT
2013-12-03 12:07:37 +01:00
#define DANBIAS_SERVER_DLL __declspec(dllexport)
#else
#define DANBIAS_SERVER_DLL __declspec(dllimport)
#endif
namespace DanBias
{
2013-12-12 09:33:59 +01:00
enum DanBiasServerReturn
2013-12-03 12:07:37 +01:00
{
2013-12-12 09:33:59 +01:00
DanBiasServerReturn_Error,
DanBiasServerReturn_Sucess,
2014-01-29 10:18:01 +01:00
DanBiasServerReturn_GameNotCreated,
2013-12-12 09:33:59 +01:00
};
2013-12-03 12:07:37 +01:00
2013-12-12 09:33:59 +01:00
extern "C"
{
2014-01-28 09:00:02 +01:00
class DANBIAS_SERVER_DLL GameServerAPI
2013-12-03 12:07:37 +01:00
{
public:
2014-01-30 00:19:00 +01:00
struct ServerInitDesc
2014-01-28 09:00:02 +01:00
{
const wchar_t* serverName;
2014-01-29 10:18:01 +01:00
int listenPort;
2014-01-30 00:19:00 +01:00
ServerInitDesc()
: serverName(L"Game Server")
, listenPort(15152)
2014-01-30 00:19:00 +01:00
{};
};
struct GameServerInfo
{
int listenPort;
wchar_t serverIp[255];
2014-01-28 09:00:02 +01:00
};
typedef void(*ClientConnectedNotify)(int ID, wchar_t clientAlias[255], wchar_t clientIp[255]);
typedef void(*ClientDisconnectedNotify)(int ID);
2014-01-29 10:18:01 +01:00
2014-01-28 09:00:02 +01:00
public:
2014-01-30 00:19:00 +01:00
static DanBiasServerReturn ServerInitiate(const ServerInitDesc& desc);
static void ServerStart();
static void ServerStop();
static void ServerUpdate();
static GameServerInfo ServerGetInfo();
static bool ServerIsRunning();
static void NotifyWhenClientConnect(ClientConnectedNotify func);
static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
2014-01-30 00:19:00 +01:00
static void GameSetGameTime(const int& val);
2014-01-30 00:19:00 +01:00
static void GameSetMaxClients(const int& val);
static void GameSetGameName(const wchar_t* val);
static void GameSetMapName(const wchar_t* val);
static void GameSetGameMode(const wchar_t* val);
2014-01-30 00:19:00 +01:00
static int GameGetGameTime();
static int GameGetMaxClients();
static const wchar_t* GameGetGameMode();
static const wchar_t* GameGetGameName();
static const wchar_t* GameGetMapName();
2014-02-18 13:12:08 +01:00
static int GetConnectedClientCount();
2014-02-18 13:12:08 +01:00
/* Starts a game
* @param forceStart If forceStart is true, server will start with or without clients.
* If there are clients not "ready" the will be stareted anyways.
*/
static bool GameStart(bool forceStart);
2014-01-30 00:19:00 +01:00
2014-01-29 10:18:01 +01:00
2013-12-12 09:33:59 +01:00
};//End class DanBiasServer
2013-12-03 12:07:37 +01:00
}//End Extern "C"
} //End namspace DanBias
#endif // !DANBIAS_SERVER_DANBIAS_SERVER_H