aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authormegamage <none@none>2009-03-29 10:12:04 -0600
committermegamage <none@none>2009-03-29 10:12:04 -0600
commit666db14e7ccfedad89cc5b8c1e24e82d770a4eb6 (patch)
treedaba23f31c83bc894bec68e5af9e69d3ae2569f1 /src
parent09342fe2bec069efa06643242dd28eadf74f6054 (diff)
*Try to fix a crash caused by attackstop.
--HG-- branch : trunk
Diffstat (limited to 'src')
-rw-r--r--src/game/Unit.cpp8
-rw-r--r--src/game/Unit.h4
2 files changed, 5 insertions, 7 deletions
diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp
index c3b5a4a8f3e..a0d88f922dc 100644
--- a/src/game/Unit.cpp
+++ b/src/game/Unit.cpp
@@ -8086,12 +8086,15 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
}
//switch target
- m_attacking->_removeAttacker(this);
InterruptSpell(CURRENT_MELEE_SPELL);
if(!meleeAttack)
clearUnitState(UNIT_STAT_MELEE_ATTACKING);
+ m_attacking->_removeAttacker(this);
}
+ m_attacking = victim;
+ m_attacking->_addAttacker(this);
+
//Set our target
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
@@ -8102,9 +8105,6 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
//if(GetTypeId()==TYPEID_UNIT)
// ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
- m_attacking = victim;
- m_attacking->_addAttacker(this);
-
//if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled)
// ((Creature*)m_attacking)->AI()->AttackedBy(this);
diff --git a/src/game/Unit.h b/src/game/Unit.h
index e2952647b6e..38ff55d526c 100644
--- a/src/game/Unit.h
+++ b/src/game/Unit.h
@@ -899,9 +899,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*)
{
- AttackerSet::iterator itr = m_attackers.find(pAttacker);
- if(itr == m_attackers.end())
- m_attackers.insert(pAttacker);
+ m_attackers.insert(pAttacker);
}
void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop()
{