mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Hotfixes: Add locales to hotfix_blob (#24913)
This commit is contained in:
6
sql/updates/hotfixes/master/2020_07_04_00_hotfixes.sql
Normal file
6
sql/updates/hotfixes/master/2020_07_04_00_hotfixes.sql
Normal file
@@ -0,0 +1,6 @@
|
||||
ALTER TABLE `hotfix_blob`
|
||||
ADD COLUMN `locale` VARCHAR(4) NOT NULL COLLATE 'utf8mb4_unicode_ci' AFTER `RecordId`,
|
||||
DROP PRIMARY KEY,
|
||||
ADD PRIMARY KEY (`TableHash`, `RecordId`, `locale`);
|
||||
|
||||
UPDATE `hotfix_blob` SET `locale` = "enUS";
|
||||
@@ -352,6 +352,8 @@ typedef std::vector<TalentEntry const*> TalentsByPosition[MAX_CLASSES][MAX_TALEN
|
||||
typedef std::unordered_set<uint32> ToyItemIdsContainer;
|
||||
typedef std::tuple<uint16, uint8, int32> WMOAreaTableKey;
|
||||
typedef std::map<WMOAreaTableKey, WMOAreaTableEntry const*> WMOAreaTableLookupContainer;
|
||||
typedef std::pair<uint32 /*tableHash*/, int32 /*recordId*/> HotfixBlobKey;
|
||||
typedef std::map<HotfixBlobKey, std::vector<uint8>> HotfixBlobMap;
|
||||
|
||||
namespace
|
||||
{
|
||||
@@ -365,7 +367,7 @@ namespace
|
||||
|
||||
StorageMap _stores;
|
||||
DB2Manager::HotfixContainer _hotfixData;
|
||||
std::map<std::pair<uint32 /*tableHash*/, int32 /*recordId*/>, std::vector<uint8>> _hotfixBlob;
|
||||
std::array<HotfixBlobMap, TOTAL_LOCALES> _hotfixBlob;
|
||||
|
||||
AreaGroupMemberContainer _areaGroupMembers;
|
||||
ArtifactPowersContainer _artifactPowers;
|
||||
@@ -1413,10 +1415,14 @@ void DB2Manager::LoadHotfixData()
|
||||
uint32 tableHash = fields[1].GetUInt32();
|
||||
int32 recordId = fields[2].GetInt32();
|
||||
bool deleted = fields[3].GetBool();
|
||||
if (!deleted && _stores.find(tableHash) == _stores.end() && _hotfixBlob.find(std::make_pair(tableHash, recordId)) == _hotfixBlob.end())
|
||||
if (!deleted && _stores.find(tableHash) == _stores.end())
|
||||
{
|
||||
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 %d with RecordID: %d", tableHash, id, recordId);
|
||||
continue;
|
||||
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(); }))
|
||||
{
|
||||
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 %d with RecordID: %d", tableHash, id, recordId);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
_maxHotfixId = std::max(_maxHotfixId, id);
|
||||
@@ -1440,9 +1446,8 @@ void DB2Manager::LoadHotfixData()
|
||||
void DB2Manager::LoadHotfixBlob()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
_hotfixBlob.clear();
|
||||
|
||||
QueryResult result = HotfixDatabase.Query("SELECT TableHash, RecordId, `Blob` FROM hotfix_blob ORDER BY TableHash");
|
||||
QueryResult result = HotfixDatabase.Query("SELECT TableHash, RecordId, locale, `Blob` FROM hotfix_blob ORDER BY TableHash");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
@@ -1450,6 +1455,7 @@ void DB2Manager::LoadHotfixBlob()
|
||||
return;
|
||||
}
|
||||
|
||||
uint32 hotfixBlobCount = 0;
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
@@ -1464,10 +1470,20 @@ void DB2Manager::LoadHotfixBlob()
|
||||
}
|
||||
|
||||
int32 recordId = fields[1].GetInt32();
|
||||
_hotfixBlob[std::make_pair(tableHash, recordId)] = fields[2].GetBinary();
|
||||
std::string localeName = fields[2].GetString();
|
||||
LocaleConstant locale = GetLocaleByName(localeName);
|
||||
|
||||
if (!IsValidLocale(locale))
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "`hotfix_blob` contains invalid locale: %s at TableHash: 0x%X and RecordID: %d", localeName.c_str(), tableHash, recordId);
|
||||
continue;
|
||||
}
|
||||
|
||||
_hotfixBlob[locale][std::make_pair(tableHash, recordId)] = fields[3].GetBinary();
|
||||
hotfixBlobCount++;
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " hotfix blob records in %u ms", _hotfixBlob.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %d hotfix blob records in %u ms", hotfixBlobCount, GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
uint32 DB2Manager::GetHotfixCount() const
|
||||
@@ -1480,9 +1496,11 @@ DB2Manager::HotfixContainer const& DB2Manager::GetHotfixData() const
|
||||
return _hotfixData;
|
||||
}
|
||||
|
||||
std::vector<uint8> const* DB2Manager::GetHotfixBlobData(uint32 tableHash, int32 recordId)
|
||||
std::vector<uint8> const* DB2Manager::GetHotfixBlobData(uint32 tableHash, int32 recordId, LocaleConstant locale)
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_hotfixBlob, std::make_pair(tableHash, recordId));
|
||||
ASSERT(IsValidLocale(locale), "Locale %u is invalid locale", uint32(locale));
|
||||
|
||||
return Trinity::Containers::MapGetValuePtr(_hotfixBlob[locale], std::make_pair(tableHash, recordId));
|
||||
}
|
||||
|
||||
uint32 DB2Manager::GetEmptyAnimStateID() const
|
||||
|
||||
@@ -282,7 +282,7 @@ public:
|
||||
void LoadHotfixBlob();
|
||||
uint32 GetHotfixCount() const;
|
||||
HotfixContainer const& GetHotfixData() const;
|
||||
std::vector<uint8> const* GetHotfixBlobData(uint32 tableHash, int32 recordId);
|
||||
std::vector<uint8> const* GetHotfixBlobData(uint32 tableHash, int32 recordId, LocaleConstant locale);
|
||||
|
||||
uint32 GetEmptyAnimStateID() const;
|
||||
std::vector<uint32> GetAreasForGroup(uint32 areaGroupId) const;
|
||||
|
||||
@@ -79,7 +79,7 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf
|
||||
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))
|
||||
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());
|
||||
|
||||
Reference in New Issue
Block a user