Fix loading server and talents.

This commit is contained in:
hondacrx
2023-01-18 17:25:54 -05:00
parent f73e64396f
commit 0584d234ad
3 changed files with 53 additions and 8 deletions
@@ -1506,6 +1506,7 @@ namespace Game.Networking.Packets
{ {
public void Read(WorldPacket data) public void Read(WorldPacket data)
{ {
data.ResetBitPos();
Flags = (SpellCastTargetFlags)data.ReadBits<uint>(28); Flags = (SpellCastTargetFlags)data.ReadBits<uint>(28);
if (data.HasBit()) if (data.HasBit())
SrcLocation = new(); SrcLocation = new();
+48 -7
View File
@@ -107,7 +107,7 @@ namespace Game
MultiMap<int, int> traitTreesIdsByTraitSystem = new(); MultiMap<int, int> traitTreesIdsByTraitSystem = new();
foreach (TraitTreeRecord traitTree in CliDB.TraitTreeStorage.Values) foreach (TraitTreeRecord traitTree in CliDB.TraitTreeStorage.Values)
{ {
Tree tree = _traitTrees[(int)traitTree.Id]; Tree tree = new();
tree.Data = traitTree; tree.Data = traitTree;
var costs = treeCosts.LookupByKey(traitTree.Id); var costs = treeCosts.LookupByKey(traitTree.Id);
@@ -123,11 +123,13 @@ namespace Game
traitTreesIdsByTraitSystem.Add(traitTree.TraitSystemID, (int)traitTree.Id); traitTreesIdsByTraitSystem.Add(traitTree.TraitSystemID, (int)traitTree.Id);
tree.ConfigType = TraitConfigType.Generic; tree.ConfigType = TraitConfigType.Generic;
} }
_traitTrees[(int)traitTree.Id] = tree;
} }
foreach (TraitNodeGroupRecord traitNodeGroup in CliDB.TraitNodeGroupStorage.Values) foreach (TraitNodeGroupRecord traitNodeGroup in CliDB.TraitNodeGroupStorage.Values)
{ {
NodeGroup nodeGroup = _traitGroups[(int)traitNodeGroup.Id]; NodeGroup nodeGroup = new();
nodeGroup.Data = traitNodeGroup; nodeGroup.Data = traitNodeGroup;
var conditions = nodeGroupConditions.LookupByKey(traitNodeGroup.Id); var conditions = nodeGroupConditions.LookupByKey(traitNodeGroup.Id);
@@ -137,11 +139,13 @@ namespace Game
var costs = nodeGroupCosts.LookupByKey(traitNodeGroup.Id); var costs = nodeGroupCosts.LookupByKey(traitNodeGroup.Id);
if (costs != null) if (costs != null)
nodeGroup.Costs = costs; nodeGroup.Costs = costs;
_traitGroups[(int)traitNodeGroup.Id] = nodeGroup;
} }
foreach (TraitNodeRecord traitNode in CliDB.TraitNodeStorage.Values) foreach (TraitNodeRecord traitNode in CliDB.TraitNodeStorage.Values)
{ {
Node node = _traitNodes[(int)traitNode.Id]; Node node = new();
node.Data = traitNode; node.Data = traitNode;
Tree tree = _traitTrees.LookupByKey(traitNode.TraitTreeID); Tree tree = _traitTrees.LookupByKey(traitNode.TraitTreeID);
@@ -181,6 +185,8 @@ namespace Game
var costs1 = nodeCosts.LookupByKey(traitNode.Id); var costs1 = nodeCosts.LookupByKey(traitNode.Id);
if (costs1 != null) if (costs1 != null)
node.Costs = costs1; node.Costs = costs1;
_traitNodes[(int)traitNode.Id] = node;
} }
foreach (TraitEdgeRecord traitEdgeEntry in CliDB.TraitEdgeStorage.Values) foreach (TraitEdgeRecord traitEdgeEntry in CliDB.TraitEdgeStorage.Values)
@@ -203,7 +209,7 @@ namespace Game
if (skillLineEntry == null) if (skillLineEntry == null)
continue; continue;
_traitTreesBySkillLine[skillLineXTraitTreeEntry.SkillLineID].Add(tree); _traitTreesBySkillLine.Add(skillLineXTraitTreeEntry.SkillLineID, tree);
if (skillLineEntry.CategoryID == SkillCategory.Class) if (skillLineEntry.CategoryID == SkillCategory.Class)
{ {
foreach (SkillRaceClassInfoRecord skillRaceClassInfo in Global.DB2Mgr.GetSkillRaceClassInfo(skillLineEntry.Id)) foreach (SkillRaceClassInfoRecord skillRaceClassInfo in Global.DB2Mgr.GetSkillRaceClassInfo(skillLineEntry.Id))
@@ -221,14 +227,14 @@ namespace Game
{ {
Tree tree = _traitTrees.LookupByKey(traitTreeId); Tree tree = _traitTrees.LookupByKey(traitTreeId);
if (tree != null) if (tree != null)
_traitTreesByTraitSystem[traitSystemId].Add(tree); _traitTreesByTraitSystem.Add(traitSystemId, tree);
} }
foreach (TraitCurrencySourceRecord traitCurrencySource in CliDB.TraitCurrencySourceStorage.Values) foreach (TraitCurrencySourceRecord traitCurrencySource in CliDB.TraitCurrencySourceStorage.Values)
_traitCurrencySourcesByCurrency[traitCurrencySource.TraitCurrencyID].Add(traitCurrencySource); _traitCurrencySourcesByCurrency.Add(traitCurrencySource.TraitCurrencyID, traitCurrencySource);
foreach (TraitDefinitionEffectPointsRecord traitDefinitionEffectPoints in CliDB.TraitDefinitionEffectPointsStorage.Values) foreach (TraitDefinitionEffectPointsRecord traitDefinitionEffectPoints in CliDB.TraitDefinitionEffectPointsStorage.Values)
_traitDefinitionEffectPointModifiers[traitDefinitionEffectPoints.TraitDefinitionID].Add(traitDefinitionEffectPoints); _traitDefinitionEffectPointModifiers.Add(traitDefinitionEffectPoints.TraitDefinitionID, traitDefinitionEffectPoints);
MultiMap<int, TraitTreeLoadoutEntryRecord> traitTreeLoadoutEntries = new(); MultiMap<int, TraitTreeLoadoutEntryRecord> traitTreeLoadoutEntries = new();
foreach (TraitTreeLoadoutEntryRecord traitTreeLoadoutEntry in CliDB.TraitTreeLoadoutEntryStorage.Values) foreach (TraitTreeLoadoutEntryRecord traitTreeLoadoutEntry in CliDB.TraitTreeLoadoutEntryStorage.Values)
@@ -364,6 +370,9 @@ namespace Game
{ {
case TraitCurrencyType.Gold: case TraitCurrencyType.Gold:
{ {
if (!currencies.ContainsKey((int)currency.Id))
currencies[(int)currency.Id] = 0;
int amount = currencies[(int)currency.Id]; int amount = currencies[(int)currency.Id];
if (player.GetMoney() > (ulong)(int.MaxValue - amount)) if (player.GetMoney() > (ulong)(int.MaxValue - amount))
amount = int.MaxValue; amount = int.MaxValue;
@@ -372,6 +381,9 @@ namespace Game
break; break;
} }
case TraitCurrencyType.CurrencyTypesBased: case TraitCurrencyType.CurrencyTypesBased:
if (!currencies.ContainsKey((int)currency.Id))
currencies[(int)currency.Id] = 0;
currencies[(int)currency.Id] += (int)player.GetCurrency((uint)currency.CurrencyTypesID); currencies[(int)currency.Id] += (int)player.GetCurrency((uint)currency.CurrencyTypesID);
break; break;
case TraitCurrencyType.TraitSourced: case TraitCurrencyType.TraitSourced:
@@ -392,6 +404,9 @@ namespace Game
if (currencySource.TraitNodeEntryID != 0 && !hasTraitNodeEntry(currencySource.TraitNodeEntryID)) if (currencySource.TraitNodeEntryID != 0 && !hasTraitNodeEntry(currencySource.TraitNodeEntryID))
continue; continue;
if (!currencies.ContainsKey(currencySource.TraitCurrencyID))
currencies[currencySource.TraitCurrencyID] = 0;
currencies[currencySource.TraitCurrencyID] += currencySource.Amount; currencies[currencySource.TraitCurrencyID] += currencySource.Amount;
} }
} }
@@ -407,22 +422,48 @@ namespace Game
{ {
Node node = _traitNodes.LookupByKey(entry.TraitNodeID); Node node = _traitNodes.LookupByKey(entry.TraitNodeID);
foreach (NodeGroup group in node.Groups) foreach (NodeGroup group in node.Groups)
{
foreach (TraitCostRecord cost in group.Costs) foreach (TraitCostRecord cost in group.Costs)
{
if (!cachedCurrencies.ContainsKey(cost.TraitCurrencyID))
cachedCurrencies[cost.TraitCurrencyID] = 0;
cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank; cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank;
}
}
var nodeEntryItr = node.Entries.Find(nodeEntry => nodeEntry.Data.Id == entry.TraitNodeEntryID); var nodeEntryItr = node.Entries.Find(nodeEntry => nodeEntry.Data.Id == entry.TraitNodeEntryID);
if (nodeEntryItr != null) if (nodeEntryItr != null)
{
foreach (TraitCostRecord cost in nodeEntryItr.Costs) foreach (TraitCostRecord cost in nodeEntryItr.Costs)
{
if (!cachedCurrencies.ContainsKey(cost.TraitCurrencyID))
cachedCurrencies[cost.TraitCurrencyID] = 0;
cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank; cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank;
}
}
foreach (TraitCostRecord cost in node.Costs) foreach (TraitCostRecord cost in node.Costs)
{
if (!cachedCurrencies.ContainsKey(cost.TraitCurrencyID))
cachedCurrencies[cost.TraitCurrencyID] = 0;
cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank; cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank;
}
Tree tree = _traitTrees.LookupByKey(node.Data.TraitTreeID); Tree tree = _traitTrees.LookupByKey(node.Data.TraitTreeID);
if (tree != null) if (tree != null)
{
foreach (TraitCostRecord cost in tree.Costs) foreach (TraitCostRecord cost in tree.Costs)
{
if (!cachedCurrencies.ContainsKey(cost.TraitCurrencyID))
cachedCurrencies[cost.TraitCurrencyID] = 0;
cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank; cachedCurrencies[cost.TraitCurrencyID] += cost.Amount * entry.Rank;
} }
}
}
public static void FillSpentCurrenciesMap(TraitConfigPacket traitConfig, Dictionary<int, int> cachedCurrencies) public static void FillSpentCurrenciesMap(TraitConfigPacket traitConfig, Dictionary<int, int> cachedCurrencies)
{ {
+3
View File
@@ -487,6 +487,9 @@ namespace Game
Log.outInfo(LogFilter.ServerLoading, "Loading Spell Totem models..."); Log.outInfo(LogFilter.ServerLoading, "Loading Spell Totem models...");
Global.SpellMgr.LoadSpellTotemModel(); Global.SpellMgr.LoadSpellTotemModel();
Log.outInfo(LogFilter.ServerLoading, "Loading Traits...");
TraitMgr.Load();
Log.outInfo(LogFilter.ServerLoading, "Loading languages..."); Log.outInfo(LogFilter.ServerLoading, "Loading languages...");
Global.LanguageMgr.LoadLanguages(); Global.LanguageMgr.LoadLanguages();