fix(awesome) randomness

Close #3123, close #3124
Co-authored-by: Emmanuel Lepage Vallee <elv1313@gmail.com>
This commit is contained in:
Aire-One 2022-01-22 17:31:53 +01:00
parent d0b9938da1
commit b807bbae56
1 changed files with 8 additions and 2 deletions

View File

@ -84,10 +84,16 @@ init_rng(void)
lua_getfield(L, -1, "randomseed"); lua_getfield(L, -1, "randomseed");
/* Push a seed */ /* Push a seed */
lua_pushnumber(L, g_random_int() + g_random_double()); lua_pushnumber(L, g_random_int());
/* Call math.randomseed */ /* Call math.randomseed */
lua_call(L, 1, 0); if(lua_pcall(L, 1, 0, 0))
{
warn("Random number generator initialization failed: %s", lua_tostring(L, -1));
/* Remove error function and error string */
lua_pop(L, 2);
return;
}
/* Remove "math" global */ /* Remove "math" global */
lua_pop(L, 1); lua_pop(L, 1);