Network - char[] unpacking.
Fixed correct unpacking on char[]. Fixed not clearing string in translator unpack function.
This commit is contained in:
parent
7c029a5242
commit
4df33b759c
|
@ -44,7 +44,7 @@ struct Translator::PrivateData
|
|||
headerString.push_back(it->second.type);
|
||||
}
|
||||
|
||||
message.PackShort(size, bytes);
|
||||
message.PackShort(headerString.size(), bytes);
|
||||
size += 2;
|
||||
|
||||
for(int i = 0; i < (int)headerString.size(); i++)
|
||||
|
@ -221,6 +221,8 @@ void Translator::Pack(OysterByte &bytes, CustomNetProtocol& protocol)
|
|||
|
||||
bool Translator::Unpack(CustomNetProtocol& protocol, OysterByte &bytes)
|
||||
{
|
||||
privateData->headerString.clear();
|
||||
|
||||
if(!privateData->UnpackHeader(protocol, bytes))
|
||||
{
|
||||
return false;
|
||||
|
|
|
@ -282,7 +282,7 @@ namespace Oyster
|
|||
char* UnpackCStr(unsigned char buffer[])
|
||||
{
|
||||
short len = UnpackS(buffer);
|
||||
char* str = new char[len];
|
||||
char* str = new char[len+1];
|
||||
|
||||
buffer += 2;
|
||||
for(int i = 0; i < len; i++)
|
||||
|
@ -290,6 +290,8 @@ namespace Oyster
|
|||
str[i] = buffer[i];
|
||||
}
|
||||
|
||||
str[len] = '\0';
|
||||
|
||||
return str;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue