Fixed Server starting.

This commit is contained in:
Hondacrx
2025-06-09 00:04:23 -04:00
parent 4214100d93
commit 59b507e93d
16 changed files with 105 additions and 98 deletions
@@ -647,6 +647,10 @@ namespace Framework.Constants
ModExplorationExperience = 637,
ModCriticalBlockAmount = 638,
Unk639 = 639,
Unk640 = 640,
Unk641 = 641,
Unk642 = 642,
ModRangedAttackSpeedFlat = 643,
Total
}
@@ -2624,8 +2624,9 @@ namespace Framework.Constants
Unk336 = 336,
Unk337 = 337,
Unk338 = 338,
Unk339 = 339,
UiAction = 339,
Unk340 = 340,
LearnWarbanScene = 341,
TotalSpellEffects
}
-61
View File
@@ -397,58 +397,6 @@ namespace Game.DataStorage
WorldMapOverlayStorage = ReadDB2<WorldMapOverlayRecord>("WorldMapOverlay.db2", HotfixStatements.SEL_WORLD_MAP_OVERLAY);
WorldStateExpressionStorage = ReadDB2<WorldStateExpressionRecord>("WorldStateExpression.db2", HotfixStatements.SEL_WORLD_STATE_EXPRESSION);
foreach (var entry in TaxiPathStorage.Values)
{
if (!TaxiPathSetBySource.ContainsKey(entry.FromTaxiNode))
TaxiPathSetBySource.Add(entry.FromTaxiNode, new Dictionary<uint, TaxiPathBySourceAndDestination>());
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;
}
// Check loaded DB2 files proper version
if (!AreaTableStorage.ContainsKey(16108) || // last area added in 11.0.7 (58162)
!CharTitlesStorage.ContainsKey(876) || // last char title added in 11.0.7 (58162)
@@ -864,15 +812,6 @@ namespace Game.DataStorage
public static GameTable<GtXpRecord> XpGameTable;
#endregion
#region Taxi Collections
public static byte[] TaxiNodesMask;
public static byte[] OldContinentsNodesMask;
public static byte[] HordeTaxiNodesMask;
public static byte[] AllianceTaxiNodesMask;
public static Dictionary<uint, Dictionary<uint, TaxiPathBySourceAndDestination>> TaxiPathSetBySource = new();
public static Dictionary<uint, TaxiPathNodeRecord[]> TaxiPathNodesByPath = new();
#endregion
#region Helper Methods
public static float GetGameTableColumnForClass(dynamic row, Class class_)
{
+59
View File
@@ -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<uint, SpellProcsPerMinuteModRecord> _spellProcsPerMinuteMods = new();
MultiMap<uint, SpellVisualMissileRecord> _spellVisualMissilesBySet = new();
List<TalentRecord>[][][] _talentsByPosition = new List<TalentRecord>[(int)Class.Max][][];
Dictionary<(uint, uint), TaxiPathRecord> _taxiPaths = new();
List<uint> _toys = new();
Dictionary<uint, TransmogIllusionRecord> _transmogIllusionsByEnchantmentId = new();
MultiMap<uint, TransmogSetRecord> _transmogSetsByItemModifiedAppearance = new();
@@ -2420,6 +2473,12 @@ namespace Game.DataStorage
List<int> _uiMapPhases = new();
Dictionary<Tuple<short, sbyte, int>, WMOAreaTableRecord> _wmoAreaTableLookup = new();
MultiMap<uint, uint> _pvpStatIdsByMap = new();
public static byte[] TaxiNodesMask;
public static byte[] OldContinentsNodesMask;
public static byte[] HordeTaxiNodesMask;
public static byte[] AllianceTaxiNodesMask;
public static Dictionary<uint, TaxiPathNodeRecord[]> TaxiPathNodesByPath = new();
}
class UiMapBounds
+1 -1
View File
@@ -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);
+7 -7
View File
@@ -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
{
+1 -1
View File
@@ -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));
+12 -17
View File
@@ -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<bool>(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)
+1 -1
View File
@@ -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
+1 -1
View File
@@ -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)
{
+2 -2
View File
@@ -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;
@@ -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];
+1 -1
View File
@@ -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})");
+7 -2
View File
@@ -249,11 +249,16 @@ namespace Game.Scripting
public class GenericConversationScript<Script> : ConversationScript where Script : ConversationAI
{
public GenericConversationScript(string name) : base(name) { }
object[] _args;
public GenericConversationScript(string name, object[] args) : base(name)
{
_args = args;
}
public override ConversationAI GetAI(Conversation conversation)
{
return (Script)Activator.CreateInstance(typeof(Script), [conversation]);
return (Script)Activator.CreateInstance(typeof(Script), [conversation, _args]);
}
}
+3
View File
@@ -126,6 +126,9 @@ namespace Game.Scripting
case nameof(AreaTriggerAI):
genericType = typeof(GenericAreaTriggerScript<>).MakeGenericType(type);
break;
case nameof(ConversationAI):
genericType = typeof(GenericConversationScript<>).MakeGenericType(type);
break;
case "SpellScriptLoader":
case "AuraScriptLoader":
case "WorldScript":
+1
View File
@@ -4842,6 +4842,7 @@ namespace Game.Spells
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 338 SPELL_EFFECT_338
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 339 SPELL_EFFECT_UI_ACTION
new StaticData(SpellEffectImplicitTargetTypes.None, SpellTargetObjectTypes.None), // 340 SPELL_EFFECT_340
new StaticData(SpellEffectImplicitTargetTypes.Explicit, SpellTargetObjectTypes.Unit), // 341 SPELL_EFFECT_LEARN_WARBAND_SCENE
};
#region Fields