From 61828baa8fe4b2f4b8d57a34b7179d840af49f92 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 18 Apr 2015 22:33:50 +0200 Subject: [PATCH] Improved manager --- src/pocketmine/MemoryManager.php | 10 +++++----- src/pocketmine/level/format/FullChunk.php | 4 ++-- src/pocketmine/level/format/generic/BaseFullChunk.php | 4 ++-- src/pocketmine/network/RakLibInterface.php | 2 +- src/pocketmine/network/protocol/DataPacket.php | 4 ++-- 5 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/pocketmine/MemoryManager.php b/src/pocketmine/MemoryManager.php index c60cbdfed..156608488 100644 --- a/src/pocketmine/MemoryManager.php +++ b/src/pocketmine/MemoryManager.php @@ -116,21 +116,21 @@ class MemoryManager{ $memory = Utils::getMemoryUsage(true); $trigger = false; if($this->memoryLimit > 0 and $memory[0] > $this->memoryLimit){ - $trigger = true; + $trigger = 0; }elseif($this->globalMemoryLimit > 0 and $memory[1] > $this->globalMemoryLimit){ - $trigger = true; + $trigger = 1; } - if($trigger){ + if($trigger !== false){ if($this->lowMemory and $this->continuousTrigger){ if(++$this->continuousTriggerTicker >= $this->continuousTriggerRate){ $this->continuousTriggerTicker = 0; - $this->trigger($memory, $this->memoryLimit, ++$this->continuousTriggerCount); + $this->trigger($memory[$trigger], $this->memoryLimit, ++$this->continuousTriggerCount); } }else{ $this->lowMemory = true; $this->continuousTriggerCount = 0; - $this->trigger($memory, $this->memoryLimit); + $this->trigger($memory[$trigger], $this->memoryLimit); } }else{ $this->lowMemory = false; diff --git a/src/pocketmine/level/format/FullChunk.php b/src/pocketmine/level/format/FullChunk.php index 38faba525..8d86bde47 100644 --- a/src/pocketmine/level/format/FullChunk.php +++ b/src/pocketmine/level/format/FullChunk.php @@ -308,9 +308,9 @@ interface FullChunk{ public function &getBlockLightArray(); - public function toBinary(); + public function &toBinary(); - public function toFastBinary(); + public function &toFastBinary(); /** * @return boolean diff --git a/src/pocketmine/level/format/generic/BaseFullChunk.php b/src/pocketmine/level/format/generic/BaseFullChunk.php index 6e46a83ce..0014904bd 100644 --- a/src/pocketmine/level/format/generic/BaseFullChunk.php +++ b/src/pocketmine/level/format/generic/BaseFullChunk.php @@ -357,8 +357,8 @@ abstract class BaseFullChunk implements FullChunk{ $this->hasChanged = (bool) $changed; } - public static function &fromFastBinary(&$data, LevelProvider $provider = null){ - static::fromBinary($data, $provider); + public static function fromFastBinary(&$data, LevelProvider $provider = null){ + return static::fromBinary($data, $provider); } public function &toFastBinary(){ diff --git a/src/pocketmine/network/RakLibInterface.php b/src/pocketmine/network/RakLibInterface.php index f6e1d5677..560cbbef2 100644 --- a/src/pocketmine/network/RakLibInterface.php +++ b/src/pocketmine/network/RakLibInterface.php @@ -246,7 +246,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{ return null; } - private function &getPacket(&$buffer){ + private function getPacket(&$buffer){ $pid = ord($buffer{0}); if(($data = $this->network->getPacket($pid)) === null){ diff --git a/src/pocketmine/network/protocol/DataPacket.php b/src/pocketmine/network/protocol/DataPacket.php index e868e2818..e4723ed65 100644 --- a/src/pocketmine/network/protocol/DataPacket.php +++ b/src/pocketmine/network/protocol/DataPacket.php @@ -58,7 +58,7 @@ abstract class DataPacket extends \stdClass{ } public function setBuffer($buffer = ""){ - $this->buffer = $buffer; + $this->buffer =& $buffer; $this->offset = 0; } @@ -66,7 +66,7 @@ abstract class DataPacket extends \stdClass{ return $this->offset; } - public function getBuffer(){ + public function &getBuffer(){ return $this->buffer; }