]> git.lizzy.rs Git - dragonfireclient.git/commitdiff
Fix float argument check in minetest.set_timeofday() (#10483)
authorZughy <63455151+Zughy@users.noreply.github.com>
Tue, 13 Oct 2020 19:28:53 +0000 (21:28 +0200)
committerGitHub <noreply@github.com>
Tue, 13 Oct 2020 19:28:53 +0000 (20:28 +0100)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
src/script/lua_api/l_env.cpp

index 8d50d664d41a860589137d525259c93c37b75f98..021ef2ea7cd0ab6f4540394ebe8a2e1fa78c0b70 100644 (file)
@@ -751,8 +751,9 @@ int ModApiEnvMod::l_set_timeofday(lua_State *L)
 
        // Do it
        float timeofday_f = readParam<float>(L, 1);
-       sanity_check(timeofday_f >= 0.0 && timeofday_f <= 1.0);
-       int timeofday_mh = (int)(timeofday_f * 24000.0);
+       luaL_argcheck(L, timeofday_f >= 0.0f && timeofday_f <= 1.0f, 1,
+               "value must be between 0 and 1");
+       int timeofday_mh = (int)(timeofday_f * 24000.0f);
        // This should be set directly in the environment but currently
        // such changes aren't immediately sent to the clients, so call
        // the server instead.