diff options
-rw-r--r-- | sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql | 6 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 9 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 8 | ||||
-rw-r--r-- | src/server/game/Handlers/HotfixHandler.cpp | 45 | ||||
-rw-r--r-- | src/server/game/Server/Packets/HotfixPackets.cpp | 13 | ||||
-rw-r--r-- | src/server/game/Server/Packets/HotfixPackets.h | 2 |
6 files changed, 47 insertions, 36 deletions
diff --git a/sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql b/sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql new file mode 100644 index 00000000000..c34d9d05b85 --- /dev/null +++ b/sql/updates/hotfixes/master/2021_02_28_00_hotfixes.sql @@ -0,0 +1,6 @@ +ALTER TABLE `hotfix_data` ADD `Status` tinyint(3) unsigned NOT NULL DEFAULT '3' AFTER `Deleted`; + +UPDATE `hotfix_data` SET `Status`=1 WHERE `Deleted`=0; +UPDATE `hotfix_data` SET `Status`=2 WHERE `Deleted`=1; + +ALTER TABLE `hotfix_data` DROP `Deleted`; diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 0edc7be8cce..21aa5f25cda 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -1465,7 +1465,7 @@ void DB2Manager::LoadHotfixData() { uint32 oldMSTime = getMSTime(); - QueryResult result = HotfixDatabase.Query("SELECT Id, TableHash, RecordId, Deleted FROM hotfix_data ORDER BY Id"); + QueryResult result = HotfixDatabase.Query("SELECT Id, TableHash, RecordId, Status FROM hotfix_data ORDER BY Id"); if (!result) { @@ -1484,8 +1484,8 @@ void DB2Manager::LoadHotfixData() int32 id = fields[0].GetInt32(); uint32 tableHash = fields[1].GetUInt32(); int32 recordId = fields[2].GetInt32(); - bool deleted = fields[3].GetBool(); - if (!deleted && _stores.find(tableHash) == _stores.end()) + HotfixRecord::Status status = static_cast<HotfixRecord::Status>(fields[3].GetUInt8()); + if (status == HotfixRecord::Status::Valid && _stores.find(tableHash) == _stores.end()) { HotfixBlobKey key = std::make_pair(tableHash, recordId); if (std::none_of(_hotfixBlob.begin(), _hotfixBlob.end(), [key](HotfixBlobMap const& blob) { return blob.find(key) != blob.end(); })) @@ -1500,8 +1500,9 @@ void DB2Manager::LoadHotfixData() hotfixRecord.TableHash = tableHash; hotfixRecord.RecordID = recordId; hotfixRecord.HotfixID = id; + hotfixRecord.HotfixStatus = status; _hotfixData.insert(hotfixRecord); - deletedRecords[std::make_pair(tableHash, recordId)] = deleted; + deletedRecords[std::make_pair(tableHash, recordId)] = status == HotfixRecord::Status::RecordRemoved; ++count; } while (result->NextRow()); diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 4d4aa2594ac..dc4d0aa8c34 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -277,9 +277,17 @@ public: struct HotfixRecord { + enum class Status : uint8 + { + Valid = 1, + RecordRemoved = 2, + Invalid = 3 + }; + uint32 TableHash = 0; int32 RecordID = 0; int32 HotfixID = 0; + Status HotfixStatus = Status::Invalid; friend bool operator<(HotfixRecord const& left, HotfixRecord const& right) { diff --git a/src/server/game/Handlers/HotfixHandler.cpp b/src/server/game/Handlers/HotfixHandler.cpp index c1a200b616e..bdc9f01a5b9 100644 --- a/src/server/game/Handlers/HotfixHandler.cpp +++ b/src/server/game/Handlers/HotfixHandler.cpp @@ -71,35 +71,38 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size()); for (DB2Manager::HotfixRecord const& hotfixRecord : hotfixQuery.Hotfixes) { - if (hotfixes.find(hotfixRecord) != hotfixes.end()) + auto serverHotfixInfo = hotfixes.find(hotfixRecord); + if (serverHotfixInfo != hotfixes.end()) { - DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash); + hotfixQueryResponse.Hotfixes.emplace_back(); - WorldPackets::Hotfix::HotfixConnect::HotfixData hotfixData; - hotfixData.Record = hotfixRecord; - if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID))) + WorldPackets::Hotfix::HotfixConnect::HotfixData& hotfixData = hotfixQueryResponse.Hotfixes.back(); + hotfixData.Record = *serverHotfixInfo; + if (serverHotfixInfo->HotfixStatus == DB2Manager::HotfixRecord::Status::Valid) { - std::size_t pos = hotfixQueryResponse.HotfixContent.size(); - storage->WriteRecord(uint32(hotfixRecord.RecordID), GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent); - - if (std::vector<DB2Manager::HotfixOptionalData> const* optionalDataEntries = sDB2Manager.GetHotfixOptionalData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale())) + DB2StorageBase const* storage = sDB2Manager.GetStorage(hotfixRecord.TableHash); + if (storage && storage->HasRecord(uint32(hotfixRecord.RecordID))) { - for (DB2Manager::HotfixOptionalData const& optionalData : *optionalDataEntries) + std::size_t pos = hotfixQueryResponse.HotfixContent.size(); + storage->WriteRecord(uint32(hotfixRecord.RecordID), GetSessionDbcLocale(), hotfixQueryResponse.HotfixContent); + + if (std::vector<DB2Manager::HotfixOptionalData> const* optionalDataEntries = sDB2Manager.GetHotfixOptionalData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale())) { - hotfixQueryResponse.HotfixContent << uint32(optionalData.Key); - hotfixQueryResponse.HotfixContent.append(optionalData.Data.data(), optionalData.Data.size()); + for (DB2Manager::HotfixOptionalData const& optionalData : *optionalDataEntries) + { + hotfixQueryResponse.HotfixContent << uint32(optionalData.Key); + hotfixQueryResponse.HotfixContent.append(optionalData.Data.data(), optionalData.Data.size()); + } } - } - hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos; - } - else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale())) - { - hotfixData.Size = blobData->size(); - hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size()); + hotfixData.Size = hotfixQueryResponse.HotfixContent.size() - pos; + } + else if (std::vector<uint8> const* blobData = sDB2Manager.GetHotfixBlobData(hotfixRecord.TableHash, hotfixRecord.RecordID, GetSessionDbcLocale())) + { + hotfixData.Size = blobData->size(); + hotfixQueryResponse.HotfixContent.append(blobData->data(), blobData->size()); + } } - - hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData)); } } diff --git a/src/server/game/Server/Packets/HotfixPackets.cpp b/src/server/game/Server/Packets/HotfixPackets.cpp index 629627ff852..43407e53a25 100644 --- a/src/server/game/Server/Packets/HotfixPackets.cpp +++ b/src/server/game/Server/Packets/HotfixPackets.cpp @@ -17,6 +17,7 @@ #include "HotfixPackets.h" #include "PacketUtilities.h" +#include "Util.h" namespace WorldPackets { @@ -88,16 +89,8 @@ void HotfixRequest::Read() ByteBuffer& operator<<(ByteBuffer& data, HotfixConnect::HotfixData const& hotfixData) { data << hotfixData.Record; - if (hotfixData.Size) - { - data << uint32(*hotfixData.Size); - data.WriteBits(1, 2); - } - else - { - data << uint32(0); - data.WriteBits(3, 2); - } + data << uint32(hotfixData.Size); + data.WriteBits(AsUnderlyingType(hotfixData.Record.HotfixStatus), 2); data.FlushBits(); return data; diff --git a/src/server/game/Server/Packets/HotfixPackets.h b/src/server/game/Server/Packets/HotfixPackets.h index ecd48021203..bf32fa2899d 100644 --- a/src/server/game/Server/Packets/HotfixPackets.h +++ b/src/server/game/Server/Packets/HotfixPackets.h @@ -89,7 +89,7 @@ namespace WorldPackets struct HotfixData { DB2Manager::HotfixRecord Record; - Optional<uint32> Size; + uint32 Size = 0; }; HotfixConnect() : ServerPacket(SMSG_HOTFIX_CONNECT) { } |