*Exit vehicle when players or vehicles are dead. This may fix some crash.
--HG-- branch : trunk
This commit is contained in:
+4
-1
@@ -8417,13 +8417,16 @@ Unit* Unit::GetFirstControlled() const
|
|||||||
|
|
||||||
void Unit::RemoveAllControlled()
|
void Unit::RemoveAllControlled()
|
||||||
{
|
{
|
||||||
|
//possessed pet and vehicle
|
||||||
|
if(GetTypeId() == TYPEID_PLAYER)
|
||||||
|
((Player*)this)->StopCastingCharm();
|
||||||
|
|
||||||
while(!m_Controlled.empty())
|
while(!m_Controlled.empty())
|
||||||
{
|
{
|
||||||
Unit *target = *m_Controlled.begin();
|
Unit *target = *m_Controlled.begin();
|
||||||
m_Controlled.erase(m_Controlled.begin());
|
m_Controlled.erase(m_Controlled.begin());
|
||||||
if(target->GetCharmerGUID() == GetGUID())
|
if(target->GetCharmerGUID() == GetGUID())
|
||||||
{
|
{
|
||||||
//TODO: possessed and vehicle
|
|
||||||
target->RemoveCharmAuras();
|
target->RemoveCharmAuras();
|
||||||
}
|
}
|
||||||
else if(target->GetOwnerGUID() == GetGUID()
|
else if(target->GetOwnerGUID() == GetGUID()
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ void Vehicle::RemoveFromWorld()
|
|||||||
|
|
||||||
void Vehicle::setDeathState(DeathState s) // overwrite virtual Creature::setDeathState and Unit::setDeathState
|
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);
|
Creature::setDeathState(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user