From 72f8f00c5d1578fb7737214e5605d5c517949a91 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sat, 25 May 2013 23:46:02 +0200 Subject: [PATCH] Autorecovery of bad chunks --- src/pmf/Level.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/pmf/Level.php b/src/pmf/Level.php index 350ed52a..a1c44cfd 100644 --- a/src/pmf/Level.php +++ b/src/pmf/Level.php @@ -209,7 +209,11 @@ class PMFLevel extends PMF{ for($Y = 0; $Y < $this->levelData["height"]; ++$Y){ $t = 1 << $Y; if(($info[0] & $t) === $t){ - $this->chunks[$index][$Y] = gzread($chunk, 8192); // 4096 + 2048 + 2048, Block Data, Meta, Light + // 4096 + 2048 + 2048, Block Data, Meta, Light + if(strlen($this->chunks[$index][$Y] = gzread($chunk, 8192)) < 8192){ + console("[NOTICE] Empty corrupt chunk detected [$X,$Z,:$Y], recovering contents"); + $this->fillMiniChunk($X, $Z, $Y); + } }else{ $this->chunks[$index][$Y] = false; } @@ -280,7 +284,7 @@ class PMFLevel extends PMF{ return false; } $index = $this->getIndex($X, $Z); - $this->chunks[$index][$Y] = $data; + $this->chunks[$index][$Y] = (string) $data; $this->chunkChange[$index][$Y] = 8192; $this->locationTable[$index][0] |= 1 << $Y; return true;