aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorZughy <63455151+Zughy@users.noreply.github.com>2020-10-13 21:28:53 +0200
committerGitHub <noreply@github.com>2020-10-13 20:28:53 +0100
commit7499ebe46af072e911fa4902faf0a7343559d2c3 (patch)
tree64be6863043e1265b875a891ec2a9b656c3604aa /src
parent2ca81d679f92ff1f0effccff5d3ee5672871324f (diff)
downloadminetest-7499ebe46af072e911fa4902faf0a7343559d2c3.tar.gz
minetest-7499ebe46af072e911fa4902faf0a7343559d2c3.tar.bz2
minetest-7499ebe46af072e911fa4902faf0a7343559d2c3.zip
Fix float argument check in minetest.set_timeofday() (#10483)
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
Diffstat (limited to 'src')
-rw-r--r--src/script/lua_api/l_env.cpp5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/script/lua_api/l_env.cpp b/src/script/lua_api/l_env.cpp
index 8d50d664d..021ef2ea7 100644
--- a/src/script/lua_api/l_env.cpp
+++ b/src/script/lua_api/l_env.cpp
@@ -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.