1
0

Don't call player movement hook if nothing changed (#4517)

Co-authored-by: peterbell10 <peterbell10@live.co.uk>
This commit is contained in:
Mat 2020-03-21 14:57:19 +02:00 committed by GitHub
parent 0e694ae257
commit 0de2a32365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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)
{