*Exit vehicle when players or vehicles are dead. This may fix some crash.

--HG--
branch : trunk
This commit is contained in:
megamage
2009-03-28 10:50:54 -06:00
parent a12682a3dd
commit 6e33427a11
2 changed files with 7 additions and 1 deletions
+4 -1
View File
@@ -8417,13 +8417,16 @@ Unit* Unit::GetFirstControlled() const
void Unit::RemoveAllControlled()
{
//possessed pet and vehicle
if(GetTypeId() == TYPEID_PLAYER)
((Player*)this)->StopCastingCharm();
while(!m_Controlled.empty())
{
Unit *target = *m_Controlled.begin();
m_Controlled.erase(m_Controlled.begin());
if(target->GetCharmerGUID() == GetGUID())
{
//TODO: possessed and vehicle
target->RemoveCharmAuras();
}
else if(target->GetOwnerGUID() == GetGUID()
+3
View File
@@ -52,6 +52,9 @@ void Vehicle::RemoveFromWorld()
void Vehicle::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState
{
if(Unit *charmer = GetCharmer())
if(charmer->GetTypeId() == TYPEID_PLAYER)
((Player*)charmer)->ExitVehicle(this);
Creature::setDeathState(s);
}