diff options
Diffstat (limited to 'src/server/game/Handlers/HotfixHandler.cpp')
-rw-r--r-- | src/server/game/Handlers/HotfixHandler.cpp | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/src/server/game/Handlers/HotfixHandler.cpp b/src/server/game/Handlers/HotfixHandler.cpp index 0ed74be8023..b58b7bedbe1 100644 --- a/src/server/game/Handlers/HotfixHandler.cpp +++ b/src/server/game/Handlers/HotfixHandler.cpp @@ -56,35 +56,38 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Hotfix::DBQueryBulk& dbQuery) void WorldSession::SendAvailableHotfixes(int32 version) { - SendPacket(WorldPackets::Hotfix::AvailableHotfixes(version, sDB2Manager.GetHotfixData()).Write()); + SendPacket(WorldPackets::Hotfix::AvailableHotfixes(version, sDB2Manager.GetHotfixCount(), sDB2Manager.GetHotfixData()).Write()); } void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotfixQuery) { - std::map<uint64, int32> const& hotfixes = sDB2Manager.GetHotfixData(); + DB2Manager::HotfixContainer const& hotfixes = sDB2Manager.GetHotfixData(); WorldPackets::Hotfix::HotfixResponse hotfixQueryResponse; hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size()); - for (uint64 hotfixId : hotfixQuery.Hotfixes) + for (WorldPackets::Hotfix::HotfixRecord const& hotfixRecord : hotfixQuery.Hotfixes) { - if (int32 const* hotfix = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixId)) + if (auto const* hotfixedRecords = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixRecord.HotfixID)) { - DB2StorageBase const* storage = sDB2Manager.GetStorage(PAIR64_HIPART(hotfixId)); - - WorldPackets::Hotfix::HotfixResponse::HotfixData hotfixData; - hotfixData.ID = hotfixId; - hotfixData.RecordID = *hotfix; - if (storage && storage->HasRecord(hotfixData.RecordID)) - { - hotfixData.Data = boost::in_place(); - storage->WriteRecord(hotfixData.RecordID, GetSessionDbcLocale(), *hotfixData.Data); - } - else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(PAIR64_HIPART(hotfixId), *hotfix)) + for (auto const& tableRecord : *hotfixedRecords) { - hotfixData.Data = boost::in_place(); - hotfixData.Data->append(blobData->data(), blobData->size()); - } + DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash); + + WorldPackets::Hotfix::HotfixResponse::HotfixData hotfixData; + hotfixData.Record = hotfixRecord; + if (storage && storage->HasRecord(hotfixData.Record.RecordID)) + { + std::size_t pos = hotfixQueryResponse.HotfixContent.size(); + storage->WriteRecord(hotfixData.Record.RecordID, GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent); + hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos; + } + else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixData.Record.TableHash, hotfixData.Record.RecordID)) + { + hotfixData.Size = blobData->size(); + hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size()); + } - hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData)); + hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData)); + } } } |