aboutsummaryrefslogtreecommitdiff
path: root/advtrains_line_automation
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2019-11-21 14:59:39 +0100
committerorwell96 <orwell@bleipb.de>2019-11-21 16:02:32 +0100
commit576365627a6ed8ba3fede9de1dce675a94747e48 (patch)
treeb8688c875cbec8c133066d8ca5d2800a2a919819 /advtrains_line_automation
parent8c55442076c9d5cfed89bac3f4acd22ea7948dd3 (diff)
downloadadvtrains-576365627a6ed8ba3fede9de1dce675a94747e48.tar.gz
advtrains-576365627a6ed8ba3fede9de1dce675a94747e48.tar.bz2
advtrains-576365627a6ed8ba3fede9de1dce675a94747e48.zip
Fix scheduler crash (H#133)
for loops don't work with manipulating i
Diffstat (limited to 'advtrains_line_automation')
-rw-r--r--advtrains_line_automation/scheduler.lua8
1 files changed, 5 insertions, 3 deletions
diff --git a/advtrains_line_automation/scheduler.lua b/advtrains_line_automation/scheduler.lua
index 3d8778a..8afaa55 100644
--- a/advtrains_line_automation/scheduler.lua
+++ b/advtrains_line_automation/scheduler.lua
@@ -90,7 +90,7 @@ function sched.enqueue(rwtime, handler, evtdata, unitid, unitlim)
ucn = (units_cnt[unitid] or 0)
local ulim=(unitlim or UNITS_THRESH)
if ucn >= ulim then
- atwarn("[lines][scheduler] discarding enqueue for",handler,"(limit",ulim,") because unit",unitid,"has already",ucn,"schedules enqueued")
+ atlog("[lines][scheduler] discarding enqueue for",handler,"(limit",ulim,") because unit",unitid,"has already",ucn,"schedules enqueued")
return false
end
@@ -118,10 +118,12 @@ end
-- Discards all schedules for unit "unitid" (removes them from the queue)
function sched.discard_all(unitid)
- for i=1,#queue do
+ local i = 1
+ while i<=#queue do
if queue[i].u == unitid then
table.remove(queue,i)
- i=i-1
+ else
+ i=i+1
end
end
units_cnt[unitid] = 0