mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
Small account data changes
This commit is contained in:
parent
8bea43063e
commit
05b8acd140
3 changed files with 28 additions and 23 deletions
|
|
@ -1071,7 +1071,8 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket & recv_data)
|
||||||
void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
||||||
{
|
{
|
||||||
sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
|
sLog.outDetail("WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
|
||||||
recv_data.hexlike();
|
|
||||||
|
CHECK_PACKET_SIZE(recv_data, 4+4+4);
|
||||||
|
|
||||||
uint32 type, timestamp, decompressedSize;
|
uint32 type, timestamp, decompressedSize;
|
||||||
recv_data >> type >> timestamp >> decompressedSize;
|
recv_data >> type >> timestamp >> decompressedSize;
|
||||||
|
|
@ -1082,7 +1083,18 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
||||||
if(decompressedSize == 0) // erase
|
if(decompressedSize == 0) // erase
|
||||||
{
|
{
|
||||||
SetAccountData(type, timestamp, "");
|
SetAccountData(type, timestamp, "");
|
||||||
SaveAccountData(type);
|
|
||||||
|
WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
|
||||||
|
data << uint32(type);
|
||||||
|
data << uint32(0);
|
||||||
|
SendPacket(&data);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(decompressedSize > 0xFFFF)
|
||||||
|
{
|
||||||
|
sLog.outError("UAD: Account data packet too big, size %u", decompressedSize);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1092,7 +1104,7 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
||||||
uLongf realSize = decompressedSize;
|
uLongf realSize = decompressedSize;
|
||||||
if(uncompress(const_cast<uint8*>(dest.contents()), &realSize, const_cast<uint8*>(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) != Z_OK)
|
if(uncompress(const_cast<uint8*>(dest.contents()), &realSize, const_cast<uint8*>(recv_data.contents() + recv_data.rpos()), recv_data.size() - recv_data.rpos()) != Z_OK)
|
||||||
{
|
{
|
||||||
sLog.outError("UAD: Failed to decompress packet");
|
sLog.outError("UAD: Failed to decompress account data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1100,7 +1112,6 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
||||||
dest >> adata;
|
dest >> adata;
|
||||||
|
|
||||||
SetAccountData(type, timestamp, adata);
|
SetAccountData(type, timestamp, adata);
|
||||||
SaveAccountData(type);
|
|
||||||
|
|
||||||
WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
|
WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
|
||||||
data << uint32(type);
|
data << uint32(type);
|
||||||
|
|
@ -1111,7 +1122,6 @@ void WorldSession::HandleUpdateAccountData(WorldPacket &recv_data)
|
||||||
void WorldSession::HandleRequestAccountData(WorldPacket& recv_data)
|
void WorldSession::HandleRequestAccountData(WorldPacket& recv_data)
|
||||||
{
|
{
|
||||||
sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
|
sLog.outDetail("WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
|
||||||
recv_data.hexlike();
|
|
||||||
|
|
||||||
CHECK_PACKET_SIZE(recv_data, 4);
|
CHECK_PACKET_SIZE(recv_data, 4);
|
||||||
|
|
||||||
|
|
@ -1122,14 +1132,15 @@ void WorldSession::HandleRequestAccountData(WorldPacket& recv_data)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
AccountData *adata = GetAccountData(type);
|
AccountData *adata = GetAccountData(type);
|
||||||
uint32 size = adata->Data.size();
|
|
||||||
uLongf destSize = size;
|
|
||||||
ByteBuffer dest;
|
|
||||||
dest.resize(size);
|
|
||||||
|
|
||||||
|
uint32 size = adata->Data.size();
|
||||||
|
|
||||||
|
ByteBuffer dest(size);
|
||||||
|
|
||||||
|
uLongf destSize = size;
|
||||||
if(compress(const_cast<uint8*>(dest.contents()), &destSize, (uint8*)adata->Data.c_str(), size) != Z_OK)
|
if(compress(const_cast<uint8*>(dest.contents()), &destSize, (uint8*)adata->Data.c_str(), size) != Z_OK)
|
||||||
{
|
{
|
||||||
sLog.outDebug("RAD: Failed to compress account data, error");
|
sLog.outDebug("RAD: Failed to compress account data");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -539,9 +539,12 @@ void WorldSession::LoadAccountData()
|
||||||
delete result;
|
delete result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void WorldSession::SaveAccountData(uint32 type)
|
void WorldSession::SetAccountData(uint32 type, time_t time_, std::string data)
|
||||||
{
|
{
|
||||||
|
m_accountData[type].Time = time_;
|
||||||
|
m_accountData[type].Data = data;
|
||||||
|
|
||||||
uint32 acc = GetAccountId();
|
uint32 acc = GetAccountId();
|
||||||
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
|
CharacterDatabase.PExecute("DELETE FROM account_data WHERE account='%u' AND type='%u'", acc, type);
|
||||||
CharacterDatabase.PExecute("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)m_accountData[type].Time, m_accountData[type].Data.c_str());
|
CharacterDatabase.PExecute("INSERT INTO account_data VALUES ('%u','%u','%u','%s')", acc, type, (uint32)time_, data.c_str());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -158,18 +158,9 @@ class MANGOS_DLL_SPEC WorldSession
|
||||||
void SendPetNameQuery(uint64 guid, uint32 petnumber);
|
void SendPetNameQuery(uint64 guid, uint32 petnumber);
|
||||||
|
|
||||||
// Account Data
|
// Account Data
|
||||||
AccountData *GetAccountData(uint32 type)
|
AccountData *GetAccountData(uint32 type) { return &m_accountData[type]; }
|
||||||
{
|
void SetAccountData(uint32 type, time_t time_, std::string data);
|
||||||
return &m_accountData[type];
|
|
||||||
}
|
|
||||||
void SetAccountData(uint32 type, time_t time_, std::string data)
|
|
||||||
{
|
|
||||||
m_accountData[type].Time = time_;
|
|
||||||
m_accountData[type].Data = data;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoadAccountData();
|
void LoadAccountData();
|
||||||
void SaveAccountData(uint32 type);
|
|
||||||
|
|
||||||
//mail
|
//mail
|
||||||
//used with item_page table
|
//used with item_page table
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue