aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/server/game/Entities/Player/Player.cpp48
1 files changed, 27 insertions, 21 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 7367b6b32c0..691618d1b36 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -24551,41 +24551,47 @@ void Player::RemoveRunesByAuraEffect(AuraEffect const* aura)
void Player::RestoreBaseRune(uint8 index)
{
+ std::vector<AuraEffect const*> removeList;
std::unordered_set<AuraEffect const*>& auras = m_runes->runes[index].ConvertAuras;
-
- AuraEffect const* aura = nullptr;
- for (auto itr = auras.begin(); itr != auras.end() && !aura;)
+ std::remove_if(auras.begin(), auras.end(), [&removeList](AuraEffect const* storedAura) -> bool
{
- if (AuraEffect const* temp = *itr)
+ // AuraEffect already gone
+ if (!storedAura)
+ return true;
+
+ if (storedAura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
{
- if (temp->GetSpellInfo()->HasAttribute(SPELL_ATTR0_PASSIVE))
- {
- aura = temp;
- auras.erase(itr);
- }
- else
- ++itr;
+ // Don't drop passive talents providing rune convertion
+ if (storedAura->GetAuraType() == SPELL_AURA_CONVERT_RUNE)
+ removeList.push_back(storedAura);
+ return true;
}
- else
- itr = auras.erase(itr);
- }
+
+ // If rune was converted by a non-passive aura that is still active we should keep it converted
+ return false;
+ });
if (!auras.empty())
return;
ConvertRune(index, GetBaseRune(index));
- // Don't drop passive talents providing rune convertion
- if (!aura || aura->GetAuraType() != SPELL_AURA_CONVERT_RUNE)
+ if (removeList.empty())
return;
- for (uint8 itr = 0; itr < MAX_RUNES; ++itr)
+ // Filter auras set to be removed if they are converting any other rune index
+ for (AuraEffect const* storedAura : removeList)
{
- if (m_runes->runes[itr].ConvertAuras.find(aura) != m_runes->runes[itr].ConvertAuras.end())
- return;
- }
+ uint8 itr = 0;
+ for (; itr < MAX_RUNES; ++itr)
+ {
+ if (m_runes->runes[itr].ConvertAuras.find(storedAura) != m_runes->runes[itr].ConvertAuras.end())
+ break;
+ }
- aura->GetBase()->Remove();
+ if (itr == MAX_RUNES)
+ storedAura->GetBase()->Remove();
+ }
}
void Player::ConvertRune(uint8 index, RuneType newType)