diff options
author | Shauren <shauren.trinity@gmail.com> | 2021-03-16 00:07:34 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2021-03-16 00:07:34 +0100 |
commit | c7d1cf74575b4af8f4605d57a320ef68b4edbdaf (patch) | |
tree | 3d6faec1c3df2cebed93eca6eda507bc48590cf0 /src | |
parent | 0c73895826f691b529026abddf4a64828e7c75ad (diff) |
Core/Spells: Fixed startup crash and log any future attempts to apply data corrections to nonexisting spell effects
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Spells/SpellMgr.cpp | 328 |
1 files changed, 261 insertions, 67 deletions
diff --git a/src/server/game/Spells/SpellMgr.cpp b/src/server/game/Spells/SpellMgr.cpp index 9606ce08971..3b1d3a1f91b 100644 --- a/src/server/game/Spells/SpellMgr.cpp +++ b/src/server/game/Spells/SpellMgr.cpp @@ -3204,6 +3204,18 @@ inline void ApplySpellFix(std::initializer_list<uint32> spellIds, void(*fix)(Spe } } +inline void ApplySpellEffectFix(SpellInfo* spellInfo, SpellEffIndex effectIndex, void(*fix)(SpellEffectInfo*)) +{ + SpellEffectInfo const* effect = spellInfo->GetEffect(effectIndex); + if (!effect) + { + TC_LOG_ERROR("server.loading", "Spell effect info correction specified for non-existing effect %u of spell %u", uint32(effectIndex), spellInfo->Id); + return; + } + + fix(const_cast<SpellEffectInfo*>(effect)); +} + void SpellMgr::LoadSpellInfoCorrections() { uint32 oldMSTime = getMSTime(); @@ -3224,24 +3236,40 @@ void SpellMgr::LoadSpellInfoCorrections() 65755 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->ApplyAuraPeriod = 1 * IN_MILLISECONDS; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraPeriod = 1 * IN_MILLISECONDS; + }); }); ApplySpellFix({ 24707, // Food 26263, // Dim Sum - 29055, // Refreshing Red Apple - 37504 // Karazhan - Chess NPC AI, action timer + 29055 // Refreshing Red Apple }, [](SpellInfo* spellInfo) { - // first effect has correct amplitude - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->ApplyAuraPeriod = const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->ApplyAuraPeriod; + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraPeriod = 1 * IN_MILLISECONDS; + }); + }); + + // Karazhan - Chess NPC AI, action timer + ApplySpellFix({ 37504 }, [](SpellInfo* spellInfo) + { + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraPeriod = 5 * IN_MILLISECONDS; + }); }); // Vomit ApplySpellFix({ 43327 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->ApplyAuraPeriod = 1 * IN_MILLISECONDS; + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraPeriod = 1 * IN_MILLISECONDS; + }); }); } @@ -3250,37 +3278,56 @@ void SpellMgr::LoadSpellInfoCorrections() // Brood Affliction: Bronze ApplySpellFix({ 23170 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 23171; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 23171; + }); }); // Feed Captured Animal ApplySpellFix({ 29917 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 29916; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 29916; + }); }); // Remote Toy ApplySpellFix({ 37027 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 37029; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 37029; + }); }); // Eye of Grillok ApplySpellFix({ 38495 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 38530; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 38530; + }); }); // Tear of Azzinoth Summon Channel - it's not really supposed to do anything, and this only prevents the console spam ApplySpellFix({ 39857 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 39856; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 39856; + }); }); // Personalized Weather ApplySpellFix({ 46736 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->TriggerSpell = 46737; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 46737; + spellEffectInfo->ApplyAuraName = SPELL_AURA_PERIODIC_TRIGGER_SPELL; + }); }); } @@ -3289,13 +3336,19 @@ void SpellMgr::LoadSpellInfoCorrections() 63137 // Summon Valiant Test (HACK: Target shouldn't be changed; summon position should be untied from spell destination) }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + }); }); // Summon Skeletons ApplySpellFix({ 52611, 52612 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->MiscValueB = 64; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->MiscValueB = 64; + }); }); ApplySpellFix({ @@ -3306,7 +3359,10 @@ void SpellMgr::LoadSpellInfoCorrections() 42835 // Spout, remove damage effect, only anim is needed }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); ApplySpellFix({ @@ -3317,8 +3373,11 @@ void SpellMgr::LoadSpellInfoCorrections() 29200 // Purify Helboar Meat }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); + spellEffectInfo->TargetB = SpellImplicitTargetInfo(); + }); }); ApplySpellFix({ @@ -3335,7 +3394,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Howl of Azgalor ApplySpellFix({ 31344 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_100_YARDS); // 100yards instead of 50000?! + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_100_YARDS); // 100yards instead of 50000?! + }); }); ApplySpellFix({ @@ -3349,7 +3411,10 @@ void SpellMgr::LoadSpellInfoCorrections() // They Must Burn Bomb Aura (self) ApplySpellFix({ 36350 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 36325; // They Must Burn Bomb Drop (DND) + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 36325; // They Must Burn Bomb Drop (DND) + }); }); // Execute @@ -3467,13 +3532,19 @@ void SpellMgr::LoadSpellInfoCorrections() ApplySpellFix({ 33711, 38794 }, [](SpellInfo* spellInfo) { spellInfo->MaxAffectedTargets = 1; - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TriggerSpell = 33760; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TriggerSpell = 33760; + }); }); // Fingers of Frost ApplySpellFix({ 44544 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->SpellClassMask[0] |= 0x20000; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->SpellClassMask[0] |= 0x20000; + }); }); ApplySpellFix({ @@ -3494,19 +3565,28 @@ void SpellMgr::LoadSpellInfoCorrections() // Crafty's Ultra-Advanced Proto-Typical Shortening Blaster ApplySpellFix({ 51912 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->ApplyAuraPeriod = 3000; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraPeriod = 3000; + }); }); // Nether Portal - Perseverence ApplySpellFix({ 30421 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_2))->BasePoints += 30000; + ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->BasePoints += 30000; + }); }); // Parasitic Shadowfiend Passive ApplySpellFix({ 41913 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->ApplyAuraName = SPELL_AURA_DUMMY; // proc debuff, and summon infinite fiends + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->ApplyAuraName = SPELL_AURA_DUMMY; // proc debuff, and summon infinite fiends + }); }); ApplySpellFix({ @@ -3515,7 +3595,10 @@ void SpellMgr::LoadSpellInfoCorrections() 27935, // To Anchor 1 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); + }); }); // Wrath of the Plaguebringer @@ -3523,8 +3606,14 @@ void SpellMgr::LoadSpellInfoCorrections() { // target allys instead of enemies, target A is src_caster, spells with effect like that have ally target // this is the only known exception, probably just wrong data - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ALLY); - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ALLY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ALLY); + }); + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ALLY); + }); }); // Vampiric Embrace @@ -3544,14 +3633,20 @@ void SpellMgr::LoadSpellInfoCorrections() 70840 // Devious Minds (needs target selection script) }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_PET); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_PET); + }); }); // Ride Carpet ApplySpellFix({ 45602 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->BasePoints = 0; // force seat 0, vehicle doesn't have the required seat flags for "no seat specified (-1)" + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->BasePoints = 0; // force seat 0, vehicle doesn't have the required seat flags for "no seat specified (-1)" + }); }); // Easter Lay Noblegarden Egg Aura - Interrupt flags copied from aura which this aura is linked with @@ -3574,7 +3669,10 @@ void SpellMgr::LoadSpellInfoCorrections() }, [](SpellInfo* spellInfo) { /// @todo: remove this when basepoints of all Ride Vehicle auras are calculated correctly - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->BasePoints = 1; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->BasePoints = 1; + }); }); // Black Magic @@ -3595,14 +3693,20 @@ void SpellMgr::LoadSpellInfoCorrections() }, [](SpellInfo* spellInfo) { //! HACK: This spell break quest complete for alliance and on retail not used - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); // Siege Cannon (Tol Barad) ApplySpellFix({ 85123 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ENTRY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ENTRY); + }); }); // Gathering Storms @@ -3629,13 +3733,19 @@ void SpellMgr::LoadSpellInfoCorrections() // Sic'em ApplySpellFix({ 42767 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_NEARBY_ENTRY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_NEARBY_ENTRY); + }); }); // Burn Body ApplySpellFix({ 42793 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_2))->MiscValue = 24008; // Fallen Combatant + ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->MiscValue = 24008; // Fallen Combatant + }); }); // Gift of the Naaru (priest and monk variants) @@ -3657,7 +3767,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Summon Corpse Scarabs ApplySpellFix({ 28864, 29105 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); + }); }); // @@ -3668,7 +3781,10 @@ void SpellMgr::LoadSpellInfoCorrections() { // in 3.3.5 there is only one radius in dbc which is 0 yards in this case // use max radius from 4.3.4 - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_25_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_25_YARDS); + }); }); // ENDOF VIOLET HOLD @@ -3678,7 +3794,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Pursued (Flame Leviathan) ApplySpellFix({ 62374 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_50000_YARDS); // 50000yd + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_50000_YARDS); // 50000yd + }); }); // Focused Eyebeam Summon Trigger (Kologarn) @@ -3713,7 +3832,10 @@ void SpellMgr::LoadSpellInfoCorrections() // then EFFECT_1, etc - instead of applying each effect on target1, then target2, etc. // The above situation causes the visual for this spell to be bugged, so we remove the instakill // effect and implement a script hack for that. - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); ApplySpellFix({ @@ -3739,14 +3861,20 @@ void SpellMgr::LoadSpellInfoCorrections() { // DBC data is wrong for EFFECT_0, it's a different dynobject target than EFFECT_1 // Both effects should be shared by the same DynObject - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_LEFT); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_CASTER_LEFT); + }); }); // Spinning Up (Mimiron) ApplySpellFix({ 63414 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); spellInfo->ChannelInterruptFlags.fill(0); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_CASTER); + }); }); // Rocket Strike (Mimiron) @@ -3782,7 +3910,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Cosmic Smash (Algalon the Observer) ApplySpellFix({ 62293 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_DEST_CASTER); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_DEST_CASTER); + }); }); // Cosmic Smash (Algalon the Observer) @@ -3803,7 +3934,10 @@ void SpellMgr::LoadSpellInfoCorrections() 65042 // Prison of Yogg-Saron Teleport }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + }); }); // ENDOF ULDUAR SPELLS @@ -3835,7 +3969,10 @@ void SpellMgr::LoadSpellInfoCorrections() // THESE SPELLS ARE WORKING CORRECTLY EVEN WITHOUT THIS HACK // THE ONLY REASON ITS HERE IS THAT CURRENT GRID SYSTEM // DOES NOT ALLOW FAR OBJECT SELECTION (dist > 333) - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + }); }); // Coldflame (Lord Marrowgar) @@ -3853,14 +3990,17 @@ void SpellMgr::LoadSpellInfoCorrections() // Lock Players and Tap Chest ApplySpellFix({ 72347 }, [](SpellInfo* spellInfo) { - spellInfo->AttributesEx3 &= ~SPELL_ATTR3_NO_INITIAL_AGGRO; + spellInfo->AttributesEx3 &= ~SPELL_ATTR3_NO_INITIAL_AGGRO; }); // Resistant Skin (Deathbringer Saurfang adds) ApplySpellFix({ 72723 }, [](SpellInfo* spellInfo) { // this spell initially granted Shadow damage immunity, however it was removed but the data was left in client - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_2))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); // Coldflame Jets (Traps after Saurfang) @@ -3874,7 +4014,10 @@ void SpellMgr::LoadSpellInfoCorrections() 71415 // Orange Ooze Summon (Professor Putricide) }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ANY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ANY); + }); }); // Awaken Plagued Zombies @@ -3886,20 +4029,29 @@ void SpellMgr::LoadSpellInfoCorrections() // Volatile Ooze Beam Protection (Professor Putricide) ApplySpellFix({ 70530 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->Effect = SPELL_EFFECT_APPLY_AURA; // for an unknown reason this was SPELL_EFFECT_APPLY_AREA_AURA_RAID + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = SPELL_EFFECT_APPLY_AURA; // for an unknown reason this was SPELL_EFFECT_APPLY_AREA_AURA_RAID + }); }); // Mutated Strength (Professor Putricide) ApplySpellFix({ 71604 }, [](SpellInfo* spellInfo) { // THIS IS HERE BECAUSE COOLDOWN ON CREATURE PROCS WERE NOT IMPLEMENTED WHEN THE SCRIPT WAS WRITTEN - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); // Unbound Plague (Professor Putricide) (needs target selection script) ApplySpellFix({ 70911 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ENEMY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ENEMY); + }); }); // Empowered Flare (Blood Prince Council) @@ -3935,15 +4087,21 @@ void SpellMgr::LoadSpellInfoCorrections() // Summon Suppressor (needs target selection script) ApplySpellFix({ 70936 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ANY); - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(); spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(157); // 90yd + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_TARGET_ANY); + spellEffectInfo->TargetB = SpellImplicitTargetInfo(); + }); }); // Sindragosa's Fury ApplySpellFix({ 70598 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DEST); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DEST); + }); }); // Frost Bomb @@ -3980,8 +4138,14 @@ void SpellMgr::LoadSpellInfoCorrections() // Defile ApplySpellFix({ 72754 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); // 200yd - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); // 200yd + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); // 200yd + }); + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_200_YARDS); // 200yd + }); }); // Val'kyr Target Search @@ -4023,7 +4187,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Summon Spirit Bomb ApplySpellFix({ 73579 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_25_YARDS); // 25yd + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_25_YARDS); // 25yd + }); }); // Raise Dead @@ -4036,15 +4203,21 @@ void SpellMgr::LoadSpellInfoCorrections() ApplySpellFix({ 71809 }, [](SpellInfo* spellInfo) { spellInfo->RangeEntry = sSpellRangeStore.LookupEntry(5); // 40yd - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); // 10yd - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->MiscValue = 190; + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_10_YARDS); // 10yd + spellEffectInfo->MiscValue = 190; + }); }); // Broken Frostmourne ApplySpellFix({ 72405 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_20_YARDS); // 20yd spellInfo->AttributesEx |= SPELL_ATTR1_NO_THREAT; + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_20_YARDS); // 20yd + }); }); // ENDOF ICECROWN CITADEL SPELLS @@ -4054,7 +4227,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Soul Consumption ApplySpellFix({ 74799 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_1))->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_12_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_1, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->RadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_12_YARDS); + }); }); // Twilight Mending @@ -4115,7 +4291,10 @@ void SpellMgr::LoadSpellInfoCorrections() 95285 // Teleport (from Slabhide to entrance) }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetB = SpellImplicitTargetInfo(TARGET_DEST_DB); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetB = SpellImplicitTargetInfo(TARGET_DEST_DB); + }); }); // ENDOF STONECORE SPELLS @@ -4128,7 +4307,10 @@ void SpellMgr::LoadSpellInfoCorrections() }, [](SpellInfo* spellInfo) { // Little hack, Increase the radius so it can hit the Cave In Stalkers in the platform. - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->MaxRadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_45_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->MaxRadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_45_YARDS); + }); }); // ENDOF HALLS OF ORIGINATION SPELLS @@ -4172,7 +4354,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Evolution ApplySpellFix({ 75697 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ENTRY); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_UNIT_SRC_AREA_ENTRY); + }); }); // @@ -4191,7 +4376,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Torment Searcher ApplySpellFix({ 99253 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->MaxRadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_15_YARDS); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->MaxRadiusEntry = sSpellRadiusStore.LookupEntry(EFFECT_RADIUS_15_YARDS); + }); }); // Torment Damage @@ -4216,7 +4404,10 @@ void SpellMgr::LoadSpellInfoCorrections() { // For some reason there is a instakill effect that serves absolutely no purpose. // Until we figure out what it's actually used for we disable it. - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_2))->Effect = 0; + ApplySpellEffectFix(spellInfo, EFFECT_2, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->Effect = 0; + }); }); // ENDOF ANTORUS THE BURNING THRONE SPELLS @@ -4224,7 +4415,10 @@ void SpellMgr::LoadSpellInfoCorrections() // Summon Master Li Fei ApplySpellFix({ 102445 }, [](SpellInfo* spellInfo) { - const_cast<SpellEffectInfo*>(spellInfo->GetEffect(EFFECT_0))->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + ApplySpellEffectFix(spellInfo, EFFECT_0, [](SpellEffectInfo* spellEffectInfo) + { + spellEffectInfo->TargetA = SpellImplicitTargetInfo(TARGET_DEST_DB); + }); }); for (SpellInfo const& s : mSpellInfoMap) |