forked from Mirrorlandia_minetest/minetest
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.
This commit is contained in:
parent
833e60d8d2
commit
e9ceead81d
10
src/map.cpp
10
src/map.cpp
@ -152,14 +152,8 @@ MapBlock * Map::getBlockNoCreate(v3s16 p3d)
|
|||||||
bool Map::isNodeUnderground(v3s16 p)
|
bool Map::isNodeUnderground(v3s16 p)
|
||||||
{
|
{
|
||||||
v3s16 blockpos = getNodeBlockPos(p);
|
v3s16 blockpos = getNodeBlockPos(p);
|
||||||
try{
|
MapBlock *block = getBlockNoCreateNoEx(blockpos);
|
||||||
MapBlock * block = getBlockNoCreate(blockpos);
|
return block && block->getIsUnderground();
|
||||||
return block->getIsUnderground();
|
|
||||||
}
|
|
||||||
catch(InvalidPositionException &e)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Map::isValidPosition(v3s16 p)
|
bool Map::isValidPosition(v3s16 p)
|
||||||
|
Loading…
Reference in New Issue
Block a user