fix(Core/Units): Fixed restoring running movement flag after charm. Source: TrinityCore (#12019)

fix(Core/Units): Fixed restoring running movement flag after charm.

Fixes #12018
This commit is contained in:
UltraNix
2022-06-16 13:45:46 +02:00
committed by GitHub
parent ee6ad8d755
commit daff1239d3
2 changed files with 14 additions and 1 deletions

View File

@@ -315,6 +315,8 @@ Unit::Unit(bool isWorldObject) : WorldObject(isWorldObject),
_oldFactionId = 0;
_isWalkingBeforeCharm = false;
_lastExtraAttackSpell = 0;
}
@@ -10464,8 +10466,12 @@ void Unit::SetCharm(Unit* charm, bool apply)
if (!charm->AddGuidValue(UNIT_FIELD_CHARMEDBY, GetGUID()))
LOG_FATAL("entities.unit", "Unit {} is being charmed, but it already has a charmer {}", charm->GetEntry(), charm->GetCharmerGUID().ToString());
if (charm->HasUnitMovementFlag(MOVEMENTFLAG_WALKING))
_isWalkingBeforeCharm = charm->IsWalking();
if (_isWalkingBeforeCharm)
{
charm->SetWalk(false);
charm->SendMovementFlagUpdate();
}
m_Controlled.insert(charm);
}
@@ -10503,6 +10509,12 @@ void Unit::SetCharm(Unit* charm, bool apply)
charm->SetByteValue(UNIT_FIELD_BYTES_2, 1, 0);
}
if (charm->IsWalking() != _isWalkingBeforeCharm)
{
charm->SetWalk(_isWalkingBeforeCharm);
charm->SendMovementFlagUpdate(true); // send packet to self, to update movement state on player.
}
m_Controlled.erase(charm);
}
}