mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-05 09:39:56 +00:00
Do not unload spawn chunks
This commit is contained in:
parent
f0ff420659
commit
fdf519398a
@ -2322,6 +2322,7 @@ class Player{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public function sendBuffer(){
|
public function sendBuffer(){
|
||||||
|
if($this->connected === true){
|
||||||
if($this->bufferLen > 0 and $this->buffer instanceof RakNetPacket){
|
if($this->bufferLen > 0 and $this->buffer instanceof RakNetPacket){
|
||||||
$this->buffer->seqNumber = $this->counter[0]++;
|
$this->buffer->seqNumber = $this->counter[0]++;
|
||||||
$this->send($this->buffer);
|
$this->send($this->buffer);
|
||||||
@ -2331,6 +2332,7 @@ class Player{
|
|||||||
$this->buffer->data = array();
|
$this->buffer->data = array();
|
||||||
$this->nextBuffer = microtime(true) + 0.1;
|
$this->nextBuffer = microtime(true) + 0.1;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private function directBigRawPacket(RakNetDataPacket $packet){
|
private function directBigRawPacket(RakNetDataPacket $packet){
|
||||||
if($this->connected === false){
|
if($this->connected === false){
|
||||||
@ -2418,7 +2420,7 @@ class Player{
|
|||||||
|
|
||||||
$packet->messageIndex = $this->counter[3]++;
|
$packet->messageIndex = $this->counter[3]++;
|
||||||
$packet->reliability = 2;
|
$packet->reliability = 2;
|
||||||
$this->buffer->data[] = $packet;
|
@$this->buffer->data[] = $packet;
|
||||||
$this->bufferLen += 6 + $len;
|
$this->bufferLen += 6 + $len;
|
||||||
return array();
|
return array();
|
||||||
}
|
}
|
||||||
|
@ -138,8 +138,11 @@ class Level{
|
|||||||
if(count($c) === 0){
|
if(count($c) === 0){
|
||||||
unset($this->usedChunks[$i]);
|
unset($this->usedChunks[$i]);
|
||||||
$X = explode(".", $i);
|
$X = explode(".", $i);
|
||||||
$Z = array_pop($X);
|
$Z = (int) array_pop($X);
|
||||||
$this->level->unloadChunk((int) array_pop($X), (int) $Z, $this->server->saveEnabled);
|
$X = (int) array_pop($X);
|
||||||
|
if(!$this->isSpawnChunk($X, $Z)){
|
||||||
|
$this->level->unloadChunk($X, $Z, $this->server->saveEnabled);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->save(false, false);
|
$this->save(false, false);
|
||||||
@ -408,14 +411,24 @@ class Level{
|
|||||||
return $this->level->loadChunk($X, $Z);
|
return $this->level->loadChunk($X, $Z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function unloadChunk($X, $Z){
|
public function unloadChunk($X, $Z, $force = false){
|
||||||
if(!isset($this->level)){
|
if(!isset($this->level)){
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if($force !== true and $this->isSpawnChunk($X, $Z)){
|
||||||
|
return false;
|
||||||
|
}
|
||||||
Cache::remove("world:{$this->name}:$X:$Z");
|
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isSpawnChunk($X, $Z){
|
||||||
|
$spawnX = $this->level->getData("spawnX") >> 4;
|
||||||
|
$spawnZ = $this->level->getData("spawnZ") >> 4;
|
||||||
|
return abs($X - $spawnX) <= 1 and abs($Z - $spawnZ) <= 1;
|
||||||
|
}
|
||||||
|
|
||||||
public function getOrderedChunk($X, $Z, $Yndex){
|
public function getOrderedChunk($X, $Z, $Yndex){
|
||||||
if(!isset($this->level)){
|
if(!isset($this->level)){
|
||||||
return false;
|
return false;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user