Core/Auras: Convert most rules from Aura::CanBeSaved to a custom spell attribute

This commit is contained in:
Shauren authored and Ovahlord committed 2023-08-19 22:26:12 +02:00
1 parent 86a06a5a5d
commit ca034f4dbf
4 files changed
+47 -66

No files matched your search

@@ -0,0 +1,21 @@
ALTER TABLE `spell_custom_attr`
MODIFY `entry` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'spell id',
MODIFY `attributes` int(10) unsigned NOT NULL DEFAULT '0' COMMENT 'SpellCustomAttributes';
DELETE FROM `spell_custom_attr` WHERE `entry` IN (44413, 40075, 55849, 96206, 81206, 81207, 81208, 81209, 68631, 89912, 67483, 67484, 48517, 48518, 94338);
INSERT INTO `spell_custom_attr` (`entry`, `attributes`) VALUES
(44413, 0x01000000),
(40075, 0x01000000),
(55849, 0x01000000),
(96206, 0x01000000),
(81206, 0x01000000),
(81207, 0x01000000),
(81208, 0x01000000),
(81209, 0x01000000),
(68631, 0x01000000),
(89912, 0x01000000),
(67483, 0x01000000),
(67484, 0x01000000),
(48517, 0x01000000),
(48518, 0x01000000),
(94338, 0x01000000);
+4 -64
View File
@@ -1117,71 +1117,11 @@ bool Aura::CanBeSaved() const
return false; return false;
// Check if aura is single target, not only spell info // Check if aura is single target, not only spell info
if (GetCasterGUID() != GetOwner()->GetGUID()) if (GetCasterGUID() != GetOwner()->GetGUID() || IsSingleTarget())
{ if (GetSpellInfo()->IsSingleTarget())
// owner == caster for area auras, check for possible bad data in DB
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (!GetSpellInfo()->Effects[i].IsEffect())
continue;
if (GetSpellInfo()->Effects[i].IsTargetingArea() || GetSpellInfo()->Effects[i].IsAreaAuraEffect())
return false;
}
if (IsSingleTarget() || GetSpellInfo()->IsSingleTarget())
return false; return false;
}
// don't save liquid auras if (GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED))
if (GetSpellInfo()->HasAttribute(SPELL_ATTR0_CU_LIQUID_AURA))
return false;
// Can't be saved - aura handler relies on calculated amount and changes it
if (HasEffectType(SPELL_AURA_CONVERT_RUNE))
return false;
// No point in saving this, since the stable dialog can't be open on aura load anyway.
if (HasEffectType(SPELL_AURA_OPEN_STABLE))
return false;
// Can't save vehicle auras, it requires both caster & target to be in world
if (HasEffectType(SPELL_AURA_CONTROL_VEHICLE))
return false;
// do not save bind sight auras
if (HasEffectType(SPELL_AURA_BIND_SIGHT))
return false;
// no charming auras (taking direct control)
if (HasEffectType(SPELL_AURA_MOD_POSSESS))
return false;
// no charming auras can be saved
if (HasEffectType(SPELL_AURA_MOD_CHARM) || HasEffectType(SPELL_AURA_AOE_CHARM))
return false;
// Incanter's Absorbtion - considering the minimal duration and problems with aura stacking
// we skip saving this aura
// Also for some reason other auras put as MultiSlot crash core on keeping them after restart,
// so put here only these for which you are sure they get removed
switch (GetId())
{
case 44413: // Incanter's Absorption
case 40075: // Fel Flak Fire
case 55849: // Power Spark
case 96206: // Nature's Bounty
case 81206: // Chakra: Sanctuary
case 81207: // Chakra: Sanctuary
case 81208: // Chakra: Serenity
case 81209: // Chakra: Chastise
case 68631: // Curse of the Worgen
case 89912: // Chakra Flow
return false;
}
// When a druid logins, he doesnt have either eclipse power, nor the marker auras, nor the eclipse buffs. Dont save them.
if (GetId() == 67483 || GetId() == 67484 || GetId() == 48517 || GetId() == 48518 || GetId() == 94338)
return false; return false;
// don't save auras removed by proc system // don't save auras removed by proc system
@@ -1189,7 +1129,7 @@ bool Aura::CanBeSaved() const
return false; return false;
// don't save permanent auras triggered by items, they'll be recasted on login if necessary // don't save permanent auras triggered by items, they'll be recasted on login if necessary
if (GetCastItemGUID() && IsPermanent()) if (!GetCastItemGUID().IsEmpty() && IsPermanent())
return false; return false;
return true; return true;
+3 -1
View File
@@ -203,7 +203,9 @@ enum SpellCustomAttributes
SPELL_ATTR0_CU_ALLOW_INFLIGHT_TARGET = 0x00040000, SPELL_ATTR0_CU_ALLOW_INFLIGHT_TARGET = 0x00040000,
SPELL_ATTR0_CU_BINARY_SPELL = 0x00100000, SPELL_ATTR0_CU_BINARY_SPELL = 0x00100000,
SPELL_ATTR0_CU_SCHOOLMASK_NORMAL_WITH_MAGIC = 0x00200000, SPELL_ATTR0_CU_SCHOOLMASK_NORMAL_WITH_MAGIC = 0x00200000,
SPELL_ATTR0_CU_LIQUID_AURA = 0x00400000, SPELL_ATTR0_CU_DEPRECATED_LIQUID_AURA = 0x00400000, // DO NOT REUSE
SPELL_ATTR0_CU_IS_TALENT = 0x00800000,
SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED = 0x01000000,
SPELL_ATTR0_CU_NEGATIVE = SPELL_ATTR0_CU_NEGATIVE_EFF0 | SPELL_ATTR0_CU_NEGATIVE_EFF1 | SPELL_ATTR0_CU_NEGATIVE_EFF2 SPELL_ATTR0_CU_NEGATIVE = SPELL_ATTR0_CU_NEGATIVE_EFF0 | SPELL_ATTR0_CU_NEGATIVE_EFF1 | SPELL_ATTR0_CU_NEGATIVE_EFF2
}; };
+19 -1
View File
@@ -2704,6 +2704,20 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
break; break;
} }
switch (spellInfo->Effects[j].ApplyAuraName)
{
case SPELL_AURA_OPEN_STABLE: // No point in saving this, since the stable dialog can't be open on aura load anyway.
// Auras that require both caster & target to be in world cannot be saved
case SPELL_AURA_CONTROL_VEHICLE:
case SPELL_AURA_BIND_SIGHT:
case SPELL_AURA_MOD_POSSESS:
case SPELL_AURA_MOD_CHARM:
case SPELL_AURA_AOE_CHARM:
case SPELL_AURA_CONVERT_RUNE:
spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED;
break;
}
switch (spellInfo->Effects[j].Effect) switch (spellInfo->Effects[j].Effect)
{ {
case SPELL_EFFECT_SCHOOL_DAMAGE: case SPELL_EFFECT_SCHOOL_DAMAGE:
@@ -2887,6 +2901,10 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
} }
spellInfo->_InitializeExplicitTargetMask(); spellInfo->_InitializeExplicitTargetMask();
// Saving to DB happens before removing from world - skip saving these auras
if (spellInfo->HasAuraInterruptFlag(SpellAuraInterruptFlags::LeaveWorld))
spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED;
} }
// addition for binary spells, omit spells triggering other spells // addition for binary spells, omit spells triggering other spells
@@ -2945,7 +2963,7 @@ void SpellMgr::LoadSpellInfoCustomAttributes()
{ {
if (uint32 spellId = liquid->SpellID) if (uint32 spellId = liquid->SpellID)
if (SpellInfo* spellInfo = _GetSpellInfo(spellId)) if (SpellInfo* spellInfo = _GetSpellInfo(spellId))
spellInfo->AttributesCu |= SPELL_ATTR0_CU_LIQUID_AURA; spellInfo->AttributesCu |= SPELL_ATTR0_CU_AURA_CANNOT_BE_SAVED;
} }
} }