diff --git a/src/game/Pet.cpp b/src/game/Pet.cpp index be4fa1800..3aa929459 100644 --- a/src/game/Pet.cpp +++ b/src/game/Pet.cpp @@ -380,17 +380,15 @@ void Pet::SavePetToDB(PetSaveMode mode) if (mode != PET_SAVE_AS_CURRENT) RemoveAllAuras(); - //save pet's spell data as one single transaction + //save pet's data as one single transaction CharacterDatabase.BeginTransaction(); _SaveSpells(); _SaveSpellCooldowns(); _SaveAuras(); - CharacterDatabase.CommitTransaction(); uint32 ownerLow = GetOwnerGuid().GetCounter(); std::string name = m_name; CharacterDatabase.escape_string(name); - CharacterDatabase.BeginTransaction(); // remove current data 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_declinedname WHERE id = '%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_cooldown WHERE guid = '%u'", guidlow); + + if(separate_transaction) + CharacterDatabase.CommitTransaction(); } void Pet::SetDeathState(DeathState s) // overwrite virtual Creature::SetDeathState and Unit::SetDeathState diff --git a/src/game/Pet.h b/src/game/Pet.h index e4f80c336..184626cb0 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -154,7 +154,7 @@ class Pet : public Creature bool LoadPetFromDB( Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false ); void SavePetToDB(PetSaveMode mode); 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 Update(uint32 update_diff, uint32 diff); // overwrite virtual Creature::Update and Unit::Update diff --git a/src/game/Player.cpp b/src/game/Player.cpp index b89de5e3e..5ee40b139 100644 --- a/src/game/Player.cpp +++ b/src/game/Player.cpp @@ -4307,7 +4307,8 @@ void Player::DeleteFromDB(ObjectGuid playerguid, uint32 accountId, bool updateRe { Field *fields3 = resultPets->Fetch(); 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()); delete resultPets; } diff --git a/src/shared/revision_nr.h b/src/shared/revision_nr.h index c5d9f064b..5d456a62d 100644 --- a/src/shared/revision_nr.h +++ b/src/shared/revision_nr.h @@ -1,4 +1,4 @@ #ifndef __REVISION_NR_H__ #define __REVISION_NR_H__ - #define REVISION_NR "11054" + #define REVISION_NR "11055" #endif // __REVISION_NR_H__