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: remove move buffering, implement simple rate limited movement… #3167

Merged
merged 3 commits into from May 31, 2020

Conversation

dktapps
Copy link
Member

@dktapps dktapps commented Oct 27, 2019

… processing

this needs some work to fix move sync spam in some areas, but this is nothing that wasn't already a problem to begin with.

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.

Tests

Basic testing has been done. There are some corner cases which I'm not completely happy with yet, but those are equivalent to problems which already existed.

@dktapps dktapps added BC break Breaks API compatibility Category: Gameplay Related to Minecraft gameplay experience Type: Contribution Type: Change Proposal RFCs (Request for Comments) on change ideas for PocketMine-MP labels Oct 27, 2019
@SatanaDev
Copy link

Wow

@dktapps
Copy link
Member Author

dktapps commented May 31, 2020

Considering the high value of the changes in this PR, I've decided to try and make this backwards compatible.

… processing

this needs some work to fix move sync spam in some areas, but this is nothing that wasn't already a problem to begin with.
@dktapps dktapps force-pushed the experimental/better-movement branch from 8e43cce to 4ed444d Compare May 31, 2020 14:27
@dktapps
Copy link
Member Author

dktapps commented May 31, 2020

never mind, seems like I can't hack this perfectly... so, it's time to bend the rules a little bit.

@dktapps dktapps changed the base branch from stable to next-minor May 31, 2020 14:46
@dktapps dktapps merged commit 485f573 into next-minor May 31, 2020
@dktapps dktapps deleted the experimental/better-movement branch May 31, 2020 14:51
@dktapps dktapps added Type: Enhancement Contributes features or other improvements to PocketMine-MP and removed Type: Contribution labels Nov 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BC break Breaks API compatibility Category: Gameplay Related to Minecraft gameplay experience Type: Change Proposal RFCs (Request for Comments) on change ideas for PocketMine-MP Type: Enhancement Contributes features or other improvements to PocketMine-MP
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