1
0
Fork 0

Fix unnecessary exception use in Map::isNodeUnderground

The isNodeUnderground calls getBlockNoCreate which calls
getBlockNoCreateNoEx and throws InvalidPositionException
if the returned value is nullptr, which isNodeUnderground
then catches to return "false". Remove the try..catch in
isNodeUnderground by calling getBlockNoCreateNoEx instead
of getBlockNoCreate and checking the returned value for
nullptr.
mutilcraft-mt53
Jozef Behran 2019-08-07 12:06:45 +02:00 committed by sfan5
parent 833e60d8d2
commit e9ceead81d
1 changed files with 2 additions and 8 deletions

View File

@ -152,14 +152,8 @@ MapBlock * Map::getBlockNoCreate(v3s16 p3d)
bool Map::isNodeUnderground(v3s16 p)
{
v3s16 blockpos = getNodeBlockPos(p);
try{
MapBlock * block = getBlockNoCreate(blockpos);
return block->getIsUnderground();
}
catch(InvalidPositionException &e)
{
return false;
}
MapBlock *block = getBlockNoCreateNoEx(blockpos);
return block && block->getIsUnderground();
}
bool Map::isValidPosition(v3s16 p)