Skip to content

Commit db8f48d

Browse files
author
Rochet2
committed
Merge TrinityCore 3.3.5 to ElunaTrinityWotlk [skip ci]
2 parents 14407e3 + 0672ad5 commit db8f48d

18 files changed

Lines changed: 595 additions & 392 deletions

src/server/game/Entities/Player/Player.cpp

Lines changed: 11 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2741,11 +2741,7 @@ void Player::SendInitialSpells()
27412741

27422742
void Player::SendUnlearnSpells()
27432743
{
2744-
WorldPacket data(SMSG_SEND_UNLEARN_SPELLS, 4 + 4 * m_spells.size());
2745-
2746-
uint32 spellCount = 0;
2747-
size_t countPos = data.wpos();
2748-
data << uint32(spellCount); // spell count placeholder
2744+
WorldPackets::Spells::SendUnlearnSpells sendUnlearnSpells;
27492745

27502746
for (PlayerSpellMap::const_iterator itr = m_spells.begin(); itr != m_spells.end(); ++itr)
27512747
{
@@ -2776,14 +2772,10 @@ void Player::SendUnlearnSpells()
27762772
if (!nextRank || !HasSpell(nextRank))
27772773
continue;
27782774

2779-
data << uint32(itr->first);
2780-
2781-
++spellCount;
2775+
sendUnlearnSpells.Spells.push_back(itr->first);
27822776
}
27832777

2784-
data.put<uint32>(countPos, spellCount); // write real count value
2785-
2786-
SendDirectMessage(&data);
2778+
SendDirectMessage(sendUnlearnSpells.Write());
27872779
}
27882780

27892781
void Player::SendTameFailure(uint8 result)
@@ -6006,27 +5998,15 @@ int16 Player::GetSkillTempBonusValue(uint32 skill) const
60065998

60075999
void Player::SendActionButtons(uint32 state) const
60086000
{
6009-
WorldPacket data(SMSG_ACTION_BUTTONS, 1+(MAX_ACTION_BUTTONS*4));
6010-
data << uint8(state);
6011-
/*
6012-
state can be 0, 1, 2
6013-
0 - Sends initial action buttons, client does not validate if we have the spell or not
6014-
1 - Used used after spec swaps, client validates if a spell is known.
6015-
2 - Clears the action bars client sided. This is sent during spec swap before unlearning and before sending the new buttons
6016-
*/
6017-
if (state != 2)
6018-
{
6019-
for (uint8 button = 0; button < MAX_ACTION_BUTTONS; ++button)
6020-
{
6021-
ActionButtonList::const_iterator itr = m_actionButtons.find(button);
6022-
if (itr != m_actionButtons.end() && itr->second.uState != ACTIONBUTTON_DELETED)
6023-
data << uint32(itr->second.packedData);
6024-
else
6025-
data << uint32(0);
6026-
}
6027-
}
6001+
WorldPackets::Spells::UpdateActionButtons packet;
60286002

6029-
SendDirectMessage(&data);
6003+
for (auto const& [i, button] : m_actionButtons)
6004+
if (button.uState != ACTIONBUTTON_DELETED && i < packet.ActionButtons.size())
6005+
packet.ActionButtons[i] = button.packedData;
6006+
6007+
packet.Reason = state;
6008+
6009+
GetSession()->SendPacket(packet.Write());
60306010
}
60316011

60326012
bool Player::IsActionButtonDataValid(uint8 button, uint32 action, uint8 type) const

src/server/game/Handlers/MiscHandler.cpp

Lines changed: 38 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "CharacterPackets.h"
2222
#include "Chat.h"
2323
#include "CinematicMgr.h"
24+
#include "ClientConfigPackets.h"
2425
#include "Common.h"
2526
#include "Corpse.h"
2627
#include "Creature.h"
@@ -826,97 +827,78 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPacket& recvData)
826827
player->TeleportTo(at->target_mapId, at->target_X, at->target_Y, at->target_Z, at->target_Orientation, TELE_TO_NOT_LEAVE_TRANSPORT);
827828
}
828829

829-
void WorldSession::HandleUpdateAccountData(WorldPacket& recvData)
830+
void WorldSession::HandleUpdateAccountData(WorldPackets::ClientConfig::UserClientUpdateAccountData& packet)
830831
{
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);
832834

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)
839836
return;
840837

841-
if (decompressedSize == 0) // erase
838+
if (packet.Size == 0) // erase
842839
{
843-
SetAccountData(AccountDataType(type), 0, "");
840+
SetAccountData(AccountDataType(packet.DataType), 0, "");
844841

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());
849846

850847
return;
851848
}
852849

853-
if (decompressedSize > 0xFFFF)
850+
if (packet.Size > 0xFFFF)
854851
{
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);
857853
return;
858854
}
859855

860-
ByteBuffer dest;
861-
dest.resize(decompressedSize);
856+
std::string dest;
857+
dest.resize(packet.Size);
862858

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)
865861
{
866-
recvData.rfinish(); // unnneded warning spam in this case
867862
TC_LOG_ERROR("network", "UAD: Failed to decompress account data");
868863
return;
869864
}
870865

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);
877867

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());
882872
}
883873

884-
void WorldSession::HandleRequestAccountData(WorldPacket& recvData)
874+
void WorldSession::HandleRequestAccountData(WorldPackets::ClientConfig::RequestAccountData& request)
885875
{
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);
890877

891-
TC_LOG_DEBUG("network", "RAD: type {}", type);
892-
893-
if (type >= NUM_ACCOUNT_DATA_TYPES)
878+
if (request.DataType >= NUM_ACCOUNT_DATA_TYPES)
894879
return;
895880

896-
AccountData* adata = GetAccountData(AccountDataType(type));
881+
AccountData const* adata = GetAccountData(AccountDataType(request.DataType));
897882

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;
899888

900-
uLongf destSize = compressBound(size);
889+
uLongf destSize = compressBound(data.Size);
901890

902-
ByteBuffer dest;
903-
dest.resize(destSize);
891+
data.CompressedData.resize(destSize);
904892

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)
906894
{
907-
TC_LOG_DEBUG("network", "RAD: Failed to compress account data");
895+
TC_LOG_ERROR("network", "RAD: Failed to compress account data");
908896
return;
909897
}
910898

911-
dest.resize(destSize);
899+
data.CompressedData.resize(destSize);
912900

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());
920902
}
921903

922904
void WorldSession::HandleSetActionButtonOpcode(WorldPacket& recvData)
@@ -1387,7 +1369,7 @@ void WorldSession::HandleQueryInspectAchievements(WorldPacket& recvData)
13871369
player->SendRespondInspectAchievements(_player);
13881370
}
13891371

1390-
void WorldSession::HandleWorldStateUITimerUpdate(WorldPacket& /*recvData*/)
1372+
void WorldSession::HandleWorldStateUITimerUpdate(WorldPackets::Misc::UITimeRequest& /*request*/)
13911373
{
13921374
// empty opcode
13931375
TC_LOG_DEBUG("network", "WORLD: CMSG_WORLD_STATE_UI_TIMER_UPDATE");

src/server/game/Handlers/MovementHandler.cpp

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "InstanceSaveMgr.h"
2424
#include "Log.h"
2525
#include "MapManager.h"
26+
#include "MiscPackets.h"
2627
#include "MotionMaster.h"
2728
#include "MovementGenerator.h"
2829
#include "MovementPackets.h"
@@ -1038,24 +1039,19 @@ void WorldSession::HandleMoveTimeSkippedOpcode(WorldPacket& recvData)
10381039
GetPlayer()->SendMessageToSet(&data, false);
10391040
}
10401041

1041-
void WorldSession::HandleTimeSyncResponse(WorldPacket& recvData)
1042+
void WorldSession::HandleTimeSyncResponse(WorldPackets::Misc::TimeSyncResponse& packet)
10421043
{
1043-
TC_LOG_DEBUG("network", "CMSG_TIME_SYNC_RESP");
1044-
1045-
uint32 counter, clientTimestamp;
1046-
recvData >> counter >> clientTimestamp;
1047-
1048-
if (_pendingTimeSyncRequests.count(counter) == 0)
1044+
if (_pendingTimeSyncRequests.count(packet.SequenceIndex) == 0)
10491045
return;
10501046

1051-
uint32 serverTimeAtSent = _pendingTimeSyncRequests.at(counter);
1052-
_pendingTimeSyncRequests.erase(counter);
1047+
uint32 serverTimeAtSent = _pendingTimeSyncRequests.at(packet.SequenceIndex);
1048+
_pendingTimeSyncRequests.erase(packet.SequenceIndex);
10531049

10541050
// time it took for the request to travel to the client, for the client to process it and reply and for response to travel back to the server.
10551051
// we are going to make 2 assumptions:
10561052
// 1) we assume that the request processing time equals 0.
10571053
// 2) we assume that the packet took as much time to travel from server to client than it took to travel from client to server.
1058-
uint32 roundTripDuration = getMSTimeDiff(serverTimeAtSent, recvData.GetReceivedTime());
1054+
uint32 roundTripDuration = getMSTimeDiff(serverTimeAtSent, packet.GetReceivedTime());
10591055
uint32 lagDelay = roundTripDuration / 2;
10601056

10611057
/*
@@ -1068,7 +1064,7 @@ void WorldSession::HandleTimeSyncResponse(WorldPacket& recvData)
10681064
using the following relation:
10691065
serverTime = clockDelta + clientTime
10701066
*/
1071-
int64 clockDelta = (int64)serverTimeAtSent + (int64)lagDelay - (int64)clientTimestamp;
1067+
int64 clockDelta = (int64)serverTimeAtSent + (int64)lagDelay - (int64)packet.ClientTime;
10721068
_timeSyncClockDeltaQueue->push_back(std::pair<int64, uint32>(clockDelta, roundTripDuration));
10731069
ComputeNewClockDelta();
10741070
}

src/server/game/Handlers/QueryHandler.cpp

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -259,43 +259,32 @@ void WorldSession::HandleNpcTextQueryOpcode(WorldPacket& recvData)
259259
}
260260

261261
/// Only _static_ data is sent in this packet !!!
262-
void WorldSession::HandleQueryPageText(WorldPacket& recvData)
262+
void WorldSession::HandleQueryPageText(WorldPackets::Query::QueryPageText& packet)
263263
{
264-
TC_LOG_DEBUG("network", "WORLD: Received CMSG_PAGE_TEXT_QUERY");
265-
266-
uint32 pageID;
267-
recvData >> pageID;
268-
recvData.read_skip<uint64>(); // guid
269-
264+
uint32 pageID = packet.PageTextID;
270265
while (pageID)
271266
{
272-
PageText const* pageText = sObjectMgr->GetPageText(pageID);
273-
// guess size
274-
WorldPacket data(SMSG_PAGE_TEXT_QUERY_RESPONSE, 50);
275-
data << pageID;
276-
277-
if (!pageText)
278-
{
279-
data << "Item page missing.";
280-
data << uint32(0);
281-
pageID = 0;
282-
}
283-
else
267+
WorldPackets::Query::QueryPageTextResponse response;
268+
response.PageTextID = pageID;
269+
if (PageText const* pageText = sObjectMgr->GetPageText(pageID))
284270
{
285-
std::string Text = pageText->Text;
271+
response.Allow = true;
272+
273+
WorldPackets::Query::QueryPageTextResponse::PageTextInfo& page = response.Page;
274+
page.NextPageID = pageText->NextPageID;
275+
page.Text = pageText->Text;
286276

287277
LocaleConstant localeConstant = GetSessionDbLocaleIndex();
288278
if (localeConstant != LOCALE_enUS)
289279
if (PageTextLocale const* pageTextLocale = sObjectMgr->GetPageTextLocale(pageID))
290-
ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, Text);
280+
ObjectMgr::GetLocaleString(pageTextLocale->Text, localeConstant, page.Text);
291281

292-
data << Text;
293-
data << uint32(pageText->NextPageID);
294282
pageID = pageText->NextPageID;
295283
}
296-
SendPacket(&data);
284+
else
285+
pageID = 0;
297286

298-
TC_LOG_DEBUG("network", "WORLD: Sent SMSG_PAGE_TEXT_QUERY_RESPONSE");
287+
SendPacket(response.Write());
299288
}
300289
}
301290

src/server/game/Movement/MovementPacketSender.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the

src/server/game/Movement/MovementPacketSender.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008-2017 TrinityCore <http://www.trinitycore.org/>
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the

src/server/game/Server/Packets/ClientConfigPackets.cpp

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (C) 2008-2014 TrinityCore <http://www.trinitycore.org/>
2+
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
33
*
44
* This program is free software; you can redistribute it and/or modify it
55
* under the terms of the GNU General Public License as published by the
@@ -84,4 +84,42 @@ WorldPacket const* ClientCacheVersion::Write()
8484

8585
return &_worldPacket;
8686
}
87+
88+
void RequestAccountData::Read()
89+
{
90+
_worldPacket >> DataType;
91+
}
92+
93+
WorldPacket const* UpdateAccountData::Write()
94+
{
95+
_worldPacket << Player;
96+
_worldPacket << int32(DataType);
97+
_worldPacket << uint32(Time);
98+
_worldPacket << uint32(Size);
99+
if (!CompressedData.empty())
100+
_worldPacket.append(CompressedData.data(), CompressedData.size());
101+
102+
return &_worldPacket;
103+
}
104+
105+
void UserClientUpdateAccountData::Read()
106+
{
107+
_worldPacket >> DataType;
108+
_worldPacket >> Time;
109+
_worldPacket >> Size;
110+
111+
std::size_t pos = _worldPacket.rpos();
112+
std::size_t remainingSize = _worldPacket.size() - pos;
113+
114+
CompressedData = { _worldPacket.contents() + pos, remainingSize };
115+
_worldPacket.rpos(pos + remainingSize);
116+
}
117+
118+
WorldPacket const* UpdateAccountDataComplete::Write()
119+
{
120+
_worldPacket << int32(DataType);
121+
_worldPacket << int32(Result);
122+
123+
return &_worldPacket;
124+
}
87125
}

0 commit comments

Comments
 (0)