mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-08-31 07:21:17 +00:00
Added advanced caching (enable-advanced-cache)
This commit is contained in:
parent
b4971abe91
commit
c88b1c97b3
@ -135,6 +135,7 @@ class ServerAPI{
|
|||||||
|
|
||||||
$this->parseProperties();
|
$this->parseProperties();
|
||||||
define("DEBUG", $this->getProperty("debug", 1));
|
define("DEBUG", $this->getProperty("debug", 1));
|
||||||
|
define("ADVANCED_CACHE", $this->getProperty("enable-advanced-cache", false));
|
||||||
if($this->getProperty("port") !== false){
|
if($this->getProperty("port") !== false){
|
||||||
$this->setProperty("server-port", $this->getProperty("port"));
|
$this->setProperty("server-port", $this->getProperty("port"));
|
||||||
$this->config->remove("port");
|
$this->config->remove("port");
|
||||||
@ -146,6 +147,10 @@ class ServerAPI{
|
|||||||
console("[INFO] This server is running PocketMine-MP version ".($version->isDev() ? FORMAT_YELLOW:"").MAJOR_VERSION.FORMAT_RESET." \"".CODENAME."\" (MCPE: ".CURRENT_MINECRAFT_VERSION.") (API ".CURRENT_API_VERSION.")", true, true, 0);
|
console("[INFO] This server is running PocketMine-MP version ".($version->isDev() ? FORMAT_YELLOW:"").MAJOR_VERSION.FORMAT_RESET." \"".CODENAME."\" (MCPE: ".CURRENT_MINECRAFT_VERSION.") (API ".CURRENT_API_VERSION.")", true, true, 0);
|
||||||
console("[INFO] PocketMine-MP is distibuted under the LGPL License", true, true, 0);
|
console("[INFO] PocketMine-MP is distibuted under the LGPL License", true, true, 0);
|
||||||
|
|
||||||
|
if(ADVANCED_CACHE == true){
|
||||||
|
console("[INFO] Advanced cache enabled");
|
||||||
|
}
|
||||||
|
|
||||||
if($this->getProperty("upnp-forwarding") === true){
|
if($this->getProperty("upnp-forwarding") === true){
|
||||||
console("[INFO] [UPnP] Trying to port forward...");
|
console("[INFO] [UPnP] Trying to port forward...");
|
||||||
UPnP_PortForward($this->getProperty("server-port"));
|
UPnP_PortForward($this->getProperty("server-port"));
|
||||||
|
@ -299,6 +299,9 @@ class Level{
|
|||||||
}
|
}
|
||||||
$block->position($pos);
|
$block->position($pos);
|
||||||
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
|
$i = ($pos->x >> 4).":".($pos->y >> 4).":".($pos->z >> 4);
|
||||||
|
if(ADVANCED_CACHE == true){
|
||||||
|
Cache::remove("world:{$this->name}:".($pos->x >> 4).":".($pos->z >> 4));
|
||||||
|
}
|
||||||
if(!isset($this->changedBlocks[$i])){
|
if(!isset($this->changedBlocks[$i])){
|
||||||
$this->changedBlocks[$i] = array();
|
$this->changedBlocks[$i] = array();
|
||||||
$this->changedCount[$i] = 0;
|
$this->changedCount[$i] = 0;
|
||||||
@ -336,6 +339,9 @@ class Level{
|
|||||||
$this->changedBlocks[$i] = array();
|
$this->changedBlocks[$i] = array();
|
||||||
$this->changedCount[$i] = 0;
|
$this->changedCount[$i] = 0;
|
||||||
}
|
}
|
||||||
|
if(ADVANCED_CACHE == true){
|
||||||
|
Cache::remove("world:{$this->name}:".($pos->x >> 4).":".($pos->z >> 4));
|
||||||
|
}
|
||||||
$this->changedBlocks[$i][] = clone $block;
|
$this->changedBlocks[$i][] = clone $block;
|
||||||
++$this->changedCount[$i];
|
++$this->changedCount[$i];
|
||||||
}
|
}
|
||||||
@ -365,6 +371,9 @@ class Level{
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
$this->changedCount[$X.":".$Y.":".$Z] = 4096;
|
$this->changedCount[$X.":".$Y.":".$Z] = 4096;
|
||||||
|
if(ADVANCED_CACHE == true){
|
||||||
|
Cache::remove("world:{$this->name}:$X:$Z");
|
||||||
|
}
|
||||||
return $this->level->setMiniChunk($X, $Z, $Y, $data);
|
return $this->level->setMiniChunk($X, $Z, $Y, $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -379,6 +388,7 @@ class Level{
|
|||||||
if(!isset($this->level)){
|
if(!isset($this->level)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
Cache::remove("world:{$this->name}:$X:$Z");
|
||||||
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
return $this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -386,6 +396,14 @@ class Level{
|
|||||||
if(!isset($this->level)){
|
if(!isset($this->level)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if(ADVANCED_CACHE == true and $Yndex == 0xff){
|
||||||
|
$identifier = "world:{$this->name}:$X:$Z";
|
||||||
|
if(($cache = Cache::get($identifier)) !== false){
|
||||||
|
return $cache;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
$raw = array();
|
$raw = array();
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
for($Y = 0; $Y < 8; ++$Y){
|
||||||
if(($Yndex & (1 << $Y)) > 0){
|
if(($Yndex & (1 << $Y)) > 0){
|
||||||
@ -401,6 +419,9 @@ class Level{
|
|||||||
$ordered .= substr($mini, $j << 5, 24); //16 + 8
|
$ordered .= substr($mini, $j << 5, 24); //16 + 8
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(ADVANCED_CACHE == true and $Yndex == 0xff){
|
||||||
|
Cache::add($identifier, $ordered, 60);
|
||||||
|
}
|
||||||
return $ordered;
|
return $ordered;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user