mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/PacketIO: Fixed receiving and sending db2 hotfix packets
This commit is contained in:
@@ -65,32 +65,27 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf
|
||||
DB2Manager::HotfixContainer const& hotfixes = sDB2Manager.GetHotfixData();
|
||||
WorldPackets::Hotfix::HotfixResponse hotfixQueryResponse;
|
||||
hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size());
|
||||
for (WorldPackets::Hotfix::HotfixRecord const& hotfixRecord : hotfixQuery.Hotfixes)
|
||||
for (DB2Manager::HotfixRecord const& hotfixRecord : hotfixQuery.Hotfixes)
|
||||
{
|
||||
if (auto const* hotfixedRecords = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixRecord.HotfixID))
|
||||
if (hotfixes.find(hotfixRecord) != hotfixes.end())
|
||||
{
|
||||
for (auto const& tableRecord : *hotfixedRecords)
|
||||
DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash);
|
||||
|
||||
WorldPackets::Hotfix::HotfixResponse::HotfixData hotfixData;
|
||||
hotfixData.Record = hotfixRecord;
|
||||
if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID)))
|
||||
{
|
||||
uint32 hotfixTableHash = tableRecord.first;
|
||||
int32 hotfixRecordId = tableRecord.second;;
|
||||
DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixTableHash);
|
||||
|
||||
WorldPackets::Hotfix::HotfixResponse::HotfixData hotfixData;
|
||||
hotfixData.Record = hotfixRecord;
|
||||
if (storage && storage->HasRecord(hotfixRecordId))
|
||||
{
|
||||
std::size_t pos = hotfixQueryResponse.HotfixContent.size();
|
||||
storage->WriteRecord(hotfixRecordId, GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
||||
hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos;
|
||||
}
|
||||
else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixTableHash, hotfixRecordId))
|
||||
{
|
||||
hotfixData.Size = blobData->size();
|
||||
hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size());
|
||||
}
|
||||
|
||||
hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData));
|
||||
std::size_t pos = hotfixQueryResponse.HotfixContent.size();
|
||||
storage->WriteRecord(uint32(hotfixRecord.RecordID), GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent);
|
||||
hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos;
|
||||
}
|
||||
else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID))
|
||||
{
|
||||
hotfixData.Size = blobData->size();
|
||||
hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size());
|
||||
}
|
||||
|
||||
hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user