Core/Pets: Pet management refactoring

Port From (https://github.com/TrinityCore/TrinityCore/commit/ca92686b44cc8c53a8991bf02d6e8534797fc115)
This commit is contained in:
hondacrx
2022-03-10 09:39:55 -05:00
parent 9d5dd66215
commit 718302fa18
14 changed files with 549 additions and 378 deletions
+6 -1
View File
@@ -536,10 +536,12 @@ namespace Game
bool isdeclined = packet.RenameData.HasDeclinedNames;
string name = packet.RenameData.NewName;
PetStable petStable = _player.GetPetStable();
Pet pet = ObjectAccessor.GetPet(GetPlayer(), petguid);
// check it!
if (!pet || !pet.IsPet() || pet.ToPet().GetPetType() != PetType.Hunter || !pet.HasPetFlag(UnitPetFlags.CanBeRenamed) ||
pet.GetOwnerGUID() != GetPlayer().GetGUID() || pet.GetCharmInfo() == null)
pet.GetOwnerGUID() != _player.GetGUID() || pet.GetCharmInfo() == null ||
petStable == null || petStable.CurrentPet == null || petStable.CurrentPet.PetNumber != pet.GetCharmInfo().GetPetNumber())
return;
PetNameInvalidReason res = ObjectManager.CheckPetName(name);
@@ -559,6 +561,9 @@ namespace Game
pet.SetGroupUpdateFlag(GroupUpdatePetFlags.Name);
pet.RemovePetFlag(UnitPetFlags.CanBeRenamed);
petStable.CurrentPet.Name = name;
petStable.CurrentPet.WasRenamed = true;
PreparedStatement stmt;
SQLTransaction trans = new();
if (isdeclined)