From 842a85606e4495dd631c2916d09a760d74a0ce13 Mon Sep 17 00:00:00 2001 From: orwell96 Date: Wed, 10 Oct 2018 22:41:59 +0200 Subject: Properly implement invalidate_all_paths, recheck lzb on aspect change --- advtrains/occupation.lua | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'advtrains/occupation.lua') diff --git a/advtrains/occupation.lua b/advtrains/occupation.lua index dd0235a..568f308 100644 --- a/advtrains/occupation.lua +++ b/advtrains/occupation.lua @@ -208,7 +208,7 @@ function o.get_occupations(train, index) return r, pos end -- Gets a mapping of train id's to indexes of trains that stand or drive over --- returns (table with train_id->index), position +-- returns (table with train_id->index) function o.get_trains_at(ppos) local pos = advtrains.round_vector_floor_y(ppos) local t = occget(pos) @@ -226,4 +226,22 @@ function o.get_trains_at(ppos) return r end +-- Gets a mapping of train id's to indexes of trains that have a path +-- generated over this node +-- returns (table with train_id->index) +function o.get_trains_over(ppos) + local pos = advtrains.round_vector_floor_y(ppos) + local t = occget(pos) + if not t then return {} end + local r = {} + local i = 1 + while t[i] do + local train = advtrains.trains[t[i]] + local idx = t[i+1] + r[t[i]] = idx + i = i + 2 + end + return r +end + advtrains.occ = o -- cgit v1.2.3