mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-04 00:59:51 +00:00
InGamePacketHandler: avoid useless object allocations when forceMoveSync=false (99.9% of the time)
This commit is contained in:
parent
b75bc61a64
commit
c26631d06d
@ -197,17 +197,20 @@ class InGamePacketHandler extends PacketHandler{
|
|||||||
|
|
||||||
$this->player->setRotation($yaw, $pitch);
|
$this->player->setRotation($yaw, $pitch);
|
||||||
|
|
||||||
$curPos = $this->player->getLocation();
|
|
||||||
$newPos = $rawPos->round(4)->subtract(0, 1.62, 0);
|
$newPos = $rawPos->round(4)->subtract(0, 1.62, 0);
|
||||||
|
|
||||||
if($this->forceMoveSync && $newPos->distanceSquared($curPos) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks
|
if($this->forceMoveSync){
|
||||||
$this->session->getLogger()->debug("Got outdated pre-teleport movement, received " . $newPos . ", expected " . $curPos);
|
$curPos = $this->player->getLocation();
|
||||||
//Still getting movements from before teleport, ignore them
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Once we get a movement within a reasonable distance, treat it as a teleport ACK and remove position lock
|
if($newPos->distanceSquared($curPos) > 1){ //Tolerate up to 1 block to avoid problems with client-sided physics when spawning in blocks
|
||||||
$this->forceMoveSync = false;
|
$this->session->getLogger()->debug("Got outdated pre-teleport movement, received " . $newPos . ", expected " . $curPos);
|
||||||
|
//Still getting movements from before teleport, ignore them
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Once we get a movement within a reasonable distance, treat it as a teleport ACK and remove position lock
|
||||||
|
$this->forceMoveSync = false;
|
||||||
|
}
|
||||||
|
|
||||||
$inputFlags = $packet->getInputFlags();
|
$inputFlags = $packet->getInputFlags();
|
||||||
if($inputFlags !== $this->lastPlayerAuthInputFlags){
|
if($inputFlags !== $this->lastPlayerAuthInputFlags){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user