mirror of
https://github.com/mangosfour/server.git
synced 2025-12-13 22:37:03 +00:00
[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:
parent
263bf2ab22
commit
eb198f8239
9 changed files with 105 additions and 108 deletions
|
|
@ -1628,16 +1628,9 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
|||
//SendMessageToSet(&data, true);
|
||||
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
|
||||
{
|
||||
//same map, only remove pet if out of range
|
||||
if(pet && !IsWithinDistInMap(pet, OWNER_MAX_DISTANCE))
|
||||
{
|
||||
if(pet->isControlled() && !pet->isTemporarySummoned() )
|
||||
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
|
||||
else
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
|
||||
RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
|
||||
}
|
||||
//same map, only remove pet if out of range for new position
|
||||
if(pet && pet->GetDistance(x,y,z) >= OWNER_MAX_DISTANCE)
|
||||
UnsummonPetTemporaryIfAny();
|
||||
}
|
||||
|
||||
if(!(options & TELE_TO_NOT_LEAVE_COMBAT))
|
||||
|
|
@ -1646,14 +1639,8 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
|||
if (!(options & TELE_TO_NOT_UNSUMMON_PET))
|
||||
{
|
||||
// resummon pet
|
||||
if(pet && m_temporaryUnsummonedPetNumber)
|
||||
{
|
||||
Pet* NewPet = new Pet;
|
||||
if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true))
|
||||
delete NewPet;
|
||||
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
}
|
||||
if (pet)
|
||||
ResummonPetTemporaryUnSummonedIfAny();
|
||||
}
|
||||
|
||||
uint32 newzone, newarea;
|
||||
|
|
@ -1712,15 +1699,7 @@ bool Player::TeleportTo(uint32 mapid, float x, float y, float z, float orientati
|
|||
|
||||
// remove pet on map change
|
||||
if (pet)
|
||||
{
|
||||
//leaving map -> delete pet right away (doing this later will cause problems)
|
||||
if(pet->isControlled() && !pet->isTemporarySummoned())
|
||||
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
|
||||
else
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
|
||||
RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
|
||||
}
|
||||
UnsummonPetTemporaryIfAny();
|
||||
|
||||
// remove all dyn objects
|
||||
RemoveAllDynObjects();
|
||||
|
|
@ -19807,3 +19786,37 @@ void Player::UpdateFallInformationIfNeed( MovementInfo const& minfo,uint16 opcod
|
|||
if (m_lastFallTime >= minfo.fallTime || m_lastFallZ <=minfo.z || opcode == MSG_MOVE_FALL_LAND)
|
||||
SetFallInformation(minfo.fallTime, minfo.z);
|
||||
}
|
||||
|
||||
void Player::UnsummonPetTemporaryIfAny()
|
||||
{
|
||||
Pet* pet = GetPet();
|
||||
if(!pet)
|
||||
return;
|
||||
|
||||
if(!m_temporaryUnsummonedPetNumber && pet->isControlled() && !pet->isTemporarySummoned() )
|
||||
{
|
||||
m_temporaryUnsummonedPetNumber = pet->GetCharmInfo()->GetPetNumber();
|
||||
m_oldpetspell = pet->GetUInt32Value(UNIT_CREATED_BY_SPELL);
|
||||
}
|
||||
|
||||
RemovePet(pet, PET_SAVE_AS_CURRENT);
|
||||
}
|
||||
|
||||
void Player::ResummonPetTemporaryUnSummonedIfAny()
|
||||
{
|
||||
if(!m_temporaryUnsummonedPetNumber)
|
||||
return;
|
||||
|
||||
// not resummon in not appropriate state
|
||||
if(IsPetNeedBeTemporaryUnsummoned())
|
||||
return;
|
||||
|
||||
if(GetPetGUID())
|
||||
return;
|
||||
|
||||
Pet* NewPet = new Pet;
|
||||
if(!NewPet->LoadPetFromDB(this, 0, m_temporaryUnsummonedPetNumber, true))
|
||||
delete NewPet;
|
||||
|
||||
m_temporaryUnsummonedPetNumber = 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue