summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-11 03:06:07 +0100
committerThorbjørn Lindeijer <thorbjorn@lindeijer.nl>2011-03-11 11:10:42 +0100
commitf066f988ac60571304b2301c57d5fbbf5da332cf (patch)
tree88efcc0479269bb726d02611edebefa8b7f14b2d /scripts
parent01977a101d839107d8c28ca31f885f67e660dd68 (diff)
downloadmanaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.tar.gz
manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.tar.xz
manaserv-f066f988ac60571304b2301c57d5fbbf5da332cf.zip
Simplified check_schedule a bit
Diffstat (limited to 'scripts')
-rw-r--r--scripts/lua/libmana.lua23
1 files changed, 9 insertions, 14 deletions
diff --git a/scripts/lua/libmana.lua b/scripts/lua/libmana.lua
index 62c089f..f9f2857 100644
--- a/scripts/lua/libmana.lua
+++ b/scripts/lua/libmana.lua
@@ -341,23 +341,18 @@ end
-- checks for jobs which have to be executed, executes them and reschedules
-- them when they are repeated jobs.
function check_schedule()
- if #scheduler_jobs==0 then return end
-
local current_time = os.time()
- while current_time > scheduler_jobs[#scheduler_jobs][0] do
+
+ while #scheduler_jobs~=0 and current_time > scheduler_jobs[#scheduler_jobs][0] do
-- retreive the job and remove it from the schedule
job = scheduler_jobs[#scheduler_jobs]
- table.remove(scheduler_jobs)
- -- reschedule the job when it is a repeated job
- if job[2] then
- schedule_every(job[2], job[1])
- end
- -- execute the job
- job[1]()
-
- -- avoid looping on an empty table
- if #scheduler_jobs==0 then return end
-
+ table.remove(scheduler_jobs)
+ -- reschedule the job when it is a repeated job
+ if job[2] then
+ schedule_every(job[2], job[1])
+ end
+ -- execute the job
+ job[1]()
end
end