mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/DataStores: Implemented sending hotfixes for db2 stores not loaded serverside (#22800)
This commit is contained in:
10
sql/updates/hotfixes/master/2018_12_07_00_hotfixes.sql
Normal file
10
sql/updates/hotfixes/master/2018_12_07_00_hotfixes.sql
Normal file
@@ -0,0 +1,10 @@
|
||||
--
|
||||
-- Table structure for table `hotfix_blob`
|
||||
--
|
||||
DROP TABLE IF EXISTS `hotfix_blob`;
|
||||
CREATE TABLE `hotfix_blob` (
|
||||
`TableHash` INT(10) UNSIGNED NOT NULL,
|
||||
`RecordId` INT(11) NOT NULL,
|
||||
`Blob` BLOB,
|
||||
PRIMARY KEY (`TableHash`,`RecordId`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8;
|
||||
@@ -348,6 +348,7 @@ namespace
|
||||
|
||||
StorageMap _stores;
|
||||
std::map<uint64, int32> _hotfixData;
|
||||
std::map<std::pair<uint32 /*tableHash*/, int32 /*recordId*/>, std::vector<uint8>> _hotfixBlob;
|
||||
|
||||
AreaGroupMemberContainer _areaGroupMembers;
|
||||
ArtifactPowersContainer _artifactPowers;
|
||||
@@ -1305,9 +1306,9 @@ void DB2Manager::LoadHotfixData()
|
||||
uint32 tableHash = fields[1].GetUInt32();
|
||||
int32 recordId = fields[2].GetInt32();
|
||||
bool deleted = fields[3].GetBool();
|
||||
if (_stores.find(tableHash) == _stores.end())
|
||||
if (_stores.find(tableHash) == _stores.end() && _hotfixBlob.find(std::make_pair(tableHash, recordId)) == _hotfixBlob.end())
|
||||
{
|
||||
TC_LOG_ERROR("sql.sql", "Table `hotfix_data` references unknown DB2 store by hash 0x%X in hotfix id %d", tableHash, id);
|
||||
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", tableHash, id);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -1322,7 +1323,40 @@ void DB2Manager::LoadHotfixData()
|
||||
if (DB2StorageBase* store = Trinity::Containers::MapGetValuePtr(_stores, itr->first.first))
|
||||
store->EraseRecord(itr->first.second);
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded %u hotfix records in %u ms", count, GetMSTimeDiffToNow(oldMSTime));
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " hotfix records in %u ms", _hotfixData.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
void DB2Manager::LoadHotfixBlob()
|
||||
{
|
||||
uint32 oldMSTime = getMSTime();
|
||||
_hotfixBlob.clear();
|
||||
|
||||
QueryResult result = HotfixDatabase.Query("SELECT TableHash, RecordId, `Blob` FROM hotfix_blob ORDER BY TableHash");
|
||||
|
||||
if (!result)
|
||||
{
|
||||
TC_LOG_INFO("server.loading", ">> Loaded 0 hotfix blob entries.");
|
||||
return;
|
||||
}
|
||||
|
||||
do
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
|
||||
uint32 tableHash = fields[0].GetUInt32();
|
||||
auto storeItr = _stores.find(tableHash);
|
||||
if (storeItr != _stores.end())
|
||||
{
|
||||
TC_LOG_ERROR("server.loading", "Table hash 0x%X points to a loaded DB2 store %s, fill related table instead of hotfix_blob",
|
||||
tableHash, storeItr->second->GetFileName().c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
int32 recordId = fields[1].GetInt32();
|
||||
_hotfixBlob[std::make_pair(tableHash, recordId)] = fields[2].GetBinary();
|
||||
} while (result->NextRow());
|
||||
|
||||
TC_LOG_INFO("server.loading", ">> Loaded " SZFMTD " hotfix blob records in %u ms", _hotfixBlob.size(), GetMSTimeDiffToNow(oldMSTime));
|
||||
}
|
||||
|
||||
std::map<uint64, int32> const& DB2Manager::GetHotfixData() const
|
||||
@@ -1330,6 +1364,11 @@ std::map<uint64, int32> const& DB2Manager::GetHotfixData() const
|
||||
return _hotfixData;
|
||||
}
|
||||
|
||||
std::vector<uint8> const* DB2Manager::GetHotfixBlobData(uint32 tableHash, int32 recordId)
|
||||
{
|
||||
return Trinity::Containers::MapGetValuePtr(_hotfixBlob, std::make_pair(tableHash, recordId));
|
||||
}
|
||||
|
||||
void DB2Manager::InsertNewHotfix(uint32 tableHash, uint32 recordId)
|
||||
{
|
||||
_hotfixData[MAKE_PAIR64(tableHash, ++_maxHotfixId)] = recordId;
|
||||
|
||||
@@ -258,7 +258,9 @@ public:
|
||||
DB2StorageBase const* GetStorage(uint32 type) const;
|
||||
|
||||
void LoadHotfixData();
|
||||
void LoadHotfixBlob();
|
||||
std::map<uint64, int32> const& GetHotfixData() const;
|
||||
std::vector<uint8> const* GetHotfixBlobData(uint32 tableHash, int32 recordId);
|
||||
|
||||
std::vector<uint32> GetAreasForGroup(uint32 areaGroupId) const;
|
||||
static bool IsInArea(uint32 objectAreaId, uint32 areaId);
|
||||
|
||||
@@ -73,11 +73,16 @@ void WorldSession::HandleHotfixRequest(WorldPackets::Hotfix::HotfixRequest& hotf
|
||||
WorldPackets::Hotfix::HotfixResponse::HotfixData hotfixData;
|
||||
hotfixData.ID = hotfixId;
|
||||
hotfixData.RecordID = *hotfix;
|
||||
if (storage->HasRecord(hotfixData.RecordID))
|
||||
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))
|
||||
{
|
||||
hotfixData.Data = boost::in_place();
|
||||
hotfixData.Data->append(blobData->data(), blobData->size());
|
||||
}
|
||||
|
||||
hotfixQueryResponse.Hotfixes.emplace_back(std::move(hotfixData));
|
||||
}
|
||||
|
||||
@@ -1564,6 +1564,8 @@ void World::SetInitialWorldSettings()
|
||||
TC_LOG_INFO("server.loading", "Initialize data stores...");
|
||||
///- Load DB2s
|
||||
sDB2Manager.LoadStores(m_dataPath, m_defaultDbcLocale);
|
||||
TC_LOG_INFO("misc", "Loading hotfix blobs...");
|
||||
sDB2Manager.LoadHotfixBlob();
|
||||
TC_LOG_INFO("misc", "Loading hotfix info...");
|
||||
sDB2Manager.LoadHotfixData();
|
||||
///- Close hotfix database - it is only used during DB2 loading
|
||||
|
||||
Reference in New Issue
Block a user