Core/Spells: Load spell label data for future use

This commit is contained in:
Shauren
2021-06-04 21:18:29 +02:00
parent a0796179b3
commit e1f3f1254c
11 changed files with 70 additions and 3 deletions

View File

@@ -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 */;

View File

@@ -1331,6 +1331,10 @@ void HotfixDatabaseConnection::DoPrepareStatements()
"Logic1, Logic2, Logic3, Logic4, Logic5 FROM spell_item_enchantment_condition WHERE (`VerifiedBuild` > 0) = ?", CONNECTION_SYNCH);
PREPARE_MAX_ID_STMT(HOTFIX_SEL_SPELL_ITEM_ENCHANTMENT_CONDITION, "SELECT MAX(ID) + 1 FROM spell_item_enchantment_condition", CONNECTION_SYNCH);
// SpellLabel.db2
PrepareStatement(HOTFIX_SEL_SPELL_LABEL, "SELECT ID, LabelID, SpellID FROM spell_label WHERE (`VerifiedBuild` > 0) = ?", CONNECTION_SYNCH);
PREPARE_MAX_ID_STMT(HOTFIX_SEL_SPELL_LABEL, "SELECT MAX(ID) + 1 FROM spell_label", CONNECTION_SYNCH);
// SpellLearnSpell.db2
PrepareStatement(HOTFIX_SEL_SPELL_LEARN_SPELL, "SELECT ID, SpellID, LearnSpellID, OverridesSpellID FROM spell_learn_spell"
" WHERE (`VerifiedBuild` > 0) = ?", CONNECTION_SYNCH);

View File

@@ -772,6 +772,9 @@ enum HotfixDatabaseStatements : uint32
HOTFIX_SEL_SPELL_ITEM_ENCHANTMENT_CONDITION,
HOTFIX_SEL_SPELL_ITEM_ENCHANTMENT_CONDITION_MAX_ID,
HOTFIX_SEL_SPELL_LABEL,
HOTFIX_SEL_SPELL_LABEL_MAX_ID,
HOTFIX_SEL_SPELL_LEARN_SPELL,
HOTFIX_SEL_SPELL_LEARN_SPELL_MAX_ID,

View File

@@ -5126,6 +5126,21 @@ struct SpellItemEnchantmentConditionLoadInfo
}
};
struct SpellLabelLoadInfo
{
static DB2LoadInfo const* Instance()
{
static DB2FieldMeta const fields[] =
{
{ false, FT_INT, "ID" },
{ false, FT_INT, "LabelID" },
{ true, FT_INT, "SpellID" },
};
static DB2LoadInfo const loadInfo(&fields[0], std::extent<decltype(fields)>::value, SpellLabelMeta::Instance(), HOTFIX_SEL_SPELL_LABEL);
return &loadInfo;
}
};
struct SpellLearnSpellLoadInfo
{
static DB2LoadInfo const* Instance()

View File

@@ -267,6 +267,7 @@ DB2Storage<SpellFocusObjectEntry> sSpellFocusObjectStore("SpellFoc
DB2Storage<SpellInterruptsEntry> sSpellInterruptsStore("SpellInterrupts.db2", SpellInterruptsLoadInfo::Instance());
DB2Storage<SpellItemEnchantmentEntry> sSpellItemEnchantmentStore("SpellItemEnchantment.db2", SpellItemEnchantmentLoadInfo::Instance());
DB2Storage<SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore("SpellItemEnchantmentCondition.db2", SpellItemEnchantmentConditionLoadInfo::Instance());
DB2Storage<SpellLabelEntry> sSpellLabelStore("SpellLabel.db2", SpellLabelLoadInfo::Instance());
DB2Storage<SpellLearnSpellEntry> sSpellLearnSpellStore("SpellLearnSpell.db2", SpellLearnSpellLoadInfo::Instance());
DB2Storage<SpellLevelsEntry> sSpellLevelsStore("SpellLevels.db2", SpellLevelsLoadInfo::Instance());
DB2Storage<SpellMiscEntry> sSpellMiscStore("SpellMisc.db2", SpellMiscLoadInfo::Instance());
@@ -809,6 +810,7 @@ uint32 DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaul
LOAD_DB2(sSpellInterruptsStore);
LOAD_DB2(sSpellItemEnchantmentStore);
LOAD_DB2(sSpellItemEnchantmentConditionStore);
LOAD_DB2(sSpellLabelStore);
LOAD_DB2(sSpellLearnSpellStore);
LOAD_DB2(sSpellLevelsStore);
LOAD_DB2(sSpellMiscStore);

View File

@@ -197,6 +197,7 @@ TC_GAME_API extern DB2Storage<SpellFocusObjectEntry> sSpellFocusO
TC_GAME_API extern DB2Storage<SpellInterruptsEntry> sSpellInterruptsStore;
TC_GAME_API extern DB2Storage<SpellItemEnchantmentEntry> sSpellItemEnchantmentStore;
TC_GAME_API extern DB2Storage<SpellItemEnchantmentConditionEntry> sSpellItemEnchantmentConditionStore;
TC_GAME_API extern DB2Storage<SpellLabelEntry> sSpellLabelStore;
TC_GAME_API extern DB2Storage<SpellLearnSpellEntry> sSpellLearnSpellStore;
TC_GAME_API extern DB2Storage<SpellLevelsEntry> sSpellLevelsStore;
TC_GAME_API extern DB2Storage<SpellMiscEntry> sSpellMiscStore;

View File

@@ -3072,6 +3072,13 @@ struct SpellItemEnchantmentConditionEntry
uint8 Logic[5];
};
struct SpellLabelEntry
{
uint32 ID;
uint32 LabelID;
int32 SpellID;
};
struct SpellLearnSpellEntry
{
uint32 ID;

View File

@@ -1079,7 +1079,8 @@ SpellEffectInfo::StaticData SpellEffectInfo::_data[TOTAL_SPELL_EFFECTS] =
{EFFECT_IMPLICIT_TARGET_EXPLICIT, TARGET_OBJECT_TYPE_UNIT}, // 283 SPELL_EFFECT_COMPLETE_CAMPAIGN
};
SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data, SpellVisualVector&& visuals)
SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data,
std::vector<SpellLabelEntry const*> const& labels, SpellVisualVector&& visuals)
: Id(spellName->ID), Difficulty(difficulty)
{
_effects.reserve(32);
@@ -1219,6 +1220,9 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S
ChannelInterruptFlags2 = SpellAuraInterruptFlags2(_interrupt->ChannelInterruptFlags[1]);
}
for (SpellLabelEntry const* label : labels)
Labels.insert(label->LabelID);
// SpellLevelsEntry
if (SpellLevelsEntry const* _levels = data.Levels)
{
@@ -4652,3 +4656,8 @@ bool SpellInfo::MeetsFutureSpellPlayerCondition(Player const* player) const
PlayerConditionEntry const* playerCondition = sPlayerConditionStore.LookupEntry(ShowFutureSpellPlayerConditionID);
return !playerCondition || ConditionMgr::IsPlayerMeetingCondition(player, playerCondition);
}
bool SpellInfo::HasLabel(uint32 labelId) const
{
return Labels.find(labelId) != Labels.end();
}

View File

@@ -457,6 +457,7 @@ class TC_GAME_API SpellInfo
int32 RequiredAreasID = -1;
uint32 SchoolMask = 0;
uint32 ChargeCategoryId = 0;
std::unordered_set<uint32> Labels;
// SpellScalingEntry
struct ScalingInfo
@@ -470,7 +471,8 @@ class TC_GAME_API SpellInfo
uint32 ExplicitTargetMask = 0;
SpellChainNode const* ChainEntry = nullptr;
SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data, SpellVisualVector&& visuals);
SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, SpellInfoLoadHelper const& data,
std::vector<SpellLabelEntry const*> const& labels, SpellVisualVector&& visuals);
SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, std::vector<SpellEffectEntry> const& effects);
~SpellInfo();
@@ -631,6 +633,8 @@ class TC_GAME_API SpellInfo
// Player Condition
bool MeetsFutureSpellPlayerCondition(Player const* player) const;
bool HasLabel(uint32 labelId) const;
private:
// loading helpers
void _InitializeExplicitTargetMask();

View File

@@ -2515,6 +2515,9 @@ void SpellMgr::LoadSpellInfoStore()
for (SpellInterruptsEntry const* interrupts : sSpellInterruptsStore)
loadData[{ interrupts->SpellID, Difficulty(interrupts->DifficultyID) }].Interrupts = interrupts;
for (SpellLabelEntry const* label : sSpellLabelStore)
loadData[{ label->LabelID, DIFFICULTY_NONE }].Labels.push_back(label);
for (SpellLevelsEntry const* levels : sSpellLevelsStore)
loadData[{ levels->SpellID, Difficulty(levels->DifficultyID) }].Levels = levels;
@@ -2568,6 +2571,7 @@ void SpellMgr::LoadSpellInfoStore()
if (!spellNameEntry)
continue;
std::vector<SpellLabelEntry const*> labels = data.second.Labels; // copy, need to ensure source remains unmodified
SpellVisualVector visuals = data.second.Visuals; // copy, need to ensure source remains unmodified
// fill blanks
@@ -2596,6 +2600,8 @@ void SpellMgr::LoadSpellInfoStore()
if (!data.second.Interrupts)
data.second.Interrupts = fallbackData->Interrupts;
labels.insert(labels.end(), fallbackData->Labels.begin(), fallbackData->Labels.end());
if (!data.second.Levels)
data.second.Levels = fallbackData->Levels;
@@ -2616,7 +2622,7 @@ void SpellMgr::LoadSpellInfoStore()
} while (difficultyEntry);
}
mSpellInfoMap.emplace(spellNameEntry, data.first.second, data.second, std::move(visuals));
mSpellInfoMap.emplace(spellNameEntry, data.first.second, data.second, labels, std::move(visuals));
}
TC_LOG_INFO("server.loading", ">> Loaded SpellInfo store in %u ms", GetMSTimeDiffToNow(oldMSTime));

View File

@@ -50,6 +50,7 @@ struct SpellCooldownsEntry;
struct SpellEffectEntry;
struct SpellEquippedItemsEntry;
struct SpellInterruptsEntry;
struct SpellLabelEntry;
struct SpellLevelsEntry;
struct SpellMiscEntry;
struct SpellNameEntry;
@@ -613,6 +614,7 @@ struct SpellInfoLoadHelper
std::array<SpellEffectEntry const*, MAX_SPELL_EFFECTS> Effects = { };
SpellEquippedItemsEntry const* EquippedItems = nullptr;
SpellInterruptsEntry const* Interrupts = nullptr;
std::vector<SpellLabelEntry const*> Labels;
SpellLevelsEntry const* Levels = nullptr;
SpellMiscEntry const* Misc = nullptr;
std::array<SpellPowerEntry const*, MAX_POWERS_PER_SPELL> Powers;