mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-06 11:57:10 +00:00
Player: use real time to update rate limit, fixes #3554 (except in very extreme cases)
This commit is contained in:
parent
c864647cd1
commit
a0de9b0d46
@ -334,8 +334,10 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
/** @var bool[] map: raw UUID (string) => bool */
|
||||
protected $hiddenPlayers = [];
|
||||
|
||||
/** @var int */
|
||||
/** @var float */
|
||||
protected $moveRateLimit = 10 * self::MOVES_PER_TICK;
|
||||
/** @var float|null */
|
||||
protected $lastMovementProcess = null;
|
||||
/** @var Vector3|null */
|
||||
protected $forceMoveSync = null;
|
||||
|
||||
@ -1593,8 +1595,11 @@ class Player extends Human implements CommandSender, ChunkLoader, IPlayer{
|
||||
* Fires movement events and synchronizes player movement, every tick.
|
||||
*/
|
||||
protected function processMostRecentMovements() : void{
|
||||
$now = microtime(true);
|
||||
$multiplier = $this->lastMovementProcess !== null ? ($now - $this->lastMovementProcess) * 20 : 1;
|
||||
$exceededRateLimit = $this->moveRateLimit < 0;
|
||||
$this->moveRateLimit = min(self::MOVE_BACKLOG_SIZE, max(0, $this->moveRateLimit) + self::MOVES_PER_TICK);
|
||||
$this->moveRateLimit = min(self::MOVE_BACKLOG_SIZE, max(0, $this->moveRateLimit) + self::MOVES_PER_TICK * $multiplier);
|
||||
$this->lastMovementProcess = $now;
|
||||
|
||||
$from = new Location($this->lastX, $this->lastY, $this->lastZ, $this->lastYaw, $this->lastPitch, $this->level);
|
||||
$to = $this->getLocation();
|
||||
|
Loading…
x
Reference in New Issue
Block a user