{ file_put_contents('.cache', serialize($this->cache)); } // checks if cache exists public function hasCache($md5) { return isset($this->cache[$md5]); } // returns cached content public function readCache($md5) { if (!isset($this->cache[$md5])) { throw new E_OTS_NoCache(); } return $this->cache[$md5]; } // saves cache for new file public function writeCache($md5, OTS_FileNode $root) { $this->cache[$md5] = $root; } } // creates instance of our driver $cache = new CacheDriver(); // creates OTBM loaded $otbm = new OTS_OTBMFile(); // sets cache for OTBM loader $otbm->setCacheDriver($cache); // if cache for this file will exist - will read it from cache // if not - will read file directly and save new cache $otbm->loadFile('/home/wrzasq/.otserv/data/world/map.otbm');
/** * Loads OTBM map. * * <p> * This method loads OTBM map from given file. You can create local instances of maps directly - calling this method will associate loaded map with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: This method will also load houses list associated with map. * </p> * * @version 0.1.0 * @since 0.1.0 * @param string $path Map file path. */ public function loadMap($path) { $this->map = new OTS_OTBMFile(); // sets items cache if any if (isset($this->mapCache)) { $this->map->setCacheDriver($this->mapCache); } $this->map->loadFile($path); $this->houses = $this->map->getHousesList(); }
/** * Loads OTBM map. * * <p> * This method loads OTBM map from given file. You can create local instances of maps directly - calling this method will associate loaded map with POT class instance and will make it available everywhere in the code. * </p> * * <p> * Note: This method will also load houses list associated with map. * </p> * * <p> * Note: Since 0.2.0+SVN this field is protected instead of private. * </p> * * @version 0.2.0+SVN * @since 0.1.0 * @param string $path Map file path. */ public static function loadMap($path) { self::$map = new OTS_OTBMFile(); // sets items cache if any if (isset(self::$mapCache)) { self::$map->setCacheDriver(self::$mapCache); } self::$map->loadFile($path); self::$houses = self::$map->getHousesList(); }