@@ -958,25 +958,36 @@ void luaentity_get(lua_State *L, u16 id)
958
958
959
959
/* *****************************************************************************/
960
960
NoiseParams *read_noiseparams (lua_State *L, int index)
961
+ {
962
+ NoiseParams *np = new NoiseParams;
963
+
964
+ if (!read_noiseparams_nc (L, index , np)) {
965
+ delete np;
966
+ np = NULL ;
967
+ }
968
+
969
+ return np;
970
+ }
971
+
972
+ bool read_noiseparams_nc (lua_State *L, int index, NoiseParams *np)
961
973
{
962
974
if (index < 0 )
963
975
index = lua_gettop (L) + 1 + index ;
964
976
965
977
if (!lua_istable (L, index ))
966
- return NULL ;
978
+ return false ;
967
979
968
- NoiseParams *np = new NoiseParams;
980
+ np->offset = getfloatfield_default (L, index , " offset" , 0.0 );
981
+ np->scale = getfloatfield_default (L, index , " scale" , 0.0 );
982
+ np->persist = getfloatfield_default (L, index , " persist" , 0.0 );
983
+ np->seed = getintfield_default (L, index , " seed" , 0 );
984
+ np->octaves = getintfield_default (L, index , " octaves" , 0 );
969
985
970
- np->offset = getfloatfield_default (L, index , " offset" , 0.0 );
971
- np->scale = getfloatfield_default (L, index , " scale" , 0.0 );
972
986
lua_getfield (L, index , " spread" );
973
987
np->spread = read_v3f (L, -1 );
974
988
lua_pop (L, 1 );
975
- np->seed = getintfield_default (L, index , " seed" , 0 );
976
- np->octaves = getintfield_default (L, index , " octaves" , 0 );
977
- np->persist = getfloatfield_default (L, index , " persist" , 0.0 );
978
989
979
- return np ;
990
+ return true ;
980
991
}
981
992
982
993
/* *****************************************************************************/
0 commit comments