mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-05-15 02:09:42 +00:00
build 10, improved levelDB constants
This commit is contained in:
parent
13906b32b8
commit
de0f653027
@ -74,8 +74,8 @@ namespace pocketmine {
|
|||||||
const VERSION = "1.5dev";
|
const VERSION = "1.5dev";
|
||||||
const API_VERSION = "1.12.0";
|
const API_VERSION = "1.12.0";
|
||||||
const CODENAME = "活発(Kappatsu)フグ(Fugu)";
|
const CODENAME = "活発(Kappatsu)フグ(Fugu)";
|
||||||
const MINECRAFT_VERSION = "v0.11.0 alpha build 9";
|
const MINECRAFT_VERSION = "v0.11.0 alpha build 10";
|
||||||
const MINECRAFT_VERSION_NETWORK = "0.11.0.9";
|
const MINECRAFT_VERSION_NETWORK = "0.11.0.10";
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Startup code. Do not look at it, it may harm you.
|
* Startup code. Do not look at it, it may harm you.
|
||||||
|
@ -38,6 +38,13 @@ use pocketmine\utils\LevelException;
|
|||||||
|
|
||||||
class LevelDB extends BaseLevelProvider{
|
class LevelDB extends BaseLevelProvider{
|
||||||
|
|
||||||
|
const ENTRY_VERSION = "v";
|
||||||
|
const ENTRY_FLAGS = "f";
|
||||||
|
const ENTRY_TICKS = "3";
|
||||||
|
const ENTRY_ENTITIES = "2";
|
||||||
|
const ENTRY_TILES = "1";
|
||||||
|
const ENTRY_TERRAIN = "0";
|
||||||
|
|
||||||
/** @var Chunk[] */
|
/** @var Chunk[] */
|
||||||
protected $chunks = [];
|
protected $chunks = [];
|
||||||
|
|
||||||
@ -220,11 +227,11 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
private function readChunk($chunkX, $chunkZ){
|
private function readChunk($chunkX, $chunkZ){
|
||||||
$index = LevelDB::chunkIndex($chunkX, $chunkZ);
|
$index = LevelDB::chunkIndex($chunkX, $chunkZ);
|
||||||
|
|
||||||
if(!$this->chunkExists($chunkX, $chunkZ) or ($data = $this->db->get($index . "\x30")) === false){
|
if(!$this->chunkExists($chunkX, $chunkZ) or ($data = $this->db->get($index . self::ENTRY_TERRAIN)) === false){
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$flags = $this->db->get($index . "f");
|
$flags = $this->db->get($index . self::ENTRY_FLAGS);
|
||||||
if($flags === false){
|
if($flags === false){
|
||||||
$flags = "\x03";
|
$flags = "\x03";
|
||||||
}
|
}
|
||||||
@ -232,19 +239,12 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
return Chunk::fromBinary($index . $data . $flags, $this);
|
return Chunk::fromBinary($index . $data . $flags, $this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function generateChunk($chunkX, $chunkZ){
|
|
||||||
return new Chunk($this, $chunkX, $chunkZ, str_repeat("\x00", 32768) .
|
|
||||||
str_repeat("\x00", 16384) . str_repeat("\xff", 16384) . str_repeat("\x00", 16384) .
|
|
||||||
str_repeat("\x01", 256) .
|
|
||||||
str_repeat("\x00\x85\xb2\x4a", 256));
|
|
||||||
}
|
|
||||||
|
|
||||||
private function writeChunk(Chunk $chunk){
|
private function writeChunk(Chunk $chunk){
|
||||||
$binary = $chunk->toBinary(true);
|
$binary = $chunk->toBinary(true);
|
||||||
$index = LevelDB::chunkIndex($chunk->getX(), $chunk->getZ());
|
$index = LevelDB::chunkIndex($chunk->getX(), $chunk->getZ());
|
||||||
$this->db->put($index . "\x30", substr($binary, 8, -1));
|
$this->db->put($index . self::ENTRY_TERRAIN, substr($binary, 8, -1));
|
||||||
$this->db->put($index . "f", substr($binary, -1));
|
$this->db->put($index . self::ENTRY_FLAGS, substr($binary, -1));
|
||||||
$this->db->put($index . "v", "\x02");
|
$this->db->put($index . self::ENTRY_VERSION, "\x02");
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unloadChunk($x, $z, $safe = true){
|
public function unloadChunk($x, $z, $safe = true){
|
||||||
@ -318,7 +318,7 @@ class LevelDB extends BaseLevelProvider{
|
|||||||
}
|
}
|
||||||
|
|
||||||
private function chunkExists($chunkX, $chunkZ){
|
private function chunkExists($chunkX, $chunkZ){
|
||||||
return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . "v") !== false;
|
return $this->db->get(LevelDB::chunkIndex($chunkX, $chunkZ) . self::ENTRY_VERSION) !== false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function isChunkGenerated($chunkX, $chunkZ){
|
public function isChunkGenerated($chunkX, $chunkZ){
|
||||||
|
Loading…
x
Reference in New Issue
Block a user