Skip to content

Commit

Permalink
minetest.after(): simplify further, pause in singleplayer (#5500)
Browse files Browse the repository at this point in the history
Using the `dtime` value entirely, this will stop the clock
if the game is paused in singleplayer. Since most of the
clocks were fixed a long time ago, this should again be
safe to use.
  • Loading branch information
sofar authored and nerzhul committed Apr 2, 2017
1 parent 26f4a5c commit 75fb3e4
Showing 1 changed file with 1 addition and 11 deletions.
12 changes: 1 addition & 11 deletions builtin/common/after.lua
@@ -1,18 +1,8 @@
local jobs = {}
local time = 0.0
local last = core.get_us_time() / 1000000

core.register_globalstep(function(dtime)
local new = core.get_us_time() / 1000000
if new > last then
time = time + (new - last)
else
-- Overflow, we may lose a little bit of time here but
-- only 1 tick max, potentially running timers slightly
-- too early.
time = time + new
end
last = new
time = time + dtime

if #jobs < 1 then
return
Expand Down

0 comments on commit 75fb3e4

Please sign in to comment.