mirror of
https://github.com/mangosfour/server.git
synced 2025-12-16 13:37:00 +00:00
[11055] Save pet related data in one single transaction. Also merge Pet::DeleteFromDB() queries into one single transaction request.
Signed-off-by: Ambal <pogrebniak@gala.net>
This commit is contained in:
parent
07c9f0cbb8
commit
7ef75985b9
4 changed files with 12 additions and 7 deletions
|
|
@ -380,17 +380,15 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||||
if (mode != PET_SAVE_AS_CURRENT)
|
if (mode != PET_SAVE_AS_CURRENT)
|
||||||
RemoveAllAuras();
|
RemoveAllAuras();
|
||||||
|
|
||||||
//save pet's spell data as one single transaction
|
//save pet's data as one single transaction
|
||||||
CharacterDatabase.BeginTransaction();
|
CharacterDatabase.BeginTransaction();
|
||||||
_SaveSpells();
|
_SaveSpells();
|
||||||
_SaveSpellCooldowns();
|
_SaveSpellCooldowns();
|
||||||
_SaveAuras();
|
_SaveAuras();
|
||||||
CharacterDatabase.CommitTransaction();
|
|
||||||
|
|
||||||
uint32 ownerLow = GetOwnerGuid().GetCounter();
|
uint32 ownerLow = GetOwnerGuid().GetCounter();
|
||||||
std::string name = m_name;
|
std::string name = m_name;
|
||||||
CharacterDatabase.escape_string(name);
|
CharacterDatabase.escape_string(name);
|
||||||
CharacterDatabase.BeginTransaction();
|
|
||||||
// remove current data
|
// remove current data
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLow, m_charmInfo->GetPetNumber());
|
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE owner = '%u' AND id = '%u'", ownerLow, m_charmInfo->GetPetNumber());
|
||||||
|
|
||||||
|
|
@ -445,13 +443,19 @@ void Pet::SavePetToDB(PetSaveMode mode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::DeleteFromDB(uint32 guidlow)
|
void Pet::DeleteFromDB(uint32 guidlow, bool separate_transaction)
|
||||||
{
|
{
|
||||||
|
if(separate_transaction)
|
||||||
|
CharacterDatabase.BeginTransaction();
|
||||||
|
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE id = '%u'", guidlow);
|
CharacterDatabase.PExecute("DELETE FROM character_pet WHERE id = '%u'", guidlow);
|
||||||
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE id = '%u'", guidlow);
|
CharacterDatabase.PExecute("DELETE FROM character_pet_declinedname WHERE id = '%u'", guidlow);
|
||||||
CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", guidlow);
|
CharacterDatabase.PExecute("DELETE FROM pet_aura WHERE guid = '%u'", guidlow);
|
||||||
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u'", guidlow);
|
CharacterDatabase.PExecute("DELETE FROM pet_spell WHERE guid = '%u'", guidlow);
|
||||||
CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", guidlow);
|
CharacterDatabase.PExecute("DELETE FROM pet_spell_cooldown WHERE guid = '%u'", guidlow);
|
||||||
|
|
||||||
|
if(separate_transaction)
|
||||||
|
CharacterDatabase.CommitTransaction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
||||||
|
|
|
||||||
|
|
@ -154,7 +154,7 @@ class Pet : public Creature
|
||||||
bool LoadPetFromDB( Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false );
|
bool LoadPetFromDB( Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false );
|
||||||
void SavePetToDB(PetSaveMode mode);
|
void SavePetToDB(PetSaveMode mode);
|
||||||
void Unsummon(PetSaveMode mode, Unit* owner = NULL);
|
void Unsummon(PetSaveMode mode, Unit* owner = NULL);
|
||||||
static void DeleteFromDB(uint32 guidlow);
|
static void DeleteFromDB(uint32 guidlow, bool separate_transaction = true);
|
||||||
|
|
||||||
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
void SetDeathState(DeathState s); // overwrite virtual Creature::SetDeathState and Unit::SetDeathState
|
||||||
void Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
void Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update
|
||||||
|
|
|
||||||
|
|
@ -4307,7 +4307,8 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe
|
||||||
{
|
{
|
||||||
Field *fields3 = resultPets->Fetch();
|
Field *fields3 = resultPets->Fetch();
|
||||||
uint32 petguidlow = fields3[0].GetUInt32();
|
uint32 petguidlow = fields3[0].GetUInt32();
|
||||||
Pet::DeleteFromDB(petguidlow);
|
//do not create separate transaction for pet delete otherwise we will get fatal error!
|
||||||
|
Pet::DeleteFromDB(petguidlow, false);
|
||||||
} while (resultPets->NextRow());
|
} while (resultPets->NextRow());
|
||||||
delete resultPets;
|
delete resultPets;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
#ifndef __REVISION_NR_H__
|
#ifndef __REVISION_NR_H__
|
||||||
#define __REVISION_NR_H__
|
#define __REVISION_NR_H__
|
||||||
#define REVISION_NR "11054"
|
#define REVISION_NR "11055"
|
||||||
#endif // __REVISION_NR_H__
|
#endif // __REVISION_NR_H__
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue