Core/DataStores: Delay building all DB2Manager containers after loading hotfix data to ignore rows marked as deleted by hotfixes

(cherry picked from commit da1ac5aa73)

# Conflicts:
#	src/server/game/DataStores/DB2Stores.cpp
This commit is contained in:
Shauren
2025-01-09 00:12:43 +01:00
committed by Ovahlord
parent efeb9add00
commit e3ecbbd1b5
3 changed files with 27 additions and 20 deletions

View File

@@ -29,6 +29,7 @@
#include "Timer.h"
#include "Util.h"
#include "World.h"
#include <algorithm>
#include <array>
#include <bitset>
#include <boost/filesystem/directory.hpp>
@@ -824,6 +825,15 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
return 0;
}
TC_LOG_INFO("server.loading", ">> Initialized {} DB2 data stores in {} ms", _stores.size(), GetMSTimeDiffToNow(oldMSTime));
return availableDb2Locales.to_ulong();
}
void DB2Manager::IndexLoadedStores()
{
uint32 oldMSTime = getMSTime();
for (AreaGroupMemberEntry const* areaGroupMember : sAreaGroupMemberStore)
_areaGroupMembers[areaGroupMember->AreaGroupID].push_back(areaGroupMember->AreaID);
@@ -860,8 +870,8 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
for (ChrClassesXPowerTypesEntry const* power : sChrClassesXPowerTypesStore)
powers.insert(power);
for (std::size_t i = 0; i < _powersByClass.size(); ++i)
_powersByClass[i].fill(MAX_POWERS);
for (std::array<uint32, MAX_POWERS>& powersForClass : _powersByClass)
powersForClass.fill(MAX_POWERS);
for (ChrClassesXPowerTypesEntry const* power : powers)
{
@@ -980,10 +990,10 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
for (auto& [curveId, curvePoints] : unsortedPoints)
{
std::sort(curvePoints.begin(), curvePoints.end(), [](CurvePointEntry const* point1, CurvePointEntry const* point2) { return point1->OrderIndex < point2->OrderIndex; });
std::ranges::sort(curvePoints, {}, &CurvePointEntry::OrderIndex);
std::vector<DBCPosition2D>& points = _curvePoints[curveId];
points.resize(curvePoints.size());
std::transform(curvePoints.begin(), curvePoints.end(), points.begin(), [](CurvePointEntry const* point) { return point->Pos; });
std::ranges::transform(curvePoints, points.begin(), &CurvePointEntry::Pos);
}
}
@@ -1055,10 +1065,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
for (MapDifficultyXConditionEntry const* mapDifficultyCondition : sMapDifficultyXConditionStore)
mapDifficultyConditions.push_back(mapDifficultyCondition);
std::sort(mapDifficultyConditions.begin(), mapDifficultyConditions.end(), [](MapDifficultyXConditionEntry const* left, MapDifficultyXConditionEntry const* right)
{
return left->OrderIndex < right->OrderIndex;
});
std::ranges::sort(mapDifficultyConditions, {}, &MapDifficultyXConditionEntry::OrderIndex);
for (MapDifficultyXConditionEntry const* mapDifficultyCondition : mapDifficultyConditions)
if (PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(mapDifficultyCondition->PlayerConditionID))
@@ -1230,8 +1237,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
std::vector<uint32> pathLength;
pathLength.resize(pathCount); // 0 and some other indexes not used
for (TaxiPathNodeEntry const* entry : sTaxiPathNodeStore)
if (pathLength[entry->PathID] < entry->NodeIndex + 1u)
pathLength[entry->PathID] = entry->NodeIndex + 1u;
pathLength[entry->PathID] = std::max(pathLength[entry->PathID], entry->NodeIndex + 1u);
// Set path length
sTaxiPathNodesByPath.resize(pathCount); // 0 and some other indexes not used
@@ -1384,9 +1390,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
sOldContinentsNodesMask[field] |= submask;
}
TC_LOG_INFO("server.loading", ">> Initialized {} DB2 data stores in {} ms", _stores.size(), GetMSTimeDiffToNow(oldMSTime));
return availableDb2Locales.to_ulong();
TC_LOG_INFO("server.loading", ">> Indexed DB2 data stores in {} ms", GetMSTimeDiffToNow(oldMSTime));
}
DB2StorageBase const* DB2Manager::GetStorage(uint32 type) const

View File

@@ -352,6 +352,7 @@ public:
static DB2Manager& Instance();
uint32 LoadStores(std::string const& dataPath, LocaleConstant defaultLocale);
void IndexLoadedStores();
DB2StorageBase const* GetStorage(uint32 type) const;
void LoadHotfixData(uint32 localeMask);

View File

@@ -1740,6 +1740,13 @@ bool World::SetInitialWorldSettings()
LoginDatabase.PExecute("UPDATE realmlist SET icon = {}, timezone = {} WHERE id = '{}'", server_type, realm_zone, sRealmList->GetCurrentRealmId().Realm); // One-time query
TC_LOG_INFO("server.loading", "Loading GameObject models...");
if (!LoadGameObjectModelList(m_dataPath))
{
TC_LOG_FATAL("server.loading", "Unable to load gameobject models (part of vmaps), objects using WMO models will crash the client - server shutting down!");
return false;
}
TC_LOG_INFO("server.loading", "Initialize data stores...");
///- Load DB2s
m_availableDbcLocaleMask = sDB2Manager.LoadStores(m_dataPath, m_defaultDbcLocale);
@@ -1749,19 +1756,14 @@ bool World::SetInitialWorldSettings()
return false;
}
TC_LOG_INFO("server.loading", "Loading GameObject models...");
if (!LoadGameObjectModelList(m_dataPath))
{
TC_LOG_FATAL("server.loading", "Unable to load gameobject models (part of vmaps), objects using WMO models will crash the client - server shutting down!");
return false;
}
TC_LOG_INFO("misc", "Loading hotfix blobs...");
sDB2Manager.LoadHotfixBlob(m_availableDbcLocaleMask);
TC_LOG_INFO("misc", "Loading hotfix info...");
sDB2Manager.LoadHotfixData(m_availableDbcLocaleMask);
TC_LOG_INFO("misc", "Loading hotfix optional data...");
sDB2Manager.LoadHotfixOptionalData(m_availableDbcLocaleMask);
TC_LOG_INFO("misc", "Indexing loaded data stores...");
sDB2Manager.IndexLoadedStores();
///- Load M2 fly by cameras
LoadM2Cameras(m_dataPath);
///- Load GameTables