From 59b507e93d0240a6ae7fd24d7f1fed0cced329ef Mon Sep 17 00:00:00 2001 From: Hondacrx Date: Mon, 9 Jun 2025 00:04:23 -0400 Subject: [PATCH] Fixed Server starting. --- .../Constants/Spells/SpellAuraConst.cs | 4 ++ .../Framework/Constants/Spells/SpellConst.cs | 3 +- Source/Game/DataStorage/CliDB.cs | 63 +------------------ Source/Game/DataStorage/DB2Manager.cs | 59 +++++++++++++++++ Source/Game/Entities/Player/Player.cs | 2 +- Source/Game/Entities/Player/PlayerTaxi.cs | 14 ++--- Source/Game/Entities/Taxi/TaxiPathGraph.cs | 2 +- Source/Game/Globals/ObjectManager.cs | 29 ++++----- Source/Game/Handlers/CharacterHandler.cs | 2 +- Source/Game/Handlers/TaxiHandler.cs | 2 +- Source/Game/Maps/TransportManager.cs | 4 +- .../Generators/FlightPathMovementGenerator.cs | 4 +- Source/Game/Movement/MotionMaster.cs | 2 +- Source/Game/Scripting/CoreScripts.cs | 9 ++- Source/Game/Scripting/ScriptManager.cs | 3 + Source/Game/Spells/SpellInfo.cs | 1 + 16 files changed, 105 insertions(+), 98 deletions(-) diff --git a/Source/Framework/Constants/Spells/SpellAuraConst.cs b/Source/Framework/Constants/Spells/SpellAuraConst.cs index 46a368abd..8d0df37bc 100644 --- a/Source/Framework/Constants/Spells/SpellAuraConst.cs +++ b/Source/Framework/Constants/Spells/SpellAuraConst.cs @@ -647,6 +647,10 @@ namespace Framework.Constants ModExplorationExperience = 637, ModCriticalBlockAmount = 638, Unk639 = 639, + Unk640 = 640, + Unk641 = 641, + Unk642 = 642, + ModRangedAttackSpeedFlat = 643, Total } diff --git a/Source/Framework/Constants/Spells/SpellConst.cs b/Source/Framework/Constants/Spells/SpellConst.cs index c314e11f6..0ab1cbd1e 100644 --- a/Source/Framework/Constants/Spells/SpellConst.cs +++ b/Source/Framework/Constants/Spells/SpellConst.cs @@ -2624,8 +2624,9 @@ namespace Framework.Constants Unk336 = 336, Unk337 = 337, Unk338 = 338, - Unk339 = 339, + UiAction = 339, Unk340 = 340, + LearnWarbanScene = 341, TotalSpellEffects } diff --git a/Source/Game/DataStorage/CliDB.cs b/Source/Game/DataStorage/CliDB.cs index 9c9af940f..da7f13aec 100644 --- a/Source/Game/DataStorage/CliDB.cs +++ b/Source/Game/DataStorage/CliDB.cs @@ -395,59 +395,7 @@ namespace Game.DataStorage WMOAreaTableStorage = ReadDB2("WMOAreaTable.db2", HotfixStatements.SEL_WMO_AREA_TABLE, HotfixStatements.SEL_WMO_AREA_TABLE_LOCALE); WorldEffectStorage = ReadDB2("WorldEffect.db2", HotfixStatements.SEL_WORLD_EFFECT); WorldMapOverlayStorage = ReadDB2("WorldMapOverlay.db2", HotfixStatements.SEL_WORLD_MAP_OVERLAY); - WorldStateExpressionStorage = ReadDB2("WorldStateExpression.db2", HotfixStatements.SEL_WORLD_STATE_EXPRESSION); - - foreach (var entry in TaxiPathStorage.Values) - { - if (!TaxiPathSetBySource.ContainsKey(entry.FromTaxiNode)) - TaxiPathSetBySource.Add(entry.FromTaxiNode, new Dictionary()); - TaxiPathSetBySource[entry.FromTaxiNode][entry.ToTaxiNode] = new TaxiPathBySourceAndDestination(entry.Id, entry.Cost); - } - - uint pathCount = TaxiPathStorage.GetNumRows(); - - // Calculate path nodes count - 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)Math.Max(pathLength[entry.PathID], entry.NodeIndex + 1u); - - // Set path length - for (uint i = 0; i < pathCount; ++i) - TaxiPathNodesByPath[i] = new TaxiPathNodeRecord[pathLength[i]]; - - // fill data - foreach (var entry in TaxiPathNodeStorage.Values) - TaxiPathNodesByPath[entry.PathID][entry.NodeIndex] = entry; - - var taxiMaskSize = ((TaxiNodesStorage.GetNumRows() - 1) / (1 * 64) + 1) * 8; - TaxiNodesMask = new byte[taxiMaskSize]; - OldContinentsNodesMask = new byte[taxiMaskSize]; - HordeTaxiNodesMask = new byte[taxiMaskSize]; - AllianceTaxiNodesMask = new byte[taxiMaskSize]; - - foreach (var node in TaxiNodesStorage.Values) - { - if (!node.IsPartOfTaxiNetwork()) - continue; - - // valid taxi network node - uint field = (node.Id - 1) / 8; - byte submask = (byte)(1 << (int)((node.Id - 1) % 8)); - - TaxiNodesMask[field] |= submask; - if (node.HasFlag(TaxiNodeFlags.ShowOnHordeMap)) - HordeTaxiNodesMask[field] |= submask; - if (node.HasFlag(TaxiNodeFlags.ShowOnAllianceMap)) - AllianceTaxiNodesMask[field] |= submask; - - uint uiMapId; - if (!Global.DB2Mgr.GetUiMapPosition(node.Pos.X, node.Pos.Y, node.Pos.Z, node.ContinentID, 0, 0, 0, UiMapSystem.Adventure, false, out uiMapId)) - Global.DB2Mgr.GetUiMapPosition(node.Pos.X, node.Pos.Y, node.Pos.Z, node.ContinentID, 0, 0, 0, UiMapSystem.Taxi, false, out uiMapId); - - if (uiMapId == 985 || uiMapId == 986) - OldContinentsNodesMask[field] |= submask; - } + WorldStateExpressionStorage = ReadDB2("WorldStateExpression.db2", HotfixStatements.SEL_WORLD_STATE_EXPRESSION); // Check loaded DB2 files proper version if (!AreaTableStorage.ContainsKey(16108) || // last area added in 11.0.7 (58162) @@ -864,15 +812,6 @@ namespace Game.DataStorage public static GameTable XpGameTable; #endregion - #region Taxi Collections - public static byte[] TaxiNodesMask; - public static byte[] OldContinentsNodesMask; - public static byte[] HordeTaxiNodesMask; - public static byte[] AllianceTaxiNodesMask; - public static Dictionary> TaxiPathSetBySource = new(); - public static Dictionary TaxiPathNodesByPath = new(); - #endregion - #region Helper Methods public static float GetGameTableColumnForClass(dynamic row, Class class_) { diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index 92625770e..9a14bf35f 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -564,6 +564,24 @@ namespace Game.DataStorage _talentsByPosition[talentInfo.ClassID][talentInfo.TierID][talentInfo.ColumnIndex].Add(talentInfo); } + foreach (var entry in TaxiPathStorage.Values) + _taxiPaths[(entry.FromTaxiNode, entry.ToTaxiNode)] = entry; + + uint pathCount = TaxiPathStorage.GetNumRows(); + + // Calculate path nodes count + uint[] pathLength = new uint[pathCount]; // 0 and some other indexes not used + foreach (TaxiPathNodeRecord entry in TaxiPathNodeStorage.Values) + pathLength[entry.PathID] = (uint)Math.Max(pathLength[entry.PathID], entry.NodeIndex + 1u); + + // Set path length + for (uint i = 0; i < pathCount; ++i) + TaxiPathNodesByPath[i] = new TaxiPathNodeRecord[pathLength[i]]; + + // fill data + foreach (var entry in TaxiPathNodeStorage.Values) + TaxiPathNodesByPath[entry.PathID][entry.NodeIndex] = entry; + foreach (ToyRecord toy in ToyStorage.Values) _toys.Add(toy.ItemID); @@ -688,6 +706,35 @@ namespace Game.DataStorage foreach (WMOAreaTableRecord entry in WMOAreaTableStorage.Values) _wmoAreaTableLookup[Tuple.Create((short)entry.WmoID, (sbyte)entry.NameSetID, entry.WmoGroupID)] = entry; + var taxiMaskSize = ((TaxiNodesStorage.GetNumRows() - 1) / (1 * 64) + 1) * 8; + TaxiNodesMask = new byte[taxiMaskSize]; + OldContinentsNodesMask = new byte[taxiMaskSize]; + HordeTaxiNodesMask = new byte[taxiMaskSize]; + AllianceTaxiNodesMask = new byte[taxiMaskSize]; + + foreach (var node in TaxiNodesStorage.Values) + { + if (!node.IsPartOfTaxiNetwork()) + continue; + + // valid taxi network node + uint field = (node.Id - 1) / 8; + byte submask = (byte)(1 << (int)((node.Id - 1) % 8)); + + TaxiNodesMask[field] |= submask; + if (node.HasFlag(TaxiNodeFlags.ShowOnHordeMap)) + HordeTaxiNodesMask[field] |= submask; + if (node.HasFlag(TaxiNodeFlags.ShowOnAllianceMap)) + AllianceTaxiNodesMask[field] |= submask; + + uint uiMapId; + if (!Global.DB2Mgr.GetUiMapPosition(node.Pos.X, node.Pos.Y, node.Pos.Z, node.ContinentID, 0, 0, 0, UiMapSystem.Adventure, false, out uiMapId)) + Global.DB2Mgr.GetUiMapPosition(node.Pos.X, node.Pos.Y, node.Pos.Z, node.ContinentID, 0, 0, 0, UiMapSystem.Taxi, false, out uiMapId); + + if (uiMapId == 985 || uiMapId == 986) + OldContinentsNodesMask[field] |= submask; + } + foreach (PvpStatRecord pvpStat in PvpStatStorage.Values) _pvpStatIdsByMap.Add(pvpStat.MapID, pvpStat.Id); @@ -2001,6 +2048,11 @@ namespace Game.DataStorage return _talentsByPosition[(int)class_][tier][column]; } + public TaxiPathRecord GetTaxiPath(uint from, uint to) + { + return _taxiPaths.LookupByKey((from, to)); + } + public bool IsTotemCategoryCompatibleWith(uint itemTotemCategoryId, uint requiredTotemCategoryId, bool requireAllTotems = true) { if (requiredTotemCategoryId == 0) @@ -2408,6 +2460,7 @@ namespace Game.DataStorage MultiMap _spellProcsPerMinuteMods = new(); MultiMap _spellVisualMissilesBySet = new(); List[][][] _talentsByPosition = new List[(int)Class.Max][][]; + Dictionary<(uint, uint), TaxiPathRecord> _taxiPaths = new(); List _toys = new(); Dictionary _transmogIllusionsByEnchantmentId = new(); MultiMap _transmogSetsByItemModifiedAppearance = new(); @@ -2420,6 +2473,12 @@ namespace Game.DataStorage List _uiMapPhases = new(); Dictionary, WMOAreaTableRecord> _wmoAreaTableLookup = new(); MultiMap _pvpStatIdsByMap = new(); + + public static byte[] TaxiNodesMask; + public static byte[] OldContinentsNodesMask; + public static byte[] HordeTaxiNodesMask; + public static byte[] AllianceTaxiNodesMask; + public static Dictionary TaxiPathNodesByPath = new(); } class UiMapBounds diff --git a/Source/Game/Entities/Player/Player.cs b/Source/Game/Entities/Player/Player.cs index fcb7e00ca..f9824f4e2 100644 --- a/Source/Game/Entities/Player/Player.cs +++ b/Source/Game/Entities/Player/Player.cs @@ -7304,7 +7304,7 @@ namespace Game.Entities // search appropriate start path node uint startNode = 0; - var nodeList = CliDB.TaxiPathNodesByPath[path]; + var nodeList = DB2Manager.TaxiPathNodesByPath[path]; float distPrev; float distNext = GetExactDistSq(nodeList[0].Loc.X, nodeList[0].Loc.Y, nodeList[0].Loc.Z); diff --git a/Source/Game/Entities/Player/PlayerTaxi.cs b/Source/Game/Entities/Player/PlayerTaxi.cs index a624ade8d..1a8e18fee 100644 --- a/Source/Game/Entities/Player/PlayerTaxi.cs +++ b/Source/Game/Entities/Player/PlayerTaxi.cs @@ -24,10 +24,10 @@ namespace Game.Entities // class specific initial known nodes if (chrClass == Class.Deathknight) { - var factionMask = Player.TeamForRace(race) == Team.Horde ? CliDB.HordeTaxiNodesMask : CliDB.AllianceTaxiNodesMask; + var factionMask = Player.TeamForRace(race) == Team.Horde ? DB2Manager.HordeTaxiNodesMask : DB2Manager.AllianceTaxiNodesMask; m_taximask = new byte[factionMask.Length]; for (int i = 0; i < factionMask.Length; ++i) - m_taximask[i] |= (byte)(CliDB.OldContinentsNodesMask[i] & factionMask[i]); + m_taximask[i] |= (byte)(DB2Manager.OldContinentsNodesMask[i] & factionMask[i]); } // race specific initial known nodes: capital and taxi hub masks @@ -102,19 +102,19 @@ namespace Game.Entities { // load and set bits only for existing taxi nodes if (uint.TryParse(split[i], out uint id)) - m_taximask[index] = (byte)(CliDB.TaxiNodesMask[index] & id); + m_taximask[index] = (byte)(DB2Manager.TaxiNodesMask[index] & id); } } public void AppendTaximaskTo(ShowTaxiNodes data, bool all) { - data.CanLandNodes = new byte[CliDB.TaxiNodesMask.Length]; - data.CanUseNodes = new byte[CliDB.TaxiNodesMask.Length]; + data.CanLandNodes = new byte[DB2Manager.TaxiNodesMask.Length]; + data.CanUseNodes = new byte[DB2Manager.TaxiNodesMask.Length]; if (all) { - Buffer.BlockCopy(CliDB.TaxiNodesMask, 0, data.CanLandNodes, 0, data.CanLandNodes.Length); // all existed nodes - Buffer.BlockCopy(CliDB.TaxiNodesMask, 0, data.CanUseNodes, 0, data.CanUseNodes.Length); + Buffer.BlockCopy(DB2Manager.TaxiNodesMask, 0, data.CanLandNodes, 0, data.CanLandNodes.Length); // all existed nodes + Buffer.BlockCopy(DB2Manager.TaxiNodesMask, 0, data.CanUseNodes, 0, data.CanUseNodes.Length); } else { diff --git a/Source/Game/Entities/Taxi/TaxiPathGraph.cs b/Source/Game/Entities/Taxi/TaxiPathGraph.cs index 599c53927..3007b979b 100644 --- a/Source/Game/Entities/Taxi/TaxiPathGraph.cs +++ b/Source/Game/Entities/Taxi/TaxiPathGraph.cs @@ -42,7 +42,7 @@ namespace Game.Entities uint toVertexID = CreateVertexFromFromNodeInfoIfNeeded(to); float totalDist = 0.0f; - TaxiPathNodeRecord[] nodes = CliDB.TaxiPathNodesByPath[pathId]; + TaxiPathNodeRecord[] nodes = DB2Manager.TaxiPathNodesByPath[pathId]; if (nodes.Length < 2) { edges.Add(Tuple.Create(Tuple.Create(fromVertexID, toVertexID), 0xFFFFu)); diff --git a/Source/Game/Globals/ObjectManager.cs b/Source/Game/Globals/ObjectManager.cs index 14591322d..3bc2d7306 100644 --- a/Source/Game/Globals/ObjectManager.cs +++ b/Source/Game/Globals/ObjectManager.cs @@ -4126,7 +4126,7 @@ namespace Game { if (got.MoTransport.taxiPathID != 0) { - if (got.MoTransport.taxiPathID >= CliDB.TaxiPathNodesByPath.Count || CliDB.TaxiPathNodesByPath[got.MoTransport.taxiPathID].Empty()) + if (got.MoTransport.taxiPathID >= DB2Manager.TaxiPathNodesByPath.Count || DB2Manager.TaxiPathNodesByPath[got.MoTransport.taxiPathID].Empty()) Log.outError(LogFilter.Sql, "GameObject (Entry: {0} GoType: {1}) have data0={2} but TaxiPath (Id: {3}) not exist.", entry, got.type, got.MoTransport.taxiPathID, got.MoTransport.taxiPathID); } @@ -9392,7 +9392,7 @@ namespace Game continue; } - SpawnTrackingStateData spawnTrackingStateData = data.spawnTrackingStates[(int)state]; + SpawnTrackingStateData spawnTrackingStateData = new(); spawnTrackingStateData.Visible = result.Read(3); if (!result.IsNull(4)) @@ -9446,6 +9446,8 @@ namespace Game spawnTrackingStateData.StateWorldEffects = worldEffectList; } + data.spawnTrackingStates[(int)state] = spawnTrackingStateData; + ++count; } while (result.NextRow()); @@ -11171,7 +11173,7 @@ namespace Game byte submask = (byte)(1 << (int)((node.Id - 1) % 8)); // skip not taxi network nodes - if ((CliDB.TaxiNodesMask[field] & submask) == 0) + if ((DB2Manager.TaxiNodesMask[field] & submask) == 0) continue; float dist2 = (node.Pos.X - x) * (node.Pos.X - x) + (node.Pos.Y - y) * (node.Pos.Y - y) + (node.Pos.Z - z) * (node.Pos.Z - z); @@ -11196,24 +11198,17 @@ namespace Game public void GetTaxiPath(uint source, uint destination, out uint path, out uint cost) { - var pathSet = CliDB.TaxiPathSetBySource.LookupByKey(source); - if (pathSet == null) + var taxiPath = Global.DB2Mgr.GetTaxiPath(source, destination); + if (taxiPath != null) + { + path = taxiPath.Id; + cost = taxiPath.Cost; + } + else { path = 0; cost = 0; - return; } - - var dest_i = pathSet.LookupByKey(destination); - if (dest_i == null) - { - path = 0; - cost = 0; - return; - } - - cost = dest_i.price; - path = dest_i.Id; } public uint GetTaxiMountDisplayId(uint id, Team team, bool allowed_alt_team = false) diff --git a/Source/Game/Handlers/CharacterHandler.cs b/Source/Game/Handlers/CharacterHandler.cs index c6f235b5f..fe6d243f4 100644 --- a/Source/Game/Handlers/CharacterHandler.cs +++ b/Source/Game/Handlers/CharacterHandler.cs @@ -1986,7 +1986,7 @@ namespace Game string taximaskstream = ""; - var factionMask = newTeamId == BattleGroundTeamId.Horde ? CliDB.HordeTaxiNodesMask : CliDB.AllianceTaxiNodesMask; + var factionMask = newTeamId == BattleGroundTeamId.Horde ? DB2Manager.HordeTaxiNodesMask : DB2Manager.AllianceTaxiNodesMask; for (int i = 0; i < factionMask.Length; ++i) { // i = (315 - 1) / 8 = 39 diff --git a/Source/Game/Handlers/TaxiHandler.cs b/Source/Game/Handlers/TaxiHandler.cs index ffb2a0603..dc75fe654 100644 --- a/Source/Game/Handlers/TaxiHandler.cs +++ b/Source/Game/Handlers/TaxiHandler.cs @@ -98,7 +98,7 @@ namespace Game GetPlayer().m_taxi.AppendTaximaskTo(data, lastTaxiCheaterState); - byte[] reachableNodes = new byte[CliDB.TaxiNodesMask.Length]; + byte[] reachableNodes = new byte[DB2Manager.TaxiNodesMask.Length]; TaxiPathGraph.GetReachableNodesMask(CliDB.TaxiNodesStorage.LookupByKey(curloc), reachableNodes); for (var i = 0; i < reachableNodes.Length; ++i) { diff --git a/Source/Game/Maps/TransportManager.cs b/Source/Game/Maps/TransportManager.cs index eedb85113..d66f0f44b 100644 --- a/Source/Game/Maps/TransportManager.cs +++ b/Source/Game/Maps/TransportManager.cs @@ -46,7 +46,7 @@ namespace Game.Maps continue; } - if (!CliDB.TaxiPathNodesByPath.ContainsKey(goInfo.MoTransport.taxiPathID)) + if (!DB2Manager.TaxiPathNodesByPath.ContainsKey(goInfo.MoTransport.taxiPathID)) { Log.outError(LogFilter.Sql, "Transport {0} (name: {1}) has an invalid path specified in `gameobject_template`.`data0` ({2}) field, skipped.", entry, goInfo.name, goInfo.MoTransport.taxiPathID); continue; @@ -307,7 +307,7 @@ namespace Game.Maps void GeneratePath(GameObjectTemplate goInfo, TransportTemplate transport) { uint pathId = goInfo.MoTransport.taxiPathID; - TaxiPathNodeRecord[] path = CliDB.TaxiPathNodesByPath[pathId]; + TaxiPathNodeRecord[] path = DB2Manager.TaxiPathNodesByPath[pathId]; transport.Speed = (double)goInfo.MoTransport.moveSpeed; transport.AccelerationRate = (double)goInfo.MoTransport.accelRate; diff --git a/Source/Game/Movement/Generators/FlightPathMovementGenerator.cs b/Source/Game/Movement/Generators/FlightPathMovementGenerator.cs index e8e119fe9..1b9c56fde 100644 --- a/Source/Game/Movement/Generators/FlightPathMovementGenerator.cs +++ b/Source/Game/Movement/Generators/FlightPathMovementGenerator.cs @@ -201,10 +201,10 @@ namespace Game.Movement { uint path, cost; Global.ObjectMgr.GetTaxiPath(taxi[src], taxi[dst], out path, out cost); - if (path >= CliDB.TaxiPathNodesByPath.Keys.Max()) + if (path >= DB2Manager.TaxiPathNodesByPath.Keys.Max()) return; - var nodes = CliDB.TaxiPathNodesByPath[path]; + var nodes = DB2Manager.TaxiPathNodesByPath[path]; if (!nodes.Empty()) { TaxiPathNodeRecord start = nodes[0]; diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index 098d61cfa..e95736e1c 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -1015,7 +1015,7 @@ namespace Game.Movement { if (_owner.IsTypeId(TypeId.Player)) { - if (path < CliDB.TaxiPathNodesByPath.Count) + if (path < DB2Manager.TaxiPathNodesByPath.Count) { Log.outDebug(LogFilter.Server, $"MotionMaster::MoveTaxiFlight: {_owner.GetGUID()} taxi to Path Id: {path} (node {pathnode})"); diff --git a/Source/Game/Scripting/CoreScripts.cs b/Source/Game/Scripting/CoreScripts.cs index 78d01ca3f..54c3377e3 100644 --- a/Source/Game/Scripting/CoreScripts.cs +++ b/Source/Game/Scripting/CoreScripts.cs @@ -249,11 +249,16 @@ namespace Game.Scripting public class GenericConversationScript