diff options
author | Jozef Behran <jozuejozef@gmail.com> | 2019-08-07 12:06:45 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2019-08-13 19:40:59 +0200 |
commit | e9ceead81dd989936e2de3ff7cd7496aecd09d39 (patch) | |
tree | 51c94e2faf111ed63e40e5bc44d8ea5ea614b6c6 /src/map.cpp | |
parent | 833e60d8d229a082e9841dc89494e6bda9cd5020 (diff) | |
download | minetest-e9ceead81dd989936e2de3ff7cd7496aecd09d39.tar.gz minetest-e9ceead81dd989936e2de3ff7cd7496aecd09d39.tar.bz2 minetest-e9ceead81dd989936e2de3ff7cd7496aecd09d39.zip |
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.
Diffstat (limited to 'src/map.cpp')
-rw-r--r-- | src/map.cpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/src/map.cpp b/src/map.cpp index 590c3f2f5..a1389fd10 100644 --- a/src/map.cpp +++ b/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) |