diff options
author | orwell <orwell@bleipb.de> | 2025-01-09 08:53:27 +0100 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2025-01-09 09:09:02 +0100 |
commit | 021332c4aaaf8cfd18b3f08e5f069b203097f01d (patch) | |
tree | 96acd5e67f0fdd1cd3cf3ee88cd0b30a0669b912 /advtrains | |
parent | 8c91ce1ec178d6d49f3ddefc57d99eecd0caef3c (diff) | |
download | advtrains-021332c4aaaf8cfd18b3f08e5f069b203097f01d.tar.gz advtrains-021332c4aaaf8cfd18b3f08e5f069b203097f01d.tar.bz2 advtrains-021332c4aaaf8cfd18b3f08e5f069b203097f01d.zip |
Two occupation loops seem to have issues with endless loops, add guards
Diffstat (limited to 'advtrains')
-rw-r--r-- | advtrains/occupation.lua | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/advtrains/occupation.lua b/advtrains/occupation.lua index 20a986e..b4b2bcd 100644 --- a/advtrains/occupation.lua +++ b/advtrains/occupation.lua @@ -103,7 +103,10 @@ function o.clear_all_items(train_id, pos) local t = occget(pos) if not t then return end local i = 1 + local grd = 0 while t[i] do + grd=grd+1 + if grd>10000 then error("loop guard occ clearall") end if t[i]==train_id then table.remove(t, i) table.remove(t, i) @@ -116,7 +119,10 @@ function o.clear_specific_item(train_id, pos, index) local t = occget(pos) if not t then return end local i = 1 + local grd = 0 while t[i] do + grd=grd+1 + if grd>10000 then error("loop guard occ clearall") end if t[i]==train_id and t[i+1]==index then table.remove(t, i) table.remove(t, i) |