Skip to content

Instantly share code, notes, and snippets.

@rsa
Created September 18, 2011 16:29
Show Gist options
  • Select an option

  • Save rsa/1225236 to your computer and use it in GitHub Desktop.

Select an option

Save rsa/1225236 to your computer and use it in GitHub Desktop.
lock part 5.4
diff --git a/src/game/SpellAuras.cpp b/src/game/SpellAuras.cpp
index 3f5b216..938c803 100644
--- a/src/game/SpellAuras.cpp
+++ b/src/game/SpellAuras.cpp
@@ -9910,8 +9910,9 @@ void SpellAuraHolder::AddAura(Aura aura, SpellEffectIndex index)
if (Aura* _aura = GetAuraByEffectIndex(index))
{
DEBUG_LOG("SpellAuraHolder::AddAura attempt to add aura (effect %u) to holder of spell %u, but holder already have active aura!", index, GetId());
- RemoveAura(index);
}
+ RemoveAura(index);
+ MAPLOCK_WRITE(m_target, MAP_LOCK_TYPE_AURAS);
AuraStorage::iterator itr = m_aurasStorage.find(index);
if (itr != m_aurasStorage.end())
m_aurasStorage.erase(index);
@@ -9927,6 +9928,7 @@ void SpellAuraHolder::RemoveAura(SpellEffectIndex index)
void SpellAuraHolder::CleanupsBeforeDelete()
{
+ MAPLOCK_WRITE(m_target, MAP_LOCK_TYPE_AURAS);
for (int32 i = 0; i < MAX_EFFECT_INDEX; ++i)
RemoveAura(SpellEffectIndex(i));
m_aurasStorage.clear();
@@ -9936,6 +9938,7 @@ Aura* SpellAuraHolder::GetAuraByEffectIndex(SpellEffectIndex index)
{
if (m_auraFlags & (1 << index))
{
+ MAPLOCK_READ(m_target, MAP_LOCK_TYPE_AURAS);
AuraStorage::iterator itr = m_aurasStorage.find(index);
if (itr != m_aurasStorage.end())
return &itr->second;
@@ -9947,6 +9950,7 @@ Aura const* SpellAuraHolder::GetAura(SpellEffectIndex index) const
{
if (m_auraFlags & (1 << index))
{
+ MAPLOCK_READ(m_target, MAP_LOCK_TYPE_AURAS);
AuraStorage::const_iterator itr = m_aurasStorage.find(index);
if (itr != m_aurasStorage.end())
return &itr->second;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment