From e4bf44919814248252d67d93733e6481897fc3f7 Mon Sep 17 00:00:00 2001 From: Shoghi Cervantes Pueyo Date: Fri, 18 Jan 2013 16:42:38 +0100 Subject: [PATCH] Added Invalid World Data warning --- src/classes/PocketMinecraftServer.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/classes/PocketMinecraftServer.php b/src/classes/PocketMinecraftServer.php index 82371865..0c1d556a 100644 --- a/src/classes/PocketMinecraftServer.php +++ b/src/classes/PocketMinecraftServer.php @@ -243,6 +243,10 @@ class PocketMinecraftServer{ public function loadMap(){ if($this->mapName !== false and trim($this->mapName) !== ""){ $this->levelData = unserialize(file_get_contents($this->mapDir."level.dat")); + if($this->levelData === false){ + console("[ERROR] Invalid world data for \"".$this->mapDir."\. Please import the world correctly"); + $this->close("invalid world data"); + } console("[INFO] Map: ".$this->levelData["LevelName"]); $this->time = (int) $this->levelData["Time"]; $this->seed = (int) $this->levelData["RandomSeed"]; @@ -279,6 +283,10 @@ class PocketMinecraftServer{ if($this->map !== false){ console("[INFO] Loading entities..."); $entities = unserialize(file_get_contents($this->mapDir."entities.dat")); + if($entities === false){ + console("[ERROR] Invalid world data for \"".$this->mapDir."\. Please import the world correctly"); + $this->close("invalid world data"); + } foreach($entities as $entity){ if(!isset($entity["id"])){ break;