Core/Spells: Load spell label data for future use

Port From (https://github.com/TrinityCore/TrinityCore/commit/e1f3f1254c3214c0a5b71db6de33f8900903d314)
This commit is contained in:
hondacrx
2021-06-04 16:26:25 -04:00
parent fee15ee311
commit 69a832b162
6 changed files with 48 additions and 3 deletions
@@ -988,6 +988,9 @@ namespace Framework.Database
"RtOperandType1, RtOperandType2, RtOperandType3, RtOperandType4, RtOperandType5, RtOperand1, RtOperand2, RtOperand3, RtOperand4, RtOperand5, " + "RtOperandType1, RtOperandType2, RtOperandType3, RtOperandType4, RtOperandType5, RtOperand1, RtOperand2, RtOperand3, RtOperand4, RtOperand5, " +
"Logic1, Logic2, Logic3, Logic4, Logic5 FROM spell_item_enchantment_condition"); "Logic1, Logic2, Logic3, Logic4, Logic5 FROM spell_item_enchantment_condition");
// SpellLabel.db2
PrepareStatement(HotfixStatements.SEL_SPELL_LABEL, "SELECT ID, LabelID, SpellID FROM spell_label");
// SpellLearnSpell.db2 // SpellLearnSpell.db2
PrepareStatement(HotfixStatements.SEL_SPELL_LEARN_SPELL, "SELECT ID, SpellID, LearnSpellID, OverridesSpellID FROM spell_learn_spell"); PrepareStatement(HotfixStatements.SEL_SPELL_LEARN_SPELL, "SELECT ID, SpellID, LearnSpellID, OverridesSpellID FROM spell_learn_spell");
@@ -1693,6 +1696,8 @@ namespace Framework.Database
SEL_SPELL_ITEM_ENCHANTMENT_CONDITION, SEL_SPELL_ITEM_ENCHANTMENT_CONDITION,
SEL_SPELL_LABEL,
SEL_SPELL_LEARN_SPELL, SEL_SPELL_LEARN_SPELL,
SEL_SPELL_LEVELS, SEL_SPELL_LEVELS,
+2
View File
@@ -277,6 +277,7 @@ namespace Game.DataStorage
SpellInterruptsStorage = ReadDB2<SpellInterruptsRecord>("SpellInterrupts.db2", HotfixStatements.SEL_SPELL_INTERRUPTS); SpellInterruptsStorage = ReadDB2<SpellInterruptsRecord>("SpellInterrupts.db2", HotfixStatements.SEL_SPELL_INTERRUPTS);
SpellItemEnchantmentStorage = ReadDB2<SpellItemEnchantmentRecord>("SpellItemEnchantment.db2", HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT, HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT_LOCALE); SpellItemEnchantmentStorage = ReadDB2<SpellItemEnchantmentRecord>("SpellItemEnchantment.db2", HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT, HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT_LOCALE);
SpellItemEnchantmentConditionStorage = ReadDB2<SpellItemEnchantmentConditionRecord>("SpellItemEnchantmentCondition.db2", HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT_CONDITION); SpellItemEnchantmentConditionStorage = ReadDB2<SpellItemEnchantmentConditionRecord>("SpellItemEnchantmentCondition.db2", HotfixStatements.SEL_SPELL_ITEM_ENCHANTMENT_CONDITION);
SpellLabelStorage = ReadDB2<SpellLabelRecord>("SpellLabel.db2", HotfixStatements.SEL_SPELL_LABEL);
SpellLearnSpellStorage = ReadDB2<SpellLearnSpellRecord>("SpellLearnSpell.db2", HotfixStatements.SEL_SPELL_LEARN_SPELL); SpellLearnSpellStorage = ReadDB2<SpellLearnSpellRecord>("SpellLearnSpell.db2", HotfixStatements.SEL_SPELL_LEARN_SPELL);
SpellLevelsStorage = ReadDB2<SpellLevelsRecord>("SpellLevels.db2", HotfixStatements.SEL_SPELL_LEVELS); SpellLevelsStorage = ReadDB2<SpellLevelsRecord>("SpellLevels.db2", HotfixStatements.SEL_SPELL_LEVELS);
SpellMiscStorage = ReadDB2<SpellMiscRecord>("SpellMisc.db2", HotfixStatements.SEL_SPELL_MISC); SpellMiscStorage = ReadDB2<SpellMiscRecord>("SpellMisc.db2", HotfixStatements.SEL_SPELL_MISC);
@@ -642,6 +643,7 @@ namespace Game.DataStorage
public static DB6Storage<SpellInterruptsRecord> SpellInterruptsStorage; public static DB6Storage<SpellInterruptsRecord> SpellInterruptsStorage;
public static DB6Storage<SpellItemEnchantmentRecord> SpellItemEnchantmentStorage; public static DB6Storage<SpellItemEnchantmentRecord> SpellItemEnchantmentStorage;
public static DB6Storage<SpellItemEnchantmentConditionRecord> SpellItemEnchantmentConditionStorage; public static DB6Storage<SpellItemEnchantmentConditionRecord> SpellItemEnchantmentConditionStorage;
public static DB6Storage<SpellLabelRecord> SpellLabelStorage;
public static DB6Storage<SpellLearnSpellRecord> SpellLearnSpellStorage; public static DB6Storage<SpellLearnSpellRecord> SpellLearnSpellStorage;
public static DB6Storage<SpellLevelsRecord> SpellLevelsStorage; public static DB6Storage<SpellLevelsRecord> SpellLevelsStorage;
public static DB6Storage<SpellMiscRecord> SpellMiscStorage; public static DB6Storage<SpellMiscRecord> SpellMiscStorage;
@@ -359,6 +359,13 @@ namespace Game.DataStorage
public byte[] Logic = new byte[5]; public byte[] Logic = new byte[5];
} }
public sealed class SpellLabelRecord
{
public uint Id;
public uint LabelID;
public int SpellID;
}
public sealed class SpellLearnSpellRecord public sealed class SpellLearnSpellRecord
{ {
public uint Id; public uint Id;
+11 -1
View File
@@ -31,7 +31,7 @@ namespace Game.Spells
{ {
public class SpellInfo public class SpellInfo
{ {
public SpellInfo(SpellNameRecord spellName, Difficulty difficulty, SpellInfoLoadHelper data, List<SpellXSpellVisualRecord> visuals) public SpellInfo(SpellNameRecord spellName, Difficulty difficulty, SpellInfoLoadHelper data, List<SpellLabelRecord> labels, List<SpellXSpellVisualRecord> visuals)
{ {
Id = spellName.Id; Id = spellName.Id;
Difficulty = difficulty; Difficulty = difficulty;
@@ -185,6 +185,9 @@ namespace Game.Spells
ChannelInterruptFlags2 = (SpellAuraInterruptFlags2)_interrupt.ChannelInterruptFlags[1]; ChannelInterruptFlags2 = (SpellAuraInterruptFlags2)_interrupt.ChannelInterruptFlags[1];
} }
foreach (var label in labels)
Labels.Add(label.LabelID);
// SpellLevelsEntry // SpellLevelsEntry
SpellLevelsRecord _levels = data.Levels; SpellLevelsRecord _levels = data.Levels;
if (_levels != null) if (_levels != null)
@@ -3556,6 +3559,11 @@ namespace Game.Spells
return playerCondition == null || ConditionManager.IsPlayerMeetingCondition(player, playerCondition); return playerCondition == null || ConditionManager.IsPlayerMeetingCondition(player, playerCondition);
} }
public bool HasLabel(uint labelId)
{
return Labels.Contains(labelId);
}
public static SpellCastTargetFlags GetTargetFlagMask(SpellTargetObjectTypes objType) public static SpellCastTargetFlags GetTargetFlagMask(SpellTargetObjectTypes objType)
{ {
switch (objType) switch (objType)
@@ -3724,6 +3732,8 @@ namespace Game.Spells
public int RequiredAreasID { get; set; } public int RequiredAreasID { get; set; }
public SpellSchoolMask SchoolMask { get; set; } public SpellSchoolMask SchoolMask { get; set; }
public uint ChargeCategoryId; public uint ChargeCategoryId;
public List<uint> Labels = new();
// SpellScalingEntry // SpellScalingEntry
public ScalingInfo Scaling; public ScalingInfo Scaling;
public uint ExplicitTargetMask { get; set; } public uint ExplicitTargetMask { get; set; }
+9 -2
View File
@@ -2217,6 +2217,9 @@ namespace Game.Entities
foreach (SpellInterruptsRecord interrupts in CliDB.SpellInterruptsStorage.Values) foreach (SpellInterruptsRecord interrupts in CliDB.SpellInterruptsStorage.Values)
GetLoadHelper(interrupts.SpellID, interrupts.DifficultyID).Interrupts = interrupts; GetLoadHelper(interrupts.SpellID, interrupts.DifficultyID).Interrupts = interrupts;
foreach (SpellLabelRecord label in CliDB.SpellLabelStorage.Values)
GetLoadHelper(label.LabelID, 0).Labels.Add(label);
foreach (SpellLevelsRecord levels in CliDB.SpellLevelsStorage.Values) foreach (SpellLevelsRecord levels in CliDB.SpellLevelsStorage.Values)
GetLoadHelper(levels.SpellID, levels.DifficultyID).Levels = levels; GetLoadHelper(levels.SpellID, levels.DifficultyID).Levels = levels;
@@ -2270,7 +2273,8 @@ namespace Game.Entities
if (spellNameEntry == null) if (spellNameEntry == null)
continue; continue;
var visuals = data.Value.Visuals; // copy, need to ensure source remains unmodified var labels = new List<SpellLabelRecord>(data.Value.Labels); // copy, need to ensure source remains unmodified
var visuals = new List<SpellXSpellVisualRecord>(data.Value.Visuals); // copy, need to ensure source remains unmodified
// fill blanks // fill blanks
DifficultyRecord difficultyEntry = CliDB.DifficultyStorage.LookupByKey(data.Key.difficulty); DifficultyRecord difficultyEntry = CliDB.DifficultyStorage.LookupByKey(data.Key.difficulty);
@@ -2300,6 +2304,8 @@ namespace Game.Entities
if (data.Value.Interrupts == null) if (data.Value.Interrupts == null)
data.Value.Interrupts = fallbackData.Interrupts; data.Value.Interrupts = fallbackData.Interrupts;
labels.AddRange(fallbackData.Labels);
if (data.Value.Levels == null) if (data.Value.Levels == null)
data.Value.Levels = fallbackData.Levels; data.Value.Levels = fallbackData.Levels;
@@ -2324,7 +2330,7 @@ namespace Game.Entities
//second key = id //second key = id
mSpellInfoMap.Add(spellNameEntry.Id, new SpellInfo(spellNameEntry, data.Key.difficulty, data.Value, visuals)); mSpellInfoMap.Add(spellNameEntry.Id, new SpellInfo(spellNameEntry, data.Key.difficulty, data.Value, labels, visuals));
} }
Log.outInfo(LogFilter.ServerLoading, "Loaded SpellInfo store in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime)); Log.outInfo(LogFilter.ServerLoading, "Loaded SpellInfo store in {0} ms", Time.GetMSTimeDiffToNow(oldMSTime));
@@ -3999,6 +4005,7 @@ namespace Game.Entities
public SpellEffectRecord[] Effects = new SpellEffectRecord[SpellConst.MaxEffects]; public SpellEffectRecord[] Effects = new SpellEffectRecord[SpellConst.MaxEffects];
public SpellEquippedItemsRecord EquippedItems; public SpellEquippedItemsRecord EquippedItems;
public SpellInterruptsRecord Interrupts; public SpellInterruptsRecord Interrupts;
public List<SpellLabelRecord> Labels = new();
public SpellLevelsRecord Levels; public SpellLevelsRecord Levels;
public SpellMiscRecord Misc; public SpellMiscRecord Misc;
public SpellPowerRecord[] Powers = new SpellPowerRecord[SpellConst.MaxPowersPerSpell]; public SpellPowerRecord[] Powers = new SpellPowerRecord[SpellConst.MaxPowersPerSpell];
@@ -0,0 +1,14 @@
--
-- Table structure for table `spell_label`
--
DROP TABLE IF EXISTS `spell_label`;
/*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `spell_label` (
`ID` int(10) unsigned NOT NULL DEFAULT '0',
`LabelID` int(10) unsigned NOT NULL DEFAULT '0',
`SpellID` int(11) NOT NULL DEFAULT '0',
`VerifiedBuild` int(11) NOT NULL DEFAULT '0',
PRIMARY KEY (`ID`,`VerifiedBuild`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
/*!40101 SET character_set_client = @saved_cs_client */;