[8742] Avoid aura remove triggered casts and packets send at logout/delete

This is must speedup logout and solve some crash cases or unexpected effects.

Also fix some nonsense code with memory lost possibility.
This commit is contained in:
VladimirMangos 2009-10-27 04:03:24 +03:00
parent 7b6f4accd1
commit 15ab6794d3
6 changed files with 117 additions and 121 deletions

View file

@ -354,38 +354,32 @@ void Pet::SavePetToDB(PetSaveMode mode)
if (!pOwner)
return;
// not save pet as current if another pet temporary unsummoned
if (mode == PET_SAVE_AS_CURRENT && pOwner->GetTemporaryUnsummonedPetNumber() &&
pOwner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber())
{
// pet will lost anyway at restore temporary unsummoned
if(getPetType()==HUNTER_PET)
return;
// for warlock case
mode = PET_SAVE_NOT_IN_SLOT;
}
uint32 curhealth = GetHealth();
uint32 curmana = GetPower(POWER_MANA);
// stable and not in slot saves
if(mode > PET_SAVE_AS_CURRENT)
{
RemoveAllAuras();
//only alive hunter pets get auras saved, the others don't
if(!(getPetType() == HUNTER_PET && isAlive()))
m_Auras.clear();
}
_SaveSpells();
_SaveSpellCooldowns();
_SaveAuras();
// current/stable/not_in_slot
if(mode >= PET_SAVE_AS_CURRENT)
if (mode >= PET_SAVE_AS_CURRENT)
{
// not save pet as current if another pet temporary unsummoned
if (mode == PET_SAVE_AS_CURRENT && pOwner->GetTemporaryUnsummonedPetNumber() &&
pOwner->GetTemporaryUnsummonedPetNumber() != m_charmInfo->GetPetNumber())
{
// pet will lost anyway at restore temporary unsummoned
if(getPetType()==HUNTER_PET)
return;
// for warlock case
mode = PET_SAVE_NOT_IN_SLOT;
}
uint32 curhealth = GetHealth();
uint32 curmana = GetPower(POWER_MANA);
// stable and not in slot saves
if (mode != PET_SAVE_AS_CURRENT)
RemoveAllAuras();
_SaveSpells();
_SaveSpellCooldowns();
_SaveAuras();
uint32 owner = GUID_LOPART(GetOwnerGUID());
std::string name = m_name;
CharacterDatabase.escape_string(name);
@ -440,7 +434,7 @@ void Pet::SavePetToDB(PetSaveMode mode)
// delete
else
{
RemoveAllAuras();
RemoveAllAuras(AURA_REMOVE_BY_DELETE);
DeleteFromDB(m_charmInfo->GetPetNumber());
}
}
@ -1144,9 +1138,7 @@ void Pet::_SaveSpells()
void Pet::_LoadAuras(uint32 timediff)
{
m_Auras.clear();
for (int i = 0; i < TOTAL_AURAS; ++i)
m_modAuras[i].clear();
RemoveAllAuras();
QueryResult *result = CharacterDatabase.PQuery("SELECT caster_guid,spell,effect_index,stackcount,amount,maxduration,remaintime,remaincharges FROM pet_aura WHERE guid = '%u'",m_charmInfo->GetPetNumber());