mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/DataStores: Don't send hotfix ids in SMSG_AVAILABLE_HOTFIXES that don't have a hotfix blob for client locale
Closes #29378
This commit is contained in:
@@ -1633,7 +1633,7 @@ DB2StorageBase const* DB2Manager::GetStorage(uint32 type) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void DB2Manager::LoadHotfixData()
|
||||
void DB2Manager::LoadHotfixData(uint32 localeMask)
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
|
||||
@@ -1658,24 +1658,39 @@ void DB2Manager::LoadHotfixData()
|
||||
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())
|
||||
std::bitset<TOTAL_LOCALES> availableDb2Locales = localeMask;
|
||||
if (status == HotfixRecord::Status::Valid && !_stores.contains(tableHash))
|
||||
{
|
||||
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(); }))
|
||||
for (std::size_t locale = 0; locale < TOTAL_LOCALES; ++locale)
|
||||
{
|
||||
if (!availableDb2Locales[locale])
|
||||
continue;
|
||||
|
||||
if (!_hotfixBlob[locale].contains(key))
|
||||
availableDb2Locales[locale] = false;
|
||||
}
|
||||
|
||||
if (availableDb2Locales.none())
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `hotfix_data` references unknown DB2 store by hash 0x{:X} and has no reference to `hotfix_blob` in hotfix id {} with RecordID: {}", tableHash, id, recordId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_maxHotfixId = std::max(_maxHotfixId, id);
|
||||
HotfixRecord hotfixRecord;
|
||||
hotfixRecord.TableHash = tableHash;
|
||||
hotfixRecord.RecordID = recordId;
|
||||
hotfixRecord.ID.PushID = id;
|
||||
hotfixRecord.ID.UniqueID = uniqueId;
|
||||
hotfixRecord.HotfixStatus = status;
|
||||
_hotfixData[id].push_back(hotfixRecord);
|
||||
hotfixRecord.AvailableLocalesMask = availableDb2Locales.to_ulong();
|
||||
|
||||
HotfixPush& push = _hotfixData[id];
|
||||
push.Records.push_back(hotfixRecord);
|
||||
push.AvailableLocalesMask |= hotfixRecord.AvailableLocalesMask;
|
||||
|
||||
_maxHotfixId = std::max(_maxHotfixId, id);
|
||||
deletedRecords[std::make_pair(tableHash, recordId)] = status == HotfixRecord::Status::RecordRemoved;
|
||||
++count;
|
||||
} while (result->NextRow());
|
||||
@@ -1853,7 +1868,11 @@ void DB2Manager::InsertNewHotfix(uint32 tableHash, uint32 recordId)
|
||||
hotfixRecord.RecordID = recordId;
|
||||
hotfixRecord.ID.PushID = ++_maxHotfixId;
|
||||
hotfixRecord.ID.UniqueID = rand32();
|
||||
_hotfixData[hotfixRecord.ID.PushID].push_back(hotfixRecord);
|
||||
hotfixRecord.AvailableLocalesMask = 0xDFF;
|
||||
|
||||
HotfixPush& push = _hotfixData[hotfixRecord.ID.PushID];
|
||||
push.Records.push_back(hotfixRecord);
|
||||
push.AvailableLocalesMask |= hotfixRecord.AvailableLocalesMask;
|
||||
}
|
||||
|
||||
std::vector<uint32> DB2Manager::GetAreasForGroup(uint32 areaGroupId) const
|
||||
|
||||
@@ -370,6 +370,8 @@ public:
|
||||
HotfixId ID;
|
||||
Status HotfixStatus = Status::Invalid;
|
||||
|
||||
uint32 AvailableLocalesMask = 0;
|
||||
|
||||
friend std::strong_ordering operator<=>(HotfixRecord const& left, HotfixRecord const& right)
|
||||
{
|
||||
if (std::strong_ordering cmp = left.ID <=> right.ID; advstd::is_neq(cmp))
|
||||
@@ -388,7 +390,13 @@ public:
|
||||
std::vector<uint8> Data;
|
||||
};
|
||||
|
||||
using HotfixContainer = std::map<int32, std::vector<HotfixRecord>>;
|
||||
struct HotfixPush
|
||||
{
|
||||
std::vector<HotfixRecord> Records;
|
||||
uint32 AvailableLocalesMask = 0;
|
||||
};
|
||||
|
||||
using HotfixContainer = std::map<int32, HotfixPush>;
|
||||
|
||||
using FriendshipRepReactionSet = std::set<FriendshipRepReactionEntry const*, FriendshipRepReactionEntryComparator>;
|
||||
using MapDifficultyConditionsContainer = std::vector<std::pair<uint32, PlayerConditionEntry const*>>;
|
||||
@@ -400,7 +408,7 @@ public:
|
||||
uint32 LoadStores(std::string const& dataPath, LocaleConstant defaultLocale);
|
||||
DB2StorageBase const* GetStorage(uint32 type) const;
|
||||
|
||||
void LoadHotfixData();
|
||||
void LoadHotfixData(uint32 localeMask);
|
||||
void LoadHotfixBlob(uint32 localeMask);
|
||||
void LoadHotfixOptionalData(uint32 localeMask);
|
||||
uint32 GetHotfixCount() const;
|
||||
|
||||
@@ -60,7 +60,18 @@ void WorldSession::HandleDBQueryBulk(WorldPackets::Hotfix::DBQueryBulk& dbQuery)
|
||||
|
||||
void WorldSession::SendAvailableHotfixes()
|
||||
{
|
||||
SendPacket(WorldPackets::Hotfix::AvailableHotfixes(realm.Id.GetAddress(), sDB2Manager.GetHotfixData()).Write());
|
||||
WorldPackets::Hotfix::AvailableHotfixes availableHotfixes;
|
||||
availableHotfixes.VirtualRealmAddress = realm.Id.GetAddress();
|
||||
|
||||
for (auto const& [pushId, push] : sDB2Manager.GetHotfixData())
|
||||
{
|
||||
if (!(push.AvailableLocalesMask & (1 << GetSessionDbcLocale())))
|
||||
continue;
|
||||
|
||||
availableHotfixes.Hotfixes.insert(push.Records.front().ID);
|
||||
}
|
||||
|
||||
SendPacket(availableHotfixes.Write());
|
||||
}
|
||||
|
||||
void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotfixQuery)
|
||||
@@ -70,13 +81,14 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf
|
||||
hotfixQueryResponse.Hotfixes.reserve(hotfixQuery.Hotfixes.size());
|
||||
for (int32 hotfixId : hotfixQuery.Hotfixes)
|
||||
{
|
||||
if (std::vector<DB2Manager::HotfixRecord> const* hotfixRecords = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixId))
|
||||
if (DB2Manager::HotfixPush const* hotfixRecords = Trinity::Containers::MapGetValuePtr(hotfixes, hotfixId))
|
||||
{
|
||||
for (DB2Manager::HotfixRecord const& hotfixRecord : *hotfixRecords)
|
||||
for (DB2Manager::HotfixRecord const& hotfixRecord : hotfixRecords->Records)
|
||||
{
|
||||
hotfixQueryResponse.Hotfixes.emplace_back();
|
||||
if (!(hotfixRecord.AvailableLocalesMask & (1 << GetSessionDbcLocale())))
|
||||
continue;
|
||||
|
||||
WorldPackets::Hotfix::HotfixConnect::HotfixData& hotfixData = hotfixQueryResponse.Hotfixes.back();
|
||||
WorldPackets::Hotfix::HotfixConnect::HotfixData& hotfixData = hotfixQueryResponse.Hotfixes.emplace_back();
|
||||
hotfixData.Record = hotfixRecord;
|
||||
if (hotfixRecord.HotfixStatus == DB2Manager::HotfixRecord::Status::Valid)
|
||||
{
|
||||
|
||||
@@ -78,10 +78,12 @@ WorldPacket const* DBReply::Write()
|
||||
|
||||
WorldPacket const* AvailableHotfixes::Write()
|
||||
{
|
||||
_worldPacket.reserve(4 + 4 + sizeof(DB2Manager::HotfixId) * Hotfixes.size());
|
||||
|
||||
_worldPacket << int32(VirtualRealmAddress);
|
||||
_worldPacket << uint32(Hotfixes.size());
|
||||
for (DB2Manager::HotfixContainer::value_type const& hotfixRecord : Hotfixes)
|
||||
_worldPacket << hotfixRecord.second.front().ID;
|
||||
for (DB2Manager::HotfixId const& hotfixId : Hotfixes)
|
||||
_worldPacket << hotfixId;
|
||||
|
||||
return &_worldPacket;
|
||||
}
|
||||
|
||||
@@ -60,13 +60,12 @@ namespace WorldPackets
|
||||
class AvailableHotfixes final : public ServerPacket
|
||||
{
|
||||
public:
|
||||
AvailableHotfixes(int32 virtualRealmAddress, DB2Manager::HotfixContainer const& hotfixes)
|
||||
: ServerPacket(SMSG_AVAILABLE_HOTFIXES), VirtualRealmAddress(virtualRealmAddress), Hotfixes(hotfixes) { }
|
||||
AvailableHotfixes() : ServerPacket(SMSG_AVAILABLE_HOTFIXES, 0) { }
|
||||
|
||||
WorldPacket const* Write() override;
|
||||
|
||||
int32 VirtualRealmAddress;
|
||||
DB2Manager::HotfixContainer const& Hotfixes;
|
||||
int32 VirtualRealmAddress = 0;
|
||||
std::set<DB2Manager::HotfixId> Hotfixes;
|
||||
};
|
||||
|
||||
class HotfixRequest final : public ClientPacket
|
||||
|
||||
@@ -1800,7 +1800,7 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("misc", "Loading hotfix blobs...");
|
||||
sDB2Manager.LoadHotfixBlob(m_availableDbcLocaleMask);
|
||||
TC_LOG_INFO("misc", "Loading hotfix info...");
|
||||
sDB2Manager.LoadHotfixData();
|
||||
sDB2Manager.LoadHotfixData(m_availableDbcLocaleMask);
|
||||
TC_LOG_INFO("misc", "Loading hotfix optional data...");
|
||||
sDB2Manager.LoadHotfixOptionalData(m_availableDbcLocaleMask);
|
||||
///- Close hotfix database - it is only used during DB2 loading
|
||||
|
||||
Reference in New Issue
Block a user