diff options
author | kwolekr <kwolekr@minetest.net> | 2014-12-10 00:37:09 -0500 |
---|---|---|
committer | kwolekr <kwolekr@minetest.net> | 2014-12-10 00:37:09 -0500 |
commit | fb2bc956b18bd70a47bff00d5726d4754867856a (patch) | |
tree | 1e8cb37de5f6b4db15cedec2e1b036e807710c06 /src/script | |
parent | 88c28414f4a88c8d66f9cadb150896f9e25527ae (diff) | |
download | minetest-fb2bc956b18bd70a47bff00d5726d4754867856a.tar.gz minetest-fb2bc956b18bd70a47bff00d5726d4754867856a.tar.bz2 minetest-fb2bc956b18bd70a47bff00d5726d4754867856a.zip |
Noise: Create a deep copy of NoiseParams
Diffstat (limited to 'src/script')
-rw-r--r-- | src/script/lua_api/l_mapgen.cpp | 9 | ||||
-rw-r--r-- | src/script/lua_api/l_noise.cpp | 8 |
2 files changed, 12 insertions, 5 deletions
diff --git a/src/script/lua_api/l_mapgen.cpp b/src/script/lua_api/l_mapgen.cpp index 0e3d219a4..3176b920c 100644 --- a/src/script/lua_api/l_mapgen.cpp +++ b/src/script/lua_api/l_mapgen.cpp @@ -546,7 +546,14 @@ int ModApiMapgen::l_register_ore(lua_State *L) getflagsfield(L, index, "flags", flagdesc_ore, &ore->flags, NULL); lua_getfield(L, index, "noise_params"); - ore->np = get_noiseparams(L, -1); + if (read_noiseparams(L, -1, &ore->np)) { + ore->flags |= OREFLAG_USE_NOISE; + } else if (ore->NEEDS_NOISE) { + errorstream << "register_ore: specified ore type requires valid " + "noise parameters" << std::endl; + delete ore; + return 0; + } lua_pop(L, 1); u32 id = oremgr->add(ore); diff --git a/src/script/lua_api/l_noise.cpp b/src/script/lua_api/l_noise.cpp index 2a57df0f6..c66f54e6f 100644 --- a/src/script/lua_api/l_noise.cpp +++ b/src/script/lua_api/l_noise.cpp @@ -161,7 +161,7 @@ int LuaPerlinNoiseMap::l_get2dMap(lua_State *L) for (int y = 0; y != n->sy; y++) { lua_newtable(L); for (int x = 0; x != n->sx; x++) { - float noiseval = n->np->offset + n->np->scale * n->result[i++]; + float noiseval = n->np.offset + n->np.scale * n->result[i++]; lua_pushnumber(L, noiseval); lua_rawseti(L, -2, x + 1); } @@ -185,7 +185,7 @@ int LuaPerlinNoiseMap::l_get2dMap_flat(lua_State *L) lua_newtable(L); for (int i = 0; i != maplen; i++) { - float noiseval = n->np->offset + n->np->scale * n->result[i]; + float noiseval = n->np.offset + n->np.scale * n->result[i]; lua_pushnumber(L, noiseval); lua_rawseti(L, -2, i + 1); } @@ -210,7 +210,7 @@ int LuaPerlinNoiseMap::l_get3dMap(lua_State *L) for (int y = 0; y != n->sy; y++) { lua_newtable(L); for (int x = 0; x != n->sx; x++) { - lua_pushnumber(L, n->np->offset + n->np->scale * n->result[i++]); + lua_pushnumber(L, n->np.offset + n->np.scale * n->result[i++]); lua_rawseti(L, -2, x + 1); } lua_rawseti(L, -2, y + 1); @@ -236,7 +236,7 @@ int LuaPerlinNoiseMap::l_get3dMap_flat(lua_State *L) lua_newtable(L); for (int i = 0; i != maplen; i++) { - float noiseval = n->np->offset + n->np->scale * n->result[i]; + float noiseval = n->np.offset + n->np.scale * n->result[i]; lua_pushnumber(L, noiseval); lua_rawseti(L, -2, i + 1); } |