diff options
author | orwell <orwell@bleipb.de> | 2023-10-15 16:40:10 +0200 |
---|---|---|
committer | orwell <orwell@bleipb.de> | 2023-10-15 16:40:10 +0200 |
commit | ea074b2a3378c1b79d37d0dd94947ebbaf8ece32 (patch) | |
tree | f8dce610bf888a3c107aef6d75201415e6d2b250 /advtrains/path.lua | |
parent | 2067ab0a90550b2fc513e032d4c4e54dd11a2290 (diff) | |
download | advtrains-ea074b2a3378c1b79d37d0dd94947ebbaf8ece32.tar.gz advtrains-ea074b2a3378c1b79d37d0dd94947ebbaf8ece32.tar.bz2 advtrains-ea074b2a3378c1b79d37d0dd94947ebbaf8ece32.zip |
Re-implement point origin handling (replace old points_split hack by proper solution)
Diffstat (limited to 'advtrains/path.lua')
-rw-r--r-- | advtrains/path.lua | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/advtrains/path.lua b/advtrains/path.lua index 588140d..28df529 100644 --- a/advtrains/path.lua +++ b/advtrains/path.lua @@ -217,9 +217,8 @@ function advtrains.path_get(train, index) advtrains.occ.set_item(train.id, adj_pos, pef) local mconnid = advtrains.get_matching_conn(adj_connid, next_connmap) - -- If we have split points, notify accordingly - -- TODO readd support for split points (remember the cp and cn of points) - + -- NO split points handling here. It is only required for backwards path calculation + adj_pos.y = adj_pos.y + nextrail_y train.path_cp[pef] = adj_connid train.path_cn[pef] = mconnid @@ -253,9 +252,15 @@ function advtrains.path_get(train, index) advtrains.occ.set_item(train.id, adj_pos, peb) local mconnid = advtrains.get_matching_conn(adj_connid, next_connmap) - -- If we have split points, notify accordingly - -- TODO readd support for split points (remember the cp and cn of points) - + -- If, for this position, we have remembered the origin conn, apply it here + if next_connmap then -- only needs to be done when this track is a turnout (>2 conns) + local origin_conn = train.path_ori_cp[advtrains.encode_pos(adj_pos)] + if origin_conn then + atdebug("Train",train.id,"at",adj_pos,"restoring turnout origin CP",origin_conn,"for path item",index) + mconnid = origin_conn + end + end + adj_pos.y = adj_pos.y + nextrail_y train.path_cn[peb] = adj_connid train.path_cp[peb] = mconnid |