[7645] Fixed problems wit temporary unsummoned pets and cleanup code.

* Save temporary unsummoned pet to current slot (instead non_in_slot mode) and
  prevent save as current pet summoned while temporay unsummon (arena)
* Prevent overwrite temporary summoned pet data
* At player loading set temporary unsummoned pet data instead pet loading
  if pet expected to be temporary unsummoned in current player state (loading in taxi flight/etc)
* Restore proper pet at arena leave and unsummon in arena summoned.
This commit is contained in:
VladimirMangos 2009-04-11 06:54:39 +04:00
parent 263bf2ab22
commit eb198f8239
9 changed files with 105 additions and 108 deletions

View file

@ -8549,21 +8549,7 @@ void Unit::Mount(uint32 mount)
// unsummon pet
if(GetTypeId() == TYPEID_PLAYER)
{
Pet* pet = GetPet();
if(pet)
{
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);
}
else
((Player*)this)->SetTemporaryUnsummonedPetNumber(0);
}
((Player*)this)->UnsummonPetTemporaryIfAny();
}
void Unit::Unmount()
@ -8579,14 +8565,8 @@ 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())
{
Pet* NewPet = new Pet;
if(!NewPet->LoadPetFromDB((Player*)this, 0, ((Player*)this)->GetTemporaryUnsummonedPetNumber(), true))
delete NewPet;
((Player*)this)->SetTemporaryUnsummonedPetNumber(0);
}
if(GetTypeId() == TYPEID_PLAYER)
((Player*)this)->ResummonPetTemporaryUnSummonedIfAny();
}
void Unit::SetInCombatWith(Unit* enemy)