Public feed
#724613
void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
{
sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
uint32 uiID;
recv_data >> uiID;
if(uiID > 8)
{
// Shit..
sLog.outString("WARNING: Accountdata > 8 (%d) was requested to be updated by %s of account %d!", uiID, GetPlayer()->GetName(), this->GetAccountId());
return;
}
uint32 uiDecompressedSize;
recv_data >> uiDecompressedSize;
uLongf uid = uiDecompressedSize;
// client wants to 'erase' current entries
if(uiDecompressedSize == 0)
{
SetAccountData(uiID, NULL, false,0);
return;
}
uint32 ReceivedPackedSize = recv_data.size() - 8;
char* data = new char[uiDecompressedSize+1];
memset(data,0,uiDecompressedSize+1); /* fix umr here */
if(uiDecompressedSize > ReceivedPackedSize) // if packed is compressed
{
int32 ZlibResult;
ZlibResult = uncompress((uint8*)data, &uid, recv_data.contents() + 8, ReceivedPackedSize);
switch (ZlibResult)
{
case Z_OK: //0 no error decompression is OK
SetAccountData(uiID, data, false,uiDecompressedSize);
sLog.outDetail("WORLD: Successfully decompressed account data %d for %s, and updated storage array.", uiID, GetPlayer()->GetName());
break;
case Z_ERRNO: //-1
case Z_STREAM_ERROR: //-2
case Z_DATA_ERROR: //-3
case Z_MEM_ERROR: //-4
case Z_BUF_ERROR: //-5
case Z_VERSION_ERROR: //-6
{
delete [] data;
sLog.outString("WORLD WARNING: Decompression of account data %d for %s FAILED.", uiID, GetPlayer()->GetName());
break;
}
default:
delete [] data;
sLog.outString("WORLD WARNING: Decompression gave a unknown error: %x, of account data %d for %s FAILED.", ZlibResult, uiID, GetPlayer()->GetName());
break;
}
}
else
{
memcpy(data,recv_data.contents() + 8,uiDecompressedSize);
SetAccountData(uiID, data, false,uiDecompressedSize);
}
}
void WorldSession::HandleRequestAccountData(WorldPacket& recv_data)
{
sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
uint32 id;
recv_data >> id;
if(id > 8)
{
// Shit..
sLog.outString("WARNING: Accountdata > 8 (%d) was requested by %s of account %d!", id, GetPlayer()->GetName(), this->GetAccountId());
return;
}
AccountDataEntry* res = GetAccountData(id);
WorldPacket data ;
data.SetOpcode(SMSG_UPDATE_ACCOUNT_DATA);
data << id;
// if red does not exists if ID == 7 and if there is no data send 0
if (!res || !res->data) // if error, send a NOTHING packet
{
data << (uint32)0;
}
else
{
data << res->sz;
uLongf destsize;
if(res->sz>200)
{
data.resize( res->sz+800 ); // give us plenty of room to work with..
if ( ( compress(const_cast<uint8*>(data.contents()) + (sizeof(uint32)*2), &destsize, (const uint8*)res->data, res->sz)) != Z_OK)
{
sLog.outError("Error while compressing ACCOUNT_DATA");
return;
}
data.resize(destsize+8);
}
else
data.append( res->data,res->sz);
}
SendPacket(&data);
}