aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authororwell <orwell@bleipb.de>2024-05-06 20:20:36 +0200
committerorwell <orwell@bleipb.de>2024-05-06 20:20:36 +0200
commit0a51d5713839cf346b1dcdf97725d525d7fa086b (patch)
tree0c5003172a783efba034fa89107091d44bd3d694
parent64776ba60e8e16cbfd4cbc51447284ba074abeec (diff)
downloadadvtrains-0a51d5713839cf346b1dcdf97725d525d7fa086b.tar.gz
advtrains-0a51d5713839cf346b1dcdf97725d525d7fa086b.tar.bz2
advtrains-0a51d5713839cf346b1dcdf97725d525d7fa086b.zip
Fix for broken get_trains_at, fixing LuaATC/Lines Scheduler execution
-rw-r--r--advtrains/occupation.lua6
1 files changed, 5 insertions, 1 deletions
diff --git a/advtrains/occupation.lua b/advtrains/occupation.lua
index 6852dfa..7fce312 100644
--- a/advtrains/occupation.lua
+++ b/advtrains/occupation.lua
@@ -188,6 +188,7 @@ local OCC_CLOSE_PROXIMITY = 3
-- Gets a mapping of train id's to index of trains that have a path item at this position. Selects at most one index based on a given heuristic, or even none if it does not match the heuristic criterion
-- returns (table with train_id->index), position
-- "in_train": first index that lies between train index and end index
+-- "train_at_node": first index where the train is standing on that node (like in_train but with +-0.5 added to index)
-- "first_ahead": smallest index that is > current index
-- "before_end"(default): smallest index that is > end index
-- "close_proximity": within 3 indices close to the train index and end_index
@@ -214,6 +215,9 @@ function o.reverse_lookup_sel(pos, heuristic)
if heuristic == "in_train" and idx < otrn.index and idx > otrn.end_index then
h_value = idx
end
+ if heuristic == "train_at_node" and idx < (otrn.index+0.5) and idx > (otrn.end_index-0.5) then
+ h_value = idx
+ end
if heuristic == "close_proximity" and idx < (otrn.index + OCC_CLOSE_PROXIMITY) and idx > (otrn.end_index - OCC_CLOSE_PROXIMITY) then
h_value = idx
end
@@ -228,7 +232,7 @@ end
-- returns (table with train_id->index)
function o.get_trains_at(ppos)
local pos = advtrains.round_vector_floor_y(ppos)
- return o.reverse_lookup_sel(pos, "in_train")
+ return o.reverse_lookup_sel(pos, "train_at_node")
end
advtrains.occ = o