2014-01-28 09:00:02 +01:00
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
// Created by [Dennis Andersen] [2013]
|
|
|
|
/////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
#include "..\GameClient.h"
|
|
|
|
#include <NetworkSession.h>
|
|
|
|
#include <Protocols.h>
|
|
|
|
|
|
|
|
using namespace Utility::DynamicMemory;
|
2014-01-29 10:18:01 +01:00
|
|
|
using namespace Oyster::Network;
|
2014-01-28 09:00:02 +01:00
|
|
|
using namespace DanBias;
|
|
|
|
using namespace GameLogic;
|
|
|
|
|
|
|
|
static int gameClientIDCount = 1;
|
|
|
|
|
2014-01-29 10:18:01 +01:00
|
|
|
GameClient::GameClient(SmartPointer<NetworkClient> client, GameLogic::IPlayerData* player)
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
|
|
|
this->client = client;
|
|
|
|
this->id = gameClientIDCount++;
|
|
|
|
this->player = player;
|
2014-02-04 16:07:10 +01:00
|
|
|
isReady = false;
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
|
|
|
GameClient::~GameClient()
|
|
|
|
{
|
2014-01-29 10:18:01 +01:00
|
|
|
this->client->Disconnect();
|
2014-01-28 09:00:02 +01:00
|
|
|
this->player = 0;
|
|
|
|
this->id = -1;
|
2014-02-04 16:07:10 +01:00
|
|
|
isReady = false;
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
GameLogic::IPlayerData* GameClient::GetPlayer()
|
|
|
|
{
|
|
|
|
return this->player;
|
|
|
|
}
|
|
|
|
GameLogic::IPlayerData* GameClient::ReleasePlayer()
|
|
|
|
{
|
|
|
|
GameLogic::IPlayerData *temp = this->player;
|
|
|
|
this->player = 0;
|
|
|
|
return temp;
|
|
|
|
}
|
2014-01-29 10:18:01 +01:00
|
|
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::GetClient()
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
2014-01-29 10:18:01 +01:00
|
|
|
return this->client;
|
2014-01-28 09:00:02 +01:00
|
|
|
}
|
2014-01-29 10:18:01 +01:00
|
|
|
SmartPointer<Oyster::Network::NetworkClient> GameClient::ReleaseClient()
|
2014-01-28 09:00:02 +01:00
|
|
|
{
|
2014-01-29 10:18:01 +01:00
|
|
|
SmartPointer<Oyster::Network::NetworkClient> temp = this->client;
|
|
|
|
this->client = 0;
|
2014-01-28 09:00:02 +01:00
|
|
|
return temp;
|
|
|
|
}
|
|
|
|
int GameClient::GetID() const
|
|
|
|
{
|
|
|
|
return this->id;
|
|
|
|
}
|
2014-02-04 16:07:10 +01:00
|
|
|
float GameClient::GetSinceLastResponse() const
|
|
|
|
{
|
|
|
|
return this->secondsSinceLastResponse;
|
|
|
|
}
|
|
|
|
bool GameClient::IsReady() const
|
|
|
|
{
|
|
|
|
return this->isReady;
|
|
|
|
}
|
2014-01-31 08:41:08 +01:00
|
|
|
bool GameClient::Equals(const NetworkClient* c)
|
|
|
|
{
|
|
|
|
return (c->GetID() == this->client->GetID());
|
|
|
|
}
|
2014-02-04 16:07:10 +01:00
|
|
|
void GameClient::SetReadyState(bool r)
|
|
|
|
{
|
|
|
|
this->isReady = r;
|
|
|
|
}
|
|
|
|
void GameClient::SetSinceLastResponse(float s)
|
|
|
|
{
|
|
|
|
this->secondsSinceLastResponse = s;
|
|
|
|
}
|
2014-01-31 08:41:08 +01:00
|
|
|
|
|
|
|
|