diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 18 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 19 | ||||
-rw-r--r-- | src/server/game/Server/Packets/HotfixPackets.cpp | 20 |
3 files changed, 43 insertions, 14 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 83dc7f388c3..ee268329549 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -24,6 +24,7 @@ #include "IteratorPair.h" #include "Log.h" #include "ObjectDefines.h" +#include "Random.h" #include "Regex.h" #include "Timer.h" #include "Util.h" @@ -1560,7 +1561,7 @@ void DB2Manager::LoadHotfixData() { uint32 oldMSTime = getMSTime(); - QueryResult result = HotfixDatabase.Query("SELECT Id, TableHash, RecordId, Status FROM hotfix_data ORDER BY Id"); + QueryResult result = HotfixDatabase.Query("SELECT Id, UniqueId, TableHash, RecordId, Status FROM hotfix_data ORDER BY Id"); if (!result) { @@ -1577,9 +1578,10 @@ void DB2Manager::LoadHotfixData() Field* fields = result->Fetch(); int32 id = fields[0].GetInt32(); - uint32 tableHash = fields[1].GetUInt32(); - int32 recordId = fields[2].GetInt32(); - HotfixRecord::Status status = static_cast<HotfixRecord::Status>(fields[3].GetUInt8()); + uint32 uniqueId = fields[1].GetUInt32(); + uint32 tableHash = fields[2].GetUInt32(); + int32 recordId = fields[3].GetInt32(); + HotfixRecord::Status status = static_cast<HotfixRecord::Status>(fields[4].GetUInt8()); if (status == HotfixRecord::Status::Valid && _stores.find(tableHash) == _stores.end()) { HotfixBlobKey key = std::make_pair(tableHash, recordId); @@ -1594,7 +1596,8 @@ void DB2Manager::LoadHotfixData() HotfixRecord hotfixRecord; hotfixRecord.TableHash = tableHash; hotfixRecord.RecordID = recordId; - hotfixRecord.HotfixID = id; + hotfixRecord.ID.PushID = id; + hotfixRecord.ID.UniqueID = uniqueId; hotfixRecord.HotfixStatus = status; _hotfixData[id].push_back(hotfixRecord); deletedRecords[std::make_pair(tableHash, recordId)] = status == HotfixRecord::Status::RecordRemoved; @@ -1772,8 +1775,9 @@ void DB2Manager::InsertNewHotfix(uint32 tableHash, uint32 recordId) HotfixRecord hotfixRecord; hotfixRecord.TableHash = tableHash; hotfixRecord.RecordID = recordId; - hotfixRecord.HotfixID = ++_maxHotfixId; - _hotfixData[hotfixRecord.HotfixID].push_back(hotfixRecord); + hotfixRecord.ID.PushID = ++_maxHotfixId; + hotfixRecord.ID.UniqueID = rand32(); + _hotfixData[hotfixRecord.ID.PushID].push_back(hotfixRecord); } std::vector<uint32> DB2Manager::GetAreasForGroup(uint32 areaGroupId) const diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index ff391647762..443ec535a1b 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -297,6 +297,17 @@ public: DEFINE_DB2_SET_COMPARATOR(FriendshipRepReactionEntry) DEFINE_DB2_SET_COMPARATOR(MountTypeXCapabilityEntry) + struct HotfixId + { + int32 PushID = 0; + uint32 UniqueID = 0; + + friend bool operator<(HotfixId const& left, HotfixId const& right) + { + return std::tie(left.PushID, left.UniqueID) < std::tie(right.PushID, right.UniqueID); + } + }; + struct HotfixRecord { enum class Status : uint8 @@ -310,22 +321,22 @@ public: uint32 TableHash = 0; int32 RecordID = 0; - int32 HotfixID = 0; + HotfixId ID; Status HotfixStatus = Status::Invalid; friend bool operator<(HotfixRecord const& left, HotfixRecord const& right) { - return std::tie(left.HotfixID, left.TableHash, left.RecordID) < std::tie(right.HotfixID, right.TableHash, right.RecordID); + return std::tie(left.ID, left.TableHash, left.RecordID) < std::tie(right.ID, right.TableHash, right.RecordID); } }; struct HotfixOptionalData { - uint32 Key; + uint32 Key = 0; std::vector<uint8> Data; }; - using HotfixContainer = std::unordered_map<int32, std::vector<HotfixRecord>>; + using HotfixContainer = std::map<int32, std::vector<HotfixRecord>>; using FriendshipRepReactionSet = std::set<FriendshipRepReactionEntry const*, FriendshipRepReactionEntryComparator>; using ItemBonusList = std::vector<ItemBonusEntry const*>; diff --git a/src/server/game/Server/Packets/HotfixPackets.cpp b/src/server/game/Server/Packets/HotfixPackets.cpp index cf47fb83156..9524a493a1c 100644 --- a/src/server/game/Server/Packets/HotfixPackets.cpp +++ b/src/server/game/Server/Packets/HotfixPackets.cpp @@ -23,19 +23,33 @@ namespace WorldPackets { namespace Hotfix { +ByteBuffer& operator>>(ByteBuffer& data, DB2Manager::HotfixId& hotfixId) +{ + data >> hotfixId.PushID; + data >> hotfixId.UniqueID; + return data; +} + +ByteBuffer& operator<<(ByteBuffer& data, DB2Manager::HotfixId const& hotfixId) +{ + data << int32(hotfixId.PushID); + data << uint32(hotfixId.UniqueID); + return data; +} + ByteBuffer& operator>>(ByteBuffer& data, DB2Manager::HotfixRecord& hotfixRecord) { + data >> hotfixRecord.ID; data >> hotfixRecord.TableHash; data >> hotfixRecord.RecordID; - data >> hotfixRecord.HotfixID; return data; } ByteBuffer& operator<<(ByteBuffer& data, DB2Manager::HotfixRecord const& hotfixRecord) { + data << hotfixRecord.ID; data << uint32(hotfixRecord.TableHash); data << int32(hotfixRecord.RecordID); - data << int32(hotfixRecord.HotfixID); return data; } @@ -67,7 +81,7 @@ WorldPacket const* AvailableHotfixes::Write() _worldPacket << int32(VirtualRealmAddress); _worldPacket << uint32(Hotfixes.size()); for (DB2Manager::HotfixContainer::value_type const& hotfixRecord : Hotfixes) - _worldPacket << int32(hotfixRecord.first); + _worldPacket << hotfixRecord.second.front().ID; return &_worldPacket; } |