Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Player: Experimental new movement processing system #2646

Closed
wants to merge 1 commit into from

Conversation

dktapps
Copy link
Member

@dktapps dktapps commented Jan 6, 2019

Introduction

The existing movement system is problematic because it only processes the last movement received on a tick. This can be a problem on laggy connections. Even when not on a laggy connection, this can cause problems like anti-cheat triggering falsely (anti fly not seeing players touch ground), the infamous "moved too fast", and more.

This PR changes movement processing to use a pending movement queue instead of only processing the last movement. This allows much more effective recovery from network lag spikes without rubberbanding. With this in place, appearances of moved too fast will be significantly reduced.

This has been carefully designed to avoid exposing the server to attack vectors, but it is not complete on the security front yet.

Relevant issues

@dktapps dktapps added Category: Gameplay Related to Minecraft gameplay experience Category: Core Related to internal functionality Type: Fix Bug fix, typo fix, or any other fix Status: Insufficiently Tested Status: Incomplete Work in progress labels Jan 6, 2019
@dktapps
Copy link
Member Author

dktapps commented Jan 16, 2019

This should make use of real time instead of ticks to reduce lag problems.

@dktapps
Copy link
Member Author

dktapps commented Jan 20, 2019

This can be enhanced by ignoring movements which only involve rotation compared to the previous movement, since rotation has no effect on movement distance.

@dktapps dktapps closed this Feb 22, 2019
@dktapps dktapps changed the base branch from 3.5 to 3.6 February 22, 2019 18:04
@dktapps dktapps reopened this Feb 22, 2019
@dktapps dktapps closed this Mar 29, 2019
@dktapps dktapps changed the base branch from 3.6 to 3.7 March 30, 2019 00:13
@dktapps dktapps reopened this Mar 30, 2019
@dktapps dktapps changed the base branch from 3.7 to stable April 14, 2019 21:50
@buchwasa
Copy link
Contributor

buchwasa commented Apr 28, 2019

I've been testing this and the only bug I've noticed was when falling from a very large height (32,000 to less than 20,000) you lose hunger rapidly, which isn't like that in vanilla.

@dktapps
Copy link
Member Author

dktapps commented Apr 28, 2019

#2708

@dktapps
Copy link
Member Author

dktapps commented Sep 16, 2019

This pull is overcomplicated. This change could be better implemented by removing buffering entirely and implementing a simple network-layer rate-limit, which would also cooperate better with things like block placement.

I'm closing this due to being stale and having conflicts.

@dktapps dktapps closed this Sep 16, 2019
@dktapps dktapps deleted the multiple-move-buffer branch September 16, 2019 15:07
@dktapps dktapps added Resolution: Declined PR has been declined by maintainers and removed Status: Insufficiently Tested Status: Incomplete Work in progress labels Sep 16, 2019
dktapps added a commit that referenced this pull request May 31, 2020
#3167)

Introduction
This PR is a second attempt at improving movement processing to fix #1215 , #2730 and more.

This is significantly less complex than the previous attempt #2646 -- it gets rid of the movement buffering system entirely and instead relies on a simple rate limit counter to restrict on-the-fly movement processing.

Movement is rate limited to a max average of 2 per tick. It allows up to 5 seconds' backlog to accommodate network lag. The rate limit counter is increased by 2 per tick and decreased once for every movement processed. This prevents movement processing being abused for denial of service attacks.

Changes
API changes
This PR, while obviously highly beneficial for most current users, poses some BC-breaking issues because of changes to the internal Player API.

Player->processMovement() (protected) has been removed. This is a BC concern for custom player classes which overrode it and called it as a parent. In addition, child implementations won't be called every tick any more, which could break some custom movement processing systems.
Player->newPosition (protected) has been removed. This internal field may have been accessed by custom movement implementations.
Player->isTeleporting (protected) has been removed. BC concern is same as previous point.
Player->getNextPosition() (public) has been @deprecated.
Added the following protected Player class members:
int $moveRateLimit
?Vector3 $forceMoveSync
handleMovement()
processMostRecentMovements()
revertMovement()
Behavioural changes
Player movement is now subject to less rubberbanding and has more reliable behaviour.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Category: Core Related to internal functionality Category: Gameplay Related to Minecraft gameplay experience Resolution: Declined PR has been declined by maintainers Type: Fix Bug fix, typo fix, or any other fix
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Movement buffering system causes various bugs on net lag spikes
2 participants