aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Handlers/MiscHandler.cpp
diff options
context:
space:
mode:
authorjoschiwald <joschiwald.trinity@gmail.com>2014-11-16 06:08:46 +0100
committerjoschiwald <joschiwald.trinity@gmail.com>2014-11-16 06:08:46 +0100
commitd55c0cbf3a4bc8fe7851b49acc144058d598a40f (patch)
treeb033e6faaf427de09d4af3f68ea19fc85182dcfc /src/server/game/Handlers/MiscHandler.cpp
parent55c61599b25da18fdd16fc22168cc9a18ae56350 (diff)
Core/Packets: updated AccountData packets
Diffstat (limited to 'src/server/game/Handlers/MiscHandler.cpp')
-rw-r--r--src/server/game/Handlers/MiscHandler.cpp84
1 files changed, 29 insertions, 55 deletions
diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp
index 49b593eb0a6..613f1e46d7b 100644
--- a/src/server/game/Handlers/MiscHandler.cpp
+++ b/src/server/game/Handlers/MiscHandler.cpp
@@ -57,6 +57,7 @@
#include "BattlefieldMgr.h"
#include "DB2Stores.h"
#include "CharacterPackets.h"
+#include "ClientConfigPackets.h"
#include "MiscPackets.h"
void WorldSession::HandleRepopRequestOpcode(WorldPacket& recvData)
@@ -967,97 +968,70 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT);
}
-void WorldSession::HandleUpdateAccountData(WorldPacket& recvData)
+void WorldSession::HandleUpdateAccountData(WorldPackets::ClientConfig::UserClientUpdateAccountData& packet)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA");
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA: type %u, time %u, decompressedSize %u",
+ packet.DataType, packet.Time, packet.Size);
- uint32 type, timestamp, decompressedSize;
- recvData >> type >> timestamp >> decompressedSize;
-
- TC_LOG_DEBUG("network", "UAD: type %u, time %u, decompressedSize %u", type, timestamp, decompressedSize);
-
- if (type > NUM_ACCOUNT_DATA_TYPES)
+ if (packet.DataType > NUM_ACCOUNT_DATA_TYPES)
return;
- if (decompressedSize == 0) // erase
+ if (packet.Size == 0) // erase
{
- SetAccountData(AccountDataType(type), 0, "");
-
- WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
- data << uint32(type);
- data << uint32(0);
- SendPacket(&data);
-
+ SetAccountData(AccountDataType(packet.DataType), 0, "");
return;
}
- if (decompressedSize > 0xFFFF)
+ if (packet.Size > 0xFFFF)
{
- recvData.rfinish(); // unnneded warning spam in this case
- TC_LOG_ERROR("network", "UAD: Account data packet too big, size %u", decompressedSize);
+ TC_LOG_ERROR("network", "UAD: Account data packet too big, size %u", packet.Size);
return;
}
ByteBuffer dest;
- dest.resize(decompressedSize);
+ dest.resize(packet.Size);
- uLongf realSize = decompressedSize;
- if (uncompress(dest.contents(), &realSize, recvData.contents() + recvData.rpos(), recvData.size() - recvData.rpos()) != Z_OK)
+ uLongf realSize = packet.Size;
+ if (uncompress(dest.contents(), &realSize, packet.CompressedData.contents(), packet.CompressedData.size()) != Z_OK)
{
- recvData.rfinish(); // unnneded warning spam in this case
TC_LOG_ERROR("network", "UAD: Failed to decompress account data");
return;
}
- recvData.rfinish(); // uncompress read (recvData.size() - recvData.rpos())
-
std::string adata;
dest >> adata;
- SetAccountData(AccountDataType(type), timestamp, adata);
-
- WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4);
- data << uint32(type);
- data << uint32(0);
- SendPacket(&data);
+ SetAccountData(AccountDataType(packet.DataType), packet.Time, adata);
}
-void WorldSession::HandleRequestAccountData(WorldPacket& recvData)
+void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request)
{
- TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA");
-
- uint32 type;
- recvData >> type;
-
- TC_LOG_DEBUG("network", "RAD: type %u", type);
+ TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA: type %u", request.DataType);
- if (type >= NUM_ACCOUNT_DATA_TYPES)
+ if (request.DataType >= NUM_ACCOUNT_DATA_TYPES)
return;
- AccountData* adata = GetAccountData(AccountDataType(type));
+ AccountData const* adata = GetAccountData(AccountDataType(request.DataType));
- uint32 size = adata->Data.size();
+ WorldPackets::ClientConfig::UpdateAccountData data;
+ data.Player = _player ? _player->GetGUID() : ObjectGuid::Empty;
+ data.Time = adata->Time;
+ data.Size = adata->Data.size();
+ data.DataType = request.DataType;
- uLongf destSize = compressBound(size);
+ uLongf destSize = compressBound(data.Size);
- ByteBuffer dest;
- dest.resize(destSize);
+ data.CompressedData.resize(destSize);
- if (size && compress(dest.contents(), &destSize, (uint8 const*)adata->Data.c_str(), size) != Z_OK)
+ if (data.Size && compress(data.CompressedData.contents(), &destSize, (uint8 const*)adata->Data.c_str(), data.Size) != Z_OK)
{
- TC_LOG_DEBUG("network", "RAD: Failed to compress account data");
+ TC_LOG_ERROR("network", "RAD: Failed to compress account data");
return;
}
- dest.resize(destSize);
+ data.CompressedData.resize(destSize);
- WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8+4+4+4+destSize);
- data << (_player ? _player->GetGUID() : ObjectGuid::Empty);
- data << uint32(type); // type (0-7)
- data << uint32(adata->Time); // unix time
- data << uint32(size); // decompressed length
- data.append(dest); // compressed data
- SendPacket(&data);
+ SendPacket(data.Write());
}
int32 WorldSession::HandleEnableNagleAlgorithm()
@@ -1752,7 +1726,7 @@ void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recvData*/)
{
// empty opcode
TC_LOG_DEBUG("network", "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE");
-
+
WorldPackets::Misc::UITime response;
response.Time = time(NULL);
SendPacket(response.Write());