const related edits in CustomNetProtocol

Should be none impact besides positive ones
This commit is contained in:
Dander7BD 2014-02-18 17:04:27 +01:00
parent 22f9daf0d8
commit 02b467be18
2 changed files with 26 additions and 5 deletions

View File

@ -40,12 +40,13 @@ CustomNetProtocol::CustomNetProtocol()
{
this->privateData = new PrivateData();
}
CustomNetProtocol::CustomNetProtocol(CustomNetProtocol& o)
CustomNetProtocol::CustomNetProtocol(const CustomNetProtocol& o)
{
this->privateData = new PrivateData();
this->privateData->attributes = o.privateData->attributes;
}
const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
CustomNetProtocol& CustomNetProtocol::operator=(const CustomNetProtocol& o)
{
if(this->privateData)
{
@ -56,11 +57,29 @@ const CustomNetProtocol& CustomNetProtocol::operator=(CustomNetProtocol& o)
this->privateData->attributes = o.privateData->attributes;
return *this;
}
CustomNetProtocol::~CustomNetProtocol()
{
delete this->privateData;
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)
{
//if(!this->privateData) this->privateData = new PrivateData();

View File

@ -130,10 +130,12 @@ namespace Oyster
public:
CustomNetProtocol();
~CustomNetProtocol();
CustomNetProtocol(CustomNetProtocol& o);
const CustomNetProtocol& operator=(CustomNetProtocol& o);
CustomNetProtocol( const CustomNetProtocol& o);
CustomNetProtocol& operator=(const CustomNetProtocol& o);
const NetAttributeContainer& operator[](int ID) const;
NetAttributeContainer& operator[](int ID);
void Set(int id, Oyster::Network::NetAttributeValue val, Oyster::Network::NetAttributeType type);
void Set(int ID, std::string s);
const NetAttributeContainer& Get(int id);