Core: Update to 10.1.5
Port From (https://github.com/TrinityCore/TrinityCore/commit/0cea730fa23473a85c47451c3bd13df816f2b6e4)
This commit is contained in:
@@ -324,61 +324,10 @@ namespace Game
|
||||
if (GetPlayer().IsMounted())
|
||||
GetPlayer().RemoveAurasByType(AuraType.Mounted);
|
||||
|
||||
SendStablePet(packet.StableMaster);
|
||||
_player.SetStableMaster(packet.StableMaster);
|
||||
}
|
||||
|
||||
public void SendStablePet(ObjectGuid guid)
|
||||
{
|
||||
PetStableList packet = new();
|
||||
packet.StableMaster = guid;
|
||||
|
||||
PetStable petStable = GetPlayer().GetPetStable();
|
||||
if (petStable == null)
|
||||
{
|
||||
SendPacket(packet);
|
||||
return;
|
||||
}
|
||||
|
||||
for (uint petSlot = 0; petSlot < petStable.ActivePets.Length; ++petSlot)
|
||||
{
|
||||
if (petStable.ActivePets[petSlot] == null)
|
||||
continue;
|
||||
|
||||
PetStable.PetInfo pet = petStable.ActivePets[petSlot];
|
||||
PetStableInfo stableEntry;
|
||||
stableEntry.PetSlot = petSlot + (int)PetSaveMode.FirstActiveSlot;
|
||||
stableEntry.PetNumber = pet.PetNumber;
|
||||
stableEntry.CreatureID = pet.CreatureId;
|
||||
stableEntry.DisplayID = pet.DisplayId;
|
||||
stableEntry.ExperienceLevel = pet.Level;
|
||||
stableEntry.PetFlags = PetStableinfo.Active;
|
||||
stableEntry.PetName = pet.Name;
|
||||
|
||||
packet.Pets.Add(stableEntry);
|
||||
}
|
||||
|
||||
for (uint petSlot = 0; petSlot < petStable.StabledPets.Length; ++petSlot)
|
||||
{
|
||||
if (petStable.StabledPets[petSlot] == null)
|
||||
continue;
|
||||
|
||||
PetStable.PetInfo pet = petStable.StabledPets[petSlot];
|
||||
PetStableInfo stableEntry;
|
||||
stableEntry.PetSlot = petSlot + (int)PetSaveMode.FirstStableSlot;
|
||||
stableEntry.PetNumber = pet.PetNumber;
|
||||
stableEntry.CreatureID = pet.CreatureId;
|
||||
stableEntry.DisplayID = pet.DisplayId;
|
||||
stableEntry.ExperienceLevel = pet.Level;
|
||||
stableEntry.PetFlags = PetStableinfo.Inactive;
|
||||
stableEntry.PetName = pet.Name;
|
||||
|
||||
packet.Pets.Add(stableEntry);
|
||||
}
|
||||
|
||||
SendPacket(packet);
|
||||
}
|
||||
|
||||
void SendPetStableResult(StableResult result)
|
||||
public void SendPetStableResult(StableResult result)
|
||||
{
|
||||
PetStableResult petStableResult = new();
|
||||
petStableResult.Result = result;
|
||||
@@ -394,141 +343,7 @@ namespace Game
|
||||
return;
|
||||
}
|
||||
|
||||
GetPlayer().RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.Interacting);
|
||||
|
||||
PetStable petStable = GetPlayer().GetPetStable();
|
||||
if (petStable == null)
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
return;
|
||||
}
|
||||
|
||||
(PetStable.PetInfo srcPet, PetSaveMode srcPetSlot) = Pet.GetLoadPetInfo(petStable, 0, setPetSlot.PetNumber, null);
|
||||
PetSaveMode dstPetSlot = (PetSaveMode)setPetSlot.DestSlot;
|
||||
PetStable.PetInfo dstPet = Pet.GetLoadPetInfo(petStable, 0, 0, dstPetSlot).Item1;
|
||||
|
||||
if (srcPet == null || srcPet.Type != PetType.Hunter)
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
return;
|
||||
}
|
||||
|
||||
if (dstPet != null && dstPet.Type != PetType.Hunter)
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
return;
|
||||
}
|
||||
|
||||
PetStable.PetInfo src = null;
|
||||
PetStable.PetInfo dst = null;
|
||||
PetSaveMode? newActivePetIndex = null;
|
||||
|
||||
if (SharedConst.IsActivePetSlot(srcPetSlot) && SharedConst.IsActivePetSlot(dstPetSlot))
|
||||
{
|
||||
// active<.active: only swap ActivePets and CurrentPetIndex (do not despawn pets)
|
||||
src = petStable.ActivePets[srcPetSlot - PetSaveMode.FirstActiveSlot];
|
||||
dst = petStable.ActivePets[dstPetSlot - PetSaveMode.FirstActiveSlot];
|
||||
|
||||
if (petStable.GetCurrentActivePetIndex().Value == (uint)srcPetSlot)
|
||||
newActivePetIndex = dstPetSlot;
|
||||
else if (petStable.GetCurrentActivePetIndex().Value == (uint)dstPetSlot)
|
||||
newActivePetIndex = srcPetSlot;
|
||||
}
|
||||
else if (SharedConst.IsStabledPetSlot(srcPetSlot) && SharedConst.IsStabledPetSlot(dstPetSlot))
|
||||
{
|
||||
// stabled<.stabled: only swap StabledPets
|
||||
src = petStable.StabledPets[srcPetSlot - PetSaveMode.FirstStableSlot];
|
||||
dst = petStable.StabledPets[dstPetSlot - PetSaveMode.FirstStableSlot];
|
||||
}
|
||||
else if (SharedConst.IsActivePetSlot(srcPetSlot) && SharedConst.IsStabledPetSlot(dstPetSlot))
|
||||
{
|
||||
// active<.stabled: swap petStable contents and despawn active pet if it is involved in swap
|
||||
if (petStable.CurrentPetIndex.Value == (uint)srcPetSlot)
|
||||
{
|
||||
Pet oldPet = _player.GetPet();
|
||||
if (oldPet != null && !oldPet.IsAlive())
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.RemovePet(oldPet, PetSaveMode.NotInSlot);
|
||||
}
|
||||
|
||||
if (dstPet != null)
|
||||
{
|
||||
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(dstPet.CreatureId);
|
||||
if (creatureInfo == null || !creatureInfo.IsTameable(_player.CanTameExoticPets(), creatureInfo.GetDifficulty(Difficulty.None)))
|
||||
{
|
||||
SendPetStableResult(StableResult.CantControlExotic);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
src = petStable.ActivePets[srcPetSlot - PetSaveMode.FirstActiveSlot];
|
||||
dst = petStable.StabledPets[dstPetSlot - PetSaveMode.FirstStableSlot];
|
||||
}
|
||||
else if (SharedConst.IsStabledPetSlot(srcPetSlot) && SharedConst.IsActivePetSlot(dstPetSlot))
|
||||
{
|
||||
// stabled<.active: swap petStable contents and despawn active pet if it is involved in swap
|
||||
if (petStable.CurrentPetIndex.Value == (uint)dstPetSlot)
|
||||
{
|
||||
Pet oldPet = _player.GetPet();
|
||||
if (oldPet != null && !oldPet.IsAlive())
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
return;
|
||||
}
|
||||
|
||||
_player.RemovePet(oldPet, PetSaveMode.NotInSlot);
|
||||
}
|
||||
|
||||
CreatureTemplate creatureInfo = Global.ObjectMgr.GetCreatureTemplate(srcPet.CreatureId);
|
||||
if (creatureInfo == null || !creatureInfo.IsTameable(_player.CanTameExoticPets(), creatureInfo.GetDifficulty(Difficulty.None)))
|
||||
{
|
||||
SendPetStableResult(StableResult.CantControlExotic);
|
||||
return;
|
||||
}
|
||||
|
||||
src = petStable.StabledPets[srcPetSlot - PetSaveMode.FirstStableSlot];
|
||||
dst = petStable.ActivePets[dstPetSlot - PetSaveMode.FirstActiveSlot];
|
||||
}
|
||||
|
||||
SQLTransaction trans = new();
|
||||
|
||||
PreparedStatement stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt.AddValue(0, (short)dstPetSlot);
|
||||
stmt.AddValue(1, _player.GetGUID().GetCounter());
|
||||
stmt.AddValue(2, srcPet.PetNumber);
|
||||
trans.Append(stmt);
|
||||
|
||||
if (dstPet != null)
|
||||
{
|
||||
stmt = CharacterDatabase.GetPreparedStatement(CharStatements.UPD_CHAR_PET_SLOT_BY_ID);
|
||||
stmt.AddValue(0, (short)srcPetSlot);
|
||||
stmt.AddValue(1, _player.GetGUID().GetCounter());
|
||||
stmt.AddValue(2, dstPet.PetNumber);
|
||||
trans.Append(stmt);
|
||||
}
|
||||
|
||||
AddTransactionCallback(DB.Characters.AsyncCommitTransaction(trans)).AfterComplete(success =>
|
||||
{
|
||||
var currentPlayerGuid = _player.GetGUID();
|
||||
if (_player && _player.GetGUID() == currentPlayerGuid)
|
||||
{
|
||||
if (success)
|
||||
{
|
||||
Extensions.Swap(ref src, ref dst);
|
||||
if (newActivePetIndex.HasValue)
|
||||
GetPlayer().GetPetStable().SetCurrentActivePetIndex((uint)newActivePetIndex.Value);
|
||||
SendPetStableResult(StableResult.StableSuccess);
|
||||
}
|
||||
else
|
||||
{
|
||||
SendPetStableResult(StableResult.InternalError);
|
||||
}
|
||||
}
|
||||
});
|
||||
_player.SetPetSlot(setPetSlot.PetNumber, (PetSaveMode)setPetSlot.DestSlot);
|
||||
}
|
||||
|
||||
[WorldPacketHandler(ClientOpcodes.RepairItem, Processing = PacketProcessing.Inplace)]
|
||||
|
||||
Reference in New Issue
Block a user