mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-06-25 04:44:03 +00:00
LevelManager::generateLevel(): avoid multiple return points
this could cause unexpected results if additional code is added after background generation in the future.
This commit is contained in:
parent
7c7f42eba6
commit
854c3a816c
@ -292,33 +292,31 @@ class LevelManager{
|
||||
|
||||
(new LevelLoadEvent($level))->call();
|
||||
|
||||
if(!$backgroundGeneration){
|
||||
return true;
|
||||
}
|
||||
if($backgroundGeneration){
|
||||
$this->server->getLogger()->notice($this->server->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
|
||||
|
||||
$this->server->getLogger()->notice($this->server->getLanguage()->translateString("pocketmine.level.backgroundGeneration", [$name]));
|
||||
$spawnLocation = $level->getSpawnLocation();
|
||||
$centerX = $spawnLocation->getFloorX() >> 4;
|
||||
$centerZ = $spawnLocation->getFloorZ() >> 4;
|
||||
|
||||
$spawnLocation = $level->getSpawnLocation();
|
||||
$centerX = $spawnLocation->getFloorX() >> 4;
|
||||
$centerZ = $spawnLocation->getFloorZ() >> 4;
|
||||
$order = [];
|
||||
|
||||
$order = [];
|
||||
|
||||
for($X = -3; $X <= 3; ++$X){
|
||||
for($Z = -3; $Z <= 3; ++$Z){
|
||||
$distance = $X ** 2 + $Z ** 2;
|
||||
$chunkX = $X + $centerX;
|
||||
$chunkZ = $Z + $centerZ;
|
||||
$index = Level::chunkHash($chunkX, $chunkZ);
|
||||
$order[$index] = $distance;
|
||||
for($X = -3; $X <= 3; ++$X){
|
||||
for($Z = -3; $Z <= 3; ++$Z){
|
||||
$distance = $X ** 2 + $Z ** 2;
|
||||
$chunkX = $X + $centerX;
|
||||
$chunkZ = $Z + $centerZ;
|
||||
$index = Level::chunkHash($chunkX, $chunkZ);
|
||||
$order[$index] = $distance;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
asort($order);
|
||||
asort($order);
|
||||
|
||||
foreach($order as $index => $distance){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$level->populateChunk($chunkX, $chunkZ, true);
|
||||
foreach($order as $index => $distance){
|
||||
Level::getXZ($index, $chunkX, $chunkZ);
|
||||
$level->populateChunk($chunkX, $chunkZ, true);
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user