From 9e63169e579bc29174ec0770c47c3daf84f776d3 Mon Sep 17 00:00:00 2001 From: ratkosrb Date: Thu, 26 Sep 2024 18:43:01 +0300 Subject: [PATCH] Drop spell_affect table. --- sql/migrations/20240926142033_world.sql | 137 ++++++++++++++++++++++++ src/game/Chat/Chat.cpp | 1 - src/game/Chat/Chat.h | 1 - src/game/Commands/ServerCommands.cpp | 9 -- src/game/Objects/Player.cpp | 6 +- src/game/Objects/Player.h | 2 +- src/game/Objects/SpellCaster.cpp | 18 ++-- src/game/Spells/Spell.cpp | 2 +- src/game/Spells/SpellAuras.cpp | 8 +- src/game/Spells/SpellAuras.h | 2 +- src/game/Spells/SpellEntry.h | 2 +- src/game/Spells/SpellMgr.cpp | 107 +----------------- src/game/Spells/SpellMgr.h | 8 -- src/game/Spells/SpellModMgr.cpp | 8 +- src/game/World.cpp | 3 - src/shared/Database/Field.h | 12 ++- 16 files changed, 177 insertions(+), 149 deletions(-) create mode 100644 sql/migrations/20240926142033_world.sql diff --git a/sql/migrations/20240926142033_world.sql b/sql/migrations/20240926142033_world.sql new file mode 100644 index 00000000000..0b62016a893 --- /dev/null +++ b/sql/migrations/20240926142033_world.sql @@ -0,0 +1,137 @@ +DROP PROCEDURE IF EXISTS add_migration; +DELIMITER ?? +CREATE PROCEDURE `add_migration`() +BEGIN +DECLARE v INT DEFAULT 1; +SET v = (SELECT COUNT(*) FROM `migrations` WHERE `id`='20240926142033'); +IF v = 0 THEN +INSERT INTO `migrations` VALUES ('20240926142033'); +-- Add your query below. + + +-- Make the column which holds the spell class mask for effects be uint64. +ALTER TABLE `spell_template` + CHANGE COLUMN `effectItemType1` `effectItemType1` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `effectChainTarget3`, + CHANGE COLUMN `effectItemType2` `effectItemType2` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `effectItemType1`, + CHANGE COLUMN `effectItemType3` `effectItemType3` BIGINT UNSIGNED NOT NULL DEFAULT '0' AFTER `effectItemType2`; + +-- Transfer spell class masks from spell_affect table to spell_template. +UPDATE `spell_template` T1, `spell_affect` T2 SET T1.`effectItemType1` = T2.`SpellFamilyMask` WHERE (T1.`entry` = T2.`entry`) && (T1.`build` BETWEEN T2.`build_min` AND T2.`build_max`) && (T2.`effectId` = 0); +UPDATE `spell_template` T1, `spell_affect` T2 SET T1.`effectItemType2` = T2.`SpellFamilyMask` WHERE (T1.`entry` = T2.`entry`) && (T1.`build` BETWEEN T2.`build_min` AND T2.`build_max`) && (T2.`effectId` = 1); +UPDATE `spell_template` T1, `spell_affect` T2 SET T1.`effectItemType3` = T2.`SpellFamilyMask` WHERE (T1.`entry` = T2.`entry`) && (T1.`build` BETWEEN T2.`build_min` AND T2.`build_max`) && (T2.`effectId` = 2); + +-- Get rid of no longer needed separate table. +DROP TABLE `spell_affect`; + +-- Change the mod table to use int64 as well. +ALTER TABLE `spell_effect_mod` + CHANGE COLUMN `EffectItemType` `EffectItemType` BIGINT NOT NULL DEFAULT '-1' AFTER `EffectApplyAuraName`; + +-- Correct spell class masks for effects in cases where its missing in vanilla Spell.dbc but present in classic SpellEffect.db2. +UPDATE `spell_template` SET `effectItemType1`=14684919 WHERE `entry`=15059 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2233056; -- Arcane Instability +UPDATE `spell_template` SET `effectItemType1`=14684919 WHERE `entry`=15058 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2233056; -- Arcane Instability +UPDATE `spell_template` SET `effectItemType1`=14684919 WHERE `entry`=15060 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2233056; -- Arcane Instability +UPDATE `spell_template` SET `effectItemType1`=14684919 WHERE `entry`=12042 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=551557879; -- Arcane Power +UPDATE `spell_template` SET `effectItemType1`=176162304 WHERE `entry`=20104 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=176161280; -- Benediction +UPDATE `spell_template` SET `effectItemType1`=176162304 WHERE `entry`=20101 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=176161280; -- Benediction +UPDATE `spell_template` SET `effectItemType1`=176162304 WHERE `entry`=20102 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=176161280; -- Benediction +UPDATE `spell_template` SET `effectItemType1`=176162304 WHERE `entry`=20103 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=176161280; -- Benediction +UPDATE `spell_template` SET `effectItemType1`=176162304 WHERE `entry`=20105 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=176161280; -- Benediction +UPDATE `spell_template` SET `effectItemType1`=4194325 WHERE `entry`=12351 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=12714007; -- Burning Soul +UPDATE `spell_template` SET `effectItemType1`=4194325 WHERE `entry`=11083 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=12714007; -- Burning Soul +UPDATE `spell_template` SET `effectItemType1`=4096 WHERE `entry`=28787 && `effect1`=6 && `effectApplyAuraName1`=109 && `effectItemType1`=8589934592; -- Cleanse +UPDATE `spell_template` SET `effectItemType1`=12589815 WHERE `entry`=12536 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=549460727; -- Clearcasting +UPDATE `spell_template` SET `effectItemType1`=12900875263 WHERE `entry`=16870 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=4512331310824191; -- Clearcasting +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=28682 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=4194327; -- Combustion +UPDATE `spell_template` SET `effectItemType1`=11813318656 WHERE `entry`=29197 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Corrupted Mind +UPDATE `spell_template` SET `effectItemType1`=34359738816 WHERE `entry`=29199 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Corrupted Mind +UPDATE `spell_template` SET `effectItemType1`=4450426437 WHERE `entry`=29184 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Corrupted Mind +UPDATE `spell_template` SET `effectItemType1`=25769804016 WHERE `entry`=29195 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Corrupted Mind +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11115 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=146931735; -- Critical Mass +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11367 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=146931735; -- Critical Mass +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11369 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=146931735; -- Critical Mass +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11370 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=146931735; -- Critical Mass +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11368 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=146931735; -- Critical Mass +UPDATE `spell_template` SET `effectItemType1`=8388608 WHERE `entry`=29588 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Defensive Tactics +UPDATE `spell_template` SET `effectItemType1`=8388608 WHERE `entry`=29589 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Defensive Tactics +UPDATE `spell_template` SET `effectItemType1`=8388608 WHERE `entry`=29559 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Defensive Tactics +UPDATE `spell_template` SET `effectItemType1`=3509583875 WHERE `entry`=16089 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=20723008519; -- Elemental Fury +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=12399 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=146931735; -- Fire Power +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=12400 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=146931735; -- Fire Power +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=11124 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=146931735; -- Fire Power +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=12378 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=146931735; -- Fire Power +UPDATE `spell_template` SET `effectItemType1`=12582935 WHERE `entry`=12398 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=146931735; -- Fire Power +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18218 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=6447547418; -- Grim Reach +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18219 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=6447547418; -- Grim Reach +UPDATE `spell_template` SET `effectItemType1`=12288 WHERE `entry`=26118 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=67108864; -- Implements of Unspoken Names Pet Bonus +UPDATE `spell_template` SET `effectItemType1`=37448586264 WHERE `entry`=30814 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2954368024; -- Mental Quickness +UPDATE `spell_template` SET `effectItemType1`=37448586264 WHERE `entry`=30812 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2954368024; -- Mental Quickness +UPDATE `spell_template` SET `effectItemType1`=37448586264 WHERE `entry`=30813 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=2954368024; -- Mental Quickness +UPDATE `spell_template` SET `effectItemType1`=151264832 WHERE `entry`=28808 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=17465351744; -- Reduced Threat +UPDATE `spell_template` SET `effectItemType1`=33685510 WHERE `entry`=28811 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=8388608; -- Reduced Threat +UPDATE `spell_template` SET `effectItemType1`=64 WHERE `entry`=28744 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Regrowth +UPDATE `spell_template` SET `effectItemType1`=16 WHERE `entry`=28716 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=0; -- Rejuvenation +UPDATE `spell_template` SET `effectItemType1`=145 WHERE `entry`=18271 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType1`=145 WHERE `entry`=18272 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType1`=145 WHERE `entry`=18275 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType1`=145 WHERE `entry`=18274 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType1`=145 WHERE `entry`=18273 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType1`=15208471 WHERE `entry`=11170 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=1090394871; -- Shatter +UPDATE `spell_template` SET `effectItemType1`=15208471 WHERE `entry`=12985 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=1090394871; -- Shatter +UPDATE `spell_template` SET `effectItemType1`=15208471 WHERE `entry`=12982 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=1090394871; -- Shatter +UPDATE `spell_template` SET `effectItemType1`=15208471 WHERE `entry`=12983 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=1090394871; -- Shatter +UPDATE `spell_template` SET `effectItemType1`=15208471 WHERE `entry`=12984 && `effect1`=6 && `effectApplyAuraName1`=112 && `effectItemType1`=1090394871; -- Shatter +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18174 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=6447531034; -- Suppression +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18175 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=6447531034; -- Suppression +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18177 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=6447531034; -- Suppression +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18176 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=6447531034; -- Suppression +UPDATE `spell_template` SET `effectItemType1`=6447219738 WHERE `entry`=18178 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=6447531034; -- Suppression +UPDATE `spell_template` SET `effectItemType1`=537399320 WHERE `entry`=28818 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=537395200; -- Totemic Energy +UPDATE `spell_template` SET `effectItemType1`=67624960 WHERE `entry`=16189 && `effect1`=6 && `effectApplyAuraName1`=107 && `effectItemType1`=67362816; -- Totemic Mastery +UPDATE `spell_template` SET `effectItemType1`=73728 WHERE `entry`=16515 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=34359861248; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType1`=73728 WHERE `entry`=16719 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=34359861248; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType1`=8192 WHERE `entry`=16513 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=34359861248; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType1`=73728 WHERE `entry`=16720 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=34359861248; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType1`=73728 WHERE `entry`=16514 && `effect1`=6 && `effectApplyAuraName1`=108 && `effectItemType1`=34359861248; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType2`=12589815 WHERE `entry`=12042 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=551557879; -- Arcane Power +UPDATE `spell_template` SET `effectItemType2`=12288 WHERE `entry`=20575 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=67108864; -- Command +UPDATE `spell_template` SET `effectItemType2`=100 WHERE `entry`=17955 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=824633725796; -- Emberstorm +UPDATE `spell_template` SET `effectItemType2`=100 WHERE `entry`=17954 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=824633725796; -- Emberstorm +UPDATE `spell_template` SET `effectItemType2`=100 WHERE `entry`=17957 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=824633725796; -- Emberstorm +UPDATE `spell_template` SET `effectItemType2`=100 WHERE `entry`=17956 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=824633725796; -- Emberstorm +UPDATE `spell_template` SET `effectItemType2`=100 WHERE `entry`=17958 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=824633725796; -- Emberstorm +UPDATE `spell_template` SET `effectItemType2`=0 WHERE `entry`=21942 && `effect2`=6 && `effectApplyAuraName2`=107 && `effectItemType2`=134217728; -- Hunter Giant Stalker +UPDATE `spell_template` SET `effectItemType2`=3221225472 WHERE `entry`=20215 && `effect2`=6 && `effectApplyAuraName2`=112 && `effectItemType2`=0; -- Illumination +UPDATE `spell_template` SET `effectItemType2`=3221225472 WHERE `entry`=20210 && `effect2`=6 && `effectApplyAuraName2`=112 && `effectItemType2`=0; -- Illumination +UPDATE `spell_template` SET `effectItemType2`=3221225472 WHERE `entry`=20212 && `effect2`=6 && `effectApplyAuraName2`=112 && `effectItemType2`=0; -- Illumination +UPDATE `spell_template` SET `effectItemType2`=3221225472 WHERE `entry`=20213 && `effect2`=6 && `effectApplyAuraName2`=112 && `effectItemType2`=0; -- Illumination +UPDATE `spell_template` SET `effectItemType2`=3221225472 WHERE `entry`=20214 && `effect2`=6 && `effectApplyAuraName2`=112 && `effectItemType2`=0; -- Illumination +UPDATE `spell_template` SET `effectItemType2`=17179869184 WHERE `entry`=29192 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=2097152; -- Improved Weapon Totems +UPDATE `spell_template` SET `effectItemType2`=17179869184 WHERE `entry`=29193 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=2097152; -- Improved Weapon Totems +UPDATE `spell_template` SET `effectItemType2`=4294968326 WHERE `entry`=28746 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=66566; -- Plagueheart +UPDATE `spell_template` SET `effectItemType2`=1048576 WHERE `entry`=14909 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=1048704; -- Searing Light +UPDATE `spell_template` SET `effectItemType2`=1048576 WHERE `entry`=15017 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=1048704; -- Searing Light +UPDATE `spell_template` SET `effectItemType2`=65536 WHERE `entry`=16515 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType2`=65536 WHERE `entry`=16719 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType2`=65536 WHERE `entry`=16513 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType2`=65536 WHERE `entry`=16720 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType2`=65536 WHERE `entry`=16514 && `effect2`=6 && `effectApplyAuraName2`=108 && `effectItemType2`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType3`=4194437 WHERE `entry`=12042 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=551557879; -- Arcane Power +UPDATE `spell_template` SET `effectItemType3`=4295509000 WHERE `entry`=18271 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType3`=4295509000 WHERE `entry`=18272 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType3`=4295509000 WHERE `entry`=18275 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType3`=4295509000 WHERE `entry`=18274 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType3`=4295509000 WHERE `entry`=18273 && `effect3`=6 && `effectApplyAuraName3`=108 && `effectItemType3`=0; -- Shadow Mastery +UPDATE `spell_template` SET `effectItemType3`=268550144 WHERE `entry`=16515 && `effect3`=6 && `effectApplyAuraName3`=107 && `effectItemType3`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType3`=268550144 WHERE `entry`=16719 && `effect3`=6 && `effectApplyAuraName3`=107 && `effectItemType3`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType3`=268550144 WHERE `entry`=16513 && `effect3`=6 && `effectApplyAuraName3`=107 && `effectItemType3`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType3`=268550144 WHERE `entry`=16720 && `effect3`=6 && `effectApplyAuraName3`=107 && `effectItemType3`=122880; -- Vile Poisons +UPDATE `spell_template` SET `effectItemType3`=268550144 WHERE `entry`=16514 && `effect3`=6 && `effectApplyAuraName3`=107 && `effectItemType3`=122880; -- Vile Poisons + + +-- End of migration. +END IF; +END?? +DELIMITER ; +CALL add_migration(); +DROP PROCEDURE IF EXISTS add_migration; diff --git a/src/game/Chat/Chat.cpp b/src/game/Chat/Chat.cpp index 590736cf340..3ee07a93b03 100644 --- a/src/game/Chat/Chat.cpp +++ b/src/game/Chat/Chat.cpp @@ -860,7 +860,6 @@ ChatCommand * ChatHandler::getCommandTable() { "reputation_spillover_template", SEC_DEVELOPER, true, &ChatHandler::HandleReloadReputationSpilloverTemplateCommand, "", nullptr }, { "skill_fishing_base_level", SEC_DEVELOPER, true, &ChatHandler::HandleReloadSkillFishingBaseLevelCommand, "", nullptr }, { "skinning_loot_template", SEC_DEVELOPER, true, &ChatHandler::HandleReloadLootTemplatesSkinningCommand, "", nullptr }, - { "spell_affect", SEC_DEVELOPER, true, &ChatHandler::HandleReloadSpellAffectCommand, "", nullptr }, { "spell_area", SEC_DEVELOPER, true, &ChatHandler::HandleReloadSpellAreaCommand, "", nullptr }, { "spell_chain", SEC_DEVELOPER, true, &ChatHandler::HandleReloadSpellChainCommand, "", nullptr }, { "spell_elixir", SEC_DEVELOPER, true, &ChatHandler::HandleReloadSpellElixirCommand, "", nullptr }, diff --git a/src/game/Chat/Chat.h b/src/game/Chat/Chat.h index 2af6b2d833f..e44f6d80677 100644 --- a/src/game/Chat/Chat.h +++ b/src/game/Chat/Chat.h @@ -854,7 +854,6 @@ class ChatHandler bool HandleReloadReputationRewardRateCommand(char* args); bool HandleReloadReputationSpilloverTemplateCommand(char* args); bool HandleReloadSkillFishingBaseLevelCommand(char* args); - bool HandleReloadSpellAffectCommand(char* args); bool HandleReloadSpellAreaCommand(char* args); bool HandleReloadSpellChainCommand(char* args); bool HandleReloadSpellElixirCommand(char* args); diff --git a/src/game/Commands/ServerCommands.cpp b/src/game/Commands/ServerCommands.cpp index b41944c4dff..321cd74a029 100644 --- a/src/game/Commands/ServerCommands.cpp +++ b/src/game/Commands/ServerCommands.cpp @@ -967,7 +967,6 @@ bool ChatHandler::HandleReloadAllScriptsCommand(char* /*args*/) bool ChatHandler::HandleReloadAllSpellCommand(char* /*args*/) { - HandleReloadSpellAffectCommand((char*)"a"); HandleReloadSpellAreaCommand((char*)"a"); HandleReloadSpellChainCommand((char*)"a"); HandleReloadSpellElixirCommand((char*)"a"); @@ -1358,14 +1357,6 @@ bool ChatHandler::HandleReloadSkillFishingBaseLevelCommand(char* /*args*/) return true; } -bool ChatHandler::HandleReloadSpellAffectCommand(char* /*args*/) -{ - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Re-Loading SpellAffect definitions..."); - sSpellMgr.LoadSpellAffects(); - SendSysMessage("DB table `spell_affect` (spell mods apply requirements) reloaded."); - return true; -} - bool ChatHandler::HandleReloadSpellAreaCommand(char* /*args*/) { sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Re-Loading SpellArea Data..."); diff --git a/src/game/Objects/Player.cpp b/src/game/Objects/Player.cpp index 3b365ca9156..541781806f6 100644 --- a/src/game/Objects/Player.cpp +++ b/src/game/Objects/Player.cpp @@ -412,7 +412,7 @@ SpellModifier::SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, A mask = sSpellMgr.GetSpellAffectMask(aura->GetId(), aura->GetEffIndex()); } -bool SpellModifier::isAffectedOnSpell(SpellEntry const* spell) const +bool SpellModifier::IsAffectedOnSpell(SpellEntry const* spell) const { SpellEntry const* affect_spell = sSpellMgr.GetSpellEntry(spellId); // False if affect_spell == nullptr or spellFamily not equal @@ -18058,7 +18058,7 @@ bool Player::HasInstantCastingSpellMod(SpellEntry const* spellInfo) const { for (const auto& mod : m_spellMods[SPELLMOD_CASTING_TIME]) { - if ((mod->type == SPELLMOD_PCT) && (mod->value <= -100) && mod->isAffectedOnSpell(spellInfo)) + if ((mod->type == SPELLMOD_PCT) && (mod->value <= -100) && mod->IsAffectedOnSpell(spellInfo)) return true; } return false; @@ -18079,7 +18079,7 @@ bool Player::IsAffectedBySpellmod(SpellEntry const* spellInfo, SpellModifier con return false; } - return mod->isAffectedOnSpell(spellInfo); + return mod->IsAffectedOnSpell(spellInfo); } void Player::AddSpellMod(SpellModifier* mod, bool apply) diff --git a/src/game/Objects/Player.h b/src/game/Objects/Player.h index a6da880bf81..0fadffb4825 100644 --- a/src/game/Objects/Player.h +++ b/src/game/Objects/Player.h @@ -127,7 +127,7 @@ struct SpellModifier SpellModifier(SpellModOp _op, SpellModType _type, int32 _value, Aura* aura, int16 _charges = 0); - bool isAffectedOnSpell(SpellEntry const* spell) const; + bool IsAffectedOnSpell(SpellEntry const* spell) const; SpellModOp op : 8; SpellModType type : 8; diff --git a/src/game/Objects/SpellCaster.cpp b/src/game/Objects/SpellCaster.cpp index 846d898d78e..939604c23e1 100644 --- a/src/game/Objects/SpellCaster.cpp +++ b/src/game/Objects/SpellCaster.cpp @@ -1221,7 +1221,7 @@ float SpellCaster::SpellHealingBonusDone(Unit const* pVictim, SpellEntry const* Unit::AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (const auto i : mOverrideClassScript) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->IsAffectedOnSpell(spellProto)) continue; switch (i->GetModifier()->m_miscvalue) { @@ -1363,17 +1363,17 @@ float SpellCaster::SpellDamageBonusDone(Unit const* pVictim, SpellEntry const* s Unit::AuraList const& mOverrideClassScript = owner->GetAurasByType(SPELL_AURA_OVERRIDE_CLASS_SCRIPTS); for (const auto i : mOverrideClassScript) { - if (!i->isAffectedOnSpell(spellProto)) + if (!i->IsAffectedOnSpell(spellProto)) continue; switch (i->GetModifier()->m_miscvalue) { - case 4418: // Increased Shock Damage - case 4554: // Increased Lightning Damage - case 4555: // Improved Moonfire - { - DoneTotal += i->GetModifier()->m_amount; - break; - } + case 4418: // Increased Shock Damage + case 4554: // Increased Lightning Damage + case 4555: // Improved Moonfire + { + DoneTotal += i->GetModifier()->m_amount; + break; + } } } } diff --git a/src/game/Spells/Spell.cpp b/src/game/Spells/Spell.cpp index 5aa77f2d33a..ad5f3832e47 100644 --- a/src/game/Spells/Spell.cpp +++ b/src/game/Spells/Spell.cpp @@ -4651,7 +4651,7 @@ void Spell::HandleAddTargetTriggerAuras() auto const& targetTriggers = m_casterUnit->GetAurasByType(SPELL_AURA_ADD_TARGET_TRIGGER); for (const auto targetTrigger : targetTriggers) { - if (!targetTrigger->isAffectedOnSpell(m_spellInfo)) + if (!targetTrigger->IsAffectedOnSpell(m_spellInfo)) continue; for (const auto& ihit : m_UniqueTargetInfo) { diff --git a/src/game/Spells/SpellAuras.cpp b/src/game/Spells/SpellAuras.cpp index 1171f28f609..436379eb436 100644 --- a/src/game/Spells/SpellAuras.cpp +++ b/src/game/Spells/SpellAuras.cpp @@ -933,10 +933,10 @@ void Aura::ApplyModifier(bool apply, bool Real, bool skipCheckExclusive) GetHolder()->SetInUse(false); } -bool Aura::isAffectedOnSpell(SpellEntry const* spell) const +bool Aura::IsAffectedOnSpell(SpellEntry const* spell) const { if (m_spellmod) - return m_spellmod->isAffectedOnSpell(spell); + return m_spellmod->IsAffectedOnSpell(spell); // Check family name if (spell->SpellFamilyName != GetSpellProto()->SpellFamilyName) @@ -948,7 +948,7 @@ bool Aura::isAffectedOnSpell(SpellEntry const* spell) const bool Aura::CanProcFrom(SpellEntry const* spell, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const { - // Check EffectClassMask (in pre-3.x stored in spell_affect in fact) + // Check EffectClassMask (stored in EffectItemType) uint64 mask = sSpellMgr.GetSpellAffectMask(GetId(), GetEffIndex()); // Nostalrius: c'est la moindre des choses d'utiliser un peu 'spell_proc_event' non ? @@ -1002,7 +1002,7 @@ void Aura::ReapplyAffectedPassiveAuras(Unit* target) // and affected by aura itr->second->GetCasterGuid() == target->GetObjectGuid() && // and affected by spellmod - isAffectedOnSpell(itr->second->GetSpellProto())) + IsAffectedOnSpell(itr->second->GetSpellProto())) affectedSelf[itr->second->GetId()] = itr->second->GetCastItemGuid(); } diff --git a/src/game/Spells/SpellAuras.h b/src/game/Spells/SpellAuras.h index 62f234323d5..30ad53bdee5 100644 --- a/src/game/Spells/SpellAuras.h +++ b/src/game/Spells/SpellAuras.h @@ -533,7 +533,7 @@ class Aura void TriggerSpell(); // more limited that used in future versions (spell_affect table based only), so need be careful with backporting uses - bool isAffectedOnSpell(SpellEntry const* spell) const; + bool IsAffectedOnSpell(SpellEntry const* spell) const; bool CanProcFrom(SpellEntry const* spell, uint32 EventProcEx, uint32 procEx, bool active, bool useClassMask) const; SpellAuraHolder* GetHolder() const { return m_spellAuraHolder; } diff --git a/src/game/Spells/SpellEntry.h b/src/game/Spells/SpellEntry.h index 1763c1d1df5..1c7e6e9acf9 100644 --- a/src/game/Spells/SpellEntry.h +++ b/src/game/Spells/SpellEntry.h @@ -611,7 +611,7 @@ class SpellEntry uint32 EffectAmplitude[MAX_EFFECT_INDEX] = {}; // 97-99 float EffectMultipleValue[MAX_EFFECT_INDEX] = {}; // 100-102 uint32 EffectChainTarget[MAX_EFFECT_INDEX] = {}; // 103-105 - uint32 EffectItemType[MAX_EFFECT_INDEX] = {}; // 106-108 + uint64 EffectItemType[MAX_EFFECT_INDEX] = {}; // 106-108 int32 EffectMiscValue[MAX_EFFECT_INDEX] = {}; // 109-111 uint32 EffectTriggerSpell[MAX_EFFECT_INDEX] = {}; // 112-114 float EffectPointsPerComboPoint[MAX_EFFECT_INDEX] = {};// 115-117 diff --git a/src/game/Spells/SpellMgr.cpp b/src/game/Spells/SpellMgr.cpp index 1090bfb0310..31a1229ca4b 100644 --- a/src/game/Spells/SpellMgr.cpp +++ b/src/game/Spells/SpellMgr.cpp @@ -3043,107 +3043,6 @@ bool SpellArea::IsFitToRequirements(Player const* player, uint32 newZone, uint32 return true; } -void SpellMgr::LoadSpellAffects() -{ - mSpellAffectMap.clear(); // need for reload case - - uint32 count = 0; - - // 0 1 2 - std::unique_ptr result(WorldDatabase.PQuery("SELECT `entry`, `effectId`, `SpellFamilyMask` FROM `spell_affect` WHERE (`build_min` <= %u) && (`build_max` >= %u)", SUPPORTED_CLIENT_BUILD, SUPPORTED_CLIENT_BUILD)); - if (!result) - { - - BarGoLink bar(1); - - bar.step(); - - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, ""); - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, ">> Loaded %u spell affect definitions", count); - return; - } - - BarGoLink bar(result->GetRowCount()); - - do - { - Field* fields = result->Fetch(); - - bar.step(); - - uint32 entry = fields[0].GetUInt32(); - uint8 effectId = fields[1].GetUInt8(); - - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(entry); - - if (!spellInfo) - { - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Spell %u listed in `spell_affect` does not exist", entry); - continue; - } - - if (effectId >= MAX_EFFECT_INDEX) - { - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Spell %u listed in `spell_affect` have invalid effect index (%u)", entry, effectId); - continue; - } - - if (spellInfo->Effect[effectId] != SPELL_EFFECT_APPLY_AURA || ( - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_FLAT_MODIFIER && - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_PCT_MODIFIER && - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_TARGET_TRIGGER && - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_OVERRIDE_CLASS_SCRIPTS)) - { - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Spell %u listed in `spell_affect` have not SPELL_AURA_ADD_FLAT_MODIFIER (%u) or SPELL_AURA_ADD_PCT_MODIFIER (%u) or SPELL_AURA_ADD_TARGET_TRIGGER (%u) or SPELL_AURA_OVERRIDE_CLASS_SCRIPTS (%u) for effect index (%u)", entry, SPELL_AURA_ADD_FLAT_MODIFIER, SPELL_AURA_ADD_PCT_MODIFIER, SPELL_AURA_ADD_TARGET_TRIGGER, SPELL_AURA_OVERRIDE_CLASS_SCRIPTS, effectId); - continue; - } - - uint64 spellAffectMask = fields[2].GetUInt64(); - - // Spell.dbc have own data for low part of SpellFamilyMask - if (spellInfo->EffectItemType[effectId]) - { - if (static_cast(spellInfo->EffectItemType[effectId]) == spellAffectMask) - { - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Spell %u listed in `spell_affect` have redundant (same with EffectItemType%d) data for effect index (%u) and not needed, skipped.", entry, effectId + 1, effectId); - continue; - } - } - - mSpellAffectMap.insert(SpellAffectMap::value_type((entry << 8) + effectId, spellAffectMask)); - - ++count; - } - while (result->NextRow()); - - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, ""); - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, ">> Loaded %u spell affect definitions", count); - - for (uint32 id = 0; id < sSpellMgr.GetMaxSpellId(); ++id) - { - SpellEntry const* spellInfo = sSpellMgr.GetSpellEntry(id); - if (!spellInfo) - continue; - - for (uint8 effectId = 0; effectId < MAX_EFFECT_INDEX; ++effectId) - { - if (spellInfo->Effect[effectId] != SPELL_EFFECT_APPLY_AURA || ( - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_FLAT_MODIFIER && - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_PCT_MODIFIER && - spellInfo->EffectApplyAuraName[effectId] != SPELL_AURA_ADD_TARGET_TRIGGER)) - continue; - - if (spellInfo->EffectItemType[effectId] != 0) - continue; - - if (mSpellAffectMap.find((id << 8) + effectId) != mSpellAffectMap.end()) - continue; - - sLog.Out(LOG_DBERROR, LOG_LVL_MINIMAL, "Spell %u (%s) misses spell_affect for effect %u", id, spellInfo->SpellName[sWorld.GetDefaultDbcLocale()].c_str(), effectId); - } - } -} - void SpellMgr::LoadExistingSpellIds() { mExistingSpellsSet.clear(); @@ -3841,9 +3740,9 @@ void SpellMgr::LoadSpells() spell->EffectChainTarget[0] = fields[104].GetUInt32(); spell->EffectChainTarget[1] = fields[105].GetUInt32(); spell->EffectChainTarget[2] = fields[106].GetUInt32(); - spell->EffectItemType[0] = fields[107].GetUInt32(); - spell->EffectItemType[1] = fields[108].GetUInt32(); - spell->EffectItemType[2] = fields[109].GetUInt32(); + spell->EffectItemType[0] = fields[107].GetUInt64(); + spell->EffectItemType[1] = fields[108].GetUInt64(); + spell->EffectItemType[2] = fields[109].GetUInt64(); spell->EffectMiscValue[0] = fields[110].GetInt32(); spell->EffectMiscValue[1] = fields[111].GetInt32(); spell->EffectMiscValue[2] = fields[112].GetInt32(); diff --git a/src/game/Spells/SpellMgr.h b/src/game/Spells/SpellMgr.h index db400c88bc7..dc437d0d83d 100644 --- a/src/game/Spells/SpellMgr.h +++ b/src/game/Spells/SpellMgr.h @@ -39,9 +39,6 @@ class Player; class Spell; class Unit; -// Spell affects related declarations (accessed using SpellMgr functions) -typedef std::map SpellAffectMap; - struct SpellProcEventEntry { uint32 schoolMask; @@ -391,9 +388,6 @@ class SpellMgr // Spell affects uint64 GetSpellAffectMask(uint32 spellId, SpellEffectIndex effectId) const { - SpellAffectMap::const_iterator itr = mSpellAffectMap.find((spellId<<8) + effectId); - if (itr != mSpellAffectMap.end()) - return itr->second; if (SpellEntry const* spellEntry = GetSpellEntry(spellId)) return spellEntry->EffectItemType[effectId]; return 0; @@ -682,7 +676,6 @@ class SpellMgr void LoadSpellLearnSkills(); void LoadSpellLearnSpells(); void LoadSpellScriptTarget(); - void LoadSpellAffects(); void LoadSpellElixirs(); void LoadSpellProcEvents(); void LoadSpellProcItemEnchant(); @@ -729,7 +722,6 @@ class SpellMgr SpellLearnSkillMap mSpellLearnSkills; SpellLearnSpellMap mSpellLearnSpells; SpellTargetPositionMap mSpellTargetPositions; - SpellAffectMap mSpellAffectMap; SpellElixirMap mSpellElixirs; SpellThreatMap mSpellThreatMap; SpellProcEventMap mSpellProcEventMap; diff --git a/src/game/Spells/SpellModMgr.cpp b/src/game/Spells/SpellModMgr.cpp index f0631ae6f88..300d88ca15e 100644 --- a/src/game/Spells/SpellModMgr.cpp +++ b/src/game/Spells/SpellModMgr.cpp @@ -45,6 +45,12 @@ SpellModMgr::~SpellModMgr() SQL : cf sql/nostalrius/spell_mod.sql et sql/nostalrius/spell_effect_mod.sql */ +inline void ModUInt64ValueIfExplicit(Field &f, uint64& value) +{ + if (f.GetInt64() >= 0) + value = f.GetUInt64(); +} + inline void ModUInt32ValueIfExplicit(Field &f, uint32& value) { if (f.GetInt32() >= 0) @@ -238,7 +244,7 @@ void SpellModMgr::LoadSpellMods() // 7 8 9 10 // EffectRadiusIndex, EffectItemType, EffectMiscValue, EffectTriggerSpell ModUInt32ValueIfExplicit(fields[7], spell->EffectRadiusIndex[effect_idx]); - ModUInt32ValueIfExplicit(fields[8], spell->EffectItemType[effect_idx]); + ModUInt64ValueIfExplicit(fields[8], spell->EffectItemType[effect_idx]); ModInt32ValueIfExplicit(fields[9], spell->EffectMiscValue[effect_idx]); ModUInt32ValueIfExplicit(fields[10], spell->EffectTriggerSpell[effect_idx]); diff --git a/src/game/World.cpp b/src/game/World.cpp index 28169c4a2b7..5b87a1b9c78 100644 --- a/src/game/World.cpp +++ b/src/game/World.cpp @@ -1599,9 +1599,6 @@ void World::SetInitialWorldSettings() sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Loading spell target destination coordinates..."); sSpellMgr.LoadSpellTargetPositions(); - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Loading SpellAffect definitions..."); - sSpellMgr.LoadSpellAffects(); - sLog.Out(LOG_BASIC, LOG_LVL_MINIMAL, "Loading spell pet auras..."); sSpellMgr.LoadSpellPetAuras(); diff --git a/src/shared/Database/Field.h b/src/shared/Database/Field.h index f070d78a276..a5974bebe83 100644 --- a/src/shared/Database/Field.h +++ b/src/shared/Database/Field.h @@ -52,11 +52,19 @@ class Field } float GetFloat() const { return mValue ? static_cast(atof(mValue)) : 0.0f; } bool GetBool() const { return mValue ? atoi(mValue) > 0 : false; } - int32 GetInt32() const { return mValue ? static_cast(atol(mValue)) : int32(0); } uint8 GetUInt8() const { return mValue ? static_cast(atol(mValue)) : uint8(0); } - uint16 GetUInt16() const { return mValue ? static_cast(atol(mValue)) : uint16(0); } int16 GetInt16() const { return mValue ? static_cast(atol(mValue)) : int16(0); } + uint16 GetUInt16() const { return mValue ? static_cast(atol(mValue)) : uint16(0); } + int32 GetInt32() const { return mValue ? static_cast(atol(mValue)) : int32(0); } uint32 GetUInt32() const { return mValue ? static_cast(atol(mValue)) : uint32(0); } + int64 GetInt64() const + { + int64 value = 0; + if (!mValue || sscanf(mValue, SI64FMTD, &value) == -1) + return 0; + + return value; + } uint64 GetUInt64() const { uint64 value = 0;