|
21 | 21 | #include "CharacterPackets.h" |
22 | 22 | #include "Chat.h" |
23 | 23 | #include "CinematicMgr.h" |
| 24 | +#include "ClientConfigPackets.h" |
24 | 25 | #include "Common.h" |
25 | 26 | #include "Corpse.h" |
26 | 27 | #include "Creature.h" |
@@ -826,97 +827,78 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) |
826 | 827 | player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT); |
827 | 828 | } |
828 | 829 |
|
829 | | -void WorldSession::HandleUpdateAccountData(WorldPacket& recvData) |
| 830 | +void WorldSession::HandleUpdateAccountData(WorldPackets::ClientConfig::UserClientUpdateAccountData& packet) |
830 | 831 | { |
831 | | - TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); |
| 832 | + TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA: type {}, time {}, decompressedSize {}", |
| 833 | + packet.DataType, packet.Time, packet.Size); |
832 | 834 |
|
833 | | - uint32 type, timestamp, decompressedSize; |
834 | | - recvData >> type >> timestamp >> decompressedSize; |
835 | | - |
836 | | - TC_LOG_DEBUG("network", "UAD: type {}, time {}, decompressedSize {}", type, timestamp, decompressedSize); |
837 | | - |
838 | | - if (type >= NUM_ACCOUNT_DATA_TYPES) |
| 835 | + if (packet.DataType >= NUM_ACCOUNT_DATA_TYPES) |
839 | 836 | return; |
840 | 837 |
|
841 | | - if (decompressedSize == 0) // erase |
| 838 | + if (packet.Size == 0) // erase |
842 | 839 | { |
843 | | - SetAccountData(AccountDataType(type), 0, ""); |
| 840 | + SetAccountData(AccountDataType(packet.DataType), 0, ""); |
844 | 841 |
|
845 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); |
846 | | - data << uint32(type); |
847 | | - data << uint32(0); |
848 | | - SendPacket(&data); |
| 842 | + WorldPackets::ClientConfig::UpdateAccountDataComplete updateAccountDataComplete; |
| 843 | + updateAccountDataComplete.DataType = packet.DataType; |
| 844 | + updateAccountDataComplete.Result = 0; |
| 845 | + SendPacket(updateAccountDataComplete.Write()); |
849 | 846 |
|
850 | 847 | return; |
851 | 848 | } |
852 | 849 |
|
853 | | - if (decompressedSize > 0xFFFF) |
| 850 | + if (packet.Size > 0xFFFF) |
854 | 851 | { |
855 | | - recvData.rfinish(); // unnneded warning spam in this case |
856 | | - TC_LOG_ERROR("network", "UAD: Account data packet too big, size {}", decompressedSize); |
| 852 | + TC_LOG_ERROR("network", "UAD: Account data packet too big, size {}", packet.Size); |
857 | 853 | return; |
858 | 854 | } |
859 | 855 |
|
860 | | - ByteBuffer dest; |
861 | | - dest.resize(decompressedSize); |
| 856 | + std::string dest; |
| 857 | + dest.resize(packet.Size); |
862 | 858 |
|
863 | | - uLongf realSize = decompressedSize; |
864 | | - if (uncompress(dest.contents(), &realSize, recvData.contents() + recvData.rpos(), recvData.size() - recvData.rpos()) != Z_OK) |
| 859 | + uLongf realSize = packet.Size; |
| 860 | + if (uncompress(reinterpret_cast<Bytef*>(dest.data()), &realSize, packet.CompressedData.data(), packet.CompressedData.size()) != Z_OK) |
865 | 861 | { |
866 | | - recvData.rfinish(); // unnneded warning spam in this case |
867 | 862 | TC_LOG_ERROR("network", "UAD: Failed to decompress account data"); |
868 | 863 | return; |
869 | 864 | } |
870 | 865 |
|
871 | | - recvData.rfinish(); // uncompress read (recvData.size() - recvData.rpos()) |
872 | | - |
873 | | - std::string adata; |
874 | | - dest >> adata; |
875 | | - |
876 | | - SetAccountData(AccountDataType(type), timestamp, adata); |
| 866 | + SetAccountData(AccountDataType(packet.DataType), packet.Time, dest); |
877 | 867 |
|
878 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); |
879 | | - data << uint32(type); |
880 | | - data << uint32(0); |
881 | | - SendPacket(&data); |
| 868 | + WorldPackets::ClientConfig::UpdateAccountDataComplete updateAccountDataComplete; |
| 869 | + updateAccountDataComplete.DataType = packet.DataType; |
| 870 | + updateAccountDataComplete.Result = 0; |
| 871 | + SendPacket(updateAccountDataComplete.Write()); |
882 | 872 | } |
883 | 873 |
|
884 | | -void WorldSession::HandleRequestAccountData(WorldPacket& recvData) |
| 874 | +void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request) |
885 | 875 | { |
886 | | - TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA"); |
887 | | - |
888 | | - uint32 type; |
889 | | - recvData >> type; |
| 876 | + TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA: type {}", request.DataType); |
890 | 877 |
|
891 | | - TC_LOG_DEBUG("network", "RAD: type {}", type); |
892 | | - |
893 | | - if (type >= NUM_ACCOUNT_DATA_TYPES) |
| 878 | + if (request.DataType >= NUM_ACCOUNT_DATA_TYPES) |
894 | 879 | return; |
895 | 880 |
|
896 | | - AccountData* adata = GetAccountData(AccountDataType(type)); |
| 881 | + AccountData const* adata = GetAccountData(AccountDataType(request.DataType)); |
897 | 882 |
|
898 | | - uint32 size = adata->Data.size(); |
| 883 | + WorldPackets::ClientConfig::UpdateAccountData data; |
| 884 | + data.Player = _player ? _player->GetGUID() : ObjectGuid::Empty; |
| 885 | + data.Time = adata->Time; |
| 886 | + data.Size = adata->Data.size(); |
| 887 | + data.DataType = request.DataType; |
899 | 888 |
|
900 | | - uLongf destSize = compressBound(size); |
| 889 | + uLongf destSize = compressBound(data.Size); |
901 | 890 |
|
902 | | - ByteBuffer dest; |
903 | | - dest.resize(destSize); |
| 891 | + data.CompressedData.resize(destSize); |
904 | 892 |
|
905 | | - if (size && compress(dest.contents(), &destSize, (uint8 const*)adata->Data.c_str(), size) != Z_OK) |
| 893 | + if (data.Size && compress(data.CompressedData.data(), &destSize, (uint8 const*)adata->Data.c_str(), data.Size) != Z_OK) |
906 | 894 | { |
907 | | - TC_LOG_DEBUG("network", "RAD: Failed to compress account data"); |
| 895 | + TC_LOG_ERROR("network", "RAD: Failed to compress account data"); |
908 | 896 | return; |
909 | 897 | } |
910 | 898 |
|
911 | | - dest.resize(destSize); |
| 899 | + data.CompressedData.resize(destSize); |
912 | 900 |
|
913 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8+4+4+4+destSize); |
914 | | - data << (_player ? _player->GetGUID() : ObjectGuid::Empty); |
915 | | - data << uint32(type); // type (0-7) |
916 | | - data << uint32(adata->Time); // unix time |
917 | | - data << uint32(size); // decompressed length |
918 | | - data.append(dest); // compressed data |
919 | | - SendPacket(&data); |
| 901 | + SendPacket(data.Write()); |
920 | 902 | } |
921 | 903 |
|
922 | 904 | void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recvData) |
@@ -1387,7 +1369,7 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket& recvData) |
1387 | 1369 | player->SendRespondInspectAchievements(_player); |
1388 | 1370 | } |
1389 | 1371 |
|
1390 | | -void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recvData*/) |
| 1372 | +void WorldSession::HandleWorldStateUITimerUpdate(WorldPackets::Misc::UITimeRequest& /*request*/) |
1391 | 1373 | { |
1392 | 1374 | // empty opcode |
1393 | 1375 | TC_LOG_DEBUG("network", "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE"); |
|
0 commit comments