diff options
author | orwell96 <orwell@bleipb.de> | 2023-06-24 14:37:52 +0200 |
---|---|---|
committer | orwell96 <orwell@bleipb.de> | 2023-06-24 14:37:52 +0200 |
commit | 2d7640d424c3d7d558ed0b81b8d98fd306562d11 (patch) | |
tree | 8850737a635a3ae6a09e081b7b0661b6643a7a5c /advtrains/couple.lua | |
parent | 283efc44ce78001ebd17f64555eb795e36b27a61 (diff) | |
download | advtrains-2d7640d424c3d7d558ed0b81b8d98fd306562d11.tar.gz advtrains-2d7640d424c3d7d558ed0b81b8d98fd306562d11.tar.bz2 advtrains-2d7640d424c3d7d558ed0b81b8d98fd306562d11.zip |
Occupation system: store multiple indices for the same train, introduce reverse_lookup_sel() to select appropriate index out of multiple based on a heuristic
Diffstat (limited to 'advtrains/couple.lua')
-rw-r--r-- | advtrains/couple.lua | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/advtrains/couple.lua b/advtrains/couple.lua index 3e6c432..1318c12 100644 --- a/advtrains/couple.lua +++ b/advtrains/couple.lua @@ -79,8 +79,9 @@ function advtrains.train_check_couples(train) end if not train.cpl_front then -- recheck front couple - local front_trains, pos = advtrains.occ.get_occupations(train, atround(train.index) + CPL_CHK_DST) + local pos = advtrains.path_get(train, atround(train.index) + CPL_CHK_DST) if advtrains.is_node_loaded(pos) then -- if the position is loaded... + local front_trains = advtrains.occ.reverse_lookup_sel(pos, "in_train") for tid, idx in pairs(front_trains) do local other_train = advtrains.trains[tid] if not advtrains.train_ensure_init(tid, other_train) then @@ -109,8 +110,9 @@ function advtrains.train_check_couples(train) end if not train.cpl_back then -- recheck back couple - local back_trains, pos = advtrains.occ.get_occupations(train, atround(train.end_index) - CPL_CHK_DST) + local pos = advtrains.path_get(train, atround(train.end_index) - CPL_CHK_DST) if advtrains.is_node_loaded(pos) then -- if the position is loaded... + local back_trains = advtrains.occ.reverse_lookup_sel(pos, "in_train") for tid, idx in pairs(back_trains) do local other_train = advtrains.trains[tid] if not advtrains.train_ensure_init(tid, other_train) then |