Don't call player movement hook if nothing changed (#4517)
Co-authored-by: peterbell10 <peterbell10@live.co.uk>
This commit is contained in:
parent
0e694ae257
commit
0de2a32365
@ -839,8 +839,28 @@ void cClientHandle::HandlePlayerPos(double a_PosX, double a_PosY, double a_PosZ,
|
||||
|
||||
Vector3d NewPosition(a_PosX, a_PosY, a_PosZ);
|
||||
Vector3d OldPosition = GetPlayer()->GetPosition();
|
||||
double OldStance = GetPlayer()->GetStance();
|
||||
auto PreviousIsOnGround = GetPlayer()->IsOnGround();
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wfloat-equal"
|
||||
#endif
|
||||
|
||||
if (
|
||||
(OldPosition == NewPosition) &&
|
||||
(OldStance == a_Stance) &&
|
||||
(PreviousIsOnGround == a_IsOnGround)
|
||||
)
|
||||
{
|
||||
// Nothing changed, no need to do anything
|
||||
return;
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
||||
// If the player has moved too far, "repair" them:
|
||||
if ((OldPosition - NewPosition).SqrLength() > 100 * 100)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user