From bfbf96ac257c6d54242465a66cd143e7ef520819 Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 2 Jun 2025 16:02:07 -0400 Subject: [PATCH] Core/DataStores: Delay building all DB2Manager containers after loading hotfix data to ignore rows marked as deleted by hotfixes Port From (https://github.com/TrinityCore/TrinityCore/commit/da1ac5aa73afdb7f2379b71761e2a6e855ce4e9a) --- Source/Game/DataStorage/CliDB.cs | 6 ++---- Source/Game/DataStorage/DB2Manager.cs | 6 +++++- Source/Game/World/WorldManager.cs | 17 ++++++++++------- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Source/Game/DataStorage/CliDB.cs b/Source/Game/DataStorage/CliDB.cs index 1464a0cb8..9c9af940f 100644 --- a/Source/Game/DataStorage/CliDB.cs +++ b/Source/Game/DataStorage/CliDB.cs @@ -397,8 +397,6 @@ namespace Game.DataStorage WorldMapOverlayStorage = ReadDB2("WorldMapOverlay.db2", HotfixStatements.SEL_WORLD_MAP_OVERLAY); WorldStateExpressionStorage = ReadDB2("WorldStateExpression.db2", HotfixStatements.SEL_WORLD_STATE_EXPRESSION); - Global.DB2Mgr.LoadStores(); - foreach (var entry in TaxiPathStorage.Values) { if (!TaxiPathSetBySource.ContainsKey(entry.FromTaxiNode)) @@ -412,7 +410,7 @@ namespace Game.DataStorage uint[] pathLength = new uint[pathCount]; // 0 and some other indexes not used foreach (TaxiPathNodeRecord entry in TaxiPathNodeStorage.Values) if (pathLength[entry.PathID] < entry.NodeIndex + 1) - pathLength[entry.PathID] = (uint)entry.NodeIndex + 1u; + pathLength[entry.PathID] = (uint)Math.Max(pathLength[entry.PathID], entry.NodeIndex + 1u); // Set path length for (uint i = 0; i < pathCount; ++i) @@ -465,7 +463,7 @@ namespace Game.DataStorage Environment.Exit(1); } - Log.outInfo(LogFilter.ServerLoading, "Initialized {0} DB2 data storages in {1} ms", loadedFileCount, Time.GetMSTimeDiffToNow(oldMSTime)); + Log.outInfo(LogFilter.ServerLoading, $"Initialized {loadedFileCount} DB2 data storages in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); return availableDb2Locales; } diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index a61d19462..92625770e 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -37,8 +37,10 @@ namespace Game.DataStorage } } - public void LoadStores() + public void IndexLoadedStores() { + uint oldMSTime = Time.GetMSTime(); + foreach (var areaGroupMember in AreaGroupMemberStorage.Values) _areaGroupMembers.Add(areaGroupMember.AreaGroupID, areaGroupMember.AreaID); @@ -688,6 +690,8 @@ namespace Game.DataStorage foreach (PvpStatRecord pvpStat in PvpStatStorage.Values) _pvpStatIdsByMap.Add(pvpStat.MapID, pvpStat.Id); + + Log.outInfo(LogFilter.ServerLoading, $"Indexed DB2 data stores in {Time.GetMSTimeDiffToNow(oldMSTime)} ms"); } public IDB2Storage GetStorage(uint type) diff --git a/Source/Game/World/WorldManager.cs b/Source/Game/World/WorldManager.cs index f1070c323..70513527f 100644 --- a/Source/Game/World/WorldManager.cs +++ b/Source/Game/World/WorldManager.cs @@ -415,6 +415,13 @@ namespace Game DB.Login.Execute($"UPDATE realmlist SET icon = {(byte)server_type}, timezone = {realm_zone} WHERE id = '{Global.RealmMgr.GetCurrentRealmId().Index}'"); // One-time query + Log.outInfo(LogFilter.ServerLoading, "Loading GameObject models..."); + if (!GameObjectModel.LoadGameObjectModelList()) + { + Log.outFatal(LogFilter.ServerLoading, "Unable to load gameobject models (part of vmaps), objects using WMO models will crash the client - server shutting down!"); + return false; + } + Log.outInfo(LogFilter.ServerLoading, "Initialize DataStorage..."); // Load DB2s m_availableDbcLocaleMask = CliDB.LoadStores(_dataPath, m_defaultDbcLocale); @@ -424,13 +431,6 @@ namespace Game return false; } - Log.outInfo(LogFilter.ServerLoading, "Loading GameObject models..."); - if (!GameObjectModel.LoadGameObjectModelList()) - { - Log.outFatal(LogFilter.ServerLoading, "Unable to load gameobject models (part of vmaps), objects using WMO models will crash the client - server shutting down!"); - return false; - } - Log.outInfo(LogFilter.ServerLoading, "Loading hotfix blobs..."); Global.DB2Mgr.LoadHotfixBlob(m_availableDbcLocaleMask); @@ -440,6 +440,9 @@ namespace Game Log.outInfo(LogFilter.ServerLoading, "Loading hotfix optional data..."); Global.DB2Mgr.LoadHotfixOptionalData(m_availableDbcLocaleMask); + Log.outInfo(LogFilter.ServerLoading, "Indexing loaded data stores..."); + Global.DB2Mgr.IndexLoadedStores(); + //- Load M2 fly by cameras M2Storage.LoadM2Cameras(_dataPath);