diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DataStores/DB2Stores.cpp | 45 | ||||
-rw-r--r-- | src/server/game/DataStores/DB2Stores.h | 2 | ||||
-rw-r--r-- | src/server/game/Handlers/HotfixHandler.cpp | 7 | ||||
-rw-r--r-- | src/server/game/World/World.cpp | 2 |
4 files changed, 52 insertions, 4 deletions
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 43e55c20fc5..957d44407e8 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -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; diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 389a19e952e..3e61c1513ad 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -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); diff --git a/src/server/game/Handlers/HotfixHandler.cpp b/src/server/game/Handlers/HotfixHandler.cpp index 0d887769d08..4fc6426c2df 100644 --- a/src/server/game/Handlers/HotfixHandler.cpp +++ b/src/server/game/Handlers/HotfixHandler.cpp @@ -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)); } diff --git a/src/server/game/World/World.cpp b/src/server/game/World/World.cpp index e65eee8a787..a6cf260746d 100644 --- a/src/server/game/World/World.cpp +++ b/src/server/game/World/World.cpp @@ -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 |