Don't unsummon pet while mounting in arena.

Disable pet's interface instead.

--HG--
branch : trunk
This commit is contained in:
krz
2009-05-29 04:52:03 +02:00
parent 2d69889a68
commit 861aad532b
+20 -4
View File
@@ -9465,16 +9465,22 @@ void Unit::Mount(uint32 mount)
{
Pet* pet = GetPet();
if(pet)
{
BattleGround *bg = ((Player *)this)->GetBattleGround();
// don't unsummon pet in arena but SetFlag UNIT_FLAG_DISABLE_ROTATE to disable pet's interface
if(bg && bg->isArena())
pet->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE);
else
{
if(pet->isControlled())
{
((Player*)this)->SetTemporaryUnsummonedPetNumber(pet->GetCharmInfo()->GetPetNumber());
((Player*)this)->SetOldPetSpell(pet->GetUInt32Value(UNIT_CREATED_BY_SPELL));
}
((Player*)this)->RemovePet(NULL,PET_SAVE_NOT_IN_SLOT);
return;
}
}
else
((Player*)this)->SetTemporaryUnsummonedPetNumber(0);
}
}
@@ -9492,14 +9498,20 @@ void Unit::Unmount()
// only resummon old pet if the player is already added to a map
// this prevents adding a pet to a not created map which would otherwise cause a crash
// (it could probably happen when logging in after a previous crash)
if(GetTypeId() == TYPEID_PLAYER && IsInWorld() && ((Player*)this)->GetTemporaryUnsummonedPetNumber() && isAlive())
if(GetTypeId() == TYPEID_PLAYER && IsInWorld() && isAlive())
{
if( ((Player*)this)->GetTemporaryUnsummonedPetNumber() )
{
Pet* NewPet = new Pet;
if(!NewPet->LoadPetFromDB(this, 0, ((Player*)this)->GetTemporaryUnsummonedPetNumber(), true))
delete NewPet;
((Player*)this)->SetTemporaryUnsummonedPetNumber(0);
}
else
if(Pet *pPet = GetPet())
if(pPet->HasFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE) && !pPet->hasUnitState(UNIT_STAT_STUNNED))
pPet->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE);
}
}
void Unit::SetInCombatWith(Unit* enemy)
@@ -12708,6 +12720,10 @@ void Unit::SetStunned(bool apply)
{
if(isAlive() && getVictim())
SetUInt64Value(UNIT_FIELD_TARGET, getVictim()->GetGUID());
// don't remove UNIT_FLAG_DISABLE_ROTATE for pet when owner is mounted (disabled pet's interface)
Unit *pOwner = GetOwner();
if(!pOwner || (pOwner->GetTypeId() == TYPEID_PLAYER && !((Player *)pOwner)->IsMounted()))
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_DISABLE_ROTATE);
if(!hasUnitState(UNIT_STAT_ROOT)) // prevent allow move if have also root effect