Pre-merge with network, (again)
This commit is contained in:
parent
2ea252919a
commit
9b9a92556a
|
@ -13,7 +13,7 @@ namespace DanBias
|
||||||
{
|
{
|
||||||
using namespace Oyster::Network;
|
using namespace Oyster::Network;
|
||||||
|
|
||||||
void GameServer::ClientConnectCallback(NetworkClient &client)
|
void GameServer::ClientConnectCallback(NetworkClient client)
|
||||||
{
|
{
|
||||||
printf("Client connected!\n");
|
printf("Client connected!\n");
|
||||||
GameLogic::Protocol_TEST t;
|
GameLogic::Protocol_TEST t;
|
||||||
|
|
|
@ -25,7 +25,7 @@ namespace DanBias
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
|
//static void ClientConnectCallbackFunction(Oyster::Network::NetworkClient& connectedClient);
|
||||||
void ClientConnectCallback(Oyster::Network::NetworkClient &client) override;
|
void ClientConnectCallback(Oyster::Network::NetworkClient client) override;
|
||||||
|
|
||||||
bool initiated;
|
bool initiated;
|
||||||
bool running;
|
bool running;
|
||||||
|
|
|
@ -13,12 +13,34 @@ struct CustomNetProtocol::PrivateData
|
||||||
|
|
||||||
PrivateData()
|
PrivateData()
|
||||||
{ }
|
{ }
|
||||||
|
PrivateData( const CustomNetProtocol::PrivateData& o)
|
||||||
|
{
|
||||||
|
for (auto i = o.attributes.begin(); i != o.attributes.end(); i++)
|
||||||
|
{
|
||||||
|
if(i->second.type == NetAttributeType_CharArray)
|
||||||
|
{
|
||||||
|
size_t size = strlen(i->second.value.netCharPtr);
|
||||||
|
if(size == 0) continue;
|
||||||
|
|
||||||
|
attributes[i->first];
|
||||||
|
attributes[i->first].value.netCharPtr = new char[size + 1];
|
||||||
|
//strcpy_s(attributes[i->first].value.netCharPtr, size + 1, i->second.value.netCharPtr);
|
||||||
|
memcpy(&attributes[i->first].value.netCharPtr[0], &i->second.value.netCharPtr[0], size + 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
attributes[i->first] = i->second;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
attributes = o.attributes;
|
||||||
|
}
|
||||||
~PrivateData()
|
~PrivateData()
|
||||||
{
|
{
|
||||||
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
for (auto i = attributes.begin(); i != attributes.end(); i++)
|
||||||
{
|
{
|
||||||
RemoveAttribute(i->first);
|
RemoveAttribute(i->first);
|
||||||
}
|
}
|
||||||
|
attributes.clear();
|
||||||
}
|
}
|
||||||
void RemoveAttribute(int ID)
|
void RemoveAttribute(int ID)
|
||||||
{
|
{
|
||||||
|
@ -28,7 +50,8 @@ struct CustomNetProtocol::PrivateData
|
||||||
switch (i->second.type)
|
switch (i->second.type)
|
||||||
{
|
{
|
||||||
case NetAttributeType_CharArray:
|
case NetAttributeType_CharArray:
|
||||||
delete [] i->second.value.netCharPtr;
|
//delete [] i->second.value.netCharPtr;
|
||||||
|
i->second.value.netCharPtr = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -41,6 +64,16 @@ CustomNetProtocol::CustomNetProtocol()
|
||||||
{
|
{
|
||||||
this->privateData = new PrivateData();
|
this->privateData = new PrivateData();
|
||||||
}
|
}
|
||||||
|
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
|
||||||
|
{
|
||||||
|
this->privateData = new PrivateData(*o.privateData);
|
||||||
|
}
|
||||||
|
const CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
this->privateData = new PrivateData(*o.privateData);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
CustomNetProtocol::~CustomNetProtocol()
|
CustomNetProtocol::~CustomNetProtocol()
|
||||||
{
|
{
|
||||||
delete this->privateData;
|
delete this->privateData;
|
||||||
|
|
|
@ -82,6 +82,8 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
CustomNetProtocol();
|
CustomNetProtocol();
|
||||||
~CustomNetProtocol();
|
~CustomNetProtocol();
|
||||||
|
CustomNetProtocol(const CustomNetProtocol& o);
|
||||||
|
const CustomNetProtocol& operator=(const CustomNetProtocol& o);
|
||||||
|
|
||||||
NetAttributeContainer& operator[](int ID);
|
NetAttributeContainer& operator[](int ID);
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@ namespace Oyster
|
||||||
typedef void(*ProtocolRecieverFunction)(CustomNetProtocol& protocol);
|
typedef void(*ProtocolRecieverFunction)(CustomNetProtocol& protocol);
|
||||||
struct ClientConnectedObject
|
struct ClientConnectedObject
|
||||||
{
|
{
|
||||||
virtual void ClientConnectCallback(NetworkClient &client) = 0;
|
virtual void ClientConnectCallback(NetworkClient client) = 0;
|
||||||
};
|
};
|
||||||
struct ProtocolRecieverObject
|
struct ProtocolRecieverObject
|
||||||
{
|
{
|
||||||
|
|
|
@ -220,6 +220,16 @@ Translator::~Translator()
|
||||||
privateData = NULL;
|
privateData = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Translator::Translator(const Translator& obj)
|
||||||
|
{
|
||||||
|
this->privateData = new PrivateData(*obj.privateData);
|
||||||
|
}
|
||||||
|
const Translator& Translator::operator=(const Translator& obj)
|
||||||
|
{
|
||||||
|
delete this->privateData;
|
||||||
|
this->privateData = new PrivateData(*obj.privateData);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
void Translator::Pack(SmartPointer<OysterByte> &bytes, CustomNetProtocol& protocol)
|
void Translator::Pack(SmartPointer<OysterByte> &bytes, CustomNetProtocol& protocol)
|
||||||
{
|
{
|
||||||
|
|
|
@ -48,6 +48,8 @@ namespace Oyster
|
||||||
public:
|
public:
|
||||||
Translator ();
|
Translator ();
|
||||||
~Translator();
|
~Translator();
|
||||||
|
Translator(const Translator& obj);
|
||||||
|
const Translator& operator=(const Translator& obj);
|
||||||
|
|
||||||
void Pack(Utility::DynamicMemory::SmartPointer<OysterByte> &bytes, CustomNetProtocol& protocol);
|
void Pack(Utility::DynamicMemory::SmartPointer<OysterByte> &bytes, CustomNetProtocol& protocol);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue