diff options
author | kwolekr <kwolekr@minetest.net> | 2014-11-29 16:50:18 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-11-29 16:52:45 -0500 |
commit | 25945dc5395a03cab069ff0e6470ba8d59b03978 (patch) | |
tree | 63b413140814c90197d55326e1d65b2672c978da /src/script | |
parent | a3e019c4f6745d06d7afed7991b9c682b0ea65b9 (diff) | |
download | minetest-25945dc5395a03cab069ff0e6470ba8d59b03978.tar.gz minetest-25945dc5395a03cab069ff0e6470ba8d59b03978.tar.bz2 minetest-25945dc5395a03cab069ff0e6470ba8d59b03978.zip |
noise: Throw exception on noise allocation failure
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_noise.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp index 4f230b76e..96ed93643 100644 --- a/src/script/lua_api/l_noise.cpp +++ b/src/script/lua_api/l_noise.cpp @@ -171,7 +171,7 @@ int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L) n->perlinMap2D(p.X, p.Y); int maplen = n->sx * n->sy; - + lua_newtable(L); for (int i = 0; i != maplen; i++) { float noiseval = n->np->offset + n->np->scale * n->result[i]; @@ -220,7 +220,7 @@ int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L) int maplen = n->sx * n->sy * n->sz; - + lua_newtable(L); for (int i = 0; i != maplen; i++) { float noiseval = n->np->offset + n->np->scale * n->result[i]; @@ -231,7 +231,11 @@ int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L) } LuaPerlinNoiseMap::LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size) { - noise = new Noise(np, seed, size.X, size.Y, size.Z); + try { + noise = new Noise(np, seed, size.X, size.Y, size.Z); + } catch (InvalidNoiseParamsException &e) { + throw LuaError(e.what()); + } } LuaPerlinNoiseMap::~LuaPerlinNoiseMap() |