mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Entities/Unit: Fix speed update packets if player is being moved by something else.
Closes #17184
Closes #17254
(cherry picked from commit 19fa504ff5)
This commit is contained in:
@@ -10024,20 +10024,20 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate)
|
||||
pet->SetSpeedRate(mtype, m_speed_rate[mtype]);
|
||||
}
|
||||
|
||||
if (GetTypeId() == TYPEID_PLAYER && ToPlayer()->m_mover->GetTypeId() == TYPEID_PLAYER)
|
||||
if (Player* playerMover = GetPlayerMover()) // unit controlled by a player.
|
||||
{
|
||||
// Send notification to self
|
||||
WorldPackets::Movement::MoveSetSpeed selfpacket(moveTypeToOpcode[mtype][1]);
|
||||
selfpacket.MoverGUID = GetGUID();
|
||||
selfpacket.SequenceIndex = m_movementCounter++;
|
||||
selfpacket.Speed = GetSpeed(mtype);
|
||||
ToPlayer()->GetSession()->SendPacket(selfpacket.Write());
|
||||
playerMover->GetSession()->SendPacket(selfpacket.Write());
|
||||
|
||||
// Send notification to other players
|
||||
WorldPackets::Movement::MoveUpdateSpeed packet(moveTypeToOpcode[mtype][2]);
|
||||
packet.movementInfo = &m_movementInfo;
|
||||
packet.Speed = GetSpeed(mtype);
|
||||
SendMessageToSet(packet.Write(), false);
|
||||
playerMover->SendMessageToSet(packet.Write(), false);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -11610,6 +11610,20 @@ void CharmInfo::SetSpellAutocast(SpellInfo const* spellInfo, bool state)
|
||||
}
|
||||
}
|
||||
|
||||
Unit* Unit::GetMover() const
|
||||
{
|
||||
if (Player const* player = ToPlayer())
|
||||
return player->m_mover;
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Player* Unit::GetPlayerMover() const
|
||||
{
|
||||
if (Unit* mover = GetMover())
|
||||
return mover->ToPlayer();
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool Unit::isFrozen() const
|
||||
{
|
||||
return HasAuraState(AURA_STATE_FROZEN);
|
||||
|
||||
@@ -1751,7 +1751,8 @@ class TC_GAME_API Unit : public WorldObject
|
||||
CharmInfo* InitCharmInfo();
|
||||
void DeleteCharmInfo();
|
||||
void UpdateCharmAI();
|
||||
//Player* GetMoverSource() const;
|
||||
Unit* GetMover() const;
|
||||
Player* GetPlayerMover() const;
|
||||
Player* m_movedPlayer;
|
||||
SharedVisionList const& GetSharedVisionList() { return m_sharedVision; }
|
||||
void AddPlayerToVision(Player* player);
|
||||
|
||||
Reference in New Issue
Block a user