aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2021-06-04 21:18:29 +0200
committerShauren <shauren.trinity@gmail.com>2021-06-04 21:18:29 +0200
commite1f3f1254c3214c0a5b71db6de33f8900903d314 (patch)
tree22d284b13abf3fa99cda418e45307b8f499b1601
parenta0796179b33dd7042330d245b43e8c91534bf8b3 (diff)
Core/Spells: Load spell label data for future use
-rw-r--r--sql/updates/hotfixes/master/2021_06_04_01_hotfixes.sql14
-rw-r--r--src/server/database/Database/Implementation/HotfixDatabase.cpp4
-rw-r--r--src/server/database/Database/Implementation/HotfixDatabase.h3
-rw-r--r--src/server/game/DataStores/DB2LoadInfo.h15
-rw-r--r--src/server/game/DataStores/DB2Stores.cpp2
-rw-r--r--src/server/game/DataStores/DB2Stores.h1
-rw-r--r--src/server/game/DataStores/DB2Structure.h7
-rw-r--r--src/server/game/Spells/SpellInfo.cpp11
-rw-r--r--src/server/game/Spells/SpellInfo.h6
-rw-r--r--src/server/game/Spells/SpellMgr.cpp8
-rw-r--r--src/server/game/Spells/SpellMgr.h2
11 files changed, 70 insertions, 3 deletions
diff --git a/sql/updates/hotfixes/master/2021_06_04_01_hotfixes.sql b/sql/updates/hotfixes/master/2021_06_04_01_hotfixes.sql
new file mode 100644
index 00000000000..c0c6e8a73e0
--- /dev/null
+++ b/sql/updates/hotfixes/master/2021_06_04_01_hotfixes.sql
@@ -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 */;
diff --git a/src/server/database/Database/Implementation/HotfixDatabase.cpp b/src/server/database/Database/Implementation/HotfixDatabase.cpp
index eae49d12b2e..208d9ca486b 100644
--- a/src/server/database/Database/Implementation/HotfixDatabase.cpp
+++ b/src/server/database/Database/Implementation/HotfixDatabase.cpp
@@ -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);
diff --git a/src/server/database/Database/Implementation/HotfixDatabase.h b/src/server/database/Database/Implementation/HotfixDatabase.h
index 8d88f734343..e2d4a788865 100644
--- a/src/server/database/Database/Implementation/HotfixDatabase.h
+++ b/src/server/database/Database/Implementation/HotfixDatabase.h
@@ -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,
diff --git a/src/server/game/DataStores/DB2LoadInfo.h b/src/server/game/DataStores/DB2LoadInfo.h
index 516842ab861..309eddd40ee 100644
--- a/src/server/game/DataStores/DB2LoadInfo.h
+++ b/src/server/game/DataStores/DB2LoadInfo.h
@@ -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()
diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp
index bd8bba408b8..0e2ffc7222b 100644
--- a/src/server/game/DataStores/DB2Stores.cpp
+++ b/src/server/game/DataStores/DB2Stores.cpp
@@ -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);
diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h
index 640fe011a3d..99b29d64be7 100644
--- a/src/server/game/DataStores/DB2Stores.h
+++ b/src/server/game/DataStores/DB2Stores.h
@@ -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;
diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h
index 101a5db0656..5309cd12193 100644
--- a/src/server/game/DataStores/DB2Structure.h
+++ b/src/server/game/DataStores/DB2Structure.h
@@ -3072,6 +3072,13 @@ struct SpellItemEnchantmentConditionEntry
uint8 Logic[5];
};
+struct SpellLabelEntry
+{
+ uint32 ID;
+ uint32 LabelID;
+ int32 SpellID;
+};
+
struct SpellLearnSpellEntry
{
uint32 ID;
diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp
index 88a598204a1..dde1cda8a3a 100644
--- a/src/server/game/Spells/SpellInfo.cpp
+++ b/src/server/game/Spells/SpellInfo.cpp
@@ -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();
+}
diff --git a/src/server/game/Spells/SpellInfo.h b/src/server/game/Spells/SpellInfo.h
index fed3f40a459..48b36d89e9e 100644
--- a/src/server/game/Spells/SpellInfo.h
+++ b/src/server/game/Spells/SpellInfo.h
@@ -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();
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp
index 6dd3ff6128b..be712095f14 100644
--- a/src/server/game/Spells/SpellMgr.cpp
+++ b/src/server/game/Spells/SpellMgr.cpp
@@ -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));
diff --git a/src/server/game/Spells/SpellMgr.h b/src/server/game/Spells/SpellMgr.h
index a1f7a5d555d..4580f100c19 100644
--- a/src/server/game/Spells/SpellMgr.h
+++ b/src/server/game/Spells/SpellMgr.h
@@ -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;