Entities/Unit: Fix speed update packets if player is being moved by something else.

Closes #17184
Closes #17254
This commit is contained in:
treeston
2016-05-31 22:49:28 +02:00
committed by Shauren
parent 7db377c7f9
commit 19fa504ff5
2 changed files with 19 additions and 4 deletions

View File

@@ -12033,7 +12033,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate)
pet->SetSpeedRate(mtype, m_speed_rate[mtype]);
}
if (m_movedPlayer) // unit controlled by a player.
if (Player* playerMover = GetPlayerMover()) // unit controlled by a player.
{
// Send notification to self. this packet is only sent to one client (the client of the player concerned by the change).
WorldPacket self;
@@ -12043,7 +12043,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate)
if (mtype == MOVE_RUN)
self << uint8(1); // unknown byte added in 2.1.0
self << float(GetSpeed(mtype));
m_movedPlayer->GetSession()->SendPacket(&self);
playerMover->GetSession()->SendPacket(&self);
// Send notification to other players. sent to every clients (if in range) except one: the client of the player concerned by the change.
WorldPacket data;
@@ -12051,7 +12051,7 @@ void Unit::SetSpeedRate(UnitMoveType mtype, float rate)
data << GetPackGUID();
BuildMovementPacket(&data);
data << float(GetSpeed(mtype));
SendMessageToSet(&data, false);
playerMover->SendMessageToSet(&data, false);
}
else // unit controlled by AI.
{
@@ -13577,6 +13577,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);

View File

@@ -1685,7 +1685,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);