From ea074b2a3378c1b79d37d0dd94947ebbaf8ece32 Mon Sep 17 00:00:00 2001 From: orwell Date: Sun, 15 Oct 2023 16:40:10 +0200 Subject: Re-implement point origin handling (replace old points_split hack by proper solution) --- advtrains/path.lua | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'advtrains/path.lua') 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 -- cgit v1.2.3