mirror of
https://github.com/mangosfour/server.git
synced 2025-12-18 01:37:01 +00:00
[10076] Fixed crash at remove from world pet under SPELL_AURA_MOD_POSSESS_PET
* Prevent crash at camera list update at attempt increment end() iterator. * Properly do unapply SPELL_AURA_MOD_POSSESS_PET (GetPet() can return NULL at call, and not need checked) * Propertly call unapply at delete auras cases for auras that set player-caster mover pointer.
This commit is contained in:
parent
81851074ad
commit
3e210228f9
4 changed files with 50 additions and 21 deletions
|
|
@ -3710,36 +3710,40 @@ void Aura::HandleModPossessPet(bool apply, bool Real)
|
|||
if(!caster || caster->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
Pet *pet = caster->GetPet();
|
||||
if(!pet || pet != GetTarget())
|
||||
Unit* target = GetTarget();
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
Creature* pet = (Creature*)target; // not need more stricted type check
|
||||
|
||||
Player* p_caster = (Player*)caster;
|
||||
Camera& camera = p_caster->GetCamera();
|
||||
|
||||
if(apply)
|
||||
if (apply)
|
||||
{
|
||||
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
camera.SetView(pet);
|
||||
}
|
||||
else
|
||||
{
|
||||
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
camera.ResetView();
|
||||
}
|
||||
p_caster->SetCharm(pet);
|
||||
p_caster->SetClientControl(pet, 1);
|
||||
((Player*)caster)->SetMover(pet);
|
||||
|
||||
p_caster->SetCharm(apply ? pet : NULL);
|
||||
p_caster->SetClientControl(pet, apply ? 1 : 0);
|
||||
((Player*)caster)->SetMover(apply ? pet : NULL);
|
||||
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
if(apply)
|
||||
{
|
||||
pet->StopMoving();
|
||||
pet->GetMotionMaster()->Clear();
|
||||
pet->GetMotionMaster()->Clear(false);
|
||||
pet->GetMotionMaster()->MoveIdle();
|
||||
}
|
||||
else
|
||||
{
|
||||
camera.ResetView();
|
||||
p_caster->SetCharm(NULL);
|
||||
p_caster->SetClientControl(pet, 0);
|
||||
p_caster->SetMover(NULL);
|
||||
|
||||
// on delete only do caster related effects
|
||||
if(m_removeMode == AURA_REMOVE_BY_DELETE)
|
||||
return;
|
||||
|
||||
pet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_PLAYER_CONTROLLED);
|
||||
|
||||
pet->AttackStop();
|
||||
pet->GetMotionMaster()->MoveFollow(caster, PET_FOLLOW_DIST, PET_FOLLOW_ANGLE);
|
||||
pet->AddSplineFlag(SPLINEFLAG_WALKMODE);
|
||||
|
|
@ -8272,9 +8276,13 @@ void Aura::HandleAuraControlVehicle(bool apply, bool Real)
|
|||
if(!Real)
|
||||
return;
|
||||
|
||||
Unit* target = GetTarget();
|
||||
if (target->GetTypeId() != TYPEID_UNIT || !((Creature*)target)->isVehicle())
|
||||
return;
|
||||
Vehicle* vehicle = (Vehicle*)target;
|
||||
|
||||
Unit *player = GetCaster();
|
||||
Vehicle *vehicle = dynamic_cast<Vehicle*>(GetTarget());
|
||||
if(!player || player->GetTypeId() != TYPEID_PLAYER || !vehicle)
|
||||
if(!player || player->GetTypeId() != TYPEID_PLAYER)
|
||||
return;
|
||||
|
||||
if (apply)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue