]> git.lizzy.rs Git - minetest.git/commit
New timer design.
authorAuke Kok <sofar@foo-projects.org>
Thu, 21 Jan 2016 09:07:38 +0000 (01:07 -0800)
committerShadowNinja <shadowninja@minetest.net>
Fri, 29 Jan 2016 06:04:51 +0000 (01:04 -0500)
commitad884f23d4e73d38ce0f529de49591dd66cee44d
tree5c596b41f2d8edd006af13d0cf2552767fb466c1
parent4ac1e9bccbd0222ab779b3fc4d2144d60e1f2b49
New timer design.

I could honestly not make much sense of the timer implementation
that was here. Instead I've implemented the type of timer algorithm
that I've used before, and tested it instead.

The concept is extremely simple: all timers are put in an ordered
list. We check every server tick if any of the timers have
elapsed, and execute the function associated with this timer.

We know that many timers by themselves cause new timers to be
added to this list, so we iterate *backwards* over the timer
list. This means that new timers being added while timers are
being executed, can never be executed in the same function pass,
as they are always appended to the table *after* the end of
the table, which we will never reach in the current pass over
all the table elements.

We switch time keeping to minetest.get_us_time(). dtime is
likely unreliable and we have our own high-res timer that we
can fix if it is indeed broken. This removes the need to do
any sort of time keeping.
builtin/game/misc.lua
doc/lua_api.txt