From d4487e66f68ee735c476d6c08c569dbf7188ecf9 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Wed, 19 Dec 2012 19:42:10 +0100 Subject: [PATCH] Preparing chunk changes... --- classes/ChunkParser.class.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/classes/ChunkParser.class.php b/classes/ChunkParser.class.php index 3ba8380bb..28c6d3938 100644 --- a/classes/ChunkParser.class.php +++ b/classes/ChunkParser.class.php @@ -77,6 +77,10 @@ class ChunkParser{ return 0x1000 + (($Z * $sectors) << 12) + (($X * $sectors) << 16); } + private function getOffsetLocation($X, $Z){ + return $X << 2 + $Z << 7; + } + public function getChunk($X, $Z){ $X = (int) $X; $Z = (int) $Z; @@ -92,7 +96,7 @@ class ChunkParser{ $chunk = ""; foreach($this->map[$X][$Z] as $section => $data){ for($i = 0; $i < 256; ++$i){ - $chunk .= $data[$i]; + $chunk .= $data[$i]; } } return Utils::writeLInt(strlen($chunk)).$chunk; @@ -113,7 +117,7 @@ class ChunkParser{ foreach($chunk as $section => &$data){ $l = $section === 0 ? 128:64; for($i = 0; $i < 256; ++$i){ - $data[] = substr($this->raw, $offset, $l); + $data[$i] = substr($this->raw, $offset, $l); $offset += $l; } } @@ -142,7 +146,7 @@ class ChunkParser{ flock($fp, LOCK_EX); foreach($this->map as $x => $d){ foreach($d as $z => $chunk){ - fseek($fp, $this->getOffset($x, $z)); + fseek($fp, $this->location[$x][$z]); fwrite($fp, $this->writeChunk($x, $z), $this->chunkLength); } }