From f30986d18788dc947cc710f5762e5b5aa2d01e52 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Date: Sun, 11 Jan 2015 15:48:08 +0100 Subject: [PATCH] Block saving chunks too big --- src/pocketmine/level/Level.php | 6 ++++-- src/pocketmine/level/format/mcregion/RegionLoader.php | 4 ++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/pocketmine/level/Level.php b/src/pocketmine/level/Level.php index 54c775f22..bcf36c745 100644 --- a/src/pocketmine/level/Level.php +++ b/src/pocketmine/level/Level.php @@ -619,9 +619,9 @@ class Level implements ChunkManager, Metadatable{ foreach($this->chunkTickList as $index => $players){ Level::getXZ($index, $chunkX, $chunkZ); - $chunk = $this->getChunk($chunkX, $chunkZ, false); - if($chunk === null){ + + if(!isset($this->chunks[$index]) or ($chunk = $this->getChunk($chunkX, $chunkZ, false)) === null){ unset($this->chunkTickList[$index]); continue; }elseif($players <= 0){ @@ -629,6 +629,8 @@ class Level implements ChunkManager, Metadatable{ } + + foreach($chunk->getEntities() as $entity){ $entity->scheduleUpdate(); } diff --git a/src/pocketmine/level/format/mcregion/RegionLoader.php b/src/pocketmine/level/format/mcregion/RegionLoader.php index 7745dbb13..6a1142d28 100644 --- a/src/pocketmine/level/format/mcregion/RegionLoader.php +++ b/src/pocketmine/level/format/mcregion/RegionLoader.php @@ -32,6 +32,7 @@ use pocketmine\nbt\tag\Int; use pocketmine\nbt\tag\IntArray; use pocketmine\nbt\tag\Long; use pocketmine\utils\Binary; +use pocketmine\utils\ChunkException; use pocketmine\utils\MainLogger; class RegionLoader{ @@ -182,6 +183,9 @@ class RegionLoader{ protected function saveChunk($x, $z, $chunkData){ $length = strlen($chunkData) + 1; + if($length + 4 > self::MAX_SECTOR_LENGTH){ + throw new ChunkException("Chunk is too big! ".($length + 4)." > ".self::MAX_SECTOR_LENGTH); + } $sectors = (int) ceil(($length + 4) / 4096); $index = self::getChunkOffset($x, $z); if($this->locationTable[$index][1] < $sectors){