Skip to content
Permalink
Browse files

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.
  • Loading branch information...
osjc authored and sfan5 committed Aug 7, 2019
1 parent 833e60d commit e9ceead81dd989936e2de3ff7cd7496aecd09d39
Showing with 2 additions and 8 deletions.
  1. +2 −8 src/map.cpp
@@ -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)

0 comments on commit e9ceead

Please sign in to comment.
You can’t perform that action at this time.