Core/Auras: Recheck aura presence on target after calling linked events in charm and vehicle aura effect handlers.

This commit is contained in:
QAston
2010-12-31 15:37:44 +01:00
parent 4eccbb81af
commit dd5a77bebc
3 changed files with 32 additions and 13 deletions
+19 -4
View File
@@ -15275,7 +15275,7 @@ void Unit::SetConfused(bool apply)
this->ToPlayer()->SetClientControl(this, !apply);
}
bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
bool Unit::SetCharmedBy(Unit* charmer, CharmType type, AuraApplication const * aurApp)
{
if (!charmer)
return false;
@@ -15336,6 +15336,11 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
return false;
}
// charm is set by aura, and aura effect remove handler was called during apply handler execution
// prevent undefined behaviour
if (aurApp && aurApp->GetRemoveMode())
return false;
// Set charmed
Map* pMap = GetMap();
if (!IsVehicle() || (IsVehicle() && pMap && !pMap->IsBattleground()))
@@ -15355,6 +15360,11 @@ bool Unit::SetCharmedBy(Unit* charmer, CharmType type)
this->ToPlayer()->SetClientControl(this, 0);
}
// charm is set by aura, and aura effect remove handler was called during apply handler execution
// prevent undefined behaviour
if (aurApp && aurApp->GetRemoveMode())
return false;
// Pets already have a properly initialized CharmInfo, don't overwrite it.
if (type != CHARM_TYPE_VEHICLE && !GetCharmInfo())
{
@@ -16308,7 +16318,7 @@ bool Unit::CheckPlayerCondition(Player* pPlayer)
}
}
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, bool byAura)
void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, AuraApplication const * aurApp)
{
if (!isAlive() || GetVehicleKit() == vehicle)
return;
@@ -16320,7 +16330,7 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, bool byAura)
if (seatId >= 0 && seatId != GetTransSeat())
{
sLog->outDebug("EnterVehicle: %u leave vehicle %u seat %d and enter %d.", GetEntry(), m_vehicle->GetBase()->GetEntry(), GetTransSeat(), seatId);
ChangeSeat(seatId, byAura);
ChangeSeat(seatId, bool(aurApp));
}
return;
}
@@ -16347,9 +16357,14 @@ void Unit::EnterVehicle(Vehicle *vehicle, int8 seatId, bool byAura)
bg->EventPlayerDroppedFlag(plr);
}
// vehicle is applied by aura, and aura effect remove handler was called during apply handler execution
// prevent undefined behaviour
if (aurApp && aurApp->GetRemoveMode())
return;
ASSERT(!m_vehicle);
m_vehicle = vehicle;
if (!m_vehicle->AddPassenger(this, seatId, byAura))
if (!m_vehicle->AddPassenger(this, seatId, bool(aurApp)))
{
m_vehicle = NULL;
return;