Merge remote-tracking branch 'origin/GameServer' into GameClient
This commit is contained in:
commit
f2cbbfcf69
|
@ -54,6 +54,7 @@ IObjectData* Game::LevelData::GetObjectAt(int ID) const
|
||||||
|
|
||||||
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
void Game::LevelData::GetAllDynamicObjects(Utility::DynamicMemory::DynamicArray<IObjectData*>& mem) const
|
||||||
{
|
{
|
||||||
|
mem.Resize(level->dynamicObjects.Size());
|
||||||
for(int i = 0; i < level->dynamicObjects.Size(); i++)
|
for(int i = 0; i < level->dynamicObjects.Size(); i++)
|
||||||
{
|
{
|
||||||
mem[i] = level->dynamicObjects[i];
|
mem[i] = level->dynamicObjects[i];
|
||||||
|
|
|
@ -17,6 +17,13 @@ namespace DanBias
|
||||||
*/
|
*/
|
||||||
class GameClient
|
class GameClient
|
||||||
{
|
{
|
||||||
|
public:
|
||||||
|
enum ClientState
|
||||||
|
{
|
||||||
|
ClientState_CreatingGame,
|
||||||
|
ClientState_Ready,
|
||||||
|
};
|
||||||
|
|
||||||
public:
|
public:
|
||||||
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
|
GameClient(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> nwClient);
|
||||||
virtual~GameClient();
|
virtual~GameClient();
|
||||||
|
@ -33,6 +40,7 @@ namespace DanBias
|
||||||
inline bool IsReady() const { return this->isReady; }
|
inline bool IsReady() const { return this->isReady; }
|
||||||
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
|
inline GameLogic::IPlayerData* GetPlayer() const { return this->player; }
|
||||||
Oyster::Network::NetClient GetClient() const { return this->client; }
|
Oyster::Network::NetClient GetClient() const { return this->client; }
|
||||||
|
ClientState GetState() const { return this->state; }
|
||||||
|
|
||||||
|
|
||||||
void SetPlayer(GameLogic::IPlayerData* player);
|
void SetPlayer(GameLogic::IPlayerData* player);
|
||||||
|
@ -40,6 +48,7 @@ namespace DanBias
|
||||||
void SetAlias(std::wstring alias);
|
void SetAlias(std::wstring alias);
|
||||||
void SetCharacter(std::wstring character);
|
void SetCharacter(std::wstring character);
|
||||||
void SetSinceLastResponse(float seconds);
|
void SetSinceLastResponse(float seconds);
|
||||||
|
void SetState(ClientState state);
|
||||||
|
|
||||||
GameLogic::IPlayerData* ReleasePlayer();
|
GameLogic::IPlayerData* ReleasePlayer();
|
||||||
Oyster::Network::NetClient ReleaseClient();
|
Oyster::Network::NetClient ReleaseClient();
|
||||||
|
@ -50,13 +59,15 @@ namespace DanBias
|
||||||
|
|
||||||
private:
|
private:
|
||||||
GameLogic::IPlayerData* player;
|
GameLogic::IPlayerData* player;
|
||||||
Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client;
|
Oyster::Network::NetClient client;
|
||||||
|
|
||||||
bool isReady;
|
bool isReady;
|
||||||
float secondsSinceLastResponse;
|
float secondsSinceLastResponse;
|
||||||
|
|
||||||
std::wstring alias;
|
std::wstring alias;
|
||||||
std::wstring character;
|
std::wstring character;
|
||||||
|
|
||||||
|
ClientState state;
|
||||||
};
|
};
|
||||||
}//End namespace DanBias
|
}//End namespace DanBias
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,9 @@ namespace DanBias
|
||||||
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
void LobbyReady(GameLogic::Protocol_LobbyClientReadyState& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_ClientReadyState:
|
||||||
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
|
void LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyster::Network::NetworkClient* c); //id = protocol_Lobby_QuerryGameType:
|
||||||
|
|
||||||
|
private:
|
||||||
|
int FindClient(Oyster::Network::NetworkClient* c);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
void ClientEventCallback(Oyster::Network::NetEvent<Oyster::Network::NetworkClient*, Oyster::Network::NetworkClient::ClientEventArgs> e) override;
|
||||||
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
void ClientConnectedEvent(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client) override;
|
||||||
|
|
|
@ -50,6 +50,10 @@ void GameClient::SetCharacter(std::wstring character)
|
||||||
{
|
{
|
||||||
this->character = character;
|
this->character = character;
|
||||||
}
|
}
|
||||||
|
void GameClient::SetState(ClientState state)
|
||||||
|
{
|
||||||
|
this->state = state;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
|
void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
|
||||||
|
@ -58,7 +62,12 @@ void GameClient::SetOwner(Oyster::Network::NetworkSession* owner)
|
||||||
}
|
}
|
||||||
void GameClient::UpdateClient()
|
void GameClient::UpdateClient()
|
||||||
{
|
{
|
||||||
this->client->Update();
|
switch (this->state)
|
||||||
|
{
|
||||||
|
case ClientState_Ready:
|
||||||
|
this->client->Update();
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,7 @@ GameLobby::GameLobby()
|
||||||
{ }
|
{ }
|
||||||
GameLobby::~GameLobby()
|
GameLobby::~GameLobby()
|
||||||
{
|
{
|
||||||
this->clients.Clear();
|
this->gClients.Clear();
|
||||||
}
|
}
|
||||||
void GameLobby::Release()
|
void GameLobby::Release()
|
||||||
{
|
{
|
||||||
|
@ -26,11 +26,11 @@ void GameLobby::Release()
|
||||||
}
|
}
|
||||||
void GameLobby::Update()
|
void GameLobby::Update()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
this->clients[i]->Update();
|
this->gClients[i]->GetClient()->Update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ void GameLobby::ClientEventCallback(NetEvent<NetworkClient*, NetworkClient::Clie
|
||||||
break;
|
break;
|
||||||
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
case NetworkClient::ClientEventArgs::EventType_ProtocolFailedToSend:
|
||||||
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
printf("\t(%i : %s) - EventType_ProtocolFailedToSend\n", e.sender->GetID(), e.sender->GetIpAddress().c_str());
|
||||||
e.sender->Disconnect();
|
//e.sender->Disconnect();
|
||||||
//this->readyList.Remove(e.sender);
|
//this->readyList.Remove(e.sender);
|
||||||
//this->gClients.Remove(e.sender);
|
//this->gClients.Remove(e.sender);
|
||||||
break;
|
break;
|
||||||
|
@ -184,7 +184,9 @@ void GameLobby::ProcessClients()
|
||||||
}
|
}
|
||||||
bool GameLobby::Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
bool GameLobby::Attach(Utility::DynamicMemory::SmartPointer<Oyster::Network::NetworkClient> client)
|
||||||
{
|
{
|
||||||
if(this->clientCount = this->description.maxClients) return false;
|
if(this->clientCount == this->description.maxClients) return false;
|
||||||
|
|
||||||
|
client->SetOwner(this);
|
||||||
|
|
||||||
bool added = false;
|
bool added = false;
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
|
|
@ -40,26 +40,46 @@ void GameLobby::GeneralStatus(GameLogic::Protocol_General_Status& p, Oyster::Net
|
||||||
{
|
{
|
||||||
case Protocol_General_Status::States_ready:
|
case Protocol_General_Status::States_ready:
|
||||||
{
|
{
|
||||||
|
int temp = FindClient(c);
|
||||||
|
if(temp != -1 )
|
||||||
|
{
|
||||||
|
switch (this->gClients[temp]->GetState())
|
||||||
|
{
|
||||||
|
case GameClient::ClientState_CreatingGame:
|
||||||
|
{
|
||||||
|
this->gameSession.Join(this->gClients[temp]);
|
||||||
|
this->gClients[temp] = 0;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
c->Disconnect();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_idle:
|
case Protocol_General_Status::States_idle:
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_leave:
|
case Protocol_General_Status::States_leave:
|
||||||
|
break;
|
||||||
case Protocol_General_Status::States_disconected:
|
case Protocol_General_Status::States_disconected:
|
||||||
{
|
{
|
||||||
Detach(c)->Disconnect();
|
Detach(c)->Disconnect();
|
||||||
}
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
void GameLobby::GeneralText(GameLogic::Protocol_General_Text& p, Oyster::Network::NetworkClient* c)
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->clients[i])
|
if(this->gClients[i])
|
||||||
{
|
{
|
||||||
this->clients[i]->Send(p);
|
this->gClients[i]->GetClient()->Send(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
printf(p.text.c_str());
|
printf(p.text.c_str());
|
||||||
|
@ -69,9 +89,9 @@ void GameLobby::LobbyStartGame(GameLogic::Protocol_LobbyStartGame& p, Oyster::Ne
|
||||||
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
if(this->sessionOwner->GetClient()->GetID() == c->GetID())
|
||||||
{
|
{
|
||||||
//Send countdown timer before lobby shuts down
|
//Send countdown timer before lobby shuts down
|
||||||
for (unsigned int i = 0; i < this->clients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
this->clients[i]->Send(Protocol_LobbyStartGame(3.0f));
|
this->gClients[i]->GetClient()->Send(Protocol_LobbyStartGame(3.0f));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -118,32 +138,41 @@ void GameLobby::LobbyQuerryGameData(GameLogic::Protocol_QuerryGameType& p, Oyste
|
||||||
{
|
{
|
||||||
if(this->gameSession)
|
if(this->gameSession)
|
||||||
{
|
{
|
||||||
gClient temp;
|
int temp = FindClient(c);
|
||||||
bool found = false;
|
|
||||||
|
|
||||||
//find client in waiting list
|
|
||||||
for (unsigned int i = 0; !found && i < this->clients.Size(); i++)
|
|
||||||
{
|
|
||||||
if(this->gClients[i]->GetClient()->GetID() == c->GetID())
|
|
||||||
{
|
|
||||||
temp = this->gClients[i];
|
|
||||||
found = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Something is wrong
|
//Something is wrong
|
||||||
if(!found)
|
if(temp == -1)
|
||||||
{
|
{
|
||||||
c->Disconnect();
|
c->Disconnect();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//Send game data
|
//Send game data
|
||||||
this->gameSession.Join(temp);
|
Protocol_LobbyCreateGame lcg((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
||||||
|
c->Send(lcg);
|
||||||
|
this->gClients[temp]->SetState(GameClient::ClientState_CreatingGame);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// Nothing.-
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int GameLobby::FindClient(Oyster::Network::NetworkClient* c)
|
||||||
|
{
|
||||||
|
int temp = -1;
|
||||||
|
|
||||||
|
//find client in waiting list
|
||||||
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
|
{
|
||||||
|
if(this->gClients[i]->GetClient()->GetID() == c->GetID())
|
||||||
|
{
|
||||||
|
temp = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return temp;
|
||||||
|
}
|
|
@ -45,7 +45,7 @@ using namespace DanBias;
|
||||||
//Find the idiot
|
//Find the idiot
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->gClients[i]->Equals(e.sender))
|
if(this->gClients[i] && this->gClients[i]->Equals(e.sender))
|
||||||
{
|
{
|
||||||
temp = i;
|
temp = i;
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ using namespace DanBias;
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
for (unsigned int i = 0; i < this->gClients.Size(); i++)
|
||||||
{
|
{
|
||||||
if(this->gClients[i])
|
if(this->gClients[i] )
|
||||||
{
|
{
|
||||||
this->gClients[i]->UpdateClient();
|
this->gClients[i]->UpdateClient();
|
||||||
}
|
}
|
||||||
|
|
|
@ -199,18 +199,12 @@ bool GameSession::Join(gClient gameClient)
|
||||||
|
|
||||||
gameClient->SetPlayer(playerData);
|
gameClient->SetPlayer(playerData);
|
||||||
NetworkClient* nwClient = gameClient->GetClient();
|
NetworkClient* nwClient = gameClient->GetClient();
|
||||||
|
|
||||||
// Send the level information
|
|
||||||
{
|
|
||||||
Protocol_LobbyCreateGame lcg((char)1, (char)0, Utility::String::WStringToString(this->description.mapName, std::string()));
|
|
||||||
nwClient->Send(lcg);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Send the player data only
|
// Send the player data only
|
||||||
{
|
{
|
||||||
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
|
Protocol_ObjectCreatePlayer oc( playerData->GetPosition(), playerData->GetRotation(), playerData->GetScale(),
|
||||||
playerData->GetID(), true, playerData->GetTeamID(),
|
playerData->GetID(), true, playerData->GetTeamID(),
|
||||||
/*nwClient->GetAlias()*/"", /*playerData->GetMesh()*/"char_white.dan");
|
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||||
nwClient->Send(oc);
|
nwClient->Send(oc);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,7 +217,7 @@ bool GameSession::Join(gClient gameClient)
|
||||||
IPlayerData* temp = this->gClients[i]->GetPlayer();
|
IPlayerData* temp = this->gClients[i]->GetPlayer();
|
||||||
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
|
Protocol_ObjectCreatePlayer oc( temp->GetPosition(), temp->GetRotation(), temp->GetScale(),
|
||||||
temp->GetID(), false, temp->GetTeamID(),
|
temp->GetID(), false, temp->GetTeamID(),
|
||||||
/*nwClient->GetAlias()*/"", /*playerData->GetMesh()*/"char_white.dan");
|
/*nwClient->GetAlias()*/"Unknown", /*playerData->GetMesh()*/"char_white.dan");
|
||||||
nwClient->Send(oc);
|
nwClient->Send(oc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -259,6 +253,8 @@ bool GameSession::Join(gClient gameClient)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
gameClient->SetState(GameClient::ClientState_Ready);
|
||||||
|
|
||||||
return added;
|
return added;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
this.forceStart = new System.Windows.Forms.CheckBox();
|
this.forceStart = new System.Windows.Forms.CheckBox();
|
||||||
this.label2 = new System.Windows.Forms.Label();
|
this.label2 = new System.Windows.Forms.Label();
|
||||||
this.label4 = new System.Windows.Forms.Label();
|
this.label4 = new System.Windows.Forms.Label();
|
||||||
|
this.labelClientsConnected = new System.Windows.Forms.Label();
|
||||||
this.label1 = new System.Windows.Forms.Label();
|
this.label1 = new System.Windows.Forms.Label();
|
||||||
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
this.nrOfClients = new System.Windows.Forms.NumericUpDown();
|
||||||
this.buttonStartGame = new System.Windows.Forms.Button();
|
this.buttonStartGame = new System.Windows.Forms.Button();
|
||||||
|
@ -50,13 +51,14 @@
|
||||||
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
this.ServerInfoTextArea = new System.Windows.Forms.RichTextBox();
|
||||||
this.splitter1 = new System.Windows.Forms.Splitter();
|
this.splitter1 = new System.Windows.Forms.Splitter();
|
||||||
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
this.clientInfoBox = new System.Windows.Forms.ListBox();
|
||||||
this.labelClientsConnected = new System.Windows.Forms.Label();
|
this.panel_CommanArea = new System.Windows.Forms.Panel();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.listenPort)).BeginInit();
|
||||||
this.panel_serverOptions.SuspendLayout();
|
this.panel_serverOptions.SuspendLayout();
|
||||||
this.panel_commands.SuspendLayout();
|
this.panel_commands.SuspendLayout();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).BeginInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).BeginInit();
|
||||||
this.panel_clientArea.SuspendLayout();
|
this.panel_clientArea.SuspendLayout();
|
||||||
|
this.panel_CommanArea.SuspendLayout();
|
||||||
this.SuspendLayout();
|
this.SuspendLayout();
|
||||||
//
|
//
|
||||||
// serverToggle
|
// serverToggle
|
||||||
|
@ -135,9 +137,10 @@
|
||||||
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
this.panel_serverOptions.Controls.Add(this.label_listenPort);
|
||||||
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
this.panel_serverOptions.Controls.Add(this.lanBroadcast);
|
||||||
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
this.panel_serverOptions.Controls.Add(this.label_serverName);
|
||||||
this.panel_serverOptions.Location = new System.Drawing.Point(12, 12);
|
this.panel_serverOptions.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
|
this.panel_serverOptions.Location = new System.Drawing.Point(0, 0);
|
||||||
this.panel_serverOptions.Name = "panel_serverOptions";
|
this.panel_serverOptions.Name = "panel_serverOptions";
|
||||||
this.panel_serverOptions.Size = new System.Drawing.Size(183, 141);
|
this.panel_serverOptions.Size = new System.Drawing.Size(200, 141);
|
||||||
this.panel_serverOptions.TabIndex = 6;
|
this.panel_serverOptions.TabIndex = 6;
|
||||||
//
|
//
|
||||||
// panel_commands
|
// panel_commands
|
||||||
|
@ -153,19 +156,19 @@
|
||||||
this.panel_commands.Controls.Add(this.label1);
|
this.panel_commands.Controls.Add(this.label1);
|
||||||
this.panel_commands.Controls.Add(this.nrOfClients);
|
this.panel_commands.Controls.Add(this.nrOfClients);
|
||||||
this.panel_commands.Controls.Add(this.buttonStartGame);
|
this.panel_commands.Controls.Add(this.buttonStartGame);
|
||||||
this.panel_commands.Location = new System.Drawing.Point(12, 159);
|
this.panel_commands.Location = new System.Drawing.Point(3, 150);
|
||||||
this.panel_commands.Name = "panel_commands";
|
this.panel_commands.Name = "panel_commands";
|
||||||
this.panel_commands.Size = new System.Drawing.Size(183, 202);
|
this.panel_commands.Size = new System.Drawing.Size(191, 202);
|
||||||
this.panel_commands.TabIndex = 7;
|
this.panel_commands.TabIndex = 7;
|
||||||
this.panel_commands.Visible = false;
|
this.panel_commands.Visible = false;
|
||||||
//
|
//
|
||||||
// mapName
|
// mapName
|
||||||
//
|
//
|
||||||
this.mapName.Location = new System.Drawing.Point(78, 7);
|
this.mapName.Location = new System.Drawing.Point(75, 10);
|
||||||
this.mapName.Name = "mapName";
|
this.mapName.Name = "mapName";
|
||||||
this.mapName.Size = new System.Drawing.Size(98, 20);
|
this.mapName.Size = new System.Drawing.Size(113, 20);
|
||||||
this.mapName.TabIndex = 12;
|
this.mapName.TabIndex = 12;
|
||||||
this.mapName.Text = "Unknown";
|
this.mapName.Text = "2ofAll_updated.bias";
|
||||||
//
|
//
|
||||||
// timeLimit
|
// timeLimit
|
||||||
//
|
//
|
||||||
|
@ -194,7 +197,7 @@
|
||||||
"Team death-match"});
|
"Team death-match"});
|
||||||
this.gameModes.Location = new System.Drawing.Point(78, 66);
|
this.gameModes.Location = new System.Drawing.Point(78, 66);
|
||||||
this.gameModes.Name = "gameModes";
|
this.gameModes.Name = "gameModes";
|
||||||
this.gameModes.Size = new System.Drawing.Size(99, 21);
|
this.gameModes.Size = new System.Drawing.Size(110, 21);
|
||||||
this.gameModes.TabIndex = 10;
|
this.gameModes.TabIndex = 10;
|
||||||
//
|
//
|
||||||
// label3
|
// label3
|
||||||
|
@ -236,6 +239,15 @@
|
||||||
this.label4.TabIndex = 8;
|
this.label4.TabIndex = 8;
|
||||||
this.label4.Text = "Map name";
|
this.label4.Text = "Map name";
|
||||||
//
|
//
|
||||||
|
// labelClientsConnected
|
||||||
|
//
|
||||||
|
this.labelClientsConnected.AutoSize = true;
|
||||||
|
this.labelClientsConnected.Location = new System.Drawing.Point(9, 149);
|
||||||
|
this.labelClientsConnected.Name = "labelClientsConnected";
|
||||||
|
this.labelClientsConnected.Size = new System.Drawing.Size(104, 13);
|
||||||
|
this.labelClientsConnected.TabIndex = 8;
|
||||||
|
this.labelClientsConnected.Text = "Clients connected: 0";
|
||||||
|
//
|
||||||
// label1
|
// label1
|
||||||
//
|
//
|
||||||
this.label1.AutoSize = true;
|
this.label1.AutoSize = true;
|
||||||
|
@ -282,9 +294,10 @@
|
||||||
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
this.panel_clientArea.Controls.Add(this.ServerInfoTextArea);
|
||||||
this.panel_clientArea.Controls.Add(this.splitter1);
|
this.panel_clientArea.Controls.Add(this.splitter1);
|
||||||
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
this.panel_clientArea.Controls.Add(this.clientInfoBox);
|
||||||
this.panel_clientArea.Location = new System.Drawing.Point(202, 12);
|
this.panel_clientArea.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||||
|
this.panel_clientArea.Location = new System.Drawing.Point(200, 0);
|
||||||
this.panel_clientArea.Name = "panel_clientArea";
|
this.panel_clientArea.Name = "panel_clientArea";
|
||||||
this.panel_clientArea.Size = new System.Drawing.Size(303, 349);
|
this.panel_clientArea.Size = new System.Drawing.Size(535, 616);
|
||||||
this.panel_clientArea.TabIndex = 8;
|
this.panel_clientArea.TabIndex = 8;
|
||||||
//
|
//
|
||||||
// ServerInfoTextArea
|
// ServerInfoTextArea
|
||||||
|
@ -297,7 +310,7 @@
|
||||||
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
|
this.ServerInfoTextArea.Location = new System.Drawing.Point(0, 152);
|
||||||
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
this.ServerInfoTextArea.Name = "ServerInfoTextArea";
|
||||||
this.ServerInfoTextArea.ReadOnly = true;
|
this.ServerInfoTextArea.ReadOnly = true;
|
||||||
this.ServerInfoTextArea.Size = new System.Drawing.Size(303, 197);
|
this.ServerInfoTextArea.Size = new System.Drawing.Size(535, 464);
|
||||||
this.ServerInfoTextArea.TabIndex = 1;
|
this.ServerInfoTextArea.TabIndex = 1;
|
||||||
this.ServerInfoTextArea.Text = "";
|
this.ServerInfoTextArea.Text = "";
|
||||||
//
|
//
|
||||||
|
@ -306,7 +319,7 @@
|
||||||
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
this.splitter1.Dock = System.Windows.Forms.DockStyle.Top;
|
||||||
this.splitter1.Location = new System.Drawing.Point(0, 147);
|
this.splitter1.Location = new System.Drawing.Point(0, 147);
|
||||||
this.splitter1.Name = "splitter1";
|
this.splitter1.Name = "splitter1";
|
||||||
this.splitter1.Size = new System.Drawing.Size(303, 5);
|
this.splitter1.Size = new System.Drawing.Size(535, 5);
|
||||||
this.splitter1.TabIndex = 2;
|
this.splitter1.TabIndex = 2;
|
||||||
this.splitter1.TabStop = false;
|
this.splitter1.TabStop = false;
|
||||||
//
|
//
|
||||||
|
@ -316,26 +329,26 @@
|
||||||
this.clientInfoBox.FormattingEnabled = true;
|
this.clientInfoBox.FormattingEnabled = true;
|
||||||
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
this.clientInfoBox.Location = new System.Drawing.Point(0, 0);
|
||||||
this.clientInfoBox.Name = "clientInfoBox";
|
this.clientInfoBox.Name = "clientInfoBox";
|
||||||
this.clientInfoBox.Size = new System.Drawing.Size(303, 147);
|
this.clientInfoBox.Size = new System.Drawing.Size(535, 147);
|
||||||
this.clientInfoBox.TabIndex = 0;
|
this.clientInfoBox.TabIndex = 0;
|
||||||
//
|
//
|
||||||
// labelClientsConnected
|
// panel_CommanArea
|
||||||
//
|
//
|
||||||
this.labelClientsConnected.AutoSize = true;
|
this.panel_CommanArea.Controls.Add(this.panel_commands);
|
||||||
this.labelClientsConnected.Location = new System.Drawing.Point(9, 149);
|
this.panel_CommanArea.Controls.Add(this.panel_serverOptions);
|
||||||
this.labelClientsConnected.Name = "labelClientsConnected";
|
this.panel_CommanArea.Dock = System.Windows.Forms.DockStyle.Left;
|
||||||
this.labelClientsConnected.Size = new System.Drawing.Size(104, 13);
|
this.panel_CommanArea.Location = new System.Drawing.Point(0, 0);
|
||||||
this.labelClientsConnected.TabIndex = 8;
|
this.panel_CommanArea.Name = "panel_CommanArea";
|
||||||
this.labelClientsConnected.Text = "Clients connected: 0";
|
this.panel_CommanArea.Size = new System.Drawing.Size(200, 616);
|
||||||
|
this.panel_CommanArea.TabIndex = 9;
|
||||||
//
|
//
|
||||||
// Form1
|
// Form1
|
||||||
//
|
//
|
||||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||||
this.ClientSize = new System.Drawing.Size(517, 373);
|
this.ClientSize = new System.Drawing.Size(735, 616);
|
||||||
this.Controls.Add(this.panel_clientArea);
|
this.Controls.Add(this.panel_clientArea);
|
||||||
this.Controls.Add(this.panel_commands);
|
this.Controls.Add(this.panel_CommanArea);
|
||||||
this.Controls.Add(this.panel_serverOptions);
|
|
||||||
this.Name = "Form1";
|
this.Name = "Form1";
|
||||||
this.Text = "Form1";
|
this.Text = "Form1";
|
||||||
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClosingEvent);
|
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.FormClosingEvent);
|
||||||
|
@ -347,6 +360,7 @@
|
||||||
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.timeLimit)).EndInit();
|
||||||
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
((System.ComponentModel.ISupportInitialize)(this.nrOfClients)).EndInit();
|
||||||
this.panel_clientArea.ResumeLayout(false);
|
this.panel_clientArea.ResumeLayout(false);
|
||||||
|
this.panel_CommanArea.ResumeLayout(false);
|
||||||
this.ResumeLayout(false);
|
this.ResumeLayout(false);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -376,6 +390,7 @@
|
||||||
private System.Windows.Forms.TextBox mapName;
|
private System.Windows.Forms.TextBox mapName;
|
||||||
private System.Windows.Forms.CheckBox forceStart;
|
private System.Windows.Forms.CheckBox forceStart;
|
||||||
private System.Windows.Forms.Label labelClientsConnected;
|
private System.Windows.Forms.Label labelClientsConnected;
|
||||||
|
private System.Windows.Forms.Panel panel_CommanArea;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,8 @@ using System.Threading.Tasks;
|
||||||
using System.Windows.Forms;
|
using System.Windows.Forms;
|
||||||
using System.Windows.Interop;
|
using System.Windows.Interop;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
using System.Threading;
|
||||||
|
using System.Timers;
|
||||||
|
|
||||||
namespace StandAloneLauncher
|
namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
|
@ -30,18 +32,17 @@ namespace StandAloneLauncher
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Run()
|
public void Run()
|
||||||
{
|
{
|
||||||
while (this.Created)
|
while (this.Created)
|
||||||
{
|
{
|
||||||
Application.DoEvents();
|
Application.DoEvents();
|
||||||
|
|
||||||
//Do some stuff
|
|
||||||
this.gameServer.ServerUpdate();
|
this.gameServer.ServerUpdate();
|
||||||
this.labelClientsConnected.Text = "Clients connected: " + this.gameServer.GetClientsConnectedCount().ToString();
|
this.labelClientsConnected.Text = "Clients connected: " + this.gameServer.GetClientsConnectedCount().ToString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void button1_serverToggle_Click(object sender, EventArgs e)
|
private void button1_serverToggle_Click(object sender, EventArgs e)
|
||||||
{
|
{
|
||||||
if (this.serverIsRunning)
|
if (this.serverIsRunning)
|
||||||
|
@ -88,8 +89,9 @@ namespace StandAloneLauncher
|
||||||
{
|
{
|
||||||
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
//this.gameServer.GameSetGameMode(this.gameModes.SelectedText);
|
||||||
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
this.gameServer.GameSetGameTime((int)this.timeLimit.Value);
|
||||||
//this.gameServer.GameSetMapId(0);
|
this.gameServer.GameSetMapName(this.mapName.Text);
|
||||||
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
this.gameServer.GameSetMaxClients((int)this.nrOfClients.Value);
|
||||||
|
|
||||||
if (!this.gameServer.GameStart( this.forceStart.Checked ))
|
if (!this.gameServer.GameStart( this.forceStart.Checked ))
|
||||||
{
|
{
|
||||||
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
this.ServerInfoTextArea.AppendText(DateTime.Now.ToUniversalTime() + "\n\t" + "Failed to start the game session!\n");
|
||||||
|
|
|
@ -52,6 +52,8 @@ OHRESOURCE OysterResource::LoadResource(const wchar_t* filename, ResourceType ty
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(!resourceData) return 0;
|
||||||
|
|
||||||
return resourceData->GetResourceHandle();
|
return resourceData->GetResourceHandle();
|
||||||
}
|
}
|
||||||
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
OHRESOURCE OysterResource::LoadResource(const wchar_t filename[], CustomLoadFunction loadFnc, int customId, bool force)
|
||||||
|
|
|
@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
}
|
}
|
||||||
CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o)
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
}
|
}
|
||||||
const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
|
||||||
|
CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
{
|
{
|
||||||
if(this->privateData)
|
if(this->privateData)
|
||||||
{
|
{
|
||||||
|
@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
|
||||||
this->privateData->attributes = o.privateData->attributes;
|
this->privateData->attributes = o.privateData->attributes;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
this->privateData = 0;
|
this->privateData = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const NetAttributeContainer& CustomNetProtocol::operator[](int ID) const
|
||||||
|
{
|
||||||
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
if((unsigned int)ID >= this->privateData->attributes.Size())
|
||||||
|
{
|
||||||
|
NetAttributeContainer temp;
|
||||||
|
|
||||||
|
temp.type = NetAttributeType_UNKNOWN;
|
||||||
|
memset(&temp.value, 0, sizeof(NetAttributeValue));
|
||||||
|
|
||||||
|
this->privateData->attributes.Push(ID, temp);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this->privateData->attributes[ID];
|
||||||
|
}
|
||||||
|
|
||||||
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
NetAttributeContainer& CustomNetProtocol::operator[](int ID)
|
||||||
{
|
{
|
||||||
//if(!this->privateData) this->privateData = new PrivateData();
|
//if(!this->privateData) this->privateData = new PrivateData();
|
||||||
|
|
|
@ -130,10 +130,12 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
CustomNetProtocol();
|
CustomNetProtocol();
|
||||||
~CustomNetProtocol();
|
~CustomNetProtocol();
|
||||||
CustomNetProtocol(CustomNetProtocol& o);
|
CustomNetProtocol( const CustomNetProtocol& o);
|
||||||
const CustomNetProtocol& operator=(CustomNetProtocol& o);
|
CustomNetProtocol& operator=(const CustomNetProtocol& o);
|
||||||
|
|
||||||
|
const NetAttributeContainer& operator[](int ID) const;
|
||||||
|
NetAttributeContainer& operator[](int ID);
|
||||||
|
|
||||||
NetAttributeContainer& operator[](int ID);
|
|
||||||
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
|
||||||
void Set(int ID, std::string s);
|
void Set(int ID, std::string s);
|
||||||
const NetAttributeContainer& Get(int id);
|
const NetAttributeContainer& Get(int id);
|
||||||
|
|
|
@ -96,6 +96,10 @@ struct NetworkClient::PrivateData : public IThreadObject
|
||||||
//printf("\t(%i)\n", this->sendQueue.Size());
|
//printf("\t(%i)\n", this->sendQueue.Size());
|
||||||
OysterByte temp;
|
OysterByte temp;
|
||||||
CustomNetProtocol p = this->sendQueue.Pop();
|
CustomNetProtocol p = this->sendQueue.Pop();
|
||||||
|
|
||||||
|
if(p[0].value.netShort == 304)
|
||||||
|
int i = 0;
|
||||||
|
|
||||||
this->translator.Pack(temp, p);
|
this->translator.Pack(temp, p);
|
||||||
errorCode = this->connection.Send(temp);
|
errorCode = this->connection.Send(temp);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue