Updated references and submodules

This commit is contained in:
Shoghi Cervantes 2015-04-19 15:37:18 +02:00
parent c2f72ea9ac
commit 094234dc0f
No known key found for this signature in database
GPG Key ID: 78464DB0A7837F89
19 changed files with 74 additions and 83 deletions

View File

@ -592,7 +592,7 @@ class Player extends Human implements CommandSender, InventoryHolder, IPlayer{
$pk = new FullChunkDataPacket(); $pk = new FullChunkDataPacket();
$pk->chunkX = $x; $pk->chunkX = $x;
$pk->chunkZ = $z; $pk->chunkZ = $z;
$pk->data =& $payload; $pk->data = $payload;
$this->batchDataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS)); $this->batchDataPacket($pk->setChannel(Network::CHANNEL_WORLD_CHUNKS));
if($this->spawned){ if($this->spawned){

View File

@ -288,29 +288,29 @@ interface FullChunk{
/** /**
* @return string[] * @return string[]
*/ */
public function &getBiomeIdArray(); public function getBiomeIdArray();
/** /**
* @return int[] * @return int[]
*/ */
public function &getBiomeColorArray(); public function getBiomeColorArray();
/** /**
* @return int[] * @return int[]
*/ */
public function &getHeightMapArray(); public function getHeightMapArray();
public function &getBlockIdArray(); public function getBlockIdArray();
public function &getBlockDataArray(); public function getBlockDataArray();
public function &getBlockSkyLightArray(); public function getBlockSkyLightArray();
public function &getBlockLightArray(); public function getBlockLightArray();
public function &toBinary(); public function toBinary();
public function &toFastBinary(); public function toFastBinary();
/** /**
* @return boolean * @return boolean
@ -328,7 +328,7 @@ interface FullChunk{
* *
* @return FullChunk * @return FullChunk
*/ */
public static function fromBinary(&$data, LevelProvider $provider = null); public static function fromBinary($data, LevelProvider $provider = null);
/** /**
* @param string $data * @param string $data
@ -336,6 +336,6 @@ interface FullChunk{
* *
* @return FullChunk * @return FullChunk
*/ */
public static function fromFastBinary(&$data, LevelProvider $provider = null); public static function fromFastBinary($data, LevelProvider $provider = null);
} }

View File

@ -135,7 +135,7 @@ class Chunk extends BaseChunk{
* *
* @return Chunk * @return Chunk
*/ */
public static function fromBinary(&$data, LevelProvider $provider = null){ public static function fromBinary($data, LevelProvider $provider = null){
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
try{ try{
@ -152,7 +152,7 @@ class Chunk extends BaseChunk{
} }
} }
public function &toBinary(){ public function toBinary(){
$nbt = clone $this->getNBT(); $nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x); $nbt->xPos = new Int("xPos", $this->x);

View File

@ -133,8 +133,7 @@ class ChunkRequestTask extends AsyncTask{
public function onCompletion(Server $server){ public function onCompletion(Server $server){
$level = $server->getLevel($this->levelId); $level = $server->getLevel($this->levelId);
if($level instanceof Level and $this->hasResult()){ if($level instanceof Level and $this->hasResult()){
$result = $this->getResult(); $level->chunkRequestCallback($this->chunkX, $this->chunkZ, $this->getResult());
$level->chunkRequestCallback($this->chunkX, $this->chunkZ, $result);
} }
} }

View File

@ -155,7 +155,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
} }
} }
public function &getBlockIdColumn($x, $z){ public function getBlockIdColumn($x, $z){
$i = ($z << 4) + $x; $i = ($z << 4) + $x;
$column = ""; $column = "";
for($y = 0; $y < 16; ++$y){ for($y = 0; $y < 16; ++$y){
@ -165,7 +165,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
return $column; return $column;
} }
public function &getBlockDataColumn($x, $z){ public function getBlockDataColumn($x, $z){
$i = ($z << 3) + ($x >> 1); $i = ($z << 3) + ($x >> 1);
$column = ""; $column = "";
if(($x & 1) === 0){ if(($x & 1) === 0){
@ -181,7 +181,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
return $column; return $column;
} }
public function &getBlockSkyLightColumn($x, $z){ public function getBlockSkyLightColumn($x, $z){
$i = ($z << 3) + ($x >> 1); $i = ($z << 3) + ($x >> 1);
$column = ""; $column = "";
if(($x & 1) === 0){ if(($x & 1) === 0){
@ -197,7 +197,7 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
return $column; return $column;
} }
public function &getBlockLightColumn($x, $z){ public function getBlockLightColumn($x, $z){
$i = ($z << 3) + ($x >> 1); $i = ($z << 3) + ($x >> 1);
$column = ""; $column = "";
if(($x & 1) === 0){ if(($x & 1) === 0){
@ -213,19 +213,19 @@ class ChunkSection implements \pocketmine\level\format\ChunkSection{
return $column; return $column;
} }
public function &getIdArray(){ public function getIdArray(){
return $this->blocks; return $this->blocks;
} }
public function &getDataArray(){ public function getDataArray(){
return $this->data; return $this->data;
} }
public function &getSkyLightArray(){ public function getSkyLightArray(){
return $this->skyLight; return $this->skyLight;
} }
public function &getLightArray(){ public function getLightArray(){
return $this->blockLight; return $this->blockLight;
} }

View File

@ -165,7 +165,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
} }
} }
public function &getBlockIdColumn($x, $z){ public function getBlockIdColumn($x, $z){
$column = ""; $column = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$column .= $this->sections[$y]->getBlockIdColumn($x, $z); $column .= $this->sections[$y]->getBlockIdColumn($x, $z);
@ -174,7 +174,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $column; return $column;
} }
public function &getBlockDataColumn($x, $z){ public function getBlockDataColumn($x, $z){
$column = ""; $column = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$column .= $this->sections[$y]->getBlockDataColumn($x, $z); $column .= $this->sections[$y]->getBlockDataColumn($x, $z);
@ -183,7 +183,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $column; return $column;
} }
public function &getBlockSkyLightColumn($x, $z){ public function getBlockSkyLightColumn($x, $z){
$column = ""; $column = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$column .= $this->sections[$y]->getBlockSkyLightColumn($x, $z); $column .= $this->sections[$y]->getBlockSkyLightColumn($x, $z);
@ -192,7 +192,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $column; return $column;
} }
public function &getBlockLightColumn($x, $z){ public function getBlockLightColumn($x, $z){
$column = ""; $column = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$column .= $this->sections[$y]->getBlockLightColumn($x, $z); $column .= $this->sections[$y]->getBlockLightColumn($x, $z);
@ -227,7 +227,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $this->getProvider() === null ? false : $this->getProvider()->getChunk($this->getX(), $this->getZ(), true) instanceof Chunk; return $this->getProvider() === null ? false : $this->getProvider()->getChunk($this->getX(), $this->getZ(), true) instanceof Chunk;
} }
public function &getBlockIdArray(){ public function getBlockIdArray(){
$blocks = ""; $blocks = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$blocks .= $this->sections[$y]->getIdArray(); $blocks .= $this->sections[$y]->getIdArray();
@ -236,7 +236,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $blocks; return $blocks;
} }
public function &getBlockDataArray(){ public function getBlockDataArray(){
$data = ""; $data = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$data .= $this->sections[$y]->getDataArray(); $data .= $this->sections[$y]->getDataArray();
@ -245,7 +245,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $data; return $data;
} }
public function &getBlockSkyLightArray(){ public function getBlockSkyLightArray(){
$skyLight = ""; $skyLight = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$skyLight .= $this->sections[$y]->getSkyLightArray(); $skyLight .= $this->sections[$y]->getSkyLightArray();
@ -254,7 +254,7 @@ abstract class BaseChunk extends BaseFullChunk implements Chunk{
return $skyLight; return $skyLight;
} }
public function &getBlockLightArray(){ public function getBlockLightArray(){
$blockLight = ""; $blockLight = "";
for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){ for($y = 0; $y < Chunk::SECTION_COUNT; ++$y){
$blockLight .= $this->sections[$y]->getLightArray(); $blockLight .= $this->sections[$y]->getLightArray();

View File

@ -82,18 +82,18 @@ abstract class BaseFullChunk implements FullChunk{
* @param Compound[] $entities * @param Compound[] $entities
* @param Compound[] $tiles * @param Compound[] $tiles
*/ */
protected function __construct($provider, $x, $z, &$blocks, &$data, &$skyLight, &$blockLight, &$biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){ protected function __construct($provider, $x, $z, $blocks, $data, $skyLight, $blockLight, $biomeIds = null, array $biomeColors = [], array $heightMap = [], array $entities = [], array $tiles = []){
$this->provider = $provider; $this->provider = $provider;
$this->x = (int) $x; $this->x = (int) $x;
$this->z = (int) $z; $this->z = (int) $z;
$this->blocks =& $blocks; $this->blocks = $blocks;
$this->data =& $data; $this->data = $data;
$this->skyLight =& $skyLight; $this->skyLight = $skyLight;
$this->blockLight =& $blockLight; $this->blockLight = $blockLight;
if(strlen($biomeIds) === 256){ if(strlen($biomeIds) === 256){
$this->biomeIds =& $biomeIds; $this->biomeIds = $biomeIds;
}else{ }else{
$this->biomeIds = str_repeat("\x01", 256); $this->biomeIds = str_repeat("\x01", 256);
} }
@ -321,31 +321,31 @@ abstract class BaseFullChunk implements FullChunk{
return true; return true;
} }
public function &getBlockIdArray(){ public function getBlockIdArray(){
return $this->blocks; return $this->blocks;
} }
public function &getBlockDataArray(){ public function getBlockDataArray(){
return $this->data; return $this->data;
} }
public function &getBlockSkyLightArray(){ public function getBlockSkyLightArray(){
return $this->skyLight; return $this->skyLight;
} }
public function &getBlockLightArray(){ public function getBlockLightArray(){
return $this->blockLight; return $this->blockLight;
} }
public function &getBiomeIdArray(){ public function getBiomeIdArray(){
return $this->biomeIds; return $this->biomeIds;
} }
public function &getBiomeColorArray(){ public function getBiomeColorArray(){
return $this->biomeColors; return $this->biomeColors;
} }
public function &getHeightMapArray(){ public function getHeightMapArray(){
return $this->heightMap; return $this->heightMap;
} }
@ -357,11 +357,11 @@ abstract class BaseFullChunk implements FullChunk{
$this->hasChanged = (bool) $changed; $this->hasChanged = (bool) $changed;
} }
public static function fromFastBinary(&$data, LevelProvider $provider = null){ public static function fromFastBinary($data, LevelProvider $provider = null){
return static::fromBinary($data, $provider); return static::fromBinary($data, $provider);
} }
public function &toFastBinary(){ public function toFastBinary(){
return $this->toBinary(); return $this->toBinary();
} }

View File

@ -32,7 +32,7 @@ class Chunk extends BaseFullChunk{
protected $isPopulated = false; protected $isPopulated = false;
protected $isGenerated = false; protected $isGenerated = false;
public function __construct($level, $chunkX, $chunkZ, &$terrain, array $entityData = null, array $tileData = null){ public function __construct($level, $chunkX, $chunkZ, $terrain, array $entityData = null, array $tileData = null){
$heightMap = array_fill(0, 256, 127); $heightMap = array_fill(0, 256, 127);
$offset = 0; $offset = 0;
@ -221,7 +221,7 @@ class Chunk extends BaseFullChunk{
$this->isGenerated = (bool) $value; $this->isGenerated = (bool) $value;
} }
public static function fromFastBinary(&$data, LevelProvider $provider = null){ public static function fromFastBinary($data, LevelProvider $provider = null){
return self::fromBinary($data, $provider); return self::fromBinary($data, $provider);
} }
@ -231,7 +231,7 @@ class Chunk extends BaseFullChunk{
* *
* @return Chunk * @return Chunk
*/ */
public static function fromBinary(&$data, LevelProvider $provider = null){ public static function fromBinary($data, LevelProvider $provider = null){
try{ try{
$chunkX = Binary::readLInt(substr($data, 0, 4)); $chunkX = Binary::readLInt(substr($data, 0, 4));
$chunkZ = Binary::readLInt(substr($data, 4, 4)); $chunkZ = Binary::readLInt(substr($data, 4, 4));

View File

@ -276,7 +276,7 @@ class Chunk extends BaseFullChunk{
* *
* @return Chunk * @return Chunk
*/ */
public static function fromBinary(&$data, LevelProvider $provider = null){ public static function fromBinary($data, LevelProvider $provider = null){
$nbt = new NBT(NBT::BIG_ENDIAN); $nbt = new NBT(NBT::BIG_ENDIAN);
try{ 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{ try{
$offset = 0; $offset = 0;
@ -340,7 +340,7 @@ class Chunk extends BaseFullChunk{
} }
} }
public function &toFastBinary(){ public function toFastBinary(){
$biomeColors = pack("N*", ...$this->getBiomeColorArray()); $biomeColors = pack("N*", ...$this->getBiomeColorArray());
$heightMap = pack("N*", ...$this->getHeightMapArray()); $heightMap = pack("N*", ...$this->getHeightMapArray());
@ -358,7 +358,7 @@ class Chunk extends BaseFullChunk{
return $data; return $data;
} }
public function &toBinary(){ public function toBinary(){
$nbt = clone $this->getNBT(); $nbt = clone $this->getNBT();
$nbt->xPos = new Int("xPos", $this->x); $nbt->xPos = new Int("xPos", $this->x);
@ -401,8 +401,7 @@ class Chunk extends BaseFullChunk{
$nbt->setName("Level"); $nbt->setName("Level");
$writer->setData(new Compound("", ["Level" => $nbt])); $writer->setData(new Compound("", ["Level" => $nbt]));
$data =& $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL); return $writer->writeCompressed(ZLIB_ENCODING_DEFLATE, RegionLoader::$COMPRESSION_LEVEL);
return $data;
} }
/** /**

View File

@ -185,7 +185,7 @@ class RegionLoader{
} }
} }
protected function saveChunk($x, $z, &$chunkData){ protected function saveChunk($x, $z, $chunkData){
$length = strlen($chunkData) + 1; $length = strlen($chunkData) + 1;
if($length + 4 > self::MAX_SECTOR_LENGTH){ if($length + 4 > self::MAX_SECTOR_LENGTH){
throw new ChunkException("Chunk is too big! ".($length + 4)." > ".self::MAX_SECTOR_LENGTH); throw new ChunkException("Chunk is too big! ".($length + 4)." > ".self::MAX_SECTOR_LENGTH);
@ -212,7 +212,7 @@ class RegionLoader{
public function writeChunk(FullChunk $chunk){ public function writeChunk(FullChunk $chunk){
$this->lastUsed = time(); $this->lastUsed = time();
$chunkData = &$chunk->toBinary(); $chunkData = $chunk->toBinary();
if($chunkData !== false){ if($chunkData !== false){
$this->saveChunk($chunk->getX() - ($this->getX() * 32), $chunk->getZ() - ($this->getZ() * 32), $chunkData); $this->saveChunk($chunk->getX() - ($this->getX() * 32), $chunk->getZ() - ($this->getZ() * 32), $chunkData);
} }

View File

@ -84,7 +84,7 @@ class NBT{
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len); return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
} }
public function put(&$v){ public function put($v){
$this->buffer .= $v; $this->buffer .= $v;
} }
@ -99,7 +99,7 @@ class NBT{
public function read($buffer, $doMultiple = false){ public function read($buffer, $doMultiple = false){
$this->offset = 0; $this->offset = 0;
$this->buffer =& $buffer; $this->buffer = $buffer;
$this->data = $this->readTag(); $this->data = $this->readTag();
if($doMultiple and $this->offset < strlen($this->buffer)){ if($doMultiple and $this->offset < strlen($this->buffer)){
$this->data = [$this->data]; $this->data = [$this->data];
@ -117,24 +117,24 @@ class NBT{
/** /**
* @return string|bool * @return string|bool
*/ */
public function &write(){ public function write(){
$this->offset = 0; $this->offset = 0;
$data = false; $data = false;
if($this->data instanceof Compound){ if($this->data instanceof Compound){
$this->writeTag($this->data); $this->writeTag($this->data);
$data =& $this->buffer; $data = $this->buffer;
}elseif(is_array($this->data)){ }elseif(is_array($this->data)){
foreach($this->data as $tag){ foreach($this->data as $tag){
$this->writeTag($tag); $this->writeTag($tag);
} }
$data =& $this->buffer; $data = $this->buffer;
} }
return $data; return $data;
} }
public function &writeCompressed($compression = ZLIB_ENCODING_GZIP, $level = 7){ public function writeCompressed($compression = ZLIB_ENCODING_GZIP, $level = 7){
$data = false; $data = false;
if(($write = $this->write()) !== false){ if(($write = $this->write()) !== false){
$data = zlib_encode($write, $compression, $level); $data = zlib_encode($write, $compression, $level);
@ -258,7 +258,7 @@ class NBT{
return $this->get($this->getShort()); return $this->get($this->getShort());
} }
public function putString(&$v){ public function putString($v){
$this->putShort(strlen($v)); $this->putShort(strlen($v));
$this->buffer .= $v; $this->buffer .= $v;
} }

View File

@ -27,13 +27,6 @@ use pocketmine\nbt\NBT;
class ByteArray extends NamedTag{ class ByteArray extends NamedTag{
public function __construct($name = "", &$value = null){
$this->name = $name;
if($value !== null){
$this->value =& $value;
}
}
public function getType(){ public function getType(){
return NBT::TAG_ByteArray; return NBT::TAG_ByteArray;
} }

View File

@ -37,7 +37,7 @@ abstract class NamedTag extends Tag{
} }
} }
public function &getName(){ public function getName(){
return $this->name; return $this->name;
} }

View File

@ -30,7 +30,7 @@ class String extends NamedTag{
public function __construct($name = "", $value = null){ public function __construct($name = "", $value = null){
$this->name = $name; $this->name = $name;
if($value !== null){ if($value !== null){
$this->value =& $value; $this->value = $value;
} }
} }

View File

@ -32,7 +32,7 @@ class CompressBatchedTask extends AsyncTask{
public $channel = 0; public $channel = 0;
public $targets = []; public $targets = [];
public function __construct(&$data, array $targets, $level = 7, $channel = 0){ public function __construct($data, array $targets, $level = 7, $channel = 0){
$this->data = $data; $this->data = $data;
$this->targets = $targets; $this->targets = $targets;
$this->level = $level; $this->level = $level;

View File

@ -248,7 +248,7 @@ class RakLibInterface implements ServerInstance, AdvancedSourceInterface{
return null; return null;
} }
private function getPacket(&$buffer){ private function getPacket($buffer){
$pid = ord($buffer{0}); $pid = ord($buffer{0});
if(($data = $this->network->getPacket($pid)) === null){ if(($data = $this->network->getPacket($pid)) === null){

View File

@ -57,8 +57,8 @@ abstract class DataPacket extends \stdClass{
return $this->channel; return $this->channel;
} }
public function setBuffer(&$buffer = null, $offset = 0){ public function setBuffer($buffer = null, $offset = 0){
$this->buffer =& $buffer; $this->buffer = $buffer;
$this->offset = (int) $offset; $this->offset = (int) $offset;
} }
@ -66,7 +66,7 @@ abstract class DataPacket extends \stdClass{
return $this->offset; return $this->offset;
} }
public function &getBuffer(){ public function getBuffer(){
return $this->buffer; return $this->buffer;
} }
@ -81,7 +81,7 @@ abstract class DataPacket extends \stdClass{
return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len); return $len === 1 ? $this->buffer{$this->offset++} : substr($this->buffer, ($this->offset += $len) - $len, $len);
} }
protected function put(&$str){ protected function put($str){
$this->buffer .= $str; $this->buffer .= $str;
} }
@ -179,7 +179,7 @@ abstract class DataPacket extends \stdClass{
return $this->get($this->getShort()); return $this->get($this->getShort());
} }
protected function putString(&$v){ protected function putString($v){
$this->putShort(strlen($v)); $this->putShort(strlen($v));
$this->put($v); $this->put($v);
} }

@ -1 +1 @@
Subproject commit 424faed1dc78564222301a56811bd6394b6c74a0 Subproject commit caa379e570dca9382d9619843ef93d753267cafa

@ -1 +1 @@
Subproject commit 3db41e1266811b20c3f52f749265f6c9d416c1bb Subproject commit c6763e38dc3da4db13bea176e05564c04cfb5e98