Added MemoryManager, new memory properties, improved performance, updated RakLib, fixed misc. bugs

This commit is contained in:
Shoghi Cervantes
2015-04-18 20:13:52 +02:00
parent ddc152ae0a
commit b2c25eaf36
32 changed files with 652 additions and 164 deletions

View File

@ -276,7 +276,7 @@ class Chunk extends BaseFullChunk{
*
* @return Chunk
*/
public static function fromBinary($data, LevelProvider $provider = null){
public static function fromBinary(&$data, LevelProvider $provider = null){
$nbt = new NBT(NBT::BIG_ENDIAN);
try{
@ -293,7 +293,7 @@ class Chunk extends BaseFullChunk{
}
}
public static function fromFastBinary($data, LevelProvider $provider = null){
public static function fromFastBinary(&$data, LevelProvider $provider = null){
try{
$offset = 0;
@ -340,11 +340,11 @@ class Chunk extends BaseFullChunk{
}
}
public function toFastBinary(){
public function &toFastBinary(){
$biomeColors = pack("N*", ...$this->getBiomeColorArray());
$heightMap = pack("N*", ...$this->getHeightMapArray());
return
$data =
Binary::writeInt($this->x) .
Binary::writeInt($this->z) .
$this->getBlockIdArray() .
@ -355,9 +355,10 @@ class Chunk extends BaseFullChunk{
$biomeColors .
$heightMap .
chr(($this->isPopulated() ? 1 << 1 : 0) + ($this->isGenerated() ? 1 : 0));
return $data;
}
public function toBinary(){
public function &toBinary(){
$nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x);
@ -400,7 +401,8 @@ class Chunk extends BaseFullChunk{
$nbt->setName("Level");
$writer->setData(new Compound("", ["Level" => $nbt]));
return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
$data =& $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
return $data;
}
/**