mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 04:37:00 +00:00
[10739] Cleanup pet remove code and some fixes.
* Merge Player::RemovePet and Pet::Remove function code to Pet::Unsummon This let be sure that in all cases all required steps doen. For example this fix creature's guardians propertly remove from guardians list. * Add new pet save mode PET_SAVE_REAGENTS as replacement PET_SAVE_NOT_IN_SLOT+true-arg stable pair in old function args This will avoid use reagent save arg with wrong different save modes. * Fixed recently added code with absent check for re-summon protector pet call.
This commit is contained in:
parent
de66f32882
commit
f9bcfa3a89
13 changed files with 138 additions and 125 deletions
|
|
@ -4590,6 +4590,25 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
|
|||
if (!propEntry)
|
||||
return;
|
||||
|
||||
PetType petType = propEntry->Title == UNITNAME_SUMMON_TITLE_COMPANION ? PROTECTOR_PET : GUARDIAN_PET;
|
||||
|
||||
// protectors allowed only in single amount
|
||||
if (petType == PROTECTOR_PET)
|
||||
{
|
||||
Pet* old_protector = m_caster->GetProtectorPet();
|
||||
|
||||
// for same pet just despawn
|
||||
if (old_protector && old_protector->GetEntry() == pet_entry)
|
||||
{
|
||||
old_protector->Unsummon(PET_SAVE_AS_DELETED, m_caster);
|
||||
return;
|
||||
}
|
||||
|
||||
// despawn old pet before summon new
|
||||
if (old_protector)
|
||||
old_protector->Unsummon(PET_SAVE_AS_DELETED, m_caster);
|
||||
}
|
||||
|
||||
// in another case summon new
|
||||
uint32 level = m_caster->getLevel();
|
||||
|
||||
|
|
@ -4621,7 +4640,7 @@ void Spell::DoSummonGuardian(SpellEffectIndex eff_idx, uint32 forceFaction)
|
|||
|
||||
for(int32 count = 0; count < amount; ++count)
|
||||
{
|
||||
Pet* spawnCreature = new Pet(propEntry->Title == UNITNAME_SUMMON_TITLE_COMPANION ? PROTECTOR_PET : GUARDIAN_PET);
|
||||
Pet* spawnCreature = new Pet(petType);
|
||||
|
||||
Map *map = m_caster->GetMap();
|
||||
uint32 pet_number = sObjectMgr.GeneratePetNumber();
|
||||
|
|
@ -5039,7 +5058,7 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
|
|||
}
|
||||
|
||||
if(m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)m_caster)->RemovePet(OldSummon,(OldSummon->getPetType()==HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT),false);
|
||||
OldSummon->Unsummon(OldSummon->getPetType() == HUNTER_PET ? PET_SAVE_AS_DELETED : PET_SAVE_NOT_IN_SLOT, m_caster);
|
||||
else
|
||||
return;
|
||||
}
|
||||
|
|
@ -5051,7 +5070,7 @@ void Spell::EffectSummonPet(SpellEffectIndex eff_idx)
|
|||
return;
|
||||
|
||||
// not error in case fail hunter call pet
|
||||
if(!petentry)
|
||||
if (!petentry)
|
||||
{
|
||||
delete NewSummon;
|
||||
return;
|
||||
|
|
@ -6194,7 +6213,7 @@ void Spell::EffectScriptEffect(SpellEffectIndex eff_idx)
|
|||
{
|
||||
// Is this all to be done at completion?
|
||||
if (Pet* pPet = m_caster->FindGuardianWithEntry(pSpell->EffectMiscValue[EFFECT_INDEX_0]))
|
||||
((Player*)m_caster)->RemovePet(pPet, PET_SAVE_NOT_IN_SLOT);
|
||||
pPet->Unsummon(PET_SAVE_NOT_IN_SLOT, m_caster);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
|
@ -7224,7 +7243,7 @@ void Spell::EffectDismissPet(SpellEffectIndex /*eff_idx*/)
|
|||
if(!pet||!pet->isAlive())
|
||||
return;
|
||||
|
||||
((Player*)m_caster)->RemovePet(pet, PET_SAVE_NOT_IN_SLOT);
|
||||
pet->Unsummon(PET_SAVE_NOT_IN_SLOT, m_caster);
|
||||
}
|
||||
|
||||
void Spell::EffectSummonObject(SpellEffectIndex eff_idx)
|
||||
|
|
@ -7602,7 +7621,7 @@ void Spell::DoSummonCritter(SpellEffectIndex eff_idx, uint32 forceFaction)
|
|||
if(duration > 0)
|
||||
critter->SetDuration(duration);
|
||||
|
||||
player->SetMiniPet(critter);
|
||||
player->_SetMiniPet(critter);
|
||||
|
||||
map->Add((Creature*)critter);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue