aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/DataStores
diff options
context:
space:
mode:
authorfunjoker <torti-esser@web.de>2018-12-08 00:05:57 +0100
committerShauren <shauren.trinity@gmail.com>2018-12-08 00:05:57 +0100
commitf272a78caab463988e0d244d92e4cb0fce2c942f (patch)
tree9bcf46c45f324537064d9fc072922162b2cad0dd /src/server/game/DataStores
parent9a8f09de57c32234a9c9db6df57bb7353d679967 (diff)
Core/DataStores: Implemented sending hotfixes for db2 stores not loaded serverside (#22800)
Diffstat (limited to 'src/server/game/DataStores')
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp45
-rw-r--r--src/server/game/DataStores/DB2Stores.h2
2 files changed, 44 insertions, 3 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);