minetest.after(): simplify further, pause in singleplayer (#5500)
authorAuke Kok <sofar+github@foo-projects.org>
Sun, 2 Apr 2017 08:51:16 +0000 (08:51 +0000)
committerLoïc Blot <nerzhul@users.noreply.github.com>
Sun, 2 Apr 2017 08:51:16 +0000 (10:51 +0200)
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.

builtin/common/after.lua

index 30a9c7badbe21d652e55699e5454c9aaede629da..cdfaaab8616ba0bccf28b962d13160f3e9fd0790 100644 (file)
@@ -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