Skip to content

Commit

Permalink
Fix float argument check in minetest.set_timeofday() (#10483)
Browse files Browse the repository at this point in the history
Co-authored-by: Zughy <4279489-marco_a@users.noreply.gitlab.com>
  • Loading branch information
Zughy and Zughy committed Oct 13, 2020
1 parent 2ca81d6 commit 7499ebe
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/script/lua_api/l_env.cpp
Expand Up @@ -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.
Expand Down

0 comments on commit 7499ebe

Please sign in to comment.