2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
#define NOMINMAX
|
|
|
|
#include <Windows.h>
|
|
|
|
#include <vld.h>
|
|
|
|
|
|
|
|
#include "DanBiasGame.h"
|
2014-01-29 10:18:01 +01:00
|
|
|
#include <GameServerAPI.h>
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
#include <thread>
|
|
|
|
|
|
|
|
|
|
|
|
void ServerFnc()
|
|
|
|
{
|
2014-01-30 00:19:00 +01:00
|
|
|
DanBias::GameServerAPI::ServerInitDesc desc;
|
2014-01-29 10:18:01 +01:00
|
|
|
desc.listenPort = 15151;
|
2014-01-30 00:19:00 +01:00
|
|
|
if(DanBias::GameServerAPI::ServerInitiate(desc) == DanBias::DanBiasServerReturn_Sucess)
|
2014-01-21 09:52:48 +01:00
|
|
|
{
|
2014-01-30 00:19:00 +01:00
|
|
|
DanBias::GameServerAPI::ServerStart();
|
|
|
|
while (!(GetAsyncKeyState(0x51))) //Q for exit
|
|
|
|
{
|
|
|
|
DanBias::GameServerAPI::ServerUpdate();
|
|
|
|
Sleep(1);
|
|
|
|
}
|
|
|
|
DanBias::GameServerAPI::ServerStop();
|
2014-01-21 09:52:48 +01:00
|
|
|
}
|
2014-01-30 00:19:00 +01:00
|
|
|
|
2014-01-21 09:52:48 +01:00
|
|
|
Sleep(100);
|
|
|
|
}
|
|
|
|
void ClientFnc()
|
|
|
|
{
|
|
|
|
// Game client starter code goes here
|
|
|
|
DanBias::DanBiasGameDesc gameDesc;
|
|
|
|
gameDesc.port = 15151;
|
|
|
|
//gameDesc.port = 15152;
|
|
|
|
//gameDesc.IP = "193.11.184.196";
|
|
|
|
//gameDesc.IP = "193.11.184.31";
|
|
|
|
//gameDesc.IP = "194.47.150.56";
|
|
|
|
gameDesc.IP = "127.0.0.1";
|
2014-01-28 09:00:02 +01:00
|
|
|
//gameDesc.IP = "194.47.150.184";
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
if( DanBias::DanBiasGame::Initiate(gameDesc) == DanBias::DanBiasClientReturn_Sucess)
|
|
|
|
{
|
|
|
|
DanBias::DanBiasGame::Run();
|
|
|
|
DanBias::DanBiasGame::Release();
|
|
|
|
}
|
|
|
|
Sleep(100);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int WINAPI WinMain( HINSTANCE hinst, HINSTANCE prevInst, PSTR cmdLine, int cmdShow)
|
|
|
|
{
|
|
|
|
std::thread serverThread;
|
|
|
|
std::thread clientThread;
|
|
|
|
|
|
|
|
if(SetDllDirectory(L"..\\DLL") == FALSE)
|
|
|
|
{
|
|
|
|
return cmdShow;
|
|
|
|
}
|
|
|
|
|
2014-01-30 15:02:02 +01:00
|
|
|
//serverThread = std::thread(ServerFnc);
|
2014-01-21 09:52:48 +01:00
|
|
|
|
2014-01-22 15:22:52 +01:00
|
|
|
Sleep(200);
|
2014-01-21 09:52:48 +01:00
|
|
|
|
|
|
|
clientThread = std::thread(ClientFnc);
|
|
|
|
|
|
|
|
if (serverThread.joinable()) serverThread.join();
|
|
|
|
if (clientThread.joinable()) clientThread.join();
|
|
|
|
|
|
|
|
return cmdShow;
|
|
|
|
}
|