diff --git a/Code/CLIStandaloneServer/C++StandaloneCLI.cpp b/Code/CLIStandaloneServer/C++StandaloneCLI.cpp new file mode 100644 index 00000000..6332289b --- /dev/null +++ b/Code/CLIStandaloneServer/C++StandaloneCLI.cpp @@ -0,0 +1,104 @@ +#include "C++StandaloneCLI.h" + +CppStandaloneCLI::CppStandaloneCLI() +{ +} + +CppStandaloneCLI::~CppStandaloneCLI() +{ +} + +DanBiasServerReturn CppStandaloneCLI::ServerInitiate(ServerInitDesc desc) +{ + DanBias::GameServerAPI::ServerInitDesc d; + //Convert from String to char* + IntPtr p = Marshal::StringToHGlobalAnsi(desc.serverName); + d.serverName = static_cast(p.ToPointer()); + Marshal::FreeHGlobal(p); + + d.listenPort = desc.listenPort; + d.broadcast = desc.broadcast; + + return (DanBiasServerReturn)DanBias::GameServerAPI::ServerInitiate(d); +} + +void CppStandaloneCLI::ServerStart() +{ + DanBias::GameServerAPI::ServerStart(); +} + +void CppStandaloneCLI::ServerStop() +{ + DanBias::GameServerAPI::ServerStop(); +} + +void CppStandaloneCLI::ServerUpdate() +{ + DanBias::GameServerAPI::ServerUpdate(); +} + +GameServerInfo CppStandaloneCLI::ServerGetInfo() +{ + GameServerInfo info; + + DanBias::GameServerAPI::GameServerInfo i = DanBias::GameServerAPI::ServerGetInfo(); + info.listenPort = i.listenPort; + info.serverIp = gcnew String(i.serverIp); + + return info; +} + +bool CppStandaloneCLI::ServerIsRunning() +{ + return DanBias::GameServerAPI::ServerIsRunning(); +} + +void CppStandaloneCLI::GameSetMapId(const int val) +{ + DanBias::GameServerAPI::GameSetMapId(val); +} + +void CppStandaloneCLI::GameSetMaxClients(const int val) +{ + DanBias::GameServerAPI::GameSetMaxClients(val); +} + +void CppStandaloneCLI::GameSetGameMode(const int val) +{ + DanBias::GameServerAPI::GameSetGameMode(val); +} + +void CppStandaloneCLI::GameSetGameTime(const int val) +{ + DanBias::GameServerAPI::GameSetGameTime(val); +} + +int CppStandaloneCLI::GameGetMapId() +{ + return DanBias::GameServerAPI::GameGetMapId(); +} + +int CppStandaloneCLI::GameGetMaxClients() +{ + return DanBias::GameServerAPI::GameGetMaxClients(); +} + +int CppStandaloneCLI::GameGetGameMode() +{ + return DanBias::GameServerAPI::GameGetGameMode(); +} + +int CppStandaloneCLI::GameGetGameTime() +{ + return DanBias::GameServerAPI::GameGetGameTime(); +} + +String^ CppStandaloneCLI::GameGetGameName() +{ + return gcnew String(DanBias::GameServerAPI::GameGetGameName()); +} + +bool CppStandaloneCLI::GameStart() +{ + return DanBias::GameServerAPI::GameStart(); +} \ No newline at end of file diff --git a/Code/CLIStandaloneServer/C++StandaloneCLI.h b/Code/CLIStandaloneServer/C++StandaloneCLI.h index c972fc15..8d819f6f 100644 --- a/Code/CLIStandaloneServer/C++StandaloneCLI.h +++ b/Code/CLIStandaloneServer/C++StandaloneCLI.h @@ -1,23 +1,67 @@ -#ifndef CLISTANDALONESERVER_C++_Standalone_CLI_H -#define CLISTANDALONESERVER_C++_Standalone_CLI_H +#ifndef CLISTANDALONESERVER_CPP_Standalone_CLI_H +#define CLISTANDALONESERVER_CPP_Standalone_CLI_H + +#include +#include +#include #include "..\Game\GameServer\GameServerAPI.h" using namespace System; +using namespace System::Windows::Interop; +using namespace System::Windows; +using namespace System::Runtime::InteropServices; +using namespace System::Collections::Generic; -struct ServerInitDesc +enum DanBiasServerReturn { - + DanBiasServerReturn_Error, + DanBiasServerReturn_Sucess, + DanBiasServerReturn_GameNotCreated, +}; + +public ref struct ServerInitDesc +{ + String^ serverName; + int listenPort; + bool broadcast; //Not fully implemented! + ServerInitDesc() + { + serverName = "Game Server"; + listenPort = 15152; + broadcast = true; + }; +}; + +public value struct GameServerInfo +{ + unsigned int listenPort; // If set to 0, the default port 15151 will be used + String^ serverIp; // This cant be mofidfied.. }; public ref class CppStandaloneCLI { public: - + CppStandaloneCLI(); + ~CppStandaloneCLI(); -protected: - DanBias::GameServerAPI* gameServer; + DanBiasServerReturn ServerInitiate(ServerInitDesc desc); + void ServerStart(); + void ServerStop(); + void ServerUpdate(); + GameServerInfo ServerGetInfo(); + bool ServerIsRunning(); + void GameSetMapId(const int val); + void GameSetMaxClients(const int val); + void GameSetGameMode(const int val); + void GameSetGameTime(const int val); + int GameGetMapId(); + int GameGetMaxClients(); + int GameGetGameMode(); + int GameGetGameTime(); + String^ GameGetGameName(); + bool GameStart(); }; #endif \ No newline at end of file diff --git a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj index 0e2eb099..6b49c390 100644 --- a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj +++ b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj @@ -97,6 +97,7 @@ true + Windows @@ -142,6 +143,16 @@ + + + + + + + + + {143bd516-20a1-4890-a3e4-f8bfd02220e7} + diff --git a/Code/Game/GameServer/GameServerAPI.h b/Code/Game/GameServer/GameServerAPI.h index 7ceab867..0b49070a 100644 --- a/Code/Game/GameServer/GameServerAPI.h +++ b/Code/Game/GameServer/GameServerAPI.h @@ -4,7 +4,7 @@ #ifndef DANBIAS_SERVER_DANBIAS_SERVER_H #define DANBIAS_SERVER_DANBIAS_SERVER_H -#include +//#include #define DANBIAS_SERVER