consistent variable naming

This commit is contained in:
Lukas Kropatschek 2016-01-13 13:44:43 +01:00
parent 57613f0aab
commit a11b254bbd

View File

@ -49,16 +49,16 @@ do -- the main scope
local writeGroups = {} local writeGroups = {}
local lastUpdateTime = 0 local lastUpdateTime = 0
local update_alive_units_counter = 0 local updateAliveUnitsCounter = 0
local write_DB_table_counter = 0 local writeDbTableCounter = 0
local check_spawn_events_counter = 0 local checkSpawnEventsCounter = 0
local mistGpId = 7000 local mistGpId = 7000
local mistUnitId = 7000 local mistUnitId = 7000
local mistDynAddIndex = 1 local mistDynAddIndex = 1
local Tasks = {} local scheduledTasks = {}
local task_id = 0 local taskId = 0
local idNum = 0 local idNum = 0
mist.nextGroupId = 1 mist.nextGroupId = 1
@ -838,30 +838,30 @@ do -- the main scope
local function doScheduledFunctions() local function doScheduledFunctions()
local i = 1 local i = 1
while i <= #Tasks do while i <= #scheduledTasks do
if not Tasks[i].rep then -- not a repeated process if not scheduledTasks[i].rep then -- not a repeated process
if Tasks[i].t <= timer.getTime() then if scheduledTasks[i].t <= timer.getTime() then
local Task = Tasks[i] -- local reference local task = scheduledTasks[i] -- local reference
table.remove(Tasks, i) table.remove(scheduledTasks, i)
local err, errmsg = pcall(Task.f, unpack(Task.vars, 1, table.maxn(Task.vars))) local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
if not err then if not err then
log:error('mist.scheduleFunction, error in scheduled function: $1', errmsg) log:error('mist.scheduleFunction, error in scheduled function: $1', errmsg)
end end
--Task.f(unpack(Task.vars, 1, table.maxn(Task.vars))) -- do the task, do not increment i --task.f(unpack(task.vars, 1, table.maxn(task.vars))) -- do the task, do not increment i
else else
i = i + 1 i = i + 1
end end
else else
if Tasks[i].st and Tasks[i].st <= timer.getTime() then --if a stoptime was specified, and the stop time exceeded if scheduledTasks[i].st and scheduledTasks[i].st <= timer.getTime() then --if a stoptime was specified, and the stop time exceeded
table.remove(Tasks, i) -- stop time exceeded, do not execute, do not increment i table.remove(scheduledTasks, i) -- stop time exceeded, do not execute, do not increment i
elseif Tasks[i].t <= timer.getTime() then elseif scheduledTasks[i].t <= timer.getTime() then
local Task = Tasks[i] -- local reference local task = scheduledTasks[i] -- local reference
Task.t = timer.getTime() + Task.rep --schedule next run task.t = timer.getTime() + task.rep --schedule next run
local err, errmsg = pcall(Task.f, unpack(Task.vars, 1, table.maxn(Task.vars))) local err, errmsg = pcall(task.f, unpack(task.vars, 1, table.maxn(task.vars)))
if not err then if not err then
log:error('mist.scheduleFunction, error in scheduled function: $1' .. errmsg) log:error('mist.scheduleFunction, error in scheduled function: $1' .. errmsg)
end end
--Tasks[i].f(unpack(Tasks[i].vars, 1, table.maxn(Tasks[i].vars))) -- do the task --scheduledTasks[i].f(unpack(scheduledTasks[i].vars, 1, table.maxn(scheduledTasks[i].vars))) -- do the task
i = i + 1 i = i + 1
else else
i = i + 1 i = i + 1
@ -988,10 +988,9 @@ do -- the main scope
function mist.main() function mist.main()
timer.scheduleFunction(mist.main, {}, timer.getTime() + 0.01) --reschedule first in case of Lua error timer.scheduleFunction(mist.main, {}, timer.getTime() + 0.01) --reschedule first in case of Lua error
write_DB_table_counter = write_DB_table_counter + 1 writeDbTableCounter = writeDbTableCounter + 1
if write_DB_table_counter == 10 then if writeDbTableCounter == 10 then
writeDbTableCounter = 0
write_DB_table_counter = 0
if not coroutines.updateDBTables then if not coroutines.updateDBTables then
coroutines.updateDBTables = coroutine.create(updateDBTables) coroutines.updateDBTables = coroutine.create(updateDBTables)
@ -1004,10 +1003,9 @@ do -- the main scope
end end
end end
check_spawn_events_counter = check_spawn_events_counter + 1 checkSpawnEventsCounter = checkSpawnEventsCounter + 1
if check_spawn_events_counter == 10 then if checkSpawnEventsCounter == 10 then
checkSpawnEventsCounter = 0
check_spawn_events_counter = 0
if not coroutines.checkSpawnedEvents then if not coroutines.checkSpawnedEvents then
coroutines.checkSpawnedEvents = coroutine.create(checkSpawnedEvents) coroutines.checkSpawnedEvents = coroutine.create(checkSpawnedEvents)
@ -1021,9 +1019,9 @@ do -- the main scope
end end
--updating alive units --updating alive units
update_alive_units_counter = update_alive_units_counter + 1 updateAliveUnitsCounter = updateAliveUnitsCounter + 1
if update_alive_units_counter == 5 then if updateAliveUnitsCounter == 5 then
update_alive_units_counter = 0 updateAliveUnitsCounter = 0
if not coroutines.update_alive_units then if not coroutines.update_alive_units then
coroutines.updateAliveUnits = coroutine.create(updateAliveUnits) coroutines.updateAliveUnits = coroutine.create(updateAliveUnits)
@ -1364,9 +1362,9 @@ do -- the main scope
if not vars then if not vars then
vars = {} vars = {}
end end
task_id = task_id + 1 taskId = taskId + 1
table.insert(Tasks, {f = f, vars = vars, t = t, rep = rep, st = st, id = task_id}) table.insert(scheduledTasks, {f = f, vars = vars, t = t, rep = rep, st = st, id = taskId})
return task_id return taskId
end end
--- Removes a scheduled function. --- Removes a scheduled function.
@ -1374,9 +1372,9 @@ do -- the main scope
-- @treturn boolean true if function was successfully removed, false otherwise. -- @treturn boolean true if function was successfully removed, false otherwise.
function mist.removeFunction(id) function mist.removeFunction(id)
local i = 1 local i = 1
while i <= #Tasks do while i <= #scheduledTasks do
if Tasks[i].id == id then if scheduledTasks[i].id == id then
table.remove(Tasks, i) table.remove(scheduledTasks, i)
else else
i = i + 1 i = i + 1
end end