diff --git a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj
index ccefa56d..7e221e48 100644
--- a/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj
+++ b/Code/CLIStandaloneServer/CLIStandaloneServer.vcxproj
@@ -73,21 +73,29 @@
$(SolutionDir)..\Bin\DLL\
$(ProjectName)_$(PlatformShortName)D
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
+ C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)
+ C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)
$(SolutionDir)..\Bin\DLL\
$(ProjectName)_$(PlatformShortName)
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
+ C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)
+ C:\Program Files %28x86%29\Visual Leak Detector\lib\Win32;$(LibraryPath)
$(SolutionDir)..\Bin\DLL\
$(ProjectName)_$(PlatformShortName)D
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
+ C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)
+ C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)
$(SolutionDir)..\Bin\DLL\
$(ProjectName)_$(PlatformShortName)
$(SolutionDir)..\Obj\$(ProjectName)\$(PlatformShortName)\$(Configuration)\
+ C:\Program Files %28x86%29\Visual Leak Detector\include;$(IncludePath)
+ C:\Program Files %28x86%29\Visual Leak Detector\lib\Win64;$(LibraryPath)
diff --git a/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp b/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp
index ff50416b..3a10b6ce 100644
--- a/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp
+++ b/Code/CLIStandaloneServer/StandaloneGameServerCLI.cpp
@@ -1,4 +1,8 @@
#include "StandaloneGameServerCLI.h"
+#include
+#include < stdio.h >
+#include < stdlib.h >
+#include < vcclr.h >
using namespace System;
@@ -6,6 +10,11 @@ using namespace System::Windows::Interop;
using namespace System::Windows;
using namespace System::Runtime::InteropServices;
+void StandaloneGameServerCLI::NewClientConnected(int ID, wchar_t clientAlias[255], wchar_t clientIp[255])
+{
+
+}
+
StandaloneGameServerCLI::StandaloneGameServerCLI()
{
}
@@ -17,13 +26,12 @@ StandaloneGameServerCLI::~StandaloneGameServerCLI()
DanBiasServerReturn StandaloneGameServerCLI::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);
+ pin_ptr wch = PtrToStringChars(desc.mainOptions.serverName);
+ std::wstring temp = wch;
+ d.serverName = temp.c_str();
+ d.listenPort = desc.mainOptions.listenPort;
- d.listenPort = desc.listenPort;
- d.broadcast = desc.broadcast;
+ DanBias::GameServerAPI::NotifyWhenClientConnect((DanBias::GameServerAPI::ClientConnectedNotify)StandaloneGameServerCLI::NewClientConnected);
return (DanBiasServerReturn)DanBias::GameServerAPI::ServerInitiate(d);
}
@@ -59,9 +67,10 @@ bool StandaloneGameServerCLI::ServerIsRunning()
return DanBias::GameServerAPI::ServerIsRunning();
}
-void StandaloneGameServerCLI::GameSetMapId(const int val)
+void StandaloneGameServerCLI::GameSetMapName(String^ value)
{
- DanBias::GameServerAPI::GameSetMapId(val);
+ pin_ptr wch = PtrToStringChars(value);
+ DanBias::GameServerAPI::GameSetMapName(wch);
}
void StandaloneGameServerCLI::GameSetMaxClients(const int val)
@@ -69,9 +78,10 @@ void StandaloneGameServerCLI::GameSetMaxClients(const int val)
DanBias::GameServerAPI::GameSetMaxClients(val);
}
-void StandaloneGameServerCLI::GameSetGameMode(const int val)
+void StandaloneGameServerCLI::GameSetGameMode(String^ value)
{
- DanBias::GameServerAPI::GameSetGameMode(val);
+ pin_ptr wch = PtrToStringChars(value);
+ DanBias::GameServerAPI::GameSetGameMode(wch);
}
void StandaloneGameServerCLI::GameSetGameTime(const int val)
diff --git a/Code/CLIStandaloneServer/StandaloneGameServerCLI.h b/Code/CLIStandaloneServer/StandaloneGameServerCLI.h
index 92ab8783..99c8b121 100644
--- a/Code/CLIStandaloneServer/StandaloneGameServerCLI.h
+++ b/Code/CLIStandaloneServer/StandaloneGameServerCLI.h
@@ -17,10 +17,11 @@ namespace System { namespace Windows { namespace Interop
public value struct ServerInitDesc
{
- System::String^ serverName;
- int listenPort;
- bool broadcast; //Not fully implemented!
-
+ value struct MainOptions
+ {
+ System::String^ serverName;
+ int listenPort;
+ } mainOptions;
};
public value struct GameServerInfo
@@ -31,6 +32,9 @@ namespace System { namespace Windows { namespace Interop
public ref class StandaloneGameServerCLI
{
+ private:
+ static void NewClientConnected(int ID, wchar_t clientAlias[255], wchar_t clientIp[255]);
+
public:
StandaloneGameServerCLI();
~StandaloneGameServerCLI();
@@ -42,9 +46,9 @@ namespace System { namespace Windows { namespace Interop
GameServerInfo ServerGetInfo();
bool ServerIsRunning();
- void GameSetMapId(const int val);
+ void GameSetMapName(String^ val);
void GameSetMaxClients(const int val);
- void GameSetGameMode(const int val);
+ void GameSetGameMode(String^ val);
void GameSetGameTime(const int val);
int GameGetMapId();
int GameGetMaxClients();
diff --git a/Code/Game/GameServer/GameServerAPI.h b/Code/Game/GameServer/GameServerAPI.h
index 0b49070a..a9e8c63f 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
@@ -30,20 +30,20 @@ namespace DanBias
public:
struct ServerInitDesc
{
- char* serverName;
+ const wchar_t* serverName;
int listenPort;
- bool broadcast; //Not fully implemented!
ServerInitDesc()
- : serverName("Game Server")
+ : serverName(L"Game Server")
, listenPort(15152)
- , broadcast(true)
{};
};
struct GameServerInfo
{
- unsigned int listenPort; // If set to 0, the default port 15151 will be used
- const char *serverIp; // This cant be mofidfied..
+ int listenPort;
+ wchar_t serverIp[255];
};
+ typedef void(*ClientConnectedNotify)(int ID, wchar_t clientAlias[255], wchar_t clientIp[255]);
+ typedef void(*ClientDisconnectedNotify)(int ID);
public:
static DanBiasServerReturn ServerInitiate(const ServerInitDesc& desc);
@@ -52,10 +52,12 @@ namespace DanBias
static void ServerUpdate();
static GameServerInfo ServerGetInfo();
static bool ServerIsRunning();
+ static void NotifyWhenClientConnect(ClientConnectedNotify func);
+ static void NotifyWhenClientDisconnect(ClientDisconnectedNotify func);
- static void GameSetMapId(const int& val);
+ static void GameSetMapName(const wchar_t* val);
static void GameSetMaxClients(const int& val);
- static void GameSetGameMode(const int& val);
+ static void GameSetGameMode(const wchar_t* val);
static void GameSetGameTime(const int& val);
static int GameGetMapId();
static int GameGetMaxClients();
diff --git a/Code/Game/GameServer/Implementation/GameLobby.cpp b/Code/Game/GameServer/Implementation/GameLobby.cpp
index 4c08a2f2..1b8b63ec 100644
--- a/Code/Game/GameServer/Implementation/GameLobby.cpp
+++ b/Code/Game/GameServer/Implementation/GameLobby.cpp
@@ -48,7 +48,7 @@ namespace DanBias
bool GameLobby::StartGameSession( )
{
//Check if all clients is ready
- if(this->GetClientCount() == this->readyList.Size())
+ if(this->GetClientCount() && this->GetClientCount() == this->readyList.Size())
{
GameSession::GameDescription desc;
desc.maxClients = this->description.maxClients;
@@ -59,10 +59,10 @@ namespace DanBias
desc.clients = this->clients;
if(desc.gameTime == 0.0f)
- desc.gameTime = (int)(60.0f * 10.0f); //note: Default game time length should be fetched from somewhere.
+ desc.gameTime = (int)(60.0f * 10.0f); //note: should be fetched from somewhere.
if(desc.maxClients == 0)
- desc.maxClients = 10; //note: Default should be fetched somewhere else..
+ desc.maxClients = 10; //note: should be fetched somewhere else..
this->clients.Clear(); //Remove clients from lobby list
diff --git a/Code/Game/GameServer/Implementation/GameServer.cpp b/Code/Game/GameServer/Implementation/GameServer.cpp
index bb046a41..4fd6e03c 100644
--- a/Code/Game/GameServer/Implementation/GameServer.cpp
+++ b/Code/Game/GameServer/Implementation/GameServer.cpp
@@ -23,18 +23,31 @@ using namespace Oyster::Network;
using namespace Oyster::Thread;
using namespace Utility;
+void DefaultClientConnectedNotify(int ID, wchar_t clientAlias[255], wchar_t clientIp[255])
+{
+
+}
+void DefaultClientDisconnectedNotify(int ID)
+{
+
+}
namespace
{
- GameLobby lobby;
- NetworkServer server;
- WinTimer timer;
+ GameLobby lobby;
+ NetworkServer server;
+ WinTimer timer;
+ GameServerAPI::ClientConnectedNotify clientConnectedCallback = DefaultClientConnectedNotify;
+ GameServerAPI::ClientDisconnectedNotify clientDisconnectedCallback = DefaultClientDisconnectedNotify;
}
DanBiasServerReturn GameServerAPI::ServerInitiate(const ServerInitDesc& desc)
{
- if(server.Init(desc.listenPort, &lobby) == NetworkServer::ServerReturnCode_Error)
+ ServerOptions opt;
+ opt.mainOptions.listenPort = desc.listenPort;
+ opt.mainOptions.ownerSession = &lobby;
+ if(server.Init(opt) == NetworkServer::ServerReturnCode_Error)
{
return DanBiasServerReturn_Error;
}
@@ -86,7 +99,9 @@ void GameServerAPI::ServerUpdate()
GameServerAPI::GameServerInfo GameServerAPI::ServerGetInfo()
{
GameServerAPI::GameServerInfo i;
- i.serverIp = server.GetLanAddress().c_str();
+ std::wstring temp;
+ Utility::String::StringToWstring(server.GetLanAddress().c_str(), temp) ;
+ memcpy(&i.serverIp[0], temp.c_str(), sizeof(wchar_t) * (temp.length() + 1));
i.listenPort = server.GetPort();
return i;
}
@@ -94,12 +109,24 @@ bool GameServerAPI::ServerIsRunning()
{
return server.IsRunning();
}
+void GameServerAPI::NotifyWhenClientConnect(ClientConnectedNotify func)
+{
+ if(!func) clientConnectedCallback = DefaultClientConnectedNotify;
+ else clientConnectedCallback = func;
-void GameServerAPI::GameSetMapId(const int& val)
+
+}
+void GameServerAPI::NotifyWhenClientDisconnect(ClientDisconnectedNotify func)
+{
+ if(!func) clientDisconnectedCallback = DefaultClientDisconnectedNotify;
+ else clientDisconnectedCallback = func;
+}
+
+void GameServerAPI::GameSetMapName(const wchar_t* val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
- d.mapNumber = val;
+ //d.mapNumber = val; //TODO: implement
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetMaxClients(const int& val)
@@ -109,11 +136,11 @@ void GameServerAPI::GameSetMaxClients(const int& val)
d.maxClients = val;
lobby.SetGameDesc(d);
}
-void GameServerAPI::GameSetGameMode(const int& val)
+void GameServerAPI::GameSetGameMode(const wchar_t* val)
{
LobbyLevelData d;
lobby.GetGameDesc(d);
- d.gameMode = val;
+ //d.gameMode = val; //TODO: implement
lobby.SetGameDesc(d);
}
void GameServerAPI::GameSetGameTime(const int& val)
diff --git a/Code/Network/NetworkAPI/NetworkServer.cpp b/Code/Network/NetworkAPI/NetworkServer.cpp
index 68a61a1a..3e840dd8 100644
--- a/Code/Network/NetworkAPI/NetworkServer.cpp
+++ b/Code/Network/NetworkAPI/NetworkServer.cpp
@@ -16,10 +16,8 @@
#include "Utilities.h"
#include "Thread/OysterThread.h"
+#include "WinTimer.h"
-#ifndef _DEBUG
-#include
-#endif
using namespace Oyster::Network;
using namespace Utility::DynamicMemory;
@@ -64,6 +62,13 @@ void Broadcast()
}
}
+struct TimeInstance
+{
+ float length;
+ float previous;
+ TimeInstance() :length(0.0f), previous(0.0f) {}
+ TimeInstance(float length, float previous) :length(length), previous(previous) {}
+};
struct NetworkServer::PrivateData : public IThreadObject
{
public:
@@ -74,6 +79,8 @@ public:
, isReleased(0)
, isRunning(0)
, port(-1)
+ , broadcast(0)
+ , broadcastTime(1.0f, 0.0f)
{ }
~PrivateData()
{ }
@@ -91,12 +98,23 @@ public:
bool isReleased;
bool isRunning;
int port;
+ bool broadcast;
+
+ TimeInstance broadcastTime;
+
+ Utility::WinTimer serverTimer;
};
bool NetworkServer::PrivateData::DoWork()
{
- //Broadcast();
-
+ if(broadcast)
+ {
+ if( (this->serverTimer.getElapsedSeconds() - this->broadcastTime.previous) >= this->broadcastTime.length )
+ {
+ Broadcast();
+ }
+ }
+
/** Check for new clients **/
if(postBox.IsFull())
{
@@ -144,11 +162,11 @@ NetworkServer::~NetworkServer()
}
}
-NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSession const* mainSession)
+NetworkServer::ServerReturnCode NetworkServer::Init(ServerOptions& options)
{
- this->privateData->mainSession = const_cast(mainSession);
+ this->privateData->mainSession = const_cast(options.mainOptions.ownerSession);
//Check if it's a valid port
- if(port == 0 || port == -1)
+ if(options.mainOptions.listenPort == 0 || options.mainOptions.listenPort == -1)
{
return NetworkServer::ServerReturnCode_Error;
}
@@ -163,7 +181,7 @@ NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSess
//Initiate listener
this->privateData->listener = new Listener(&this->privateData->postBox);
- if(!this->privateData->listener->Init(port, false))
+ if(!this->privateData->listener->Init(options.mainOptions.listenPort, false))
{
return NetworkServer::ServerReturnCode_Error;
}
@@ -180,6 +198,7 @@ NetworkServer::ServerReturnCode NetworkServer::Init(const int& port, NetworkSess
NetworkServer::ServerReturnCode NetworkServer::Start()
{
+ this->privateData->serverTimer.reset();
//Start listener
if(!this->privateData->listener->Start())
{
@@ -234,15 +253,17 @@ int NetworkServer::Update()
int c = 0;
while(!this->privateData->clientQueue.IsEmpty())
{
+ SmartPointer client = this->privateData->clientQueue.Pop();
+
if(this->privateData->mainSession)
{
- this->privateData->mainSession->ClientConnectedEvent(this->privateData->clientQueue.Pop());
+ this->privateData->mainSession->ClientConnectedEvent(client);
c++;
}
else
{
//Clients have nowhere to go?
- this->privateData->clientQueue.Pop()->Disconnect();
+ client->Disconnect();
}
}
return c;
diff --git a/Code/Network/NetworkAPI/NetworkServer.h b/Code/Network/NetworkAPI/NetworkServer.h
index 1e3ddd21..593c3847 100644
--- a/Code/Network/NetworkAPI/NetworkServer.h
+++ b/Code/Network/NetworkAPI/NetworkServer.h
@@ -18,6 +18,34 @@ namespace Oyster
{
extern "C"
{
+ struct ServerOptions
+ {
+ struct BroadcastOptions
+ {
+ //bool broadcast;
+ //float broadcastInterval;
+ //std::wstring subnetToBroadcast;
+ //CustomNetProtocol broadcastMessage;
+ //BroadcastOptions()
+ //{
+ // broadcast = true;
+ // broadcastInterval = 1.0f;
+ // subnetToBroadcast = L"192.168.0.1";
+ //}
+ } broadcastOptions;
+
+ struct MainOptions
+ {
+ NetworkSession* ownerSession;
+ int listenPort;
+ MainOptions()
+ {
+ ownerSession = 0;
+ listenPort = 0;
+ }
+ } mainOptions;
+ };
+
class NET_API_EXPORT NetworkServer
{
public:
@@ -39,7 +67,7 @@ namespace Oyster
* @param mainSession The main session the server will send connected clients to.
* @return The server returncode
*/
- ServerReturnCode Init(const int& port, NetworkSession const* mainSession);
+ ServerReturnCode Init(ServerOptions& options);
/** Starts the server allowing clients to connect
* @return The server returncode
diff --git a/Code/StandAloneLauncher/Form1.Designer.cs b/Code/StandAloneLauncher/Form1.Designer.cs
index 82913f45..df569295 100644
--- a/Code/StandAloneLauncher/Form1.Designer.cs
+++ b/Code/StandAloneLauncher/Form1.Designer.cs
@@ -37,15 +37,29 @@
this.panel_serverOptions = new System.Windows.Forms.Panel();
this.panel_commands = new System.Windows.Forms.Panel();
this.panel_clientArea = new System.Windows.Forms.Panel();
+ this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
+ this.splitter1 = new System.Windows.Forms.Splitter();
this.clientInfoBox = new System.Windows.Forms.ListBox();
+ this.buttonStartGame = new System.Windows.Forms.Button();
+ this.nrOfClients = new System.Windows.Forms.NumericUpDown();
+ this.label1 = new System.Windows.Forms.Label();
+ this.label2 = new System.Windows.Forms.Label();
+ this.gameModes = new System.Windows.Forms.ComboBox();
+ this.timeLimit = new System.Windows.Forms.NumericUpDown();
+ this.label3 = new System.Windows.Forms.Label();
+ this.label4 = new System.Windows.Forms.Label();
+ this.mapName = new System.Windows.Forms.TextBox();
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
this.panel_serverOptions.SuspendLayout();
+ this.panel_commands.SuspendLayout();
this.panel_clientArea.SuspendLayout();
+ ((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
+ ((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
this.SuspendLayout();
//
// serverToggle
//
- this.serverToggle.Location = new System.Drawing.Point(90, 81);
+ this.serverToggle.Location = new System.Drawing.Point(9, 81);
this.serverToggle.Name = "serverToggle";
this.serverToggle.Size = new System.Drawing.Size(75, 23);
this.serverToggle.TabIndex = 0;
@@ -56,7 +70,7 @@
// lanBroadcast
//
this.lanBroadcast.AutoSize = true;
- this.lanBroadcast.Location = new System.Drawing.Point(81, 58);
+ this.lanBroadcast.Location = new System.Drawing.Point(9, 58);
this.lanBroadcast.Name = "lanBroadcast";
this.lanBroadcast.Size = new System.Drawing.Size(95, 17);
this.lanBroadcast.TabIndex = 1;
@@ -69,6 +83,7 @@
this.serverName.Name = "serverName";
this.serverName.Size = new System.Drawing.Size(95, 20);
this.serverName.TabIndex = 3;
+ this.serverName.Text = "GameServer";
//
// label_serverName
//
@@ -120,32 +135,173 @@
this.panel_serverOptions.Controls.Add(this.label_serverName);
this.panel_serverOptions.Location = new System.Drawing.Point(12, 12);
this.panel_serverOptions.Name = "panel_serverOptions";
- this.panel_serverOptions.Size = new System.Drawing.Size(183, 112);
+ this.panel_serverOptions.Size = new System.Drawing.Size(183, 113);
this.panel_serverOptions.TabIndex = 6;
//
// panel_commands
//
- this.panel_commands.Location = new System.Drawing.Point(12, 130);
+ this.panel_commands.Controls.Add(this.mapName);
+ this.panel_commands.Controls.Add(this.timeLimit);
+ this.panel_commands.Controls.Add(this.gameModes);
+ this.panel_commands.Controls.Add(this.label3);
+ this.panel_commands.Controls.Add(this.label2);
+ this.panel_commands.Controls.Add(this.label4);
+ this.panel_commands.Controls.Add(this.label1);
+ this.panel_commands.Controls.Add(this.nrOfClients);
+ this.panel_commands.Controls.Add(this.buttonStartGame);
+ this.panel_commands.Location = new System.Drawing.Point(12, 131);
this.panel_commands.Name = "panel_commands";
- this.panel_commands.Size = new System.Drawing.Size(183, 231);
+ this.panel_commands.Size = new System.Drawing.Size(183, 230);
this.panel_commands.TabIndex = 7;
+ this.panel_commands.Visible = false;
//
// panel_clientArea
//
+ this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
+ this.panel_clientArea.Controls.Add(this.splitter1);
this.panel_clientArea.Controls.Add(this.clientInfoBox);
this.panel_clientArea.Location = new System.Drawing.Point(202, 12);
this.panel_clientArea.Name = "panel_clientArea";
this.panel_clientArea.Size = new System.Drawing.Size(303, 349);
this.panel_clientArea.TabIndex = 8;
//
+ // ServerInfoTextArea
+ //
+ this.ServerInfoTextArea.BackColor = System.Drawing.SystemColors.ActiveCaptionText;
+ this.ServerInfoTextArea.BorderStyle = System.Windows.Forms.BorderStyle.None;
+ this.ServerInfoTextArea.Dock = System.Windows.Forms.DockStyle.Fill;
+ this.ServerInfoTextArea.Font = new System.Drawing.Font("GulimChe", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
+ this.ServerInfoTextArea.ForeColor = System.Drawing.SystemColors.Info;
+ this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
+ this.ServerInfoTextArea.Name = "ServerInfoTextArea";
+ this.ServerInfoTextArea.ReadOnly = true;
+ this.ServerInfoTextArea.Size = new System.Drawing.Size(303, 197);
+ this.ServerInfoTextArea.TabIndex = 1;
+ this.ServerInfoTextArea.Text = "";
+ //
+ // splitter1
+ //
+ this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
+ this.splitter1.Location = new System.Drawing.Point(0, 147);
+ this.splitter1.Name = "splitter1";
+ this.splitter1.Size = new System.Drawing.Size(303, 5);
+ this.splitter1.TabIndex = 2;
+ this.splitter1.TabStop = false;
+ //
// clientInfoBox
//
+ this.clientInfoBox.Dock = System.Windows.Forms.DockStyle.Top;
this.clientInfoBox.FormattingEnabled = true;
- this.clientInfoBox.Location = new System.Drawing.Point(3, 6);
+ this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
this.clientInfoBox.Name = "clientInfoBox";
- this.clientInfoBox.Size = new System.Drawing.Size(297, 342);
+ this.clientInfoBox.Size = new System.Drawing.Size(303, 147);
this.clientInfoBox.TabIndex = 0;
//
+ // buttonStartGame
+ //
+ this.buttonStartGame.Location = new System.Drawing.Point(53, 195);
+ this.buttonStartGame.Name = "buttonStartGame";
+ this.buttonStartGame.Size = new System.Drawing.Size(75, 23);
+ this.buttonStartGame.TabIndex = 6;
+ this.buttonStartGame.Text = "Start game";
+ this.buttonStartGame.UseVisualStyleBackColor = true;
+ this.buttonStartGame.Click += new System.EventHandler(this.buttonStartGame_Click);
+ //
+ // nrOfClients
+ //
+ this.nrOfClients.Location = new System.Drawing.Point(78, 36);
+ this.nrOfClients.Maximum = new decimal(new int[] {
+ 20,
+ 0,
+ 0,
+ 0});
+ this.nrOfClients.Minimum = new decimal(new int[] {
+ 2,
+ 0,
+ 0,
+ 0});
+ this.nrOfClients.Name = "nrOfClients";
+ this.nrOfClients.Size = new System.Drawing.Size(39, 20);
+ this.nrOfClients.TabIndex = 7;
+ this.nrOfClients.Value = new decimal(new int[] {
+ 2,
+ 0,
+ 0,
+ 0});
+ //
+ // label1
+ //
+ this.label1.AutoSize = true;
+ this.label1.Location = new System.Drawing.Point(8, 38);
+ this.label1.Name = "label1";
+ this.label1.Size = new System.Drawing.Size(53, 13);
+ this.label1.TabIndex = 8;
+ this.label1.Text = "Client limit";
+ //
+ // label2
+ //
+ this.label2.AutoSize = true;
+ this.label2.Location = new System.Drawing.Point(8, 69);
+ this.label2.Name = "label2";
+ this.label2.Size = new System.Drawing.Size(64, 13);
+ this.label2.TabIndex = 9;
+ this.label2.Text = "Game mode";
+ //
+ // gameModes
+ //
+ this.gameModes.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
+ this.gameModes.FormattingEnabled = true;
+ this.gameModes.Items.AddRange(new object[] {
+ "Free-for-all",
+ "Team death-match"});
+ this.gameModes.Location = new System.Drawing.Point(78, 66);
+ this.gameModes.Name = "gameModes";
+ this.gameModes.Size = new System.Drawing.Size(99, 21);
+ this.gameModes.TabIndex = 10;
+ //
+ // timeLimit
+ //
+ this.timeLimit.Location = new System.Drawing.Point(109, 94);
+ this.timeLimit.Minimum = new decimal(new int[] {
+ 5,
+ 0,
+ 0,
+ 0});
+ this.timeLimit.Name = "timeLimit";
+ this.timeLimit.Size = new System.Drawing.Size(68, 20);
+ this.timeLimit.TabIndex = 11;
+ this.timeLimit.ThousandsSeparator = true;
+ this.timeLimit.Value = new decimal(new int[] {
+ 5,
+ 0,
+ 0,
+ 0});
+ //
+ // label3
+ //
+ this.label3.AutoSize = true;
+ this.label3.Location = new System.Drawing.Point(8, 96);
+ this.label3.Name = "label3";
+ this.label3.Size = new System.Drawing.Size(95, 13);
+ this.label3.TabIndex = 9;
+ this.label3.Text = "Time limit (minutes)";
+ //
+ // label4
+ //
+ this.label4.AutoSize = true;
+ this.label4.Location = new System.Drawing.Point(9, 15);
+ this.label4.Name = "label4";
+ this.label4.Size = new System.Drawing.Size(57, 13);
+ this.label4.TabIndex = 8;
+ this.label4.Text = "Map name";
+ //
+ // mapName
+ //
+ this.mapName.Location = new System.Drawing.Point(78, 7);
+ this.mapName.Name = "mapName";
+ this.mapName.Size = new System.Drawing.Size(98, 20);
+ this.mapName.TabIndex = 12;
+ //
// Form1
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@@ -159,7 +315,11 @@
((System.ComponentModel.ISupportInitialize)(this.listenPort)).EndInit();
this.panel_serverOptions.ResumeLayout(false);
this.panel_serverOptions.PerformLayout();
+ this.panel_commands.ResumeLayout(false);
+ this.panel_commands.PerformLayout();
this.panel_clientArea.ResumeLayout(false);
+ ((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
+ ((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
this.ResumeLayout(false);
}
@@ -176,6 +336,17 @@
private System.Windows.Forms.Panel panel_commands;
private System.Windows.Forms.Panel panel_clientArea;
private System.Windows.Forms.ListBox clientInfoBox;
+ private System.Windows.Forms.RichTextBox ServerInfoTextArea;
+ private System.Windows.Forms.Splitter splitter1;
+ private System.Windows.Forms.Button buttonStartGame;
+ private System.Windows.Forms.Label label1;
+ private System.Windows.Forms.NumericUpDown nrOfClients;
+ private System.Windows.Forms.ComboBox gameModes;
+ private System.Windows.Forms.Label label2;
+ private System.Windows.Forms.NumericUpDown timeLimit;
+ private System.Windows.Forms.Label label3;
+ private System.Windows.Forms.Label label4;
+ private System.Windows.Forms.TextBox mapName;
}
}
diff --git a/Code/StandAloneLauncher/Form1.cs b/Code/StandAloneLauncher/Form1.cs
index 56d69810..1240c333 100644
--- a/Code/StandAloneLauncher/Form1.cs
+++ b/Code/StandAloneLauncher/Form1.cs
@@ -51,24 +51,51 @@ namespace StandAloneLauncher
this.serverName.Enabled = true;
this.lanBroadcast.Enabled = true;
this.serverToggle.Text = "Start server";
+ this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server terminated!\n");
+ this.panel_commands.Visible = false;
}
else
{
- this.serverIsRunning = true;
ServerInitDesc desc = new ServerInitDesc();
- desc.broadcast = this.lanBroadcast.Checked;
- desc.listenPort = (int)this.listenPort.Value;
- desc.serverName = this.serverName.Text;
+ //desc.mainOptions.broadcast = this.lanBroadcast.Checked;
+ desc.mainOptions.listenPort = (int)this.listenPort.Value;
+ desc.mainOptions.serverName = this.serverName.Text;
if (this.gameServer.ServerInitiate(desc) == DanBiasServerReturn.DanBiasServerReturn_Sucess)
{
+ this.serverIsRunning = true;
+
+ GameServerInfo info = this.gameServer.ServerGetInfo();
+ this.Text = this.serverName.Text + " - " + info.serverIp;
+
this.listenPort.Enabled = false;
this.serverName.Enabled = false;
this.lanBroadcast.Enabled = false;
this.serverToggle.Text = "Stop server";
this.gameServer.ServerStart();
- this.clientInfoBox.Items.Add((Object)"Server initiated!");
+ this.panel_commands.Visible = true;
+ this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Server initiated!\n\tListening on port " + this.listenPort.Value.ToString() + "\n\tLocal IP: " + info.serverIp + "\n");
}
+ else
+ {
+ this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to initiate the server!");
+ }
+ }
+ }
+
+ private void buttonStartGame_Click(object sender, EventArgs e)
+ {
+ //this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
+ this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
+ //this.gameServer.GameSetMapId(0);
+ this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
+ if (!this.gameServer.GameStart())
+ {
+ this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
+ }
+ else
+ {
+ this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Game session started!\n");
}
}
}