aboutsummaryrefslogtreecommitdiff
path: root/advtrains/trainlogic.lua
diff options
context:
space:
mode:
authororwell96 <orwell@bleipb.de>2018-10-10 22:41:59 +0200
committerorwell96 <orwell@bleipb.de>2018-10-10 22:41:59 +0200
commit842a85606e4495dd631c2916d09a760d74a0ce13 (patch)
treef28bb815ecd01681f98166578c659aef48082b2a /advtrains/trainlogic.lua
parent33c839b40d48e154f5b03619a9bdce1bed1fc602 (diff)
downloadadvtrains-842a85606e4495dd631c2916d09a760d74a0ce13.tar.gz
advtrains-842a85606e4495dd631c2916d09a760d74a0ce13.tar.bz2
advtrains-842a85606e4495dd631c2916d09a760d74a0ce13.zip
Properly implement invalidate_all_paths, recheck lzb on aspect change
Diffstat (limited to 'advtrains/trainlogic.lua')
-rw-r--r--advtrains/trainlogic.lua29
1 files changed, 13 insertions, 16 deletions
diff --git a/advtrains/trainlogic.lua b/advtrains/trainlogic.lua
index f26f7da..7147787 100644
--- a/advtrains/trainlogic.lua
+++ b/advtrains/trainlogic.lua
@@ -1037,26 +1037,23 @@ function advtrains.get_train_at_pos(pos)
end
end
+
+-- ehm... I never adapted this function to the new path system ?!
function advtrains.invalidate_all_paths(pos)
- --if a position is given, only invalidate inside a radius to save performance
- local inv_radius=50
- atprint("invalidating all paths")
- for k,v in pairs(advtrains.trains) do
- local exec=true
- if pos and v.path and v.index and v.end_index then
- --start and end pos of the train
- local cmp1=v.path[atround(v.index)]
- local cmp2=v.path[atround(v.end_index)]
- if vector.distance(pos, cmp1)>inv_radius and vector.distance(pos, cmp2)>inv_radius then
- exec=false
- end
- end
- if exec then
- advtrains.invalidate_path(k)
- end
+ local tab
+ if pos then
+ -- if position given, check occupation system
+ tab = advtrains.occ.get_trains_over(pos)
+ else
+ tab = advtrains.trains
+ end
+
+ for id, _ in pairs(tab) do
+ advtrains.invalidate_path(id)
end
end
function advtrains.invalidate_path(id)
+ atdebug("Path invalidate:",id)
local v=advtrains.trains[id]
if not v then return end
advtrains.path_invalidate(v)