X-Git-Url: https://git.lizzy.rs/?a=blobdiff_plain;f=src%2Fscript%2Flua_api%2Fl_noise.h;h=40bfd13152b6e914d7e8ec0a2c25d114548c54dd;hb=fbc1432fe8e821f58e97a5f35340efb2f46f93e4;hp=56d2d59f8fb1a335f602727096dc552a0011b460;hpb=3993093f51544d4eb44efb57c973e29107ea2f7a;p=dragonfireclient.git diff --git a/src/script/lua_api/l_noise.h b/src/script/lua_api/l_noise.h index 56d2d59f8..40bfd1315 100644 --- a/src/script/lua_api/l_noise.h +++ b/src/script/lua_api/l_noise.h @@ -74,8 +74,12 @@ class LuaPerlinNoiseMap : public ModApiBase { static int l_get3dMap(lua_State *L); static int l_get3dMap_flat(lua_State *L); + static int l_calc2dMap(lua_State *L); + static int l_calc3dMap(lua_State *L); + static int l_getMapSlice(lua_State *L); + public: - LuaPerlinNoiseMap(NoiseParams *np, int seed, v3s16 size); + LuaPerlinNoiseMap(NoiseParams *np, s32 seed, v3s16 size); ~LuaPerlinNoiseMap(); @@ -107,7 +111,7 @@ class LuaPseudoRandom : public ModApiBase { static int l_next(lua_State *L); public: - LuaPseudoRandom(int seed) : + LuaPseudoRandom(s32 seed) : m_pseudo(seed) {} // LuaPseudoRandom(seed) @@ -156,4 +160,37 @@ class LuaPcgRandom : public ModApiBase { static void Register(lua_State *L); }; + +/* + LuaSecureRandom +*/ +class LuaSecureRandom : public ModApiBase { +private: + static const size_t RAND_BUF_SIZE = 2048; + static const char className[]; + static const luaL_reg methods[]; + + u32 m_rand_idx; + char m_rand_buf[RAND_BUF_SIZE]; + + // Exported functions + + // garbage collector + static int gc_object(lua_State *L); + + // next_bytes(self, count) -> get count many bytes + static int l_next_bytes(lua_State *L); + +public: + bool fillRandBuf(); + + // LuaSecureRandom() + // Creates an LuaSecureRandom and leaves it on top of stack + static int create_object(lua_State *L); + + static LuaSecureRandom *checkobject(lua_State *L, int narg); + + static void Register(lua_State *L); +}; + #endif /* L_NOISE_H_ */