*Try to fix a crash caused by attackstop.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-29 10:12:04 -06:00
parent 09342fe2be
commit 666db14e7c
2 changed files with 5 additions and 7 deletions
+4 -4
View File
@@ -8086,12 +8086,15 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
} }
//switch target //switch target
m_attacking->_removeAttacker(this);
InterruptSpell(CURRENT_MELEE_SPELL); InterruptSpell(CURRENT_MELEE_SPELL);
if(!meleeAttack) if(!meleeAttack)
clearUnitState(UNIT_STAT_MELEE_ATTACKING); clearUnitState(UNIT_STAT_MELEE_ATTACKING);
m_attacking->_removeAttacker(this);
} }
m_attacking = victim;
m_attacking->_addAttacker(this);
//Set our target //Set our target
SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID()); SetUInt64Value(UNIT_FIELD_TARGET, victim->GetGUID());
@@ -8102,9 +8105,6 @@ bool Unit::Attack(Unit *victim, bool meleeAttack)
//if(GetTypeId()==TYPEID_UNIT) //if(GetTypeId()==TYPEID_UNIT)
// ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ()); // ((Creature*)this)->SetCombatStartPosition(GetPositionX(), GetPositionY(), GetPositionZ());
m_attacking = victim;
m_attacking->_addAttacker(this);
//if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled) //if(m_attacking->GetTypeId()==TYPEID_UNIT && ((Creature*)m_attacking)->IsAIEnabled)
// ((Creature*)m_attacking)->AI()->AttackedBy(this); // ((Creature*)m_attacking)->AI()->AttackedBy(this);
+1 -3
View File
@@ -899,9 +899,7 @@ class TRINITY_DLL_SPEC Unit : public WorldObject
void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*) void _addAttacker(Unit *pAttacker) // must be called only from Unit::Attack(Unit*)
{ {
AttackerSet::iterator itr = m_attackers.find(pAttacker); m_attackers.insert(pAttacker);
if(itr == m_attackers.end())
m_attackers.insert(pAttacker);
} }
void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop() void _removeAttacker(Unit *pAttacker) // must be called only from Unit::AttackStop()
{ {