mirror of
https://github.com/oldminecraftcommunity/NostalgiaCore.git
synced 2026-11-22 04:29:43 +00:00
fixed memory leak during light recalculation, importing the world saves nc level data and uses blocklight from vanilla world
This commit is contained in:
parent
a61d4936c5
commit
cc3f333660
4 changed files with 15 additions and 4 deletions
|
|
@ -402,7 +402,7 @@ class PMFLevel extends PMF{
|
||||||
foreach($this->checkLight as $index => [$X, $Z]){
|
foreach($this->checkLight as $index => [$X, $Z]){
|
||||||
$update = false;
|
$update = false;
|
||||||
if(!$this->hasBlocklight($X, $Z)){
|
if(!$this->hasBlocklight($X, $Z)){
|
||||||
ConsoleAPI::notice("Chunk $X $Z (Level: {$this->level->getName()} has no blocklight! Forcing light update(it might take a while).");
|
ConsoleAPI::notice("Chunk $X $Z (Level: {$this->level->getName()}) has no blocklight! Forcing light update(it might take a while).");
|
||||||
$this->level->updateLight(0, $X*16, 0, $Z*16, $X*16+15, 127, $Z*16+15);
|
$this->level->updateLight(0, $X*16, 0, $Z*16, $X*16+15, 127, $Z*16+15);
|
||||||
$update = true;
|
$update = true;
|
||||||
$this->markHasBlocklight($X, $Z);
|
$this->markHasBlocklight($X, $Z);
|
||||||
|
|
@ -550,7 +550,6 @@ class PMFLevel extends PMF{
|
||||||
|
|
||||||
if($old_m != $m){
|
if($old_m != $m){
|
||||||
$this->chunks[$index][$Y][$mindex] = chr($m);
|
$this->chunks[$index][$Y][$mindex] = chr($m);
|
||||||
|
|
||||||
if(!isset($this->chunkChange[$index][$Y])){
|
if(!isset($this->chunkChange[$index][$Y])){
|
||||||
$this->chunkChange[$index][$Y] = 1;
|
$this->chunkChange[$index][$Y] = 1;
|
||||||
}else{
|
}else{
|
||||||
|
|
|
||||||
|
|
@ -710,6 +710,7 @@ class Level{
|
||||||
if(!--$limit) return true;
|
if(!--$limit) return true;
|
||||||
}while($this->lightUpdateIndx >= 0);
|
}while($this->lightUpdateIndx >= 0);
|
||||||
if(count($this->lightUpdates) > 0) return true;
|
if(count($this->lightUpdates) > 0) return true;
|
||||||
|
$this->lightUpdates = []; //php uses a lot of memory without this thing if it performed a lot of light updates
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
public function onTick(PocketMinecraftServer $server, $currentTime){
|
public function onTick(PocketMinecraftServer $server, $currentTime){
|
||||||
|
|
|
||||||
|
|
@ -66,14 +66,17 @@ class LevelImport{
|
||||||
6 => "",
|
6 => "",
|
||||||
7 => ""
|
7 => ""
|
||||||
];
|
];
|
||||||
|
$pmf->markHasBlocklight($X, $Z);
|
||||||
|
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($x = 0; $x < 16; ++$x){
|
||||||
$block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
|
$block = $chunks->getChunkColumn($X, $Z, $x, $z, 0);
|
||||||
$meta = $chunks->getChunkColumn($X, $Z, $x, $z, 1);
|
$meta = $chunks->getChunkColumn($X, $Z, $x, $z, 1);
|
||||||
|
$blocklight = $chunks->getChunkColumn($X, $Z, $x, $z, 3);
|
||||||
for($Y = 0; $Y < 8; ++$Y){
|
for($Y = 0; $Y < 8; ++$Y){
|
||||||
$chunk[$Y] .= substr($block, $Y << 4, 16);
|
$chunk[$Y] .= substr($block, $Y << 4, 16);
|
||||||
$chunk[$Y] .= substr($meta, $Y << 3, 8);
|
$chunk[$Y] .= substr($meta, $Y << 3, 8);
|
||||||
$chunk[$Y] .= "\x00\x00\x00\x00\x00\x00\x00\x00";
|
$chunk[$Y] .= substr($blocklight, $Y << 3, 8);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -84,7 +87,8 @@ class LevelImport{
|
||||||
}
|
}
|
||||||
console("[NOTICE] Importing level " . ceil(($Z + 1) / 0.16) . "%");
|
console("[NOTICE] Importing level " . ceil(($Z + 1) / 0.16) . "%");
|
||||||
}
|
}
|
||||||
$chunks->map = null;
|
$pmf->writeNCData();
|
||||||
|
|
||||||
$chunks = null;
|
$chunks = null;
|
||||||
if(file_exists($this->path . "level.dat")) @unlink($this->path . "level.dat");
|
if(file_exists($this->path . "level.dat")) @unlink($this->path . "level.dat");
|
||||||
if(file_exists($this->path . "level.dat_old")) @unlink($this->path . "level.dat_old");
|
if(file_exists($this->path . "level.dat_old")) @unlink($this->path . "level.dat_old");
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@ class PocketChunkParser{
|
||||||
var $map; //21 * $sectorLength
|
var $map; //21 * $sectorLength
|
||||||
private $location, $raw = b"", $file;
|
private $location, $raw = b"", $file;
|
||||||
|
|
||||||
|
public function __destruct(){
|
||||||
|
unset($this->location);
|
||||||
|
unset($this->raw);
|
||||||
|
unset($this->file);
|
||||||
|
unset($this->map);
|
||||||
|
}
|
||||||
|
|
||||||
public function loadFile($file){
|
public function loadFile($file){
|
||||||
if(file_exists($file . ".gz")){
|
if(file_exists($file . ".gz")){
|
||||||
$this->raw = gzinflate(file_get_contents($file . ".gz"));
|
$this->raw = gzinflate(file_get_contents($file . ".gz"));
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue