Skip to content

Commit e9ceead

Browse files
osjcsfan5
authored andcommittedAug 13, 2019
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.
1 parent 833e60d commit e9ceead

File tree

1 file changed

+2
-8
lines changed

1 file changed

+2
-8
lines changed
 

Diff for: ‎src/map.cpp

+2-8
Original file line numberDiff line numberDiff line change
@@ -152,14 +152,8 @@ MapBlock * Map::getBlockNoCreate(v3s16 p3d)
152152
bool Map::isNodeUnderground(v3s16 p)
153153
{
154154
v3s16 blockpos = getNodeBlockPos(p);
155-
try{
156-
MapBlock * block = getBlockNoCreate(blockpos);
157-
return block->getIsUnderground();
158-
}
159-
catch(InvalidPositionException &e)
160-
{
161-
return false;
162-
}
155+
MapBlock *block = getBlockNoCreateNoEx(blockpos);
156+
return block && block->getIsUnderground();
163157
}
164158

165159
bool Map::isValidPosition(v3s16 p)

0 commit comments

Comments
 (0)
Please sign in to comment.