mirror of
https://github.com/pmmp/PocketMine-MP.git
synced 2025-07-11 12:27:51 +00:00
Avoid usage of for-loop vars outside of for-loop context
these problems were reported by PHPStan strict rules. They aren't actually bugs, but they could become bugs in the future.
This commit is contained in:
parent
88afedd1e8
commit
99038c752c
@ -411,8 +411,8 @@ class Chunk{
|
|||||||
* @return int New calculated heightmap value (0-256 inclusive)
|
* @return int New calculated heightmap value (0-256 inclusive)
|
||||||
*/
|
*/
|
||||||
public function recalculateHeightMapColumn(int $x, int $z) : int{
|
public function recalculateHeightMapColumn(int $x, int $z) : int{
|
||||||
$max = $this->getHighestBlockAt($x, $z);
|
$y = $this->getHighestBlockAt($x, $z);
|
||||||
for($y = $max; $y >= 0; --$y){
|
for(; $y >= 0; --$y){
|
||||||
if(BlockFactory::$lightFilter[$id = $this->getBlockId($x, $y, $z)] > 1 or BlockFactory::$diffusesSkyLight[$id]){
|
if(BlockFactory::$lightFilter[$id = $this->getBlockId($x, $y, $z)] > 1 or BlockFactory::$diffusesSkyLight[$id]){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -438,9 +438,9 @@ class Chunk{
|
|||||||
|
|
||||||
for($x = 0; $x < 16; ++$x){
|
for($x = 0; $x < 16; ++$x){
|
||||||
for($z = 0; $z < 16; ++$z){
|
for($z = 0; $z < 16; ++$z){
|
||||||
|
$y = $maxY;
|
||||||
$heightMap = $this->getHeightMap($x, $z);
|
$heightMap = $this->getHeightMap($x, $z);
|
||||||
|
for(; $y >= $heightMap; --$y){
|
||||||
for($y = $maxY; $y >= $heightMap; --$y){
|
|
||||||
$this->setBlockSkyLight($x, $y, $z, 15);
|
$this->setBlockSkyLight($x, $y, $z, 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -805,10 +805,10 @@ class Chunk{
|
|||||||
//No need to thoroughly prune empties at runtime, this will just reduce performance.
|
//No need to thoroughly prune empties at runtime, this will just reduce performance.
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
break;
|
return $y;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -47,7 +47,8 @@ class GroundCover extends Populator{
|
|||||||
}
|
}
|
||||||
|
|
||||||
$column = $chunk->getBlockIdColumn($x, $z);
|
$column = $chunk->getBlockIdColumn($x, $z);
|
||||||
for($y = 127; $y > 0; --$y){
|
$y = 127;
|
||||||
|
for(; $y > 0; --$y){
|
||||||
if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){
|
if($column[$y] !== "\x00" and !BlockFactory::get(ord($column[$y]))->isTransparent()){
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -77,10 +77,10 @@ class TallGrass extends Populator{
|
|||||||
for($y = 127; $y >= 0; --$y){
|
for($y = 127; $y >= 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){
|
if($b !== Block::AIR and $b !== Block::LEAVES and $b !== Block::LEAVES2 and $b !== Block::SNOW_LAYER){
|
||||||
break;
|
return $y + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $y === 0 ? -1 : ++$y;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,12 +83,12 @@ class Tree extends Populator{
|
|||||||
for($y = 127; $y > 0; --$y){
|
for($y = 127; $y > 0; --$y){
|
||||||
$b = $this->level->getBlockIdAt($x, $y, $z);
|
$b = $this->level->getBlockIdAt($x, $y, $z);
|
||||||
if($b === Block::DIRT or $b === Block::GRASS){
|
if($b === Block::DIRT or $b === Block::GRASS){
|
||||||
break;
|
return $y + 1;
|
||||||
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
|
}elseif($b !== Block::AIR and $b !== Block::SNOW_LAYER){
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return ++$y;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -287,7 +287,8 @@ class PlayerNetworkSessionAdapter extends NetworkSession{
|
|||||||
if($quoteType === null){
|
if($quoteType === null){
|
||||||
$quoteType = $raw[$i];
|
$quoteType = $raw[$i];
|
||||||
}elseif($raw[$i] === $quoteType){
|
}elseif($raw[$i] === $quoteType){
|
||||||
for($backslashes = 0; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
$backslashes = 0;
|
||||||
|
for(; $backslashes < $i && $raw[$i - $backslashes - 1] === "\\"; ++$backslashes){}
|
||||||
if(($backslashes % 2) === 0){ //unescaped quote
|
if(($backslashes % 2) === 0){ //unescaped quote
|
||||||
$quoteType = null;
|
$quoteType = null;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user