diff options
author | Craig Robbins <kde.psych@gmail.com> | 2014-11-14 18:05:34 +1000 |
---|---|---|
committer | Craig Robbins <kde.psych@gmail.com> | 2014-11-14 18:05:34 +1000 |
commit | 5b8855e83c0d1cc7aef21492e7fe862b7d06917e (patch) | |
tree | b05139dcea07222cfa3fab23064eeef0076c8019 /src/script/lua_api | |
parent | 92815ad54b23fe92742ebca7263bb227149248c1 (diff) | |
download | minetest-5b8855e83c0d1cc7aef21492e7fe862b7d06917e.tar.gz minetest-5b8855e83c0d1cc7aef21492e7fe862b7d06917e.tar.bz2 minetest-5b8855e83c0d1cc7aef21492e7fe862b7d06917e.zip |
Remove most exceptions from getNode() (and variants)
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_env.cpp | 23 |
1 files changed, 11 insertions, 12 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp index 7c7a68b7e..130b15c0b 100644 --- a/src/script/lua_api/l_env.cpp +++ b/src/script/lua_api/l_env.cpp @@ -159,16 +159,15 @@ int ModApiEnvMod::l_get_node_or_nil(lua_State *L) // pos v3s16 pos = read_v3s16(L, 1); // Do it - try{ - MapNode n = env->getMap().getNode(pos); + bool pos_ok; + MapNode n = env->getMap().getNodeNoEx(pos, &pos_ok); + if (pos_ok) { // Return node pushnode(L, n, env->getGameDef()->ndef()); - return 1; - } catch(InvalidPositionException &e) - { + } else { lua_pushnil(L); - return 1; } + return 1; } // get_node_light(pos, timeofday) @@ -185,16 +184,16 @@ int ModApiEnvMod::l_get_node_light(lua_State *L) time_of_day = 24000.0 * lua_tonumber(L, 2); time_of_day %= 24000; u32 dnr = time_to_daynight_ratio(time_of_day, true); - try{ - MapNode n = env->getMap().getNode(pos); + + bool is_position_ok; + MapNode n = env->getMap().getNodeNoEx(pos, &is_position_ok); + if (is_position_ok) { INodeDefManager *ndef = env->getGameDef()->ndef(); lua_pushinteger(L, n.getLightBlend(dnr, ndef)); - return 1; - } catch(InvalidPositionException &e) - { + } else { lua_pushnil(L); - return 1; } + return 1; } // place_node(pos, node) |