Timer - Fixed bug where behaviour of new timers added during iteration through timer handles was indeterminate.

This commit is contained in:
shru 2018-02-16 13:52:44 +10:30
parent 945423f9f5
commit e62e69999c

View File

@ -32,7 +32,14 @@ local function _nothing_() end
function Timer:update(dt) function Timer:update(dt)
local to_remove = {} local to_remove = {}
local handles = {}
local len = 0
for handle in pairs(self.functions) do for handle in pairs(self.functions) do
len = len + 1
handles[len] = handle
end
for _, handle in ipairs(handles) do
-- handle: { -- handle: {
-- time = <number>, -- time = <number>,
-- after = <function>, -- after = <function>,