From: Zefram Date: Wed, 16 Jul 2014 15:24:39 +0000 (+0200) Subject: Fix indexing error in timer processing X-Git-Url: http://81.2.79.47:8989/gitweb/?a=commitdiff_plain;h=aebbcbf398a9dde6b2cbc8ab05c103f44f6f703d;p=zefram%2Fminetest%2Fminetest_engine.git Fix indexing error in timer processing --- diff --git a/builtin/game/misc.lua b/builtin/game/misc.lua index 4afcdb99..a392386f 100644 --- a/builtin/game/misc.lua +++ b/builtin/game/misc.lua @@ -11,11 +11,15 @@ core.register_globalstep(function(dtime) table.insert(core.timers, timer) end core.timers_to_add = {} - for index, timer in ipairs(core.timers) do + local index = 1 + while index <= #core.timers do + local timer = core.timers[index] timer.time = timer.time - dtime if timer.time <= 0 then timer.func(unpack(timer.args or {})) table.remove(core.timers,index) + else + index = index + 1 end end end)