|
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" |
@@ -763,97 +764,78 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData) |
763 | 764 | player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT); |
764 | 765 | } |
765 | 766 |
|
766 | | -void WorldSession::HandleUpdateAccountData(WorldPacket& recvData) |
| 767 | +void WorldSession::HandleUpdateAccountData(WorldPackets::ClientConfig::UserClientUpdateAccountData& packet) |
767 | 768 | { |
768 | | - TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA"); |
| 769 | + TC_LOG_DEBUG("network", "WORLD: Received CMSG_UPDATE_ACCOUNT_DATA: type {}, time {}, decompressedSize {}", |
| 770 | + packet.DataType, packet.Time, packet.Size); |
769 | 771 |
|
770 | | - uint32 type, timestamp, decompressedSize; |
771 | | - recvData >> type >> timestamp >> decompressedSize; |
772 | | - |
773 | | - TC_LOG_DEBUG("network", "UAD: type {}, time {}, decompressedSize {}", type, timestamp, decompressedSize); |
774 | | - |
775 | | - if (type >= NUM_ACCOUNT_DATA_TYPES) |
| 772 | + if (packet.DataType >= NUM_ACCOUNT_DATA_TYPES) |
776 | 773 | return; |
777 | 774 |
|
778 | | - if (decompressedSize == 0) // erase |
| 775 | + if (packet.Size == 0) // erase |
779 | 776 | { |
780 | | - SetAccountData(AccountDataType(type), 0, ""); |
| 777 | + SetAccountData(AccountDataType(packet.DataType), 0, ""); |
781 | 778 |
|
782 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); |
783 | | - data << uint32(type); |
784 | | - data << uint32(0); |
785 | | - SendPacket(&data); |
| 779 | + WorldPackets::ClientConfig::UpdateAccountDataComplete updateAccountDataComplete; |
| 780 | + updateAccountDataComplete.DataType = packet.DataType; |
| 781 | + updateAccountDataComplete.Result = 0; |
| 782 | + SendPacket(updateAccountDataComplete.Write()); |
786 | 783 |
|
787 | 784 | return; |
788 | 785 | } |
789 | 786 |
|
790 | | - if (decompressedSize > 0xFFFF) |
| 787 | + if (packet.Size > 0xFFFF) |
791 | 788 | { |
792 | | - recvData.rfinish(); // unnneded warning spam in this case |
793 | | - TC_LOG_ERROR("network", "UAD: Account data packet too big, size {}", decompressedSize); |
| 789 | + TC_LOG_ERROR("network", "UAD: Account data packet too big, size {}", packet.Size); |
794 | 790 | return; |
795 | 791 | } |
796 | 792 |
|
797 | | - ByteBuffer dest; |
798 | | - dest.resize(decompressedSize); |
| 793 | + std::string dest; |
| 794 | + dest.resize(packet.Size); |
799 | 795 |
|
800 | | - uLongf realSize = decompressedSize; |
801 | | - if (uncompress(dest.contents(), &realSize, recvData.contents() + recvData.rpos(), recvData.size() - recvData.rpos()) != Z_OK) |
| 796 | + uLongf realSize = packet.Size; |
| 797 | + if (uncompress(reinterpret_cast<Bytef*>(dest.data()), &realSize, packet.CompressedData.data(), packet.CompressedData.size()) != Z_OK) |
802 | 798 | { |
803 | | - recvData.rfinish(); // unnneded warning spam in this case |
804 | 799 | TC_LOG_ERROR("network", "UAD: Failed to decompress account data"); |
805 | 800 | return; |
806 | 801 | } |
807 | 802 |
|
808 | | - recvData.rfinish(); // uncompress read (recvData.size() - recvData.rpos()) |
809 | | - |
810 | | - std::string adata; |
811 | | - dest >> adata; |
812 | | - |
813 | | - SetAccountData(AccountDataType(type), timestamp, adata); |
| 803 | + SetAccountData(AccountDataType(packet.DataType), packet.Time, dest); |
814 | 804 |
|
815 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA_COMPLETE, 4+4); |
816 | | - data << uint32(type); |
817 | | - data << uint32(0); |
818 | | - SendPacket(&data); |
| 805 | + WorldPackets::ClientConfig::UpdateAccountDataComplete updateAccountDataComplete; |
| 806 | + updateAccountDataComplete.DataType = packet.DataType; |
| 807 | + updateAccountDataComplete.Result = 0; |
| 808 | + SendPacket(updateAccountDataComplete.Write()); |
819 | 809 | } |
820 | 810 |
|
821 | | -void WorldSession::HandleRequestAccountData(WorldPacket& recvData) |
| 811 | +void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request) |
822 | 812 | { |
823 | | - TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA"); |
824 | | - |
825 | | - uint32 type; |
826 | | - recvData >> type; |
| 813 | + TC_LOG_DEBUG("network", "WORLD: Received CMSG_REQUEST_ACCOUNT_DATA: type {}", request.DataType); |
827 | 814 |
|
828 | | - TC_LOG_DEBUG("network", "RAD: type {}", type); |
829 | | - |
830 | | - if (type >= NUM_ACCOUNT_DATA_TYPES) |
| 815 | + if (request.DataType >= NUM_ACCOUNT_DATA_TYPES) |
831 | 816 | return; |
832 | 817 |
|
833 | | - AccountData* adata = GetAccountData(AccountDataType(type)); |
| 818 | + AccountData const* adata = GetAccountData(AccountDataType(request.DataType)); |
834 | 819 |
|
835 | | - uint32 size = adata->Data.size(); |
| 820 | + WorldPackets::ClientConfig::UpdateAccountData data; |
| 821 | + data.Player = _player ? _player->GetGUID() : ObjectGuid::Empty; |
| 822 | + data.Time = adata->Time; |
| 823 | + data.Size = adata->Data.size(); |
| 824 | + data.DataType = request.DataType; |
836 | 825 |
|
837 | | - uLongf destSize = compressBound(size); |
| 826 | + uLongf destSize = compressBound(data.Size); |
838 | 827 |
|
839 | | - ByteBuffer dest; |
840 | | - dest.resize(destSize); |
| 828 | + data.CompressedData.resize(destSize); |
841 | 829 |
|
842 | | - if (size && compress(dest.contents(), &destSize, (uint8 const*)adata->Data.c_str(), size) != Z_OK) |
| 830 | + if (data.Size && compress(data.CompressedData.data(), &destSize, (uint8 const*)adata->Data.c_str(), data.Size) != Z_OK) |
843 | 831 | { |
844 | | - TC_LOG_DEBUG("network", "RAD: Failed to compress account data"); |
| 832 | + TC_LOG_ERROR("network", "RAD: Failed to compress account data"); |
845 | 833 | return; |
846 | 834 | } |
847 | 835 |
|
848 | | - dest.resize(destSize); |
| 836 | + data.CompressedData.resize(destSize); |
849 | 837 |
|
850 | | - WorldPacket data(SMSG_UPDATE_ACCOUNT_DATA, 8+4+4+4+destSize); |
851 | | - data << (_player ? _player->GetGUID() : ObjectGuid::Empty); |
852 | | - data << uint32(type); // type (0-7) |
853 | | - data << uint32(adata->Time); // unix time |
854 | | - data << uint32(size); // decompressed length |
855 | | - data.append(dest); // compressed data |
856 | | - SendPacket(&data); |
| 838 | + SendPacket(data.Write()); |
857 | 839 | } |
858 | 840 |
|
859 | 841 | void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recvData) |
|
0 commit comments