Modified function used in many cases. For example for stacking in spellbook. And clear that not always req. spell must be take in checks.
Possible this version more safe (it used req. checks only for cases when both spell have same spellspec):
diff --git a/src/game/SpellMgr.cpp b/src/game/SpellMgr.cpp
index 7ef35a5..62f95af 100644
--- a/src/game/SpellMgr.cpp
+++ b/src/game/SpellMgr.cpp
@@ -1055,13 +1055,43 @@ void SpellMgr::LoadSpellThreats()
sLog.outString();
}
-bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const
+bool SpellMgr::IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2, bool with_req) const
{
+ if(!spellInfo_1) return false;
+
SpellEntry const *spellInfo_2 = sSpellStore.LookupEntry(spellId_2);
- if(!spellInfo_1 || !spellInfo_2) return false;
- if(spellInfo_1->Id == spellId_2) return false;
+ if(!spellInfo_2) return false;
+
+ // same spell
+ if(spellInfo_1->Id == spellId_2)
+ return false;
+
+ // not ranked
+ SpellChainNode const* node1 = GetSpellChainNode(spellInfo_1->Id);
+ if(!node1)
+ return false;
+
+ // not ranked
+ SpellChainNode const* node2 = GetSpellChainNode(spellInfo_2->Id);
+ if(!node2)
+ return false;
- return GetFirstSpellInChain(spellInfo_1->Id)==GetFirstSpellInChain(spellId_2);
+ // from same chain both
+ if(node1->first==node2->first)
+ return true;
+
+ if(with_req)
+ {
+ // maybe req from another chain
+ if(node1->req && GetFirstSpellInChain(node1->req)==node2->first)
+ return true;
+
+ // maybe req from another chain
+ if(node2->req && GetFirstSpellInChain(node2->req)==node1->first)
+ return true;
+ }
+
+ return false;
}
bool SpellMgr::canStackSpellRanks(SpellEntry const *spellInfo)
diff --git a/src/game/SpellMgr.h b/src/game/SpellMgr.h
index d026ccb..68f43f9 100644
--- a/src/game/SpellMgr.h
+++ b/src/game/SpellMgr.h
@@ -720,7 +720,7 @@ class SpellMgr
return false;
}
- bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2) const;
+ bool IsRankSpellDueToSpell(SpellEntry const *spellInfo_1,uint32 spellId_2, bool with_req = false) const;
static bool canStackSpellRanks(SpellEntry const *spellInfo);
bool IsNoStackSpellDueToSpell(uint32 spellId_1, uint32 spellId_2) const;
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index 309b551..7065f69 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -3566,7 +3566,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
if( is_sspc && Aur->GetCasterGUID() == (*i).second->GetCasterGUID() )
{
// cannot remove higher rank
- if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId))
+ if (spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId, true))
if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)
return false;
@@ -3583,7 +3583,7 @@ bool Unit::RemoveNoStackAurasDueToAura(Aura *Aur)
else
next = m_Auras.begin();
}
- else if( is_sspt && Aur->GetCasterGUID() != (*i).second->GetCasterGUID() && spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId) )
+ else if( is_sspt && Aur->GetCasterGUID() != (*i).second->GetCasterGUID() && spellmgr.IsRankSpellDueToSpell(spellProto, i_spellId, true) )
{
// cannot remove higher rank
if(CompareAuraRanks(spellId, effIndex, i_spellId, i_effIndex) < 0)